state

package
v0.0.0-...-5cda5f8 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CALLFLAG_CALL         = 0
	CALLFLAG_CALLCODE     = 1
	CALLFLAG_DELEGATECALL = 2
	CALLFLAG_STATICCALL   = 3
	CALLFLAG_CREATE       = 4
	CALLFLAG_CREATE2      = 5
)
View Source
const RECENT_BLOCK_HASHES_LENGTH = 256

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessListTrie

type AccessListTrie struct {
}

func NewAccessListTrie

func NewAccessListTrie() *AccessListTrie

func (*AccessListTrie) EncodeState

func (s *AccessListTrie) EncodeState() []byte

func (*AccessListTrie) Root

func (s *AccessListTrie) Root() common.Hash

type Account

type Account struct {
	Nonce       uint64
	Balance     uint256.Int
	StorageRoot common.Hash
	CodeHash    common.Hash
}

func AccountFromEVM

func AccountFromEVM(acc types.StateAccount) *Account

func (*Account) Encode

func (acc *Account) Encode() []byte

type BlockHash

type BlockHash common.Hash

func (BlockHash) CalculateHash

func (b BlockHash) CalculateHash() ([]byte, error)

func (BlockHash) Equals

func (b BlockHash) Equals(other basic_merkletree.Content) (bool, error)

type BlockHashTree

type BlockHashTree struct {
	Hashes BlockHashes
	// contains filtered or unexported fields
}

func BlockHashTreeFromBlockContext

func BlockHashTreeFromBlockContext(blockCtx *vm.BlockContext) (*BlockHashTree, error)

func BlockHashTreeFromContext

func BlockHashTreeFromContext(blockCtx *vm.Context) (*BlockHashTree, error)

func NewBlockHashTree

func NewBlockHashTree(hashes *BlockHashes) (*BlockHashTree, error)

func (*BlockHashTree) Copy

func (b *BlockHashTree) Copy() *BlockHashTree

func (*BlockHashTree) EncodeState

func (b *BlockHashTree) EncodeState() []byte

func (*BlockHashTree) GetBlockHash

func (b *BlockHashTree) GetBlockHash(number uint64) common.Hash

func (*BlockHashTree) GetProof

func (b *BlockHashTree) GetProof(number uint64) ([]common.Hash, uint64, error)

func (*BlockHashTree) Root

func (b *BlockHashTree) Root() common.Hash

func (*BlockHashTree) SetBlockHash

func (b *BlockHashTree) SetBlockHash(number *uint256.Int, hash common.Hash) error

type BlockState

type BlockState struct {
	BlockNumber   uint64
	GlobalState   vm.StateDB
	BlockHashTree *BlockHashTree
}

Represent the state at the end of a finalized block

func BlockStateFromBlock

func BlockStateFromBlock(blockNumber uint64, stateDB vm.StateDB, blockHashTree *BlockHashTree) (*BlockState, error)

func (*BlockState) Hash

func (s *BlockState) Hash() common.Hash

func (*BlockState) IsInter

func (s *BlockState) IsInter() bool

type CallFlag

type CallFlag byte

func OpCodeToCallFlag

func OpCodeToCallFlag(op vm.OpCode) CallFlag

func (CallFlag) IsCreate

func (f CallFlag) IsCreate() bool

type InterState

type InterState struct {
	BlockNumber     uint64
	TransactionIdx  uint64
	GlobalState     vm.StateDB
	BlockGasUsed    *uint256.Int
	BlockHashTree   *BlockHashTree
	TransactionTrie *TransactionTrie
	ReceiptTrie     *ReceiptTrie
}

func InterStateFromCaptured

func InterStateFromCaptured(
	blockNumber, transactionIdx uint64,
	statedb vm.StateDB,
	blockGasUsed *big.Int,
	transactions types.Transactions,
	receipts types.Receipts,
	blockHashTree *BlockHashTree,
) *InterState

func (*InterState) Hash

func (s *InterState) Hash() common.Hash

func (*InterState) IsInter

func (s *InterState) IsInter() bool

type IntraState

type IntraState struct {
	BlockNumber          uint64
	TransactionIdx       uint64
	Depth                uint16
	Gas                  uint64
	Refund               uint64
	LastDepthState       OneStepState
	ContractAddress      common.Address
	Caller               common.Address
	Value                uint256.Int
	CallFlag             CallFlag
	Out                  uint64
	OutSize              uint64
	Pc                   uint64
	OpCode               vm.OpCode
	CodeHash             common.Hash
	Stack                *Stack
	Memory               *Memory
	InputData            *Memory
	ReturnData           *Memory
	CommittedGlobalState vm.StateDB
	GlobalState          vm.StateDB
	SelfDestructSet      *SelfDestructSet
	LogSeries            *LogSeries
	BlockHashTree        *BlockHashTree
	AccessListTrie       *AccessListTrie
}

func StateFromCaptured

func StateFromCaptured(
	blockNumber, transactionIdx uint64,
	committedGlobalState vm.StateDB,
	selfDestructSet *SelfDestructSet,
	blockHashTree *BlockHashTree,
	accessListTrie *AccessListTrie,
	evm *vm.EVM,
	lastDepthState OneStepState,
	callFlag CallFlag,
	inputData *Memory,
	out, outSize, pc uint64,
	op vm.OpCode,
	gas, cost uint64,
	memory *vm.Memory,
	stack *vm.Stack,
	contract *vm.Contract,
	rData []byte,
	depth int,
) *IntraState

func (*IntraState) Encode

func (s *IntraState) Encode() []byte

func (*IntraState) Hash

func (s *IntraState) Hash() common.Hash

func (*IntraState) HashAsLastDepth

func (s *IntraState) HashAsLastDepth(callFlag CallFlag, cost uint64) common.Hash

func (*IntraState) IsInter

func (s *IntraState) IsInter() bool

func (*IntraState) StateAsLastDepth

func (s *IntraState) StateAsLastDepth(callFlag CallFlag, cost uint64) *IntraState

Make sure the cost is less than the current gas

type LogSeries

type LogSeries struct {
	Logs           []*types.Log
	AccumulateHash common.Hash
	Bloom          types.Bloom
}

func LogSeriesFromLogs

func LogSeriesFromLogs(logs []*types.Log) *LogSeries

func (*LogSeries) EncodeState

func (l *LogSeries) EncodeState() []byte

func (*LogSeries) Hash

func (l *LogSeries) Hash() common.Hash

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

func MemoryFromEVMMemory

func MemoryFromEVMMemory(mem *vm.Memory) *Memory

func NewMemoryFromBytes

func NewMemoryFromBytes(values []byte) *Memory

func (*Memory) Cell

func (m *Memory) Cell(i uint64) *uint256.Int

func (*Memory) CellNum

func (m *Memory) CellNum() uint64

func (*Memory) Data

func (m *Memory) Data() []byte

func (*Memory) Empty

func (m *Memory) Empty() bool

func (*Memory) EncodeState

func (m *Memory) EncodeState() []byte

func (*Memory) GetAppendProof

func (m *Memory) GetAppendProof() []common.Hash

func (*Memory) GetCombinedProof

func (m *Memory) GetCombinedProof(indices []uint64) ([]common.Hash, error)

func (*Memory) GetProof

func (m *Memory) GetProof(indices []uint64) []common.Hash

func (*Memory) Root

func (m *Memory) Root() common.Hash

func (*Memory) Size

func (m *Memory) Size() uint64

type OneStepState

type OneStepState interface {
	Hash() common.Hash
	IsInter() bool
}

type ReceiptTrie

type ReceiptTrie struct {
	// contains filtered or unexported fields
}

func NewReceiptTrie

func NewReceiptTrie(receipts types.Receipts) *ReceiptTrie

func (*ReceiptTrie) Bloom

func (r *ReceiptTrie) Bloom() types.Bloom

func (*ReceiptTrie) EncodeState

func (r *ReceiptTrie) EncodeState() []byte

func (*ReceiptTrie) GetReceipt

func (r *ReceiptTrie) GetReceipt(index int) *types.Receipt

func (*ReceiptTrie) Prove

func (r *ReceiptTrie) Prove(index int) ([][]byte, error)

func (*ReceiptTrie) Root

func (r *ReceiptTrie) Root() common.Hash

type SelfDestructSet

type SelfDestructSet struct {
	Contracts []common.Address
	Hash      common.Hash
}

func NewSelfDestructSet

func NewSelfDestructSet() *SelfDestructSet

func (*SelfDestructSet) Add

func (*SelfDestructSet) EncodeState

func (s *SelfDestructSet) EncodeState() []byte

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

func EmptyStack

func EmptyStack() *Stack

func NewStack

func NewStack(values []uint256.Int) *Stack

func StackFromEVMStack

func StackFromEVMStack(s *vm.Stack) *Stack

func (*Stack) Back

func (st *Stack) Back(n int) *uint256.Int

func (*Stack) Copy

func (st *Stack) Copy() *Stack

func (*Stack) Data

func (st *Stack) Data() []uint256.Int

func (*Stack) EncodeState

func (st *Stack) EncodeState() []byte

func (*Stack) Hash

func (st *Stack) Hash() common.Hash

func (*Stack) HashAfterPops

func (st *Stack) HashAfterPops(n int) common.Hash

func (*Stack) Len

func (st *Stack) Len() int

func (*Stack) Peek

func (st *Stack) Peek() *uint256.Int

func (*Stack) PopN

func (st *Stack) PopN(n int)

type StateType

type StateType string
const (
	BlockStateType StateType = "BlockState"
	InterStateType StateType = "InterState"
	IntraStateType StateType = "IntraState"
)

type TransactionTrie

type TransactionTrie struct {
	// contains filtered or unexported fields
}

func NewTransactionTrie

func NewTransactionTrie(txs types.Transactions) *TransactionTrie

func (*TransactionTrie) EncodeState

func (t *TransactionTrie) EncodeState() []byte

func (*TransactionTrie) GetTransaction

func (t *TransactionTrie) GetTransaction(index int) *types.Transaction

func (*TransactionTrie) Prove

func (t *TransactionTrie) Prove(index int) ([][]byte, error)

func (*TransactionTrie) Root

func (t *TransactionTrie) Root() common.Hash

Jump to

Keyboard shortcuts

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