Skip to content

Wire VM bridge to upstream Forest/Lotus for block production state-root computation #4

Description

@Reiers

Problem

MinerCreateBlock (rpc/handlers/miner_block.go) produces a syntactically valid block with real Parents, Ticket, ElectionProof, BeaconEntries, and Messages. But ParentStateRoot is copied verbatim from the parent tipset because Lantern has no FVM. A published block with that state root is rejected by the network.

SyncSubmitBlock is gated by AllowBlockSubmit=true and returns ErrNotImpl by default. Correct posture today.

What's already there

vm/bridge/ is designed for this. The handler code (miner_block.go:294) already has:

if c.Bridge != nil && c.AllowBlockSubmit {
    root, _, berr := c.Bridge.ComputeStateRoot(ctx, parentBlock.ParentStateRoot, int64(bt.Epoch-1), unsignedMessagesForBridge(bt.Messages))
    ...
}

The bridge interface is defined, but no concrete implementation ships in main today.

Proposed implementation

Path A: Forest/Lotus side-channel JSON-RPC client

  1. Implement vm/bridge/forest.go as a thin JSON-RPC client that calls the upstream's StateCompute or equivalent method to obtain the post-execution state root for the candidate block's messages.
  2. Wire a --vm-bridge-rpc=<url> flag on lantern daemon that constructs the bridge when set.
  3. Document that AllowBlockSubmit=true is allowed only when --vm-bridge-rpc is also set; refuse to start otherwise.

For an SP backup use case, the operator already runs Lotus as primary. Pointing the bridge at the same Lotus instance is fine: the read path is trustless (everything verifiable via the F3-anchored state root), the production path delegates to local Lotus for state-root computation. If Lotus is down for the read path, Lantern serves chain head / state queries. If Lotus is up for the bridge, Lantern can produce blocks.

Acceptance

  • lantern daemon --allow-block-submit --vm-bridge-rpc=http://lotus:1234/rpc/v1 starts cleanly.
  • SyncSubmitBlock with a valid block produces a state root that matches what an upstream Lotus computes for the same messages.
  • SyncSubmitBlock actually publishes to /fil/blocks/testnetnet and the block is accepted by peers (validated by tailing peer logs).

Out of scope

  • Pure-Go FVM port (Path B from the proposal). Multi-month, not realistic.
  • Forest subprocess spawn (Path C). Punt to follow-up if anyone wants full local autonomy.

Related

  • vm/bridge/doc.go
  • rpc/handlers/miner_block.go
  • net/blockpub/blockpub.go (the publish channel exists, just gated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureTrust model / swarm designenhancementNew feature or requestp2Medium priority

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions