Documentation
¶
Index ¶
- Constants
- Variables
- func ContractRoot(addr *felt.Felt, txn db.IndexedBatch) (felt.Felt, error)
- func ContractStorage(addr, key *felt.Felt, txn db.IndexedBatch) (felt.Felt, error)
- func NewHistory(state *State, blockNumber uint64) *stateHistory
- type ContractUpdater
- type OnValueChanged
- 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(contractAddress *felt.Felt, height uint64) (felt.Felt, error)
- func (s *State) ContractDeployedAt(addr *felt.Felt, blockNumber uint64) (bool, error)
- func (s *State) ContractNonce(addr *felt.Felt) (felt.Felt, error)
- func (s *State) ContractNonceAt(contractAddress *felt.Felt, height uint64) (felt.Felt, error)
- func (s *State) ContractStorage(addr, key *felt.Felt) (felt.Felt, error)
- func (s *State) ContractStorageAt(contractAddress, storageLocation *felt.Felt, height uint64) (felt.Felt, error)
- func (s *State) ContractStorageLastUpdatedAt(addr *felt.Address, key *felt.Felt, blockNumber 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(blockNumber 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
Constants ¶
const ContractStorageTrieHeight = 251
contract storage has fixed height at 251
Variables ¶
var ( ErrContractNotDeployed = errors.New("contract not deployed") ErrContractAlreadyDeployed = errors.New("contract already deployed") )
var (
ErrCheckHeadState = errors.New("check head state")
)
var ErrHistoricalTrieNotSupported = errors.New("cannot support historical trie")
Functions ¶
func ContractRoot ¶
ContractRoot returns the root of the contract storage.
func ContractStorage ¶
func NewHistory ¶
Types ¶
type ContractUpdater ¶
type ContractUpdater struct {
// Address that this contract instance is deployed to
Address *felt.Felt
// contains filtered or unexported fields
}
ContractUpdater is a helper to update an existing contract instance.
func DeployContract ¶
func DeployContract(addr, classHash *felt.Felt, txn db.IndexedBatch) (*ContractUpdater, error)
DeployContract sets up the database for a new contract.
func NewContractUpdater ¶
func NewContractUpdater(addr *felt.Felt, txn db.IndexedBatch) (*ContractUpdater, error)
NewContractUpdater creates an updater for the contract instance at the given address. Deploy should be called for contracts that were just deployed to the network.
func (*ContractUpdater) Purge ¶
func (c *ContractUpdater) Purge() error
Purge eliminates the contract instance, deleting all associated data from storage assumes storage is cleared in revert process
func (*ContractUpdater) Replace ¶
func (c *ContractUpdater) Replace(classHash *felt.Felt) error
Replace replaces the class that the contract instantiates
func (*ContractUpdater) UpdateNonce ¶
func (c *ContractUpdater) UpdateNonce(nonce *felt.Felt) error
UpdateNonce updates the nonce value in the database.
func (*ContractUpdater) UpdateStorage ¶
func (c *ContractUpdater) UpdateStorage(diff map[felt.Felt]*felt.Felt, cb OnValueChanged) error
UpdateStorage applies a change-set to the contract storage.
type OnValueChanged ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
func New ¶
func New(txn db.IndexedBatch) *State
func (*State) Commitment ¶
Root returns the state commitment. protocolVersion controls the commitment formula: since v0.14.0, the Poseidon hash is always applied even when classesRoot is zero.
func (*State) CompiledClassHash ¶
func (s *State) CompiledClassHash( classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func (*State) CompiledClassHashAt ¶
func (s *State) CompiledClassHashAt( classHash *felt.SierraClassHash, blockNumber uint64, ) (felt.CasmClassHash, error)
func (*State) CompiledClassHashV2 ¶
func (s *State) CompiledClassHashV2( classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func (*State) ContractClassHash ¶
ContractClassHash returns class hash of a contract at a given address.
func (*State) ContractClassHashAt ¶
func (*State) ContractDeployedAt ¶
ContractDeployedAt returns if contract at given addr was deployed at blockNumber
func (*State) ContractNonce ¶
ContractNonce returns nonce of a contract at a given address.
func (*State) ContractNonceAt ¶
func (*State) ContractStorage ¶
ContractStorage returns value of a key in the storage of the contract at the given address.
func (*State) ContractStorageAt ¶
func (s *State) ContractStorageAt( contractAddress, storageLocation *felt.Felt, height uint64, ) (felt.Felt, error)
ContractStorageAt returns the value of a storage location of the given contract at the height `height`.
func (*State) ContractStorageLastUpdatedAt ¶
func (s *State) ContractStorageLastUpdatedAt( addr *felt.Address, key *felt.Felt, blockNumber uint64, ) (uint64, error)
ContractStorageLastUpdatedAt 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 ¶
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) Update ¶
func (s *State) Update( header *core.Header, update *core.StateUpdate, declaredClasses map[felt.Felt]core.ClassDefinition, skipVerifyNewRoot bool, ) error
Update applies a StateUpdate to the State object. State is not updated if an error is encountered during the operation. If update's old or new root does not match the state's old or new roots, [ErrMismatchedRoot] is returned.