Documentation
¶
Index ¶
- Constants
- Variables
- func PackGetBlockchainID() ([]byte, error)
- func PackGetBlockchainIDOutput(blockchainID common.Hash) ([]byte, error)
- func PackGetVerifiedWarpBlockHash(index uint32) ([]byte, error)
- func PackGetVerifiedWarpBlockHashOutput(outputStruct GetVerifiedWarpBlockHashOutput) ([]byte, error)
- func PackGetVerifiedWarpMessage(index uint32) ([]byte, error)
- func PackGetVerifiedWarpMessageOutput(outputStruct GetVerifiedWarpMessageOutput) ([]byte, error)
- func PackSendWarpMessage(inputStruct SendWarpMessageInput) ([]byte, error)
- func UnpackGetVerifiedWarpBlockHashInput(input []byte) (uint32, error)
- func UnpackGetVerifiedWarpMessageInput(input []byte) (uint32, error)
- type Config
- func (c *Config) Accept(acceptCtx *precompileconfig.AcceptContext, txHash common.Hash, logIndex int, ...) error
- func (c *Config) Equal(s precompileconfig.Config) bool
- func (*Config) Key() string
- func (c *Config) PredicateGas(predicateBytes []byte) (uint64, error)
- func (c *Config) Verify(precompileconfig.ChainConfig) error
- func (c *Config) VerifyPredicate(predicateContext *precompileconfig.PredicateContext, predicates [][]byte) []byte
- type GetVerifiedWarpBlockHashOutput
- type GetVerifiedWarpMessageOutput
- type SendWarpMessageInput
- type WarpBlockHash
- type WarpMessage
Constants ¶
const ( GetVerifiedWarpMessageBaseCost uint64 = 2 // Base cost of entering getVerifiedWarpMessage GetBlockchainIDGasCost uint64 = 2 // Based on GasQuickStep used in existing EVM instructions AddWarpMessageGasCost uint64 = 20_000 // Cost of producing and serving a BLS Signature SendWarpMessageGasCost uint64 = params.LogGas + 4*params.LogTopicGas + AddWarpMessageGasCost + contract.WriteGasCostPerSlot // SendWarpMessageGasCostPerByte cost accounts for producing a signed message of a given size SendWarpMessageGasCostPerByte uint64 = params.LogDataGas GasCostPerWarpSigner uint64 = 500 GasCostPerWarpMessageBytes uint64 = 100 GasCostPerSignatureVerification uint64 = 200_000 )
const ConfigKey = "warpConfig"
ConfigKey is the key used in json config files to specify this precompile precompileconfig. must be unique across all precompiles.
Variables ¶
var ( // WarpRawABI contains the raw ABI of Warp contract. //go:embed contract.abi WarpRawABI string WarpABI = contract.ParseABI(WarpRawABI) WarpPrecompile = createWarpPrecompile() )
Singleton StatefulPrecompiledContract and signatures.
var ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000005")
ContractAddress is the address of the warp precompile contract
var Module = modules.Module{ ConfigKey: ConfigKey, Address: ContractAddress, Contract: WarpPrecompile, Configurator: &configurator{}, }
Module is the precompile module. It is used to register the precompile contract.
Functions ¶
func PackGetBlockchainID ¶
PackGetBlockchainID packs the include selector (first 4 func signature bytes). This function is mostly used for tests.
func PackGetBlockchainIDOutput ¶
PackGetBlockchainIDOutput attempts to pack given blockchainID of type common.Hash to conform the ABI outputs.
func PackGetVerifiedWarpBlockHash ¶ added in v0.5.6
PackGetVerifiedWarpBlockHash packs [index] of type uint32 into the appropriate arguments for getVerifiedWarpBlockHash. the packed bytes include selector (first 4 func signature bytes). This function is mostly used for tests.
func PackGetVerifiedWarpBlockHashOutput ¶ added in v0.5.6
func PackGetVerifiedWarpBlockHashOutput(outputStruct GetVerifiedWarpBlockHashOutput) ([]byte, error)
PackGetVerifiedWarpBlockHashOutput attempts to pack given [outputStruct] of type GetVerifiedWarpBlockHashOutput to conform the ABI outputs.
func PackGetVerifiedWarpMessage ¶
PackGetVerifiedWarpMessage packs [index] of type uint32 into the appropriate arguments for getVerifiedWarpMessage. the packed bytes include selector (first 4 func signature bytes). This function is mostly used for tests.
func PackGetVerifiedWarpMessageOutput ¶
func PackGetVerifiedWarpMessageOutput(outputStruct GetVerifiedWarpMessageOutput) ([]byte, error)
PackGetVerifiedWarpMessageOutput attempts to pack given [outputStruct] of type GetVerifiedWarpMessageOutput to conform the ABI outputs.
func PackSendWarpMessage ¶
func PackSendWarpMessage(inputStruct SendWarpMessageInput) ([]byte, error)
PackSendWarpMessage packs [inputStruct] of type SendWarpMessageInput into the appropriate arguments for sendWarpMessage.
func UnpackGetVerifiedWarpBlockHashInput ¶ added in v0.5.6
UnpackGetVerifiedWarpBlockHashInput attempts to unpack [input] into the uint32 type argument assumes that [input] does not include selector (omits first 4 func signature bytes)
func UnpackGetVerifiedWarpMessageInput ¶ added in v0.5.6
UnpackGetVerifiedWarpMessageInput attempts to unpack [input] into the uint32 type argument assumes that [input] does not include selector (omits first 4 func signature bytes)
Types ¶
type Config ¶
type Config struct { precompileconfig.Upgrade QuorumNumerator uint64 `json:"quorumNumerator"` }
Config implements the precompileconfig.Config interface and adds specific configuration for Warp.
func NewConfig ¶
NewConfig returns a config for a network upgrade at [blockTimestamp] that enables Warp with the given quorum numerator.
func NewDefaultConfig ¶
NewDefaultConfig returns a config for a network upgrade at [blockTimestamp] that enables Warp with the default quorum numerator (0 denotes using the default).
func NewDisableConfig ¶
NewDisableConfig returns config for a network upgrade at [blockTimestamp] that disables Warp.
func (*Config) Accept ¶
func (c *Config) Accept(acceptCtx *precompileconfig.AcceptContext, txHash common.Hash, logIndex int, topics []common.Hash, logData []byte) error
func (*Config) Equal ¶
func (c *Config) Equal(s precompileconfig.Config) bool
Equal returns true if [s] is a *Config and it has been configured identical to [c].
func (*Config) Key ¶
Key returns the key for the Warp precompileconfig. This should be the same key as used in the precompile module.
func (*Config) PredicateGas ¶
PredicateGas returns the amount of gas necessary to verify the predicate PredicateGas charges for: 1. Base cost of the message 2. Size of the message 3. Number of signers 4. TODO: Lookup of the validator set
func (*Config) Verify ¶
func (c *Config) Verify(precompileconfig.ChainConfig) error
Verify tries to verify Config and returns an error accordingly.
func (*Config) VerifyPredicate ¶
func (c *Config) VerifyPredicate(predicateContext *precompileconfig.PredicateContext, predicates [][]byte) []byte
VerifyPredicate verifies the predicate represents a valid signed and properly formatted Avalanche Warp Message.
type GetVerifiedWarpBlockHashOutput ¶ added in v0.5.6
type GetVerifiedWarpBlockHashOutput struct { WarpBlockHash WarpBlockHash Valid bool }
func UnpackGetVerifiedWarpBlockHashOutput ¶ added in v0.5.6
func UnpackGetVerifiedWarpBlockHashOutput(output []byte) (GetVerifiedWarpBlockHashOutput, error)
UnpackGetVerifiedWarpBlockHashOutput attempts to unpack [output] as GetVerifiedWarpBlockHashOutput assumes that [output] does not include selector (omits first 4 func signature bytes)
type GetVerifiedWarpMessageOutput ¶
type GetVerifiedWarpMessageOutput struct { Message WarpMessage Valid bool }
func UnpackGetVerifiedWarpMessageOutput ¶ added in v0.5.6
func UnpackGetVerifiedWarpMessageOutput(output []byte) (GetVerifiedWarpMessageOutput, error)
UnpackGetVerifiedWarpMessageOutput attempts to unpack [output] as GetVerifiedWarpMessageOutput assumes that [output] does not include selector (omits first 4 func signature bytes)
type SendWarpMessageInput ¶
type SendWarpMessageInput struct { DestinationChainID common.Hash DestinationAddress common.Address Payload []byte }
func UnpackSendWarpMessageInput ¶
func UnpackSendWarpMessageInput(input []byte) (SendWarpMessageInput, error)
UnpackSendWarpMessageInput attempts to unpack [input] as SendWarpMessageInput assumes that [input] does not include selector (omits first 4 func signature bytes)
type WarpBlockHash ¶ added in v0.5.6
WarpBlockHash is an auto generated low-level Go binding around an user-defined struct.