evm

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2025 License: Apache-2.0, MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Methods = map[abi.MethodNum]builtin.MethodMeta{
	1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)),
	2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)),
	3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)),
	4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)),
	5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)),
	6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)),
	builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)),
}

Functions

func CheckStateInvariants

func CheckStateInvariants(st *State, store adt.Store) *builtin.MessageAccumulator

Checks internal invariants of evm state.

Types

type ConstructorParams

type ConstructorParams struct {
	Creator  [20]byte
	Initcode []byte
}

func (*ConstructorParams) MarshalCBOR

func (t *ConstructorParams) MarshalCBOR(w io.Writer) error

func (*ConstructorParams) UnmarshalCBOR

func (t *ConstructorParams) UnmarshalCBOR(r io.Reader) (err error)

type DelegateCallParams

type DelegateCallParams struct {
	Code   cid.Cid
	Input  []byte
	Caller [20]byte
	Value  abi.TokenAmount
}

func (*DelegateCallParams) MarshalCBOR

func (t *DelegateCallParams) MarshalCBOR(w io.Writer) error

func (*DelegateCallParams) UnmarshalCBOR

func (t *DelegateCallParams) UnmarshalCBOR(r io.Reader) (err error)

type GetBytecodeReturn

type GetBytecodeReturn struct {
	Cid *cid.Cid
}

func (*GetBytecodeReturn) MarshalCBOR

func (bc *GetBytecodeReturn) MarshalCBOR(w io.Writer) error

func (*GetBytecodeReturn) UnmarshalCBOR

func (bc *GetBytecodeReturn) UnmarshalCBOR(r io.Reader) error

type GetStorageAtParams

type GetStorageAtParams struct {
	StorageKey [32]byte
}

func (*GetStorageAtParams) MarshalCBOR

func (t *GetStorageAtParams) MarshalCBOR(w io.Writer) error

func (*GetStorageAtParams) UnmarshalCBOR

func (t *GetStorageAtParams) UnmarshalCBOR(r io.Reader) (err error)

type ResurrectParams

type ResurrectParams = ConstructorParams

type State

type State struct {
	Bytecode      cid.Cid        // CID of the EVM contract bytecode.
	BytecodeHash  [32]byte       // Keccak256 hash of the contract bytecode.
	ContractState cid.Cid        // CID of the contract's persistent state dictionary.
	TransientData *TransientData // Optional transient storage data associated with the contract.
	Nonce         uint64         // Tracks how many times CREATE or CREATE2 have been invoked.
	Tombstone     *Tombstone     // Optional marker indicating if the contract has been self-destructed.
}

State represents the on-chain state of an EVM contract. It includes the contract bytecode, its hash, storage state, transient data, and nonce tracking.

func ConstructState

func ConstructState(store adt.Store, bytecode cid.Cid) (*State, error)

ConstructState initializes and returns a new contract state with an empty state dictionary.

Parameters:

  • store: The ADT store used for state management.
  • bytecode: CID representing the contract bytecode.

Returns:

  • *State: A pointer to the newly constructed State object.
  • error: An error if state initialization fails.

func (*State) MarshalCBOR

func (t *State) MarshalCBOR(w io.Writer) error

func (*State) UnmarshalCBOR

func (t *State) UnmarshalCBOR(r io.Reader) (err error)

type Tombstone

type Tombstone struct {
	Origin abi.ActorID // The ActorID that initiated the self-destruct.
	Nonce  uint64      // The transaction nonce at the time of self-destruction.
}

Tombstone represents a marker for contracts that have been self-destructed.

func (*Tombstone) MarshalCBOR

func (t *Tombstone) MarshalCBOR(w io.Writer) error

func (*Tombstone) UnmarshalCBOR

func (t *Tombstone) UnmarshalCBOR(r io.Reader) (err error)

type TransientData

type TransientData struct {
	TransientDataState    cid.Cid               // CID of the transient data state dictionary.
	TransientDataLifespan TransientDataLifespan // Data representing the transient data lifespan.
}

TransientData represents transient storage data in an EVM contract. It consists of a state dictionary (KAMT<U256, U256>) and a lifespan tracker.

func (*TransientData) MarshalCBOR

func (t *TransientData) MarshalCBOR(w io.Writer) error

func (*TransientData) UnmarshalCBOR

func (t *TransientData) UnmarshalCBOR(r io.Reader) (err error)

type TransientDataLifespan

type TransientDataLifespan struct {
	Origin abi.ActorID // The origin actor ID associated with the transient data.
	Nonce  uint64      // A unique nonce identifying the transaction.
}

TransientDataLifespan represents the lifespan of transient data. It includes an origin ActorID and a unique nonce to track the transaction.

func (*TransientDataLifespan) MarshalCBOR

func (t *TransientDataLifespan) MarshalCBOR(w io.Writer) error

func (*TransientDataLifespan) UnmarshalCBOR

func (t *TransientDataLifespan) UnmarshalCBOR(r io.Reader) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL