Documentation ¶
Index ¶
- Constants
- func NewPersistentSlabStorage(baseStorage atree.BaseStorage) (*atree.PersistentSlabStorage, error)
- type Account
- type BaseView
- func (v *BaseView) AddressInAccessList(gethCommon.Address) bool
- func (v *BaseView) Commit() error
- func (v *BaseView) CreateAccount(addr gethCommon.Address, balance *uint256.Int, nonce uint64, code []byte, ...) error
- func (v *BaseView) DeleteAccount(addr gethCommon.Address) error
- func (v *BaseView) Exist(addr gethCommon.Address) (bool, error)
- func (v *BaseView) GetBalance(addr gethCommon.Address) (*uint256.Int, error)
- func (v *BaseView) GetCode(addr gethCommon.Address) ([]byte, error)
- func (v *BaseView) GetCodeHash(addr gethCommon.Address) (gethCommon.Hash, error)
- func (v *BaseView) GetCodeSize(addr gethCommon.Address) (int, error)
- func (v *BaseView) GetNonce(addr gethCommon.Address) (uint64, error)
- func (v *BaseView) GetRefund() uint64
- func (v *BaseView) GetState(sk types.SlotAddress) (gethCommon.Hash, error)
- func (v *BaseView) GetStorageRoot(addr common.Address) (common.Hash, error)
- func (v *BaseView) GetTransientState(types.SlotAddress) gethCommon.Hash
- func (v *BaseView) HasSelfDestructed(gethCommon.Address) (bool, *uint256.Int)
- func (v *BaseView) IsCreated(gethCommon.Address) bool
- func (v *BaseView) IsNewContract(gethCommon.Address) bool
- func (v *BaseView) NumberOfAccounts() uint64
- func (v *BaseView) NumberOfContracts() uint64
- func (v *BaseView) SlotInAccessList(types.SlotAddress) (addressOk bool, slotOk bool)
- func (v *BaseView) UpdateAccount(addr gethCommon.Address, balance *uint256.Int, nonce uint64, code []byte, ...) error
- func (v *BaseView) UpdateSlot(sk types.SlotAddress, value gethCommon.Hash) error
- type ByteStringValue
- func (v ByteStringValue) ByteSize() uint32
- func (v ByteStringValue) Bytes() []byte
- func (v ByteStringValue) ChildStorables() []atree.Storable
- func (v ByteStringValue) Encode(enc *atree.Encoder) error
- func (v ByteStringValue) Storable(storage atree.SlabStorage, address atree.Address, maxInlineSize uint64) (atree.Storable, error)
- func (v ByteStringValue) StoredValue(_ atree.SlabStorage) (atree.Value, error)
- func (v ByteStringValue) String() string
- type CodeContainer
- type Collection
- type CollectionProvider
- type DeltaView
- func (d *DeltaView) AddAddressToAccessList(addr gethCommon.Address) bool
- func (d *DeltaView) AddBalance(addr gethCommon.Address, amount *uint256.Int) error
- func (d *DeltaView) AddLog(log *gethTypes.Log)
- func (d *DeltaView) AddPreimage(hash gethCommon.Hash, preimage []byte)
- func (d *DeltaView) AddRefund(amount uint64) error
- func (d *DeltaView) AddSlotToAccessList(sk types.SlotAddress) (addrAdded bool, slotAdded bool)
- func (d *DeltaView) AddressInAccessList(addr gethCommon.Address) bool
- func (d *DeltaView) CreateAccount(addr gethCommon.Address) error
- func (d *DeltaView) CreateContract(addr gethCommon.Address)
- func (d *DeltaView) DirtyAddresses() map[gethCommon.Address]struct{}
- func (d *DeltaView) DirtySlots() map[types.SlotAddress]struct{}
- func (d *DeltaView) Exist(addr gethCommon.Address) (bool, error)
- func (d *DeltaView) GetBalance(addr gethCommon.Address) (*uint256.Int, error)
- func (d *DeltaView) GetCode(addr gethCommon.Address) ([]byte, error)
- func (d *DeltaView) GetCodeHash(addr gethCommon.Address) (gethCommon.Hash, error)
- func (d *DeltaView) GetCodeSize(addr gethCommon.Address) (int, error)
- func (d *DeltaView) GetNonce(addr gethCommon.Address) (uint64, error)
- func (d *DeltaView) GetRefund() uint64
- func (d *DeltaView) GetState(sk types.SlotAddress) (gethCommon.Hash, error)
- func (d *DeltaView) GetStorageRoot(addr gethCommon.Address) (gethCommon.Hash, error)
- func (d *DeltaView) GetTransientState(sk types.SlotAddress) gethCommon.Hash
- func (d *DeltaView) HasSelfDestructed(addr gethCommon.Address) (bool, *uint256.Int)
- func (d *DeltaView) IsCreated(addr gethCommon.Address) bool
- func (d *DeltaView) IsNewContract(addr gethCommon.Address) bool
- func (d *DeltaView) Logs() []*gethTypes.Log
- func (d *DeltaView) NewChildView() *DeltaView
- func (d *DeltaView) Preimages() map[gethCommon.Hash][]byte
- func (d *DeltaView) SelfDestruct(addr gethCommon.Address) error
- func (d *DeltaView) SetCode(addr gethCommon.Address, code []byte) error
- func (d *DeltaView) SetNonce(addr gethCommon.Address, nonce uint64) error
- func (d *DeltaView) SetState(sk types.SlotAddress, value gethCommon.Hash) error
- func (d *DeltaView) SetTransientState(sk types.SlotAddress, value gethCommon.Hash)
- func (d *DeltaView) SlotInAccessList(sk types.SlotAddress) (addressOk bool, slotOk bool)
- func (d *DeltaView) SubBalance(addr gethCommon.Address, amount *uint256.Int) error
- func (d *DeltaView) SubRefund(amount uint64) error
- type StateDB
- func (db *StateDB) AddAddressToAccessList(addr gethCommon.Address)
- func (db *StateDB) AddBalance(addr gethCommon.Address, amount *uint256.Int, ...)
- func (db *StateDB) AddLog(lg *gethTypes.Log)
- func (db *StateDB) AddPreimage(hash gethCommon.Hash, data []byte)
- func (db *StateDB) AddRefund(amount uint64)
- func (db *StateDB) AddSlotToAccessList(addr gethCommon.Address, key gethCommon.Hash)
- func (db *StateDB) AddressInAccessList(addr gethCommon.Address) bool
- func (db *StateDB) Commit(finalize bool) error
- func (db *StateDB) CreateAccount(addr gethCommon.Address)
- func (db *StateDB) CreateContract(addr gethCommon.Address)
- func (db *StateDB) Empty(addr gethCommon.Address) bool
- func (s *StateDB) Error() error
- func (db *StateDB) Exist(addr gethCommon.Address) bool
- func (db *StateDB) Finalize() error
- func (db *StateDB) GetBalance(addr gethCommon.Address) *uint256.Int
- func (db *StateDB) GetCode(addr gethCommon.Address) []byte
- func (db *StateDB) GetCodeHash(addr gethCommon.Address) gethCommon.Hash
- func (db *StateDB) GetCodeSize(addr gethCommon.Address) int
- func (db *StateDB) GetCommittedState(addr gethCommon.Address, key gethCommon.Hash) gethCommon.Hash
- func (db *StateDB) GetNonce(addr gethCommon.Address) uint64
- func (db *StateDB) GetRefund() uint64
- func (db *StateDB) GetState(addr gethCommon.Address, key gethCommon.Hash) gethCommon.Hash
- func (db *StateDB) GetStorageRoot(addr gethCommon.Address) gethCommon.Hash
- func (db *StateDB) GetTransientState(addr gethCommon.Address, key gethCommon.Hash) gethCommon.Hash
- func (db *StateDB) HasSelfDestructed(addr gethCommon.Address) bool
- func (db *StateDB) IsCreated(addr gethCommon.Address) bool
- func (db *StateDB) IsNewContract(addr gethCommon.Address) bool
- func (db *StateDB) Logs(blockNumber uint64, txHash gethCommon.Hash, txIndex uint) []*gethTypes.Log
- func (s *StateDB) PointCache() *gethUtils.PointCache
- func (db *StateDB) Preimages() map[gethCommon.Hash][]byte
- func (db *StateDB) Prepare(rules gethParams.Rules, sender, coinbase gethCommon.Address, ...)
- func (db *StateDB) Reset()
- func (db *StateDB) RevertToSnapshot(index int)
- func (db *StateDB) SelfDestruct(addr gethCommon.Address)
- func (db *StateDB) Selfdestruct6780(addr gethCommon.Address)
- func (db *StateDB) SetCode(addr gethCommon.Address, code []byte)
- func (db *StateDB) SetNonce(addr gethCommon.Address, nonce uint64)
- func (db *StateDB) SetState(addr gethCommon.Address, key gethCommon.Hash, value gethCommon.Hash)
- func (db *StateDB) SetTransientState(addr gethCommon.Address, key, value gethCommon.Hash)
- func (db *StateDB) SlotInAccessList(addr gethCommon.Address, key gethCommon.Hash) (addressOk bool, slotOk bool)
- func (db *StateDB) Snapshot() int
- func (db *StateDB) SubBalance(addr gethCommon.Address, amount *uint256.Int, ...)
- func (db *StateDB) SubRefund(amount uint64)
- func (s *StateDB) Witness() *gethStateless.Witness
Constants ¶
const ( // AccountsStorageIDKey is the path where we store the collection ID for accounts AccountsStorageIDKey = "AccountsStorageIDKey" // CodesStorageIDKey is the path where we store the collection ID for codes CodesStorageIDKey = "CodesStorageIDKey" )
Variables ¶
This section is empty.
Functions ¶
func NewPersistentSlabStorage ¶
func NewPersistentSlabStorage(baseStorage atree.BaseStorage) (*atree.PersistentSlabStorage, error)
Types ¶
type Account ¶
type Account struct { // address Address gethCommon.Address // balance of the address Balance *uint256.Int // nonce of the address Nonce uint64 // hash of the code // if no code the gethTypes.EmptyCodeHash is stored CodeHash gethCommon.Hash // the id of the collection holds storage slots for this account // this value is nil for EOA accounts CollectionID []byte }
Account holds the metadata of an address and provides (de)serialization functionality
Note that code and storage slots of an address is not part of this data structure
func DecodeAccount ¶
DecodeAccount constructs a new account from the encoded data
func NewAccount ¶
func NewAccount( address gethCommon.Address, balance *uint256.Int, nonce uint64, codeHash gethCommon.Hash, collectionID []byte, ) *Account
NewAccount constructs a new account
type BaseView ¶
type BaseView struct {
// contains filtered or unexported fields
}
BaseView implements a types.BaseView it acts as the base layer of state queries for the stateDB it stores accounts, codes and storage slots.
under the hood it uses a set of collections, one for account's meta data, one for codes and one for each of account storage space.
func NewBaseView ¶
NewBaseView constructs a new base view
func (*BaseView) AddressInAccessList ¶
func (v *BaseView) AddressInAccessList(gethCommon.Address) bool
AddressInAccessList checks if an address is in the access list
access list control is not a functionality of the base view it always returns false
func (*BaseView) CreateAccount ¶
func (v *BaseView) CreateAccount( addr gethCommon.Address, balance *uint256.Int, nonce uint64, code []byte, codeHash gethCommon.Hash, ) error
CreateAccount creates a new account
func (*BaseView) DeleteAccount ¶
func (v *BaseView) DeleteAccount(addr gethCommon.Address) error
DeleteAccount deletes an account's meta data, code, and storage slots associated with that address
func (*BaseView) Exist ¶
func (v *BaseView) Exist(addr gethCommon.Address) (bool, error)
Exist returns true if the address exist in the state
func (*BaseView) GetBalance ¶
GetBalance returns the balance of an address
for non-existent accounts it returns a balance of zero
func (*BaseView) GetCode ¶
func (v *BaseView) GetCode(addr gethCommon.Address) ([]byte, error)
GetCode returns the code of an address
for non-existent accounts or accounts without a code (e.g. EOAs) it returns nil
func (*BaseView) GetCodeHash ¶
func (v *BaseView) GetCodeHash(addr gethCommon.Address) (gethCommon.Hash, error)
GetCodeHash returns the code hash of an address
for non-existent accounts it returns gethCommon.Hash{} and for accounts without a code (e.g. EOAs) it returns default empty hash value (gethTypes.EmptyCodeHash)
func (*BaseView) GetCodeSize ¶
func (v *BaseView) GetCodeSize(addr gethCommon.Address) (int, error)
GetCodeSize returns the code size of an address
for non-existent accounts or accounts without a code (e.g. EOAs) it returns zero
func (*BaseView) GetNonce ¶
func (v *BaseView) GetNonce(addr gethCommon.Address) (uint64, error)
GetNonce returns the nonce of an address
for non-existent accounts it returns zero
func (*BaseView) GetRefund ¶
GetRefund returns the total amount of (gas) refund
this method returns the value of zero
func (*BaseView) GetState ¶
func (v *BaseView) GetState(sk types.SlotAddress) (gethCommon.Hash, error)
GetState returns values for a slot in the main storage
for non-existent slots it returns the default empty hash value (gethTypes.EmptyCodeHash)
func (*BaseView) GetStorageRoot ¶ added in v0.36.2
GetStorageRoot returns some sort of storage root for the given address WARNING! the root that is returned is not a commitment to the state Mostly is returned to satisfy the requirements of the EVM, where the returned value is compared against empty hash and empty root hash to determine smart contracts that already has data.
Since BaseView doesn't construct a Merkel tree for each account hash of root slab as some sort of root hash. if account doesn't exist we return empty hash if account exist but not a smart contract we return EmptyRootHash if is a contract we return the hash of the root slab content (some sort of commitment).
func (*BaseView) GetTransientState ¶
func (v *BaseView) GetTransientState(types.SlotAddress) gethCommon.Hash
GetTransientState returns values for an slot transient storage
transient storage is not a functionality for the base view so it always returns the default value for non-existent slots
func (*BaseView) HasSelfDestructed ¶
HasSelfDestructed returns true if an address is flagged for destruction at the end of transaction
func (*BaseView) IsCreated ¶
func (v *BaseView) IsCreated(gethCommon.Address) bool
IsCreated returns true if the address has been created in the context of this transaction
func (*BaseView) IsNewContract ¶ added in v0.36.2
func (v *BaseView) IsNewContract(gethCommon.Address) bool
IsNewContract returns true if the address is a new contract
func (*BaseView) NumberOfAccounts ¶ added in v0.33.30
NumberOfContracts returns the number of accounts
func (*BaseView) NumberOfContracts ¶ added in v0.33.30
NumberOfContracts returns the number of unique contracts
func (*BaseView) SlotInAccessList ¶
func (v *BaseView) SlotInAccessList(types.SlotAddress) (addressOk bool, slotOk bool)
SlotInAccessList checks if a slot is in the access list
access list control is not a functionality of the base view it always returns false
func (*BaseView) UpdateAccount ¶
func (v *BaseView) UpdateAccount( addr gethCommon.Address, balance *uint256.Int, nonce uint64, code []byte, codeHash gethCommon.Hash, ) error
UpdateAccount updates an account's meta data
func (*BaseView) UpdateSlot ¶
func (v *BaseView) UpdateSlot(sk types.SlotAddress, value gethCommon.Hash) error
UpdateSlot updates the value for a slot
type ByteStringValue ¶
type ByteStringValue struct {
// contains filtered or unexported fields
}
func NewByteStringValue ¶
func NewByteStringValue(data []byte) ByteStringValue
func (ByteStringValue) ByteSize ¶
func (v ByteStringValue) ByteSize() uint32
func (ByteStringValue) Bytes ¶
func (v ByteStringValue) Bytes() []byte
func (ByteStringValue) ChildStorables ¶
func (v ByteStringValue) ChildStorables() []atree.Storable
func (ByteStringValue) Storable ¶
func (v ByteStringValue) Storable(storage atree.SlabStorage, address atree.Address, maxInlineSize uint64) (atree.Storable, error)
func (ByteStringValue) StoredValue ¶
func (v ByteStringValue) StoredValue(_ atree.SlabStorage) (atree.Value, error)
func (ByteStringValue) String ¶
func (v ByteStringValue) String() string
type CodeContainer ¶ added in v0.33.30
type CodeContainer struct {
// contains filtered or unexported fields
}
CodeContainer contains codes and keeps track of reference counts
func CodeContainerFromEncoded ¶ added in v0.33.30
func CodeContainerFromEncoded(encoded []byte) (*CodeContainer, error)
CodeContainerFromEncoded constructs a code container from the encoded data
func NewCodeContainer ¶ added in v0.33.30
func NewCodeContainer(code []byte) *CodeContainer
NewCodeContainer constructs a new code container
func (*CodeContainer) Code ¶ added in v0.33.30
func (cc *CodeContainer) Code() []byte
Code returns the code part of the code container
func (*CodeContainer) DecRefCount ¶ added in v0.33.30
func (cc *CodeContainer) DecRefCount() bool
DecRefCount decrement the ref count and returns true if the ref has reached to zero
func (*CodeContainer) Encode ¶ added in v0.33.30
func (cc *CodeContainer) Encode() []byte
Encoded returns the encoded content of the code container
func (*CodeContainer) IncRefCount ¶ added in v0.33.30
func (cc *CodeContainer) IncRefCount()
IncRefCount increment the ref count
func (*CodeContainer) RefCount ¶ added in v0.33.30
func (cc *CodeContainer) RefCount() uint64
RefCount returns the ref count
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection provides a persistent and compact way of storing key/value pairs each collection has a unique collectionID that can be used to fetch the collection
TODO(ramtin): we might not need any extra hashing on the atree side and optimize this to just use the key given the keys are hashed ?
func (*Collection) CollectionID ¶
func (c *Collection) CollectionID() []byte
CollectionID returns the unique id for the collection
func (*Collection) Destroy ¶
func (c *Collection) Destroy() ([][]byte, error)
Destroy destroys the whole collection
func (*Collection) Get ¶
func (c *Collection) Get(key []byte) ([]byte, error)
Get gets the value for the given key
if key doesn't exist it returns nil (no error)
func (*Collection) Remove ¶
func (c *Collection) Remove(key []byte) error
Remove removes a key from the collection
if the key doesn't exist it return no error
func (*Collection) Set ¶
func (c *Collection) Set(key, value []byte) error
Set sets the value for the given key
if a value already stored at the given key it replaces the value
func (*Collection) Size ¶ added in v0.33.30
func (c *Collection) Size() uint64
Size returns the number of items in the collection
type CollectionProvider ¶
type CollectionProvider struct {
// contains filtered or unexported fields
}
CollectionProvider provides access to collections
func NewCollectionProvider ¶
func NewCollectionProvider( rootAddr atree.Address, ledger atree.Ledger, ) (*CollectionProvider, error)
NewCollectionProvider constructs a new CollectionProvider
func (*CollectionProvider) CollectionByID ¶
func (cp *CollectionProvider) CollectionByID(collectionID []byte) (*Collection, error)
CollectionByID returns the collection by collection ID
if no collection is found with that collection id, it return error Warning: this method should only used only once for each collection and the returned pointer should be kept for the future. calling twice for the same collection might result in odd-behaviours currently collection provider doesn't do any internal caching to protect against these cases
func (*CollectionProvider) Commit ¶
func (cp *CollectionProvider) Commit() error
Commit commits all changes to the collections with changes
func (*CollectionProvider) NewCollection ¶
func (cp *CollectionProvider) NewCollection() (*Collection, error)
NewCollection constructs a new collection
type DeltaView ¶
type DeltaView struct {
// contains filtered or unexported fields
}
DeltaView captures the changes to the state during the execution
for most of the read calls it checks its change logs and if no record is found it would redirect the call to the parent view.
func NewDeltaView ¶
func NewDeltaView(parent types.ReadOnlyView) *DeltaView
NewDeltaView constructs a new delta view
func (*DeltaView) AddAddressToAccessList ¶
func (d *DeltaView) AddAddressToAccessList(addr gethCommon.Address) bool
AddAddressToAccessList adds an address to the access list
func (*DeltaView) AddBalance ¶
AddBalance adds the amount to the current balance of the given address
func (*DeltaView) AddPreimage ¶
func (d *DeltaView) AddPreimage(hash gethCommon.Hash, preimage []byte)
AddPreimage adds a preimage
func (*DeltaView) AddSlotToAccessList ¶
func (d *DeltaView) AddSlotToAccessList(sk types.SlotAddress) (addrAdded bool, slotAdded bool)
AddSlotToAccessList adds a slot to the access list it also adds the address to the address list
func (*DeltaView) AddressInAccessList ¶
func (d *DeltaView) AddressInAccessList(addr gethCommon.Address) bool
AddressInAccessList checks if the address is in the access list
func (*DeltaView) CreateAccount ¶
func (d *DeltaView) CreateAccount(addr gethCommon.Address) error
CreateAccount creates a new account for the given address
if address already exists (even if destructed), carry over the balance and reset the data from the original account.
func (*DeltaView) CreateContract ¶ added in v0.36.2
func (d *DeltaView) CreateContract(addr gethCommon.Address)
CreateContract is used whenever a contract is created. This may be preceded by CreateAccount, but that is not required if it already existed in the state due to funds sent beforehand.
func (*DeltaView) DirtyAddresses ¶
func (d *DeltaView) DirtyAddresses() map[gethCommon.Address]struct{}
DirtyAddresses returns a set of addresses that has been updated in this view
func (*DeltaView) DirtySlots ¶
func (d *DeltaView) DirtySlots() map[types.SlotAddress]struct{}
DirtySlots returns a set of slots that has been updated in this view
func (*DeltaView) Exist ¶
func (d *DeltaView) Exist(addr gethCommon.Address) (bool, error)
Exist returns true if address exists
it also returns true for both newly created accounts or accounts that has been flagged for deletion
func (*DeltaView) GetBalance ¶
GetBalance returns the balance of the given address
func (*DeltaView) GetCode ¶
func (d *DeltaView) GetCode(addr gethCommon.Address) ([]byte, error)
GetCode returns the code of the given address
func (*DeltaView) GetCodeHash ¶
func (d *DeltaView) GetCodeHash(addr gethCommon.Address) (gethCommon.Hash, error)
GetCodeHash returns the code hash of the given address
func (*DeltaView) GetCodeSize ¶
func (d *DeltaView) GetCodeSize(addr gethCommon.Address) (int, error)
GetCodeSize returns the code size of the given address
func (*DeltaView) GetNonce ¶
func (d *DeltaView) GetNonce(addr gethCommon.Address) (uint64, error)
GetNonce returns the nonce of the given address
func (*DeltaView) GetState ¶
func (d *DeltaView) GetState(sk types.SlotAddress) (gethCommon.Hash, error)
GetState returns the value of the slot of the main state
func (*DeltaView) GetStorageRoot ¶ added in v0.36.2
func (d *DeltaView) GetStorageRoot(addr gethCommon.Address) (gethCommon.Hash, error)
GetStorageRoot returns some sort of storage root for the given address
WARNING! the root that is returned is not a commitment to the state Mostly is returned to satisfy the requirements of the EVM, where the returned value is compared against empty hash and empty root hash values to determine smart contracts that already has data.
Here we return values for non-existing accounts, and redirect the call all the way back to the base view. This means that the state root that is returned ignores the updates to slots during the transaction.
func (*DeltaView) GetTransientState ¶
func (d *DeltaView) GetTransientState(sk types.SlotAddress) gethCommon.Hash
GetTransientState returns the value of the slot of the transient state
func (*DeltaView) HasSelfDestructed ¶
HasSelfDestructed returns true if address has been flagged for destruction it also returns the balance of the address before the destruction call
func (*DeltaView) IsCreated ¶
func (d *DeltaView) IsCreated(addr gethCommon.Address) bool
IsCreated returns true if address has been created in this tx
func (*DeltaView) IsNewContract ¶ added in v0.36.2
func (d *DeltaView) IsNewContract(addr gethCommon.Address) bool
IsNewContract returns true if address has been created in this tx. It's used to correctly handle EIP-6780 'delete-in-same-transaction' logic.
func (*DeltaView) NewChildView ¶
NewChildView constructs a new delta view having the current view as parent
func (*DeltaView) Preimages ¶
func (d *DeltaView) Preimages() map[gethCommon.Hash][]byte
Preimages returns a map of preimages
func (*DeltaView) SelfDestruct ¶
func (d *DeltaView) SelfDestruct(addr gethCommon.Address) error
SelfDestruct sets a flag to destruct the account at the end of transaction
if an account has been created in this transaction, it would return an error
func (*DeltaView) SetCode ¶
func (d *DeltaView) SetCode(addr gethCommon.Address, code []byte) error
SetCode sets the code for the given address
func (*DeltaView) SetNonce ¶
func (d *DeltaView) SetNonce(addr gethCommon.Address, nonce uint64) error
SetNonce sets the nonce for the given address
func (*DeltaView) SetState ¶
func (d *DeltaView) SetState(sk types.SlotAddress, value gethCommon.Hash) error
SetState adds sets a value for the given slot of the main storage
func (*DeltaView) SetTransientState ¶
func (d *DeltaView) SetTransientState(sk types.SlotAddress, value gethCommon.Hash)
SetTransientState adds sets a value for the given slot of the transient storage
func (*DeltaView) SlotInAccessList ¶
func (d *DeltaView) SlotInAccessList(sk types.SlotAddress) (addressOk bool, slotOk bool)
SlotInAccessList checks if the slot is in the access list
func (*DeltaView) SubBalance ¶
SubBalance subtracts the amount from the current balance of the given address
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
StateDB implements a types.StateDB interface
stateDB interface defined by the Geth doesn't support returning errors when state calls are happening, and requires stateDB to cache the error and return it at a later time (when commit is called). Only the first error is expected to be returned. Warning: current implementation of the StateDB is considered to be used for a single EVM transaction execution and is not thread safe. yet the current design supports addition of concurrency in the future if needed
func NewStateDB ¶
NewStateDB constructs a new StateDB
func (*StateDB) AddAddressToAccessList ¶
func (db *StateDB) AddAddressToAccessList(addr gethCommon.Address)
AddAddressToAccessList adds the given address to the access list.
func (*StateDB) AddBalance ¶
func (db *StateDB) AddBalance( addr gethCommon.Address, amount *uint256.Int, reason gethTracing.BalanceChangeReason, )
AddBalance adds the amount from the balance of the given address
func (*StateDB) AddPreimage ¶
func (db *StateDB) AddPreimage(hash gethCommon.Hash, data []byte)
AddPreimage adds a pre-image to the collection of pre-images
func (*StateDB) AddSlotToAccessList ¶
func (db *StateDB) AddSlotToAccessList(addr gethCommon.Address, key gethCommon.Hash)
AddSlotToAccessList adds the given (address,slot) to the access list.
func (*StateDB) AddressInAccessList ¶
func (db *StateDB) AddressInAccessList(addr gethCommon.Address) bool
AddressInAccessList checks if an address is in the access list
func (*StateDB) CreateAccount ¶
func (db *StateDB) CreateAccount(addr gethCommon.Address)
CreateAccount creates a new account for the given address it sets the nonce to zero
func (*StateDB) CreateContract ¶ added in v0.36.2
func (db *StateDB) CreateContract(addr gethCommon.Address)
CreateContract is used whenever a contract is created. This may be preceded by CreateAccount, but that is not required if it already existed in the state due to funds sent beforehand. This operation sets the 'newContract'-flag, which is required in order to correctly handle EIP-6780 'delete-in-same-transaction' logic.
func (*StateDB) Empty ¶
func (db *StateDB) Empty(addr gethCommon.Address) bool
Empty returns whether the given account is empty.
Empty is defined according to EIP161 (balance = nonce = code = 0).
func (*StateDB) Exist ¶
func (db *StateDB) Exist(addr gethCommon.Address) bool
Exist returns true if the given address exists in state.
this should also return true for self destructed accounts during the transaction execution.
func (*StateDB) Finalize ¶ added in v0.33.30
Finalize flushes all the changes to the permanent storage
func (*StateDB) GetBalance ¶
func (db *StateDB) GetBalance(addr gethCommon.Address) *uint256.Int
GetBalance returns the balance of the given address
func (*StateDB) GetCode ¶
func (db *StateDB) GetCode(addr gethCommon.Address) []byte
GetCode returns the code for the given address
func (*StateDB) GetCodeHash ¶
func (db *StateDB) GetCodeHash(addr gethCommon.Address) gethCommon.Hash
GetCodeHash returns the code hash of the given address
func (*StateDB) GetCodeSize ¶
func (db *StateDB) GetCodeSize(addr gethCommon.Address) int
GetCodeSize returns the size of the code for the given address
func (*StateDB) GetCommittedState ¶
func (db *StateDB) GetCommittedState(addr gethCommon.Address, key gethCommon.Hash) gethCommon.Hash
GetCommittedState returns the value for the given storage slot considering only the committed state and not changes in the scope of current transaction.
func (*StateDB) GetNonce ¶
func (db *StateDB) GetNonce(addr gethCommon.Address) uint64
GetNonce returns the nonce of the given address
func (*StateDB) GetState ¶
func (db *StateDB) GetState(addr gethCommon.Address, key gethCommon.Hash) gethCommon.Hash
GetState returns the value for the given storage slot
func (*StateDB) GetStorageRoot ¶ added in v0.36.2
func (db *StateDB) GetStorageRoot(addr gethCommon.Address) gethCommon.Hash
GetStorageRoot returns some sort of root for the given address.
Warning! Since StateDB doesn't construct a Merkle tree under the hood, the behavior of this endpoint is as follow: - if an account doesn't exist it returns common.Hash{} - if account is EOA it returns gethCommon.EmptyRootHash - else it returns a unique hash value as the root but this returned
This behavior is ok for this version of EVM as the only use case in the EVM right now is here https://github.com/onflow/go-ethereum/blob/37590b2c5579c36d846c788c70861685b0ea240e/core/vm/evm.go#L480 where the value that is returned is compared to empty values to make sure the storage is empty This endpoint is added mostly to prevent the case that an smart contract is self-destructed and a later transaction tries to deploy a contract to the same address.
func (*StateDB) GetTransientState ¶
func (db *StateDB) GetTransientState(addr gethCommon.Address, key gethCommon.Hash) gethCommon.Hash
GetTransientState returns the value for the given key of the transient storage
func (*StateDB) HasSelfDestructed ¶
func (db *StateDB) HasSelfDestructed(addr gethCommon.Address) bool
HasSelfDestructed returns true if address is flagged with self destruct.
func (*StateDB) IsCreated ¶
func (db *StateDB) IsCreated(addr gethCommon.Address) bool
IsCreated returns true if address is recently created (context of a transaction)
func (*StateDB) IsNewContract ¶ added in v0.36.2
func (db *StateDB) IsNewContract(addr gethCommon.Address) bool
IsCreated returns true if address is a new contract
func (*StateDB) Logs ¶
func (db *StateDB) Logs( blockNumber uint64, txHash gethCommon.Hash, txIndex uint, ) []*gethTypes.Log
Logs returns the list of logs it also update each log with the block and tx info
func (*StateDB) PointCache ¶ added in v0.36.2
func (s *StateDB) PointCache() *gethUtils.PointCache
PointCache is not supported and only needed when EIP-4762 is enabled in the future versions (currently planned for after Verkle fork).
func (*StateDB) Preimages ¶
func (db *StateDB) Preimages() map[gethCommon.Hash][]byte
Preimages returns a set of pre-images
func (*StateDB) Prepare ¶
func (db *StateDB) Prepare(rules gethParams.Rules, sender, coinbase gethCommon.Address, dest *gethCommon.Address, precompiles []gethCommon.Address, txAccesses gethTypes.AccessList)
Prepare is a high level logic that sadly is considered to be part of the stateDB interface and not on the layers above. based on parameters that are passed it updates access-lists
func (*StateDB) Reset ¶ added in v0.33.30
func (db *StateDB) Reset()
Reset resets uncommitted changes and transient artifacts such as error, logs, pre-images, access lists, ... The method is often called between execution of different transactions
func (*StateDB) RevertToSnapshot ¶
RevertToSnapshot reverts the changes until we reach the given snapshot
func (*StateDB) SelfDestruct ¶
func (db *StateDB) SelfDestruct(addr gethCommon.Address)
SelfDestruct flags the address for deletion.
while this address exists for the rest of transaction, the balance of this account is return zero after the SelfDestruct call.
func (*StateDB) Selfdestruct6780 ¶
func (db *StateDB) Selfdestruct6780(addr gethCommon.Address)
Selfdestruct6780 would only follow the self destruct steps if account is a new contract either just created, or address had balance before but got a contract deployed to it (in this tx).
func (*StateDB) SetCode ¶
func (db *StateDB) SetCode(addr gethCommon.Address, code []byte)
SetCode sets the code for the given address
func (*StateDB) SetNonce ¶
func (db *StateDB) SetNonce(addr gethCommon.Address, nonce uint64)
SetNonce sets the nonce value for the given address
func (*StateDB) SetState ¶
func (db *StateDB) SetState(addr gethCommon.Address, key gethCommon.Hash, value gethCommon.Hash)
SetState sets a value for the given storage slot
func (*StateDB) SetTransientState ¶
func (db *StateDB) SetTransientState(addr gethCommon.Address, key, value gethCommon.Hash)
SetTransientState sets a value for the given key of the transient storage
func (*StateDB) SlotInAccessList ¶
func (db *StateDB) SlotInAccessList(addr gethCommon.Address, key gethCommon.Hash) (addressOk bool, slotOk bool)
SlotInAccessList checks if the given (address,slot) is in the access list
func (*StateDB) Snapshot ¶
Snapshot takes an snapshot of the state and returns an int that can be used later for revert calls.
func (*StateDB) SubBalance ¶
func (db *StateDB) SubBalance( addr gethCommon.Address, amount *uint256.Int, reason gethTracing.BalanceChangeReason, )
SubBalance substitutes the amount from the balance of the given address
func (*StateDB) Witness ¶ added in v0.36.2
func (s *StateDB) Witness() *gethStateless.Witness
Witness is not supported and only needed when if witness collection is enabled (EnableWitnessCollection flag). By definition it should returns a set containing all trie nodes that have been accessed. The returned map could be nil if the witness is empty.