Files
evm/precompile/precompileconfig/config.go
zeekay 2bc16e3494 refactor(warp): Core -> Message — track warp v1.22.0
Rename across the evm warp backend and the warp precompile: warp.Core ->
warp.Message, NewCore -> NewMessage, ParseCore -> ParseMessage, the .Core field
-> .Message, and local core/msgCore/testCore vars -> msg/testMsg. deps: warp
v1.21.0 -> v1.22.0, precompile v0.11.0 -> v0.12.0.

geth's core/types and core/vm imports are untouched — the rename is scoped to
the warp message type, never the geth core package. ./warp/... and
./precompile/contracts/warp/... green, including TestWarpWrongNetworkID.
2026-06-27 00:48:35 -07:00

91 lines
4.1 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Defines the stateless interface for unmarshalling an arbitrary config of a precompile
package precompileconfig
import (
"context"
"github.com/luxfi/evm/commontype"
"github.com/luxfi/geth/common"
"github.com/luxfi/vm/chain"
"github.com/luxfi/warp"
)
// StatefulPrecompileConfig defines the interface for a stateful precompile to
// be enabled via a network upgrade.
type Config interface {
// Key returns the unique key for the stateful precompile.
Key() string
// Timestamp returns the timestamp at which this stateful precompile should be enabled.
// 1) 0 indicates that the precompile should be enabled from genesis.
// 2) n indicates that the precompile should be enabled in the first block with timestamp >= [n].
// 3) nil indicates that the precompile is never enabled.
Timestamp() *uint64
// IsDisabled returns true if this network upgrade should disable the precompile.
IsDisabled() bool
// Equal returns true if the provided argument configures the same precompile with the same parameters.
Equal(Config) bool
// Verify is called on startup and an error is treated as fatal. Configure can assume the Config has passed verification.
Verify(ChainConfig) error
}
// PredicateContext is the context passed in to the Predicater interface to verify
// a precompile predicate within a specific ProposerVM wrapper.
type PredicateContext struct {
ConsensusCtx context.Context
// ProposerVMBlockCtx defines the ProposerVM context the predicate is verified within
ProposerVMBlockCtx *chain.Context
}
// Predicater is an optional interface for StatefulPrecompileContracts to implement.
// If implemented, the predicate will be called for each predicate included in the
// access list of a transaction.
// PredicateGas will be called while calculating the IntrinsicGas of a transaction
// causing it to be dropped if the total gas goes above the tx gas limit.
// VerifyPredicate is used to populate a bit set of predicates verified prior to
// block execution, which can be accessed via the StateDB during execution.
// The bitset is stored in the block, so that historical blocks can be re-verified
// without calling VerifyPredicate.
type Predicater interface {
PredicateGas(predicateBytes []byte) (uint64, error)
VerifyPredicate(predicateContext *PredicateContext, predicateBytes []byte) error
}
// WarpMessageWriter queues a precompile-emitted cross-chain message for the
// validator set to attest. Post-ZAP hard fork the unsigned subject is the
// warp.Message (whose D = keccak256(DST ‖ zap_c14n) the BLS Beam / Pulsar
// Pulse / ML-DSA lanes sign), replacing the deleted RLP unsigned-message type.
// Build a core via warp.NewMessage(networkID, sourceChainID, payload).
type WarpMessageWriter interface {
AddMessage(msg *warp.Message) error
}
// AcceptContext defines the context passed in to a precompileconfig's Accepter
type AcceptContext struct {
ConsensusCtx context.Context
Warp WarpMessageWriter
}
// Accepter is an optional interface for StatefulPrecompiledContracts to implement.
// If implemented, Accept will be called for every log with the address of the precompile when the block is accepted.
// WARNING: If you are implementing a custom precompile, beware that evm
// will not maintain backwards compatibility of this interface and your code should not
// rely on this. Designed for use only by precompiles that ship with evm.
type Accepter interface {
Accept(acceptCtx *AcceptContext, blockHash common.Hash, blockNumber uint64, txHash common.Hash, logIndex int, topics []common.Hash, logData []byte) error
}
// ChainContext defines an interface that provides information to a stateful precompile
// about the chain configuration. The precompile can access this information to initialize
// its state.
type ChainConfig interface {
// GetFeeConfig returns the original FeeConfig that was set in the genesis.
GetFeeConfig() commontype.FeeConfig
// AllowedFeeRecipients returns true if fee recipients are allowed in the genesis.
AllowedFeeRecipients() bool
// IsDurango returns true if the time is after Durango.
IsDurango(time uint64) bool
}