Documentation
¶
Index ¶
- Variables
- type Bridge
- type CachingBridge
- func (c *CachingBridge) ComputeStateRoot(ctx context.Context, base cid.Cid, epoch int64, msgs []*types.Message) (cid.Cid, []*types.MessageReceipt, error)
- func (c *CachingBridge) Provenance() string
- func (c *CachingBridge) RawJSONRPC(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, error)
- type ForestBridge
- func (f *ForestBridge) ComputeStateRoot(ctx context.Context, base cid.Cid, epoch int64, msgs []*types.Message) (cid.Cid, []*types.MessageReceipt, error)
- func (f *ForestBridge) Provenance() string
- func (f *ForestBridge) RawJSONRPC(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoBridge = errors.New("vm/bridge: no bridge configured (StateCall beyond Send + post-execution state root require a bridge — see TRUST-MODEL.md)")
ErrNoBridge is returned from helper code paths when a bridge was expected but not configured.
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge interface {
// ComputeStateRoot applies `msgs` against `base` (the parent
// tipset's stateRoot) at the given epoch and returns the resulting
// state root + per-message receipts.
//
// The returned receipts MUST be in the same order as `msgs`.
//
// `epoch` lets the upstream node pick the right network version /
// actor version table. Callers should pass the epoch of the parent
// tipset (i.e. the epoch at which messages execute).
//
// `ctx` cancellation propagates to the upstream RPC call.
ComputeStateRoot(ctx context.Context, base cid.Cid, epoch int64, msgs []*types.Message) (cid.Cid, []*types.MessageReceipt, error)
// RawJSONRPC forwards a JSON-RPC method call to the upstream and
// returns the raw `result` JSON. Used to delegate FEVM-shaped
// methods (eth_call, eth_estimateGas, eth_sendRawTransaction)
// that need real FEVM execution — Lantern's native VM is Send-only.
//
// `params` should be the already-marshaled JSON array of the
// upstream method's parameters (e.g. `["0xdeadbeef", "latest"]`).
//
// Returns the raw `result` JSON on success, or an error if the
// upstream call failed or returned a JSON-RPC error.
RawJSONRPC(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, error)
// Provenance returns a short, opaque identifier for the upstream
// node serving this bridge — typically "forest@<host>" or
// "lotus@<host>". Used for trace logging only; not security-bearing.
Provenance() string
}
Bridge is the operator-pluggable VM bridge. Implementations call out to an upstream Forest/Lotus (or a private FVM service) to compute the post-execution state root + receipts for a base + message list, AND to forward arbitrary FEVM-shaped JSON-RPC calls (eth_call, eth_estimateGas, eth_sendRawTransaction).
Implementations MUST be safe for concurrent use.
type CachingBridge ¶
type CachingBridge struct {
// contains filtered or unexported fields
}
CachingBridge wraps a Bridge with a small LRU keyed by (base, epoch, msgs digest). Repeated StateCall against the same base + message list short-circuits to the cached result.
func NewCachingBridge ¶
func NewCachingBridge(b Bridge, maxEntries int) *CachingBridge
NewCachingBridge returns a CachingBridge with the given upper bound on cache entries. 1024 is a generous default for V1.
func (*CachingBridge) ComputeStateRoot ¶
func (c *CachingBridge) ComputeStateRoot(ctx context.Context, base cid.Cid, epoch int64, msgs []*types.Message) (cid.Cid, []*types.MessageReceipt, error)
ComputeStateRoot is the cached variant.
func (*CachingBridge) Provenance ¶
func (c *CachingBridge) Provenance() string
Provenance proxies to the underlying bridge.
func (*CachingBridge) RawJSONRPC ¶
func (c *CachingBridge) RawJSONRPC(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, error)
RawJSONRPC proxies straight through. We don't cache FEVM RPC calls because eth_call results depend on chain state (which changes every tipset) and eth_sendRawTransaction MUST not be cached — it has side effects on the upstream mempool.
type ForestBridge ¶
type ForestBridge struct {
URL string
Token string // optional Bearer token (empty for unauthenticated)
Client *http.Client
// contains filtered or unexported fields
}
ForestBridge talks JSON-RPC to a Forest (or Lotus) full node.
func NewForestBridge ¶
func NewForestBridge(url, token string, timeout time.Duration) *ForestBridge
NewForestBridge constructs a ForestBridge.
url — base RPC URL, e.g. "http://127.0.0.1:2345/rpc/v1" token — optional Bearer token (empty string for unauthenticated) timeout — per-request timeout; 30s is a reasonable default
func (*ForestBridge) ComputeStateRoot ¶
func (f *ForestBridge) ComputeStateRoot(ctx context.Context, base cid.Cid, epoch int64, msgs []*types.Message) (cid.Cid, []*types.MessageReceipt, error)
ComputeStateRoot calls Filecoin.StateCompute on the upstream node.
func (*ForestBridge) Provenance ¶
func (f *ForestBridge) Provenance() string
Provenance returns "forest@<host>" or similar tag.
func (*ForestBridge) RawJSONRPC ¶
func (f *ForestBridge) RawJSONRPC(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, error)
RawJSONRPC forwards an arbitrary JSON-RPC method call to the upstream Forest/Lotus node. Used by handlers for FEVM-shaped methods (eth_call, eth_estimateGas, eth_sendRawTransaction) that Lantern's native Send-only VM can't execute.
`params` is already-marshaled JSON. The upstream's `result` is returned verbatim as json.RawMessage so the caller can decode it with the shape it expects.