Snapshot is created for the previous block
Closed this issue · 2 comments
Problem
I started the Flow emulator (using flow-cli v0.41.1) with below command:
flow emulator --snapshot
Before starting the emulator I also removed the flowdb
folder (if present).
The first block was created during the initialization phase. Then I created a second block by calling http://localhost:8080/emulator/newBlock
emulator endpoint.
After that, I wanted to create a snapshot pointing at the second block with the command: curl http://localhost:8080/emulator/snapshot/<random-uuid>
, but the snapshot was instead pointing to the first block, which was unexpected to me, as I thought the snapshot always points to the latest block.
Here are the step-by-step command logs:
➜ snapshot-test flow blocks get latest
Block ID 13c7ff23bb65feb5757cc65fdd75cd243506518c126385fae530ddebdad10b17
Parent ID 0000000000000000000000000000000000000000000000000000000000000000
Proposal Timestamp 2018-12-19 22:32:30.000000042 +0000 UTC
Proposal Timestamp Unix 1545258750
Height 0
Total Seals 0
Total Collections 0
➜ snapshot-test curl http://localhost:8080/emulator/newBlock
{"height":1,"blockId":"f17636471935ed6cce45562d2b7fa74b94f4a1a7ae4e78109e5d01e854642efb"}
➜ snapshot-test flow blocks get latest
Block ID f17636471935ed6cce45562d2b7fa74b94f4a1a7ae4e78109e5d01e854642efb
Parent ID 13c7ff23bb65feb5757cc65fdd75cd243506518c126385fae530ddebdad10b17
Proposal Timestamp 2022-10-25 12:35:37.725078 +0000 UTC
Proposal Timestamp Unix 1666701337
Height 1
Total Seals 0
Total Collections 0
➜ snapshot-test curl http://localhost:8080/emulator/snapshot/18e27ec4-6c25-4b80-b0cd-7c5c799da42b
{"height":0,"blockId":"13c7ff23bb65feb5757cc65fdd75cd243506518c126385fae530ddebdad10b17","context":"18e27ec4-6c25-4b80-b0cd-7c5c799da42b"}%
➜ snapshot-test flow blocks get latest
Block ID 13c7ff23bb65feb5757cc65fdd75cd243506518c126385fae530ddebdad10b17
Parent ID 0000000000000000000000000000000000000000000000000000000000000000
Proposal Timestamp 2018-12-19 22:32:30.000000042 +0000 UTC
Proposal Timestamp Unix 1545258750
Height 0
Total Seals 0
Total Collections 0
Steps to Reproduce
- Start the flow emulator (with
--snapshot
flag) - Create a new block
- Make sure there are now 2 blocks on the blockchain with
flow blocks get latest
- Create a new snapshot with
curl http://localhost:8080/emulator/snapshot/<insert-random-uuid>
- The snapshot response should return
blockId=<id-of-the-first-block>
, which means it isn't pointing to the second (latest) block
Acceptance Criteria
Snapshots should always be created at the latest block.
Context
I'm currently testing out the beta version of Flowser desktop app. I noticed this issue just recently, so I have a feeling this actually worked in the previous flow-cli versions - will try to test that.
Sorry for getting back late on this, I was out of town last week, but I am on it today; it can be related to an empty block not being pushed on state probably.