Documentation
¶
Overview ¶
Deprecated: superseded by core/state; only migrations and the old state backend should use it.
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 DeleteContractClassHashHistory(w db.KeyValueWriter, contractAddress *felt.Felt, height uint64) error
- func DeleteContractDeploymentHeight(w db.KeyValueWriter, addr *felt.Felt) error
- func DeleteContractNonceHistory(w db.KeyValueWriter, contractAddress *felt.Felt, height uint64) error
- func DeleteContractStorageHistory(w db.KeyValueWriter, contractAddress, storageLocation *felt.Felt, ...) error
- func GetContractClassHash(r db.KeyValueReader, addr *felt.Felt) (felt.Felt, error)
- func GetContractDeploymentHeight(r db.KeyValueReader, addr *felt.Felt) (uint64, error)
- func GetContractNonce(r db.KeyValueReader, addr *felt.Felt) (felt.Felt, error)
- func NewHistory(state *State, blockNumber uint64) *stateHistory
- func WriteContractClassHash(w db.KeyValueWriter, addr, classHash *felt.Felt) error
- func WriteContractClassHashHistory(w db.KeyValueWriter, contractAddress, oldValue *felt.Felt, height uint64) error
- func WriteContractDeploymentHeight(w db.KeyValueWriter, addr *felt.Felt, height uint64) error
- func WriteContractNonce(w db.KeyValueWriter, addr, nonce *felt.Felt) error
- func WriteContractNonceHistory(w db.KeyValueWriter, contractAddress, oldValue *felt.Felt, height uint64) error
- func WriteContractStorageHistory(w db.KeyValueWriter, contractAddress, storageLocation, oldValue *felt.Felt, ...) error
- type ContractUpdater
- type OnValueChanged
- type State
- func (s *State) Class(classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
- func (s *State) ClassTrie() (core.TrieReader, 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.TrieReader, error)
- func (s *State) ContractTrie() (core.TrieReader, 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 DeleteContractClassHashHistory ¶ added in v0.17.0
func DeleteContractDeploymentHeight ¶ added in v0.17.0
func DeleteContractDeploymentHeight(w db.KeyValueWriter, addr *felt.Felt) error
func DeleteContractNonceHistory ¶ added in v0.17.0
func DeleteContractNonceHistory( w db.KeyValueWriter, contractAddress *felt.Felt, height uint64, ) error
DeleteContractNonceHistory deletes the history at the given height
func DeleteContractStorageHistory ¶ added in v0.17.0
func DeleteContractStorageHistory( w db.KeyValueWriter, contractAddress, storageLocation *felt.Felt, height uint64, ) error
DeleteContractStorageHistory deletes the history at the given height
func GetContractClassHash ¶ added in v0.17.0
func GetContractDeploymentHeight ¶ added in v0.17.0
func GetContractNonce ¶ added in v0.17.0
func NewHistory ¶
func WriteContractClassHash ¶ added in v0.17.0
func WriteContractClassHash(w db.KeyValueWriter, addr, classHash *felt.Felt) error
func WriteContractClassHashHistory ¶ added in v0.17.0
func WriteContractDeploymentHeight ¶ added in v0.17.0
func WriteContractNonce ¶ added in v0.17.0
func WriteContractNonce(w db.KeyValueWriter, addr, nonce *felt.Felt) error
func WriteContractNonceHistory ¶ added in v0.17.0
func WriteContractNonceHistory( w db.KeyValueWriter, contractAddress, oldValue *felt.Felt, height uint64, ) error
WriteContractNonceHistory writes the old value of a nonce for the given contract which changed on height `height`
func WriteContractStorageHistory ¶ added in v0.17.0
func WriteContractStorageHistory( w db.KeyValueWriter, contractAddress, storageLocation, oldValue *felt.Felt, height uint64, ) error
WriteContractStorageHistory writes the old value of a storage location for the given contract which changed on height `height`.
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) ContractTrie ¶
func (s *State) ContractTrie() (core.TrieReader, error)
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.