Feat/apply message for simulation#567
Feat/apply message for simulation#567nijoe1 wants to merge 2 commits intofilecoin-project:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an FFI entrypoint to apply Filecoin messages in a “simulation” mode intended to support EVM JSON-RPC workflows (e.g., eth_call / eth_estimateGas) as part of #13470.
Changes:
- Introduces
(*FVM).ApplyMessageForSimulationthat executes a message withapplyImplicitsemantics while still taking achainLeninput. - Documents the intended behavior for simulation (skipping sender type validation).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // ApplyMessageForSimulation applies a message for simulation purposes (eth_call/eth_estimateGas). | ||
| // This mode skips sender type validation, allowing calls from any actor type (including EVM contracts), | ||
| // but still validates nonce and balance. | ||
| func (f *FVM) ApplyMessageForSimulation(msgBytes []byte, chainLen uint) (*ApplyRet, error) { | ||
| defer runtime.KeepAlive(f) | ||
| resp, err := cgo.FvmMachineExecuteMessage( | ||
| f.executor, | ||
| cgo.AsSliceRefUint8(msgBytes), | ||
| uint64(chainLen), | ||
| applyImplicit, | ||
| ) |
There was a problem hiding this comment.
ApplyMessageForSimulation is added to the CGO-backed FVM implementation, but the //go:build nofvm stub (fvm_stub.go) does not provide a matching method. This makes the exported ffi.FVM API differ across build tags and will break compilation for -tags nofvm consumers as soon as they start calling this new method. Add a corresponding stub method in fvm_stub.go that returns the same "FVM support not built in this binary" error to keep the API consistent.
part of #13470
cc: @rvagg