deprecatedstate

package
v0.16.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ContractStorageTrieHeight = 251

contract storage has fixed height at 251

Variables

View Source
var (
	ErrContractNotDeployed     = errors.New("contract not deployed")
	ErrContractAlreadyDeployed = errors.New("contract already deployed")
)
View Source
var (
	ErrCheckHeadState = errors.New("check head state")
)
View Source
var ErrHistoricalTrieNotSupported = errors.New("cannot support historical trie")

Functions

func ContractRoot

func ContractRoot(addr *felt.Felt, txn db.IndexedBatch) (felt.Felt, error)

ContractRoot returns the root of the contract storage.

func ContractStorage

func ContractStorage(addr, key *felt.Felt, txn db.IndexedBatch) (felt.Felt, error)

func NewHistory

func NewHistory(
	state *State,
	blockNumber uint64,
) *stateHistory

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 OnValueChanged = func(location, oldValue *felt.Felt) error

type State

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

func New

func New(txn db.IndexedBatch) *State

func (*State) Class

func (s *State) Class(classHash *felt.Felt) (*core.DeclaredClassDefinition, error)

Class returns the class object corresponding to the given classHash

func (*State) ClassTrie

func (s *State) ClassTrie() (core.Trie, error)

func (*State) Commitment

func (s *State) Commitment(protocolVersion string) (felt.Felt, error)

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

func (s *State) ContractClassHash(addr *felt.Felt) (felt.Felt, error)

ContractClassHash returns class hash of a contract at a given address.

func (*State) ContractClassHashAt

func (s *State) ContractClassHashAt(
	contractAddress *felt.Felt,
	height uint64,
) (felt.Felt, error)

func (*State) ContractDeployedAt

func (s *State) ContractDeployedAt(addr *felt.Felt, blockNumber uint64) (bool, error)

ContractDeployedAt returns if contract at given addr was deployed at blockNumber

func (*State) ContractNonce

func (s *State) ContractNonce(addr *felt.Felt) (felt.Felt, error)

ContractNonce returns nonce of a contract at a given address.

func (*State) ContractNonceAt

func (s *State) ContractNonceAt(
	contractAddress *felt.Felt,
	height uint64,
) (felt.Felt, error)

func (*State) ContractStorage

func (s *State) ContractStorage(addr, key *felt.Felt) (felt.Felt, error)

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 (s *State) ContractStorageTrie(addr *felt.Felt) (core.Trie, error)

func (*State) ContractTrie

func (s *State) ContractTrie() (core.Trie, error)

func (*State) GetReverseStateDiff

func (s *State) GetReverseStateDiff(
	blockNumber uint64,
	diff *core.StateDiff,
) (core.StateDiff, error)

func (*State) Revert

func (s *State) Revert(
	header *core.Header, update *core.StateUpdate,
) error

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.

Jump to

Keyboard shortcuts

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