mirror of
https://github.com/luxfi/chains.git
synced 2026-07-27 03:39:41 +00:00
graphvm + oraclevm + relayvm: complete FeePolicy coverage
graphvm: G-Chain is read-only (graphql.go explicitly rejects `mutation`
operations). Wires NoUserTxPolicy{} so any attempted user-tx is refused
at the boundary. Field + Initialize gate added; fee.Validate ensures
the policy choice is sound at boot.
oraclevm + relayvm: these chains are thin re-export shims of the
canonical impls in luxfi/oracle/vm and luxfi/relay/vm (which already
have feegate.go). Added in-file pointers documenting where the gate
lives, so future readers don't add a duplicate stub here.
Closes the FeePolicy migration: every VM in luxfi/chains/ either has
its own feegate.go (8 VMs), points to the canonical impl (oraclevm +
relayvm), or is exempt via native gas (evm). The matrix at
node/CLAUDE.md FeePolicy section is now complete.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package graphvm
|
||||
|
||||
import "github.com/luxfi/node/vms/types/fee"
|
||||
|
||||
// newFeePolicy returns the canonical G-Chain FeePolicy.
|
||||
//
|
||||
// G-Chain is read-only — the GraphQL executor explicitly rejects
|
||||
// `mutation` operations (see graphql.go: "mutations not allowed:
|
||||
// G-chain is read-only"). There is no user-submitted-tx mempool, so
|
||||
// the only sound policy is NoUserTxPolicy{}: any path that ever tried
|
||||
// to admit a user-tx is a bug.
|
||||
//
|
||||
// Per node/CLAUDE.md FeePolicy section: service-only chains use
|
||||
// NoUserTxPolicy. Read-only chains are a subset of service-only.
|
||||
func newFeePolicy() fee.Policy {
|
||||
return fee.NoUserTxPolicy{}
|
||||
}
|
||||
|
||||
// FeePolicy exposes the chain's declared fee policy for diagnostics and
|
||||
// the boot-time Validate gate.
|
||||
func (vm *VM) FeePolicy() fee.Policy { return vm.feePolicy }
|
||||
+12
-1
@@ -17,12 +17,13 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/luxfi/vm/chain"
|
||||
"github.com/luxfi/database"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/log"
|
||||
"github.com/luxfi/node/vms/types/fee"
|
||||
"github.com/luxfi/runtime"
|
||||
vmcore "github.com/luxfi/vm"
|
||||
"github.com/luxfi/vm/chain"
|
||||
"github.com/luxfi/warp"
|
||||
|
||||
nodeversion "github.com/luxfi/node/version"
|
||||
@@ -82,6 +83,10 @@ type VM struct {
|
||||
// Synchronization
|
||||
schemaMu sync.RWMutex
|
||||
queryMu sync.RWMutex
|
||||
|
||||
// G-Chain is read-only; the policy refuses all user-tx at the boundary.
|
||||
// See feegate.go.
|
||||
feePolicy fee.Policy
|
||||
}
|
||||
|
||||
// GraphSchema represents a GraphQL schema definition
|
||||
@@ -169,6 +174,12 @@ func (vm *VM) Initialize(
|
||||
vm.dataIndexes = make(map[string]*DataIndex)
|
||||
vm.chainSources = make(map[ids.ID]*ChainDataSource)
|
||||
|
||||
// Fee gate: read-only chain → NoUserTxPolicy (refuses all user-tx).
|
||||
vm.feePolicy = newFeePolicy()
|
||||
if err := fee.Validate(vm.feePolicy); err != nil {
|
||||
return fmt.Errorf("feepolicy: %w", err)
|
||||
}
|
||||
|
||||
// Parse genesis if needed
|
||||
if len(vmInit.Genesis) > 0 {
|
||||
if err := vm.parseGenesis(vmInit.Genesis); err != nil {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package oraclevm
|
||||
|
||||
// FeePolicy lives at the canonical impl in luxfi/oracle/vm. This package
|
||||
// is a thin re-export shim (see oraclevm.go header); the gate is wired
|
||||
// there and re-exported via the type alias `VM = oraclevm.VM`, so any
|
||||
// caller that constructs a VM through this shim transitively gets the
|
||||
// NoUserTxPolicy{} declared in ~/work/lux/oracle/vm/feegate.go.
|
||||
//
|
||||
// See:
|
||||
// - oraclevm.go: re-export shim
|
||||
// - ~/work/lux/oracle/vm/feegate.go: canonical NoUserTxPolicy
|
||||
// - ~/work/lux/node/CLAUDE.md FeePolicy section
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package relayvm
|
||||
|
||||
// FeePolicy lives at the canonical impl in luxfi/relay/vm. This package
|
||||
// is a thin re-export shim (see relayvm.go header); the gate is wired
|
||||
// there and re-exported via the type alias `VM = relayvm.VM`, so any
|
||||
// caller that constructs a VM through this shim transitively gets the
|
||||
// NoUserTxPolicy{} declared in ~/work/lux/relay/vm/feegate.go.
|
||||
//
|
||||
// See:
|
||||
// - relayvm.go: re-export shim
|
||||
// - ~/work/lux/relay/vm/feegate.go: canonical NoUserTxPolicy
|
||||
// - ~/work/lux/node/CLAUDE.md FeePolicy section
|
||||
Reference in New Issue
Block a user