flow-cli
flow-cli copied to clipboard
Emulator snapshot managment
The CLI should support the new emulator snapshot management feature developed by @bluesign
Emulator exposes a new emulator admin API on /emulator which exposes new functionality such as snapshot management. You can save a new snapshot by calling /emulator/snapshot/{name} and retrieve a snapshot by name if already exists on that same endpoint. Besides that it enables creating new blocks on demand by calling /emulator/newBlock.
This API should be supported and exposed by the CLI as emulator subcommand. My thinking here is flow emulator blocks commit and flow emulator snapshot {name}.
@sideninja I can take this if you want, actually I was planning to implement those, somehow forgot :(
@sideninja I can take this if you want, actually I was planning to implement those, somehow forgot :(
For sure that would be great.
@bluesign do you still have the intention to take this at some later point or should we schedule it to do internally? No pressure or rush, I just think that's a great feature that gets overlooked because it's not part of the CLI so I want to one day have it there.
@sideninja tbh I totally forgot about this, now just added to top of my todo, this week I will send a PR for sure.
@bluesign no worries, like I said no rush, just at some point in future it would be nice to have.
@sideninja I started today on this, delayed a bit because of debugging some strange setup problems on new computer.
More about the works of this API found here https://github.com/onflow/flow-emulator#managing-emulator-state cc @sukantoraymond
Currently doesn't seem like we have the API implemented for saving snapshot for emulator
Raymonds-MBP-3:flow raymondsukanto$ ./flow snapshot save /tmp/snapshot.json
⚠️ warning: using insecure client connection to download snapshot, you should use a secure network configuration...
❌ Command Error: failed to get latest finalized protocol snapshot from gateway: client: rpc error: code = Unavailable desc = error reading from server: EOF
Terminal running emulator exited due to panic
Raymonds-MBP-3:flow raymondsukanto$ ./flow emulator
INFO[0000] ⚙️ Using service account 0xf8d6e0586b0a20c7 serviceAddress=f8d6e0586b0a20c7 serviceHashAlgo=SHA3_256 servicePrivKey=e2f55d130f6aada644c315436a8faee35c2e7d42f8c9fd4e94761b3e00119cc9 servicePubKey=3d25391c2e8a6def0c1786de192bc3022e086c8db85059beedf24f5177af3a8d4ecab8eb3862cb411ff56e243c354e171da575d20f253d50ff52939087ea6cca serviceSigAlgo=ECDSA_P256
INFO[0000] 📜 Flow contract FlowServiceAccount=0xf8d6e0586b0a20c7
INFO[0000] 📜 Flow contract FlowToken=0x0ae53cb6e3f42a79
INFO[0000] 📜 Flow contract FungibleToken=0xee82856bf20e2aa6
INFO[0000] 📜 Flow contract FlowFees=0xe5a8b7f23e8b548f
INFO[0000] 📜 Flow contract FlowStorageFees=0xf8d6e0586b0a20c7
INFO[0000] 🌱 Starting gRPC server on port 3569 port=3569
INFO[0000] 🌱 Starting REST API on port 8888 port=8888
INFO[0000] 🌱 Starting admin server on port 8080 port=8080
panic: implement me
goroutine 55 [running]:
github.com/onflow/flow-emulator/server/backend.(*Backend).GetLatestProtocolStateSnapshot(...)
/Users/raymondsukanto/go/pkg/mod/github.com/onflow/[email protected]/server/backend/backend.go:585
github.com/onflow/flow-emulator/server/backend.(*Adapter).GetLatestProtocolStateSnapshot(0x140013199d8?, {0x1013109ac?, 0x1020ca000?})
We need to implement saving snapshot api in emulator first before implementing emulator snapshot management
The snapshot save command is unfortunately unrelated to this, it just saves the snapshot that it gets from AN, I think we should rename this command honestly. This command should use the mentioned API on the emulator that already exists https://github.com/onflow/flow-emulator#managing-emulator-state