consensus-shipyard / ipc

🌳 Spawn multi-level trees of customized, scalable, EVM-compatible networks with IPC. L2++ powered by FVM, Wasm, libp2p, IPFS/IPLD, and CometBFT.
https://ipc.space
Apache License 2.0
44 stars 39 forks source link

feat(node): call state from exec state #1169

Closed cryptoAtwill closed 4 weeks ago

cryptoAtwill commented 1 month ago

Currently to invoke getter fvm actors, one must use the FvmExecState which is taking &mut self. This imposes some restrictions on how tratis, query functions are written as it forces getter to use &mut self if the getter is hold FvmExecState.

This PR creates a FvmCallState from FvmExecState so that when calling getters, it's a &self instead of &mut self. Behind the scene it's using a ReadOnlyBlockStore wrapper for the blockstore to ensure no data will be committed.

Fendermint already has FvmQueryState for the App, I also looked into that strcut first, but it seems to be holding quite a few fields which is pretty difficult to derive from FvmExecState. The current approach might be easier or smaller a change.