Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteClass(w db.KeyValueWriter, classHash *felt.Felt) error
- func DeleteClassHashHistory(w db.KeyValueWriter, addr *felt.Felt, blockNum uint64) error
- func DeleteContract(w db.KeyValueWriter, addr *felt.Felt) error
- func DeleteNonceHistory(w db.KeyValueWriter, addr *felt.Felt, blockNum uint64) error
- func DeleteStorageHistory(w db.KeyValueWriter, addr, key *felt.Felt, blockNum uint64) error
- func GetClass(r db.KeyValueReader, classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
- func GetContract(r db.KeyValueReader, addr *felt.Felt) (stateContract, error)
- func GetStateObject(r db.KeyValueReader, state *State, addr *felt.Felt) (*stateObject, error)
- func HasClass(r db.KeyValueReader, classHash *felt.Felt) (bool, error)
- func HasContract(r db.KeyValueReader, addr *felt.Felt) (bool, error)
- func NewStateHistory(blockNum uint64, stateRoot *felt.Felt, db *StateDB) (stateHistory, error)
- func WriteClass(w db.KeyValueWriter, classHash *felt.Felt, class core.ClassDefinition, ...) error
- func WriteClassHashHistory(w db.KeyValueWriter, addr *felt.Felt, blockNum uint64, classHash *felt.Felt) error
- func WriteContract(w db.KeyValueWriter, addr *felt.Felt, contract *stateContract) error
- func WriteNonceHistory(w db.KeyValueWriter, addr *felt.Felt, blockNum uint64, nonce *felt.Felt) error
- func WriteStorageHistory(w db.KeyValueWriter, addr, key *felt.Felt, blockNum uint64, value *felt.Felt) error
- type State
- func (s *State) Class(classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
- func (s *State) ClassTrie() (core.Trie, error)
- func (s *State) Commitment(protocolVersion string) (felt.Felt, error)
- func (s *State) CompiledClassHash(classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
- func (s *State) CompiledClassHashAt(classHash *felt.SierraClassHash, blockNumber uint64) (felt.CasmClassHash, error)
- func (s *State) CompiledClassHashV2(classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
- func (s *State) ContractClassHash(addr *felt.Felt) (felt.Felt, error)
- func (s *State) ContractClassHashAt(addr *felt.Felt, blockNum uint64) (felt.Felt, error)
- func (s *State) ContractDeployedAt(addr *felt.Felt, blockNum uint64) (bool, error)
- func (s *State) ContractNonce(addr *felt.Felt) (felt.Felt, error)
- func (s *State) ContractNonceAt(addr *felt.Felt, blockNum uint64) (felt.Felt, error)
- func (s *State) ContractStorage(addr, key *felt.Felt) (felt.Felt, error)
- func (s *State) ContractStorageAt(addr, key *felt.Felt, blockNum uint64) (felt.Felt, error)
- func (s *State) ContractStorageLastUpdatedAt(addr *felt.Address, key *felt.Felt, blockNum uint64) (uint64, error)
- func (s *State) ContractStorageLastUpdatedBlock(addr *felt.Address, key *felt.Felt) (uint64, error)
- func (s *State) ContractStorageTrie(addr *felt.Felt) (core.Trie, error)
- func (s *State) ContractTrie() (core.Trie, error)
- func (s *State) GetReverseStateDiff(blockNum uint64, diff *core.StateDiff) (core.StateDiff, error)
- func (s *State) Revert(header *core.Header, update *core.StateUpdate) error
- func (s *State) Update(header *core.Header, update *core.StateUpdate, ...) error
- type StateDB
- type Storage
Constants ¶
const ( ClassTrieHeight = 251 ContractTrieHeight = 251 ContractStorageTrieHeight = 251 )
const DefaultMaxLayers = 128
DefaultMaxLayers is the default maximum number of layers to keep in the cache
Variables ¶
Functions ¶
func DeleteClass ¶
func DeleteClass(w db.KeyValueWriter, classHash *felt.Felt) error
func DeleteClassHashHistory ¶
func DeleteContract ¶
func DeleteContract(w db.KeyValueWriter, addr *felt.Felt) error
func DeleteNonceHistory ¶
func DeleteStorageHistory ¶
func GetClass ¶
func GetClass(r db.KeyValueReader, classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
func GetContract ¶
func GetContract(r db.KeyValueReader, addr *felt.Felt) (stateContract, error)
Gets a contract instance from the database. If it doesn't exist returns a contract not deployed error
func GetStateObject ¶
func HasContract ¶
func NewStateHistory ¶
func WriteClass ¶
func WriteClass( w db.KeyValueWriter, classHash *felt.Felt, class core.ClassDefinition, declaredAt uint64, ) error
func WriteClassHashHistory ¶
func WriteContract ¶
func WriteContract(w db.KeyValueWriter, addr *felt.Felt, contract *stateContract) error
func WriteNonceHistory ¶
func WriteStorageHistory ¶
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
func (*State) Commitment ¶
Returns the state commitment
func (*State) CompiledClassHash ¶ added in v0.15.20
func (s *State) CompiledClassHash( classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func (*State) CompiledClassHashAt ¶ added in v0.15.20
func (s *State) CompiledClassHashAt( classHash *felt.SierraClassHash, blockNumber uint64, ) (felt.CasmClassHash, error)
func (*State) CompiledClassHashV2 ¶ added in v0.15.20
func (s *State) CompiledClassHashV2( classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func (*State) ContractClassHash ¶
func (*State) ContractClassHashAt ¶
Returns the class hash of a contract at a given block number.
func (*State) ContractDeployedAt ¶
func (*State) ContractNonceAt ¶
Returns the nonce of a contract at a given block number.
func (*State) ContractStorage ¶
func (*State) ContractStorageAt ¶
Returns the storage value of a contract at a given storage key at a given block number.
func (*State) ContractStorageLastUpdatedAt ¶ added in v0.15.20
func (s *State) ContractStorageLastUpdatedAt( addr *felt.Address, key *felt.Felt, blockNum uint64, ) (uint64, error)
Returns the block number at which a given storage slot key of a given contract was last updated, up to and including the given block number.
func (*State) ContractStorageLastUpdatedBlock ¶ added in v0.15.20
func (s *State) ContractStorageLastUpdatedBlock( addr *felt.Address, key *felt.Felt, ) (uint64, error)
ContractStorageLastUpdatedBlock returns the most recent block number at which a given storage slot key of a given contract was last updated.
func (*State) ContractStorageTrie ¶
func (*State) GetReverseStateDiff ¶
func (*State) Revert ¶
Revert a given state update. The block number is the block number of the state update.
func (*State) Update ¶
func (s *State) Update( header *core.Header, update *core.StateUpdate, declaredClasses map[felt.Felt]core.ClassDefinition, skipVerifyNewRoot bool, ) error
Applies a state update to a given state. If any error is encountered, state is not updated. After a state update is applied, the root of the state must match the given new root in the state update. TODO(weiihann): deal with flush atomicity
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
func NewStateDB ¶
func NewStateDB(disk db.KeyValueStore, triedb database.TrieDB) *StateDB
func (*StateDB) ContractStorageTrie ¶
Opens a contract storage trie for the given state root and contract address