Documentation
¶
Index ¶
- Constants
- Variables
- func CheckBlockVersion(protocolVersion string) error
- func ConcatCounts(txCount, eventCount, stateDiffLen uint64, l1Mode L1DAMode) felt.Felt
- func ContractAddress(callerAddress, classHash, salt *felt.Felt, constructorCallData []*felt.Felt) felt.Felt
- func ContractClassHash(addr *felt.Felt, txn db.KeyValueReader) (felt.Felt, error)
- func ContractNonce(addr *felt.Felt, txn db.KeyValueReader) (felt.Felt, error)
- func ContractRoot(addr *felt.Felt, txn db.IndexedBatch) (felt.Felt, error)
- func ContractStorage(addr, key *felt.Felt, txn db.IndexedBatch) (felt.Felt, error)
- func DeleteBlockCommitment(w db.KeyValueWriter, blockNum uint64) error
- func DeleteBlockHeaderByNumber(w db.KeyValueWriter, number uint64) error
- func DeleteBlockHeaderNumberByHash(w db.KeyValueWriter, hash *felt.Felt) error
- func DeleteCasmClassHashV2(w db.KeyValueWriter, classHash *felt.SierraClassHash) error
- func DeleteChainHeight(w db.KeyValueWriter) error
- func DeleteClass(w db.KeyValueWriter, classHash *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 DeleteL1HandlerTxnHashByMsgHash(w db.KeyValueWriter, msgHash []byte) error
- func DeleteStateUpdateByBlockNum(w db.KeyValueWriter, blockNum uint64) error
- func DeleteTxsAndReceipts(batch db.IndexedBatch, blockNum, numTxs uint64) error
- func EventsBloom(receipts []*TransactionReceipt) *bloom.BloomFilter
- func GetBlockHeaderNumberByHash(r db.KeyValueReader, hash *felt.Felt) (uint64, error)
- func GetCasmClassHashV2(r db.KeyValueReader, classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
- func GetChainHeight(r db.KeyValueReader) (uint64, 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 GetL1HandlerTxnHashByMsgHash(r db.KeyValueReader, msgHash []byte) (felt.Felt, error)
- func HasClass(r db.KeyValueReader, classHash *felt.Felt) (bool, error)
- func MarshalBlockNumber(blockNumber uint64) []byte
- func NewDeprecatedStateHistory(state StateHistoryReader, blockNumber uint64) *deprecatedStateHistory
- func ParseBlockVersion(protocolVersion string) (*semver.Version, error)
- func SegmentedBytecodeHash(bytecode []*felt.Felt, segmentLengths []SegmentLengths, h Hasher) felt.Felt
- func TransactionHash(transaction Transaction, n *utils.Network) (felt.Felt, error)
- func UnmarshalBlockNumber(val []byte) uint64
- func VerifyClassHashes(classes map[felt.Felt]ClassDefinition) error
- func VerifyTransactions(txs []Transaction, n *utils.Network, protocolVersion string) error
- func WriteAggregatedBloomFilter(w db.KeyValueWriter, filter *AggregatedBloomFilter) error
- func WriteBlockCommitment(w db.KeyValueWriter, blockNum uint64, commitment *BlockCommitments) error
- func WriteBlockHeader(w db.KeyValueWriter, header *Header) error
- func WriteBlockHeaderByNumber(w db.KeyValueWriter, header *Header) error
- func WriteBlockHeaderNumberByHash(w db.KeyValueWriter, hash *felt.Felt, number uint64) error
- func WriteCasmClassHashV2(w db.KeyValueWriter, classHash *felt.SierraClassHash, ...) error
- func WriteChainHeight(w db.KeyValueWriter, height uint64) error
- func WriteClass(w db.KeyValueWriter, classHash *felt.Felt, class *DeclaredClassDefinition) error
- 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
- func WriteL1HandlerMsgHashes(w db.KeyValueWriter, txns []Transaction) error
- func WriteL1HandlerTxnHashByMsgHash(w db.KeyValueWriter, msgHash []byte, l1HandlerTxnHash *felt.Felt) error
- func WriteL1Head(w db.KeyValueWriter, l1Head *L1Head) error
- func WriteRunningEventFilter(w db.KeyValueWriter, filter *RunningEventFilter) error
- func WriteStateUpdateByBlockNum(w db.KeyValueWriter, blockNum uint64, stateUpdate *StateUpdate) error
- func WriteTxAndReceipt(w db.KeyValueWriter, num, index uint64, tx Transaction, ...) error
- type AggregatedBloomFilter
- func (f *AggregatedBloomFilter) BlocksForKeys(keys [][]byte) *bitset.BitSet
- func (f *AggregatedBloomFilter) BlocksForKeysInto(keys [][]byte, out *bitset.BitSet) error
- func (f *AggregatedBloomFilter) Clone() AggregatedBloomFilter
- func (f *AggregatedBloomFilter) FromBlock() uint64
- func (f *AggregatedBloomFilter) Insert(filter *bloom.BloomFilter, blockNumber uint64) error
- func (f *AggregatedBloomFilter) MarshalBinary() ([]byte, error)
- func (f *AggregatedBloomFilter) ToBlock() uint64
- func (f *AggregatedBloomFilter) UnmarshalBinary(data []byte) error
- type Block
- type BlockCommitments
- func BlockHash(b *Block, stateDiff *StateDiff, network *utils.Network, ...) (felt.Felt, *BlockCommitments, error)
- func GetBlockCommitmentByBlockNum(r db.KeyValueReader, blockNum uint64) (*BlockCommitments, error)
- func Post0132Hash(b *Block, stateDiff *StateDiff) (felt.Felt, *BlockCommitments, error)
- func VerifyBlockHash(b *Block, network *utils.Network, stateDiff *StateDiff) (*BlockCommitments, error)
- type BuiltinInstanceCounter
- type CasmClass
- type CasmEntryPoint
- type CasmHashVersion
- type ClassDefinition
- type ContractUpdater
- type DataAvailability
- type DataAvailabilityMode
- type DeclareTransaction
- type DeclaredClassDefinition
- type DeployAccountTransaction
- type DeployTransaction
- type DeprecatedCairoClass
- type DeprecatedEntryPoint
- type Event
- type ExecutionResources
- type FeeUnit
- type GasConsumed
- type GasPrice
- type Hasher
- type Header
- type InvokeTransaction
- type L1DAMode
- type L1HandlerTransaction
- type L1Head
- type L1ToL2Message
- type L2ToL1Message
- type OnValueChanged
- type Pending
- func (p *Pending) GetBlock() *Block
- func (p *Pending) GetCandidateTransaction() []Transaction
- func (p *Pending) GetHeader() *Header
- func (p *Pending) GetNewClasses() map[felt.Felt]ClassDefinition
- func (p *Pending) GetPreLatest() *PreLatest
- func (p *Pending) GetStateUpdate() *StateUpdate
- func (p *Pending) GetTransactionStateDiffs() []*StateDiff
- func (p *Pending) GetTransactions() []Transaction
- func (p *Pending) PendingState(baseState StateReader) StateReader
- func (p *Pending) PendingStateBeforeIndex(baseState StateReader, index uint) (StateReader, error)
- func (p *Pending) ReceiptByHash(hash *felt.Felt) (*TransactionReceipt, *felt.Felt, uint64, error)
- func (p *Pending) TransactionByHash(hash *felt.Felt) (Transaction, error)
- func (p *Pending) Validate(parent *Header) bool
- func (p *Pending) Variant() PendingDataVariant
- type PendingData
- type PendingDataVariant
- type PendingState
- func (p *PendingState) Class(classHash *felt.Felt) (*DeclaredClassDefinition, error)
- func (p *PendingState) ClassTrie() (commontrie.Trie, error)
- func (p *PendingState) CompiledClassHash(classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
- func (p *PendingState) CompiledClassHashV2(classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
- func (p *PendingState) ContractClassHash(addr *felt.Felt) (felt.Felt, error)
- func (p *PendingState) ContractNonce(addr *felt.Felt) (felt.Felt, error)
- func (p *PendingState) ContractStorage(addr, key *felt.Felt) (felt.Felt, error)
- func (p *PendingState) ContractStorageTrie(addr *felt.Felt) (commontrie.Trie, error)
- func (p *PendingState) ContractTrie() (commontrie.Trie, error)
- func (p *PendingState) StateDiff() *StateDiff
- type PendingStateWriter
- func (p *PendingStateWriter) IncrementNonce(contractAddress *felt.Felt) error
- func (p *PendingStateWriter) SetClassHash(contractAddress, classHash *felt.Felt) error
- func (p *PendingStateWriter) SetCompiledClassHash(classHash, compiledClassHash *felt.Felt) error
- func (p *PendingStateWriter) SetContractClass(classHash *felt.Felt, class ClassDefinition) error
- func (p *PendingStateWriter) SetStateDiff(stateDiff *StateDiff)
- func (p *PendingStateWriter) SetStorage(contractAddress, key, value *felt.Felt) error
- func (p *PendingStateWriter) StateDiffAndClasses() (StateDiff, map[felt.Felt]ClassDefinition)
- type PreConfirmed
- func (p *PreConfirmed) Copy() *PreConfirmed
- func (p *PreConfirmed) GetBlock() *Block
- func (p *PreConfirmed) GetCandidateTransaction() []Transaction
- func (p *PreConfirmed) GetHeader() *Header
- func (p *PreConfirmed) GetNewClasses() map[felt.Felt]ClassDefinition
- func (p *PreConfirmed) GetPreLatest() *PreLatest
- func (p *PreConfirmed) GetStateUpdate() *StateUpdate
- func (p *PreConfirmed) GetTransactionStateDiffs() []*StateDiff
- func (p *PreConfirmed) GetTransactions() []Transaction
- func (p *PreConfirmed) PendingState(baseState StateReader) StateReader
- func (p *PreConfirmed) PendingStateBeforeIndex(baseState StateReader, index uint) (StateReader, error)
- func (p *PreConfirmed) ReceiptByHash(hash *felt.Felt) (*TransactionReceipt, *felt.Felt, uint64, error)
- func (p *PreConfirmed) TransactionByHash(hash *felt.Felt) (Transaction, error)
- func (p *PreConfirmed) Validate(parent *Header) bool
- func (p *PreConfirmed) Variant() PendingDataVariant
- func (p *PreConfirmed) WithNewClasses(newClasses map[felt.Felt]ClassDefinition) *PreConfirmed
- func (p *PreConfirmed) WithPreLatest(preLatest *PreLatest) *PreConfirmed
- type PreLatest
- type Resource
- type ResourceBounds
- type RunningEventFilter
- func (f *RunningEventFilter) BlocksForKeys(keys [][]byte) *bitset.BitSet
- func (f *RunningEventFilter) BlocksForKeysInto(keys [][]byte, out *bitset.BitSet) error
- func (f *RunningEventFilter) Clone() *RunningEventFilter
- func (f *RunningEventFilter) FromBlock() uint64
- func (f *RunningEventFilter) InnerFilter() *AggregatedBloomFilter
- func (f *RunningEventFilter) Insert(bloom *bloom.BloomFilter, blockNumber uint64) error
- func (f *RunningEventFilter) MarshalBinary() ([]byte, error)
- func (f *RunningEventFilter) NextBlock() uint64
- func (f *RunningEventFilter) OnReorg() error
- func (f *RunningEventFilter) ToBlock() uint64
- func (f *RunningEventFilter) UnmarshalBinary(data []byte) error
- func (f *RunningEventFilter) Write() error
- type SegmentLengths
- type SierraClass
- type SierraEntryPoint
- type SierraEntryPointsByType
- type State
- func (s *State) Class(classHash *felt.Felt) (*DeclaredClassDefinition, error)
- func (s *State) ClassTrie() (commontrie.Trie, error)
- func (s *State) Commitment() (felt.Felt, error)
- func (s *State) CompiledClassHash(classHash *felt.SierraClassHash) (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) ContractStorageTrie(addr *felt.Felt) (commontrie.Trie, error)
- func (s *State) ContractTrie() (commontrie.Trie, error)
- func (s *State) GetReverseStateDiff(blockNumber uint64, diff *StateDiff) (*StateDiff, error)
- func (s *State) Revert(blockNumber uint64, update *StateUpdate) error
- func (s *State) Update(blockNumber uint64, update *StateUpdate, ...) error
- type StateDiff
- type StateHistoryReader
- type StateReader
- type StateUpdate
- type Transaction
- type TransactionReceipt
- type TransactionVersion
- func (v *TransactionVersion) AsFelt() *felt.Felt
- func (v *TransactionVersion) HasQueryBit() bool
- func (v *TransactionVersion) Is(u64 uint64) bool
- func (v *TransactionVersion) MarshalCBOR() ([]byte, error)
- func (v *TransactionVersion) SetUint64(u64 uint64) *TransactionVersion
- func (v *TransactionVersion) String() string
- func (v *TransactionVersion) UnmarshalCBOR(data []byte) error
- func (v *TransactionVersion) WithoutQueryBit() TransactionVersion
Constants ¶
const ( // Calculated at https://hur.st/bloomfilter/?n=1000&p=&m=8192&k= // provides 1 in 51 possibility of false positives for approximately 1000 elements EventsBloomLength = 8192 EventsBloomHashFuncs = 6 )
const ContractStorageTrieHeight = 251
contract storage has fixed height at 251
const (
NumBlocksPerFilter uint64 = 8192
)
Variables ¶
var ( ErrAggregatedBloomFilterBlockOutOfRange error = errors.New("block number is not within range") ErrBloomFilterSizeMismatch error = errors.New("bloom filter len mismatch") ErrMatchesBufferNil error = errors.New("matches buffer must not be nil") ErrMatchesBufferSizeMismatch error = errors.New("matches buffer size mismatch") )
var ( ErrContractNotDeployed = errors.New("contract not deployed") ErrContractAlreadyDeployed = errors.New("contract already deployed") )
var ( ErrPendingDataNotFound = errors.New("pending_data not found") ErrTransactionNotFound = errors.New("pending_data: transaction not found") ErrTransactionReceiptNotFound = errors.New("pending_data: transaction receipt not found") ErrTransactionIndexOutOfBounds = errors.New( "pending_data: transaction index out of bounds", ) ErrPendingStateBeforeIndexNotSupported = errors.New( "pending_data: PendingStateBeforeIndex not supported for Pending block", ) )
var ( Ver0_13_2 = semver.MustParse("0.13.2") Ver0_13_4 = semver.MustParse("0.13.4") Ver0_14_0 = semver.MustParse("0.14.0") Ver0_14_1 = semver.MustParse("0.14.1") LatestVer = Ver0_14_1 )
var AggregatedBloomFiltersBucket = typed.NewBucket( db.AggregatedBloomFilters, key.Marshal[db.AggregatedBloomFilterRangeKey](), value.Cbor[AggregatedBloomFilter](), )
Bucket 37: AggregatedBloomFilterRangeKey -> AggregatedBloomFilter TODO: Integrate this bucket
var BlockCommitmentsBucket = typed.NewBucket( db.BlockCommitments, key.Uint64, value.Cbor[BlockCommitments](), )
Bucket 21: Block number (uint64) -> Block commitments (BlockCommitments) TODO: Integrate this bucket
var BlockHeaderNumbersByHashBucket = typed.NewBucket( db.BlockHeaderNumbersByHash, key.Felt, value.Uint64, )
Bucket 7: Block hash (Felt) -> Block number (uint64) TODO: Integrate this bucket
var BlockHeadersByNumberBucket = typed.NewBucket( db.BlockHeadersByNumber, key.Uint64, value.Cbor[Header](), )
Bucket 8: Block number (uint64) -> Header TODO: Integrate this bucket
var ChainHeightBucket = typed.NewBucket( db.ChainHeight, key.Empty, value.Uint64, )
Bucket 6: Chain height (uint64) TODO: Integrate this bucket
var ClassBucket = typed.NewBucket( db.Class, key.ClassHash, value.Binary[DeclaredClassDefinition](), )
Bucket 4: Class hash (ClassHash) -> Class definition (DeclaredClassDefinition) TODO: Integrate this bucket
var ClassHashToCasmHashV2Bucket = typed.NewBucket( db.ClassHashToCasmHashV2, key.SierraClassHash, value.CasmClassHash, )
Bucket 39: Class hash (SierraClassHash) -> CASM hash (CasmCasmHash) TODO: Integrate this bucket
var ContractClassHashBucket = typed.NewBucket( db.ContractClassHash, key.Address, value.ClassHash, )
Bucket 2: Contract class (Address) -> Contract class hash (ClassHash) TODO: Integrate this bucket
var ContractDeploymentHeightBucket = typed.NewBucket( db.ContractDeploymentHeight, key.Address, value.Uint64, )
Bucket 17: Contract address (Address) -> Deployment height (uint64) TODO: Integrate this bucket
var ContractNonceBucket = typed.NewBucket( db.ContractNonce, key.Address, value.Felt, )
Bucket 5: Contract address (Address) -> Contract nonce (Felt) TODO: Integrate this bucket
var (
ErrCheckHeadState = errors.New("check head state")
)
var ErrHistoricalTrieNotSupported = errors.New("cannot support historical trie")
var L1HandlerTxnHashByMsgHashBucket = typed.NewBucket( db.L1HandlerTxnHashByMsgHash, key.Bytes, value.Hash, )
Bucket 24: L1 handler msg hash ([]byte) -> L1 handler txn hash (Felt) TODO: Integrate this bucket
Bucket 18: L1 height (uint64) -> L1 head (L1Head) TODO: Integrate this bucket
var ReceiptsByBlockNumberAndIndexBucket = prefix.NewPrefixedBucket( typed.NewBucket( db.ReceiptsByBlockNumberAndIndex, key.Marshal[db.BlockNumIndexKey](), value.Cbor[TransactionReceipt](), ), prefix.Prefix(key.Uint64, prefix.Prefix(key.Uint64, prefix.End[TransactionReceipt]())), )
Bucket 11: Block number (uint64) -> Transaction index (uint64) -> TransactionReceipt
var RunningEventFilterBucket = typed.NewBucket( db.RunningEventFilter, key.Empty, value.Cbor[RunningEventFilter](), )
Bucket 38: RunningEventFilter TODO: Integrate this bucket
var SierraVersion010 felt.Felt = felt.Felt( [4]uint64{ 18446737451840584193, 18446744073709551615, 18446744073709551615, 576348180530977296, })
Single felt identifying the number "0.1.0" as a short string
var StateUpdatesByBlockNumberBucket = typed.NewBucket( db.StateUpdatesByBlockNumber, key.Uint64, value.Cbor[StateUpdate](), )
Bucket 12: Block number (uint64) -> StateUpdate TODO: Integrate this bucket
var TransactionBlockNumbersAndIndicesByHashBucket = typed.NewBucket( db.TransactionBlockNumbersAndIndicesByHash, key.TransactionHash, value.Binary[db.BlockNumIndexKey](), )
Bucket 9: Transaction hash (TransactionHash) -> Block number and index (BlockNumIndexKey)
var TransactionsByBlockNumberAndIndexBucket = prefix.NewPrefixedBucket( typed.NewBucket( db.TransactionsByBlockNumberAndIndex, key.Marshal[db.BlockNumIndexKey](), value.Cbor[Transaction](), ), prefix.Prefix(key.Uint64, prefix.Prefix(key.Uint64, prefix.End[Transaction]())), )
Bucket 10: Block number (uint64) -> Transaction index (uint64) -> Transaction
Functions ¶
func CheckBlockVersion ¶ added in v0.15.6
CheckBlockVersion checks if the block protocol version is supported by Juno
func ConcatCounts ¶ added in v0.14.6
func ContractAddress ¶
func ContractAddress( callerAddress, classHash, salt *felt.Felt, constructorCallData []*felt.Felt, ) felt.Felt
ContractAddress computes the address of a Starknet contract.
func ContractClassHash ¶ added in v0.7.5
ContractClassHash returns hash of the class that the contract at the given address instantiates.
func ContractNonce ¶ added in v0.7.5
ContractNonce returns the amount transactions sent from this contract. Only account contracts can have a non-zero nonce.
func ContractRoot ¶ added in v0.7.5
ContractRoot returns the root of the contract storage.
func ContractStorage ¶ added in v0.7.5
func DeleteBlockCommitment ¶ added in v0.14.4
func DeleteBlockCommitment(w db.KeyValueWriter, blockNum uint64) error
func DeleteBlockHeaderByNumber ¶ added in v0.14.4
func DeleteBlockHeaderByNumber(w db.KeyValueWriter, number uint64) error
func DeleteBlockHeaderNumberByHash ¶ added in v0.14.4
func DeleteBlockHeaderNumberByHash(w db.KeyValueWriter, hash *felt.Felt) error
func DeleteCasmClassHashV2 ¶ added in v0.15.11
func DeleteCasmClassHashV2( w db.KeyValueWriter, classHash *felt.SierraClassHash, ) error
func DeleteChainHeight ¶ added in v0.14.3
func DeleteChainHeight(w db.KeyValueWriter) error
func DeleteClass ¶ added in v0.14.4
func DeleteClass(w db.KeyValueWriter, classHash *felt.Felt) error
func DeleteContractClassHashHistory ¶ added in v0.15.12
func DeleteContractDeploymentHeight ¶ added in v0.14.4
func DeleteContractDeploymentHeight(w db.KeyValueWriter, addr *felt.Felt) error
func DeleteContractNonceHistory ¶ added in v0.15.12
func DeleteContractNonceHistory( w db.KeyValueWriter, contractAddress *felt.Felt, height uint64, ) error
DeleteContractNonceHistory deletes the history at the given height
func DeleteContractStorageHistory ¶ added in v0.15.12
func DeleteContractStorageHistory( w db.KeyValueWriter, contractAddress, storageLocation *felt.Felt, height uint64, ) error
DeleteContractStorageHistory deletes the history at the given height
func DeleteL1HandlerTxnHashByMsgHash ¶ added in v0.14.4
func DeleteL1HandlerTxnHashByMsgHash(w db.KeyValueWriter, msgHash []byte) error
func DeleteStateUpdateByBlockNum ¶ added in v0.14.4
func DeleteStateUpdateByBlockNum(w db.KeyValueWriter, blockNum uint64) error
func DeleteTxsAndReceipts ¶ added in v0.14.4
func DeleteTxsAndReceipts(batch db.IndexedBatch, blockNum, numTxs uint64) error
func EventsBloom ¶ added in v0.3.1
func EventsBloom(receipts []*TransactionReceipt) *bloom.BloomFilter
func GetBlockHeaderNumberByHash ¶ added in v0.14.4
func GetCasmClassHashV2 ¶ added in v0.15.11
func GetCasmClassHashV2( r db.KeyValueReader, classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func GetChainHeight ¶ added in v0.14.4
func GetChainHeight(r db.KeyValueReader) (uint64, error)
func GetContractClassHash ¶ added in v0.14.4
func GetContractDeploymentHeight ¶ added in v0.14.4
func GetContractNonce ¶ added in v0.14.4
func GetL1HandlerTxnHashByMsgHash ¶ added in v0.14.4
func MarshalBlockNumber ¶ added in v0.4.0
func NewDeprecatedStateHistory ¶ added in v0.15.12
func NewDeprecatedStateHistory( state StateHistoryReader, blockNumber uint64, ) *deprecatedStateHistory
func ParseBlockVersion ¶ added in v0.3.1
ParseBlockVersion computes the block version, defaulting to "0.0.0" for empty strings
func SegmentedBytecodeHash ¶ added in v0.11.0
func TransactionHash ¶ added in v0.4.0
func UnmarshalBlockNumber ¶ added in v0.14.3
func VerifyClassHashes ¶ added in v0.2.1
func VerifyClassHashes(classes map[felt.Felt]ClassDefinition) error
func VerifyTransactions ¶ added in v0.2.1
func VerifyTransactions(txs []Transaction, n *utils.Network, protocolVersion string) error
func WriteAggregatedBloomFilter ¶ added in v0.14.6
func WriteAggregatedBloomFilter(w db.KeyValueWriter, filter *AggregatedBloomFilter) error
func WriteBlockCommitment ¶ added in v0.14.4
func WriteBlockCommitment(w db.KeyValueWriter, blockNum uint64, commitment *BlockCommitments) error
func WriteBlockHeader ¶ added in v0.14.4
func WriteBlockHeader(w db.KeyValueWriter, header *Header) error
func WriteBlockHeaderByNumber ¶ added in v0.14.4
func WriteBlockHeaderByNumber(w db.KeyValueWriter, header *Header) error
func WriteBlockHeaderNumberByHash ¶ added in v0.14.4
func WriteCasmClassHashV2 ¶ added in v0.15.11
func WriteCasmClassHashV2( w db.KeyValueWriter, classHash *felt.SierraClassHash, casmClassHash *felt.CasmClassHash, ) error
func WriteChainHeight ¶ added in v0.14.4
func WriteChainHeight(w db.KeyValueWriter, height uint64) error
func WriteClass ¶ added in v0.14.4
func WriteClass(w db.KeyValueWriter, classHash *felt.Felt, class *DeclaredClassDefinition) error
func WriteContractClassHash ¶ added in v0.14.4
func WriteContractClassHash(w db.KeyValueWriter, addr, classHash *felt.Felt) error
func WriteContractClassHashHistory ¶ added in v0.15.12
func WriteContractDeploymentHeight ¶ added in v0.14.4
func WriteContractNonce ¶ added in v0.14.4
func WriteContractNonce(w db.KeyValueWriter, addr, nonce *felt.Felt) error
func WriteContractNonceHistory ¶ added in v0.15.12
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.15.12
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`.
func WriteL1HandlerMsgHashes ¶ added in v0.14.4
func WriteL1HandlerMsgHashes(w db.KeyValueWriter, txns []Transaction) error
func WriteL1HandlerTxnHashByMsgHash ¶ added in v0.14.4
func WriteL1Head ¶ added in v0.14.4
func WriteL1Head(w db.KeyValueWriter, l1Head *L1Head) error
func WriteRunningEventFilter ¶ added in v0.14.6
func WriteRunningEventFilter(w db.KeyValueWriter, filter *RunningEventFilter) error
func WriteStateUpdateByBlockNum ¶ added in v0.14.4
func WriteStateUpdateByBlockNum(w db.KeyValueWriter, blockNum uint64, stateUpdate *StateUpdate) error
func WriteTxAndReceipt ¶ added in v0.14.4
func WriteTxAndReceipt( w db.KeyValueWriter, num, index uint64, tx Transaction, receipt *TransactionReceipt, ) error
Types ¶
type AggregatedBloomFilter ¶ added in v0.14.6
type AggregatedBloomFilter struct {
// contains filtered or unexported fields
}
AggregatedBloomFilter provides a space-efficient, probabilistic data structure for testing set membership of keys (such as event topics or contract addresses) across large block ranges in a blockchain.
When querying which blocks in a large range might contain a certain key, it is inefficient to load and individually check every block’s Bloom filter. To optimise this, AggregatedBloomFilter aggregates multiple Bloom filters (spanning a range of blocks) into a single structure. This aggregation makes it possible to check, in a single operation, which blocks in the range might include a given key.
Internally, AggregatedBloomFilter is represented as a bit matrix: each row corresponds to a Bloom filter index, and each column corresponds to a block in the range. When adding a key for a particular block, the indices mapped by Bloom hash functions are determined, and the bits at those row-column intersections are set for that block.
Visually, this can be thought of as "rotating" the per-block Bloom filters into columns of a matrix.
-----| Block 0 | Block 1 | Block 2 | ... | Block 9 | Idx0 | 0 | 0 | 0 | ... | 0 | Idx1 | 1 | 0 | 1 | ... | 0 | Idx2 | 0 | 1 | 0 | ... | 0 | Idx3 | 1 | 0 | 0 | ... | 0 | Idx4 | 1 | 0 | 1 | ... | 1 | Idx5 | 0 | 0 | 0 | ... | 0 | Idx6 | 0 | 0 | 1 | ... | 0 | Idx7 | 0 | 1 | 0 | ... | 0 |
To query for a key, the AggregatedBloomFilter:
- Determines the relevant indices for the key using the same hash functions.
- Performs a bitwise AND over the selected rows, producing a bit vector.
- The set bits in this result indicate block numbers within the filter's range where the key may be present (with the usual caveat of possible false positives). Note: The set bit positions are *relative to the filter's range start* (i.e., the range's first block number), not absolute global block numbers.
Query example for a key mapping to indices Idx1 and Idx4:
Select rows 1 and 4 (Idx1 & Idx4): Idx1: 1 0 1 ... 0 Idx4: 1 0 1 ... 1
------------------------------- AND: 1 0 1 ... 0
After AND: Resulting vector is 1 0 1 ... 0
This means Block 0 and Block 2 are possible matches for this key.
This approach allows for efficient, bulk event queries on blockchain data without needing to individually examine every single block’s Bloom filter.
Using this method, you can quickly identify candidate blocks for a key, improving the performance of large-range event queries.
func GetAggregatedBloomFilter ¶ added in v0.14.6
func GetAggregatedBloomFilter(r db.KeyValueReader, fromBlock, toBLock uint64) (AggregatedBloomFilter, error)
func NewAggregatedFilter ¶ added in v0.14.6
func NewAggregatedFilter(fromBlock uint64) AggregatedBloomFilter
NewAggregatedFilter creates a new AggregatedBloomFilter starting from the specified block number. It initialises the bitmap array with empty bitsets of size NumBlocksPerFilter.
func (*AggregatedBloomFilter) BlocksForKeys ¶ added in v0.14.6
func (f *AggregatedBloomFilter) BlocksForKeys(keys [][]byte) *bitset.BitSet
BlocksForKeys returns a bitset indicating which blocks within the range might contain the given keys. If no keys are provided, returns a bitset with all bits set.
func (*AggregatedBloomFilter) BlocksForKeysInto ¶ added in v0.14.6
func (f *AggregatedBloomFilter) BlocksForKeysInto(keys [][]byte, out *bitset.BitSet) error
BlocksForKeysInto reuses a preallocated bitset (should be NumBlocksPerFilter bits).
func (*AggregatedBloomFilter) Clone ¶ added in v0.14.6
func (f *AggregatedBloomFilter) Clone() AggregatedBloomFilter
Copy creates a deep copy of the AggregatedBloomFilter.
func (*AggregatedBloomFilter) FromBlock ¶ added in v0.14.6
func (f *AggregatedBloomFilter) FromBlock() uint64
FromBlock returns the starting block number of the filter's range.
func (*AggregatedBloomFilter) Insert ¶ added in v0.14.6
func (f *AggregatedBloomFilter) Insert(filter *bloom.BloomFilter, blockNumber uint64) error
Insert adds a bloom filter's data for a specific block number into the aggregated filter. If filter is nil, no-op. Returns an error if the block number is out of range or if the bloom filter size doesn't match.
func (*AggregatedBloomFilter) MarshalBinary ¶ added in v0.14.6
func (f *AggregatedBloomFilter) MarshalBinary() ([]byte, error)
func (*AggregatedBloomFilter) ToBlock ¶ added in v0.14.6
func (f *AggregatedBloomFilter) ToBlock() uint64
ToBlock returns the ending block number of the filter's range.
func (*AggregatedBloomFilter) UnmarshalBinary ¶ added in v0.14.6
func (f *AggregatedBloomFilter) UnmarshalBinary(data []byte) error
type Block ¶
type Block struct {
*Header
Transactions []Transaction
Receipts []*TransactionReceipt
}
func GetBlockByNumber ¶ added in v0.14.4
func GetBlockByNumber(r db.KeyValueReader, blockNum uint64) (*Block, error)
func (*Block) L2GasConsumed ¶ added in v0.15.3
type BlockCommitments ¶ added in v0.6.0
type BlockCommitments struct {
TransactionCommitment *felt.Felt
EventCommitment *felt.Felt
ReceiptCommitment *felt.Felt
StateDiffCommitment *felt.Felt
}
func BlockHash ¶ added in v0.10.0
func BlockHash( b *Block, stateDiff *StateDiff, network *utils.Network, overrideSeqAddr *felt.Felt, ) (felt.Felt, *BlockCommitments, error)
blockHash computes the block hash, with option to override sequence address
func GetBlockCommitmentByBlockNum ¶ added in v0.14.4
func GetBlockCommitmentByBlockNum(r db.KeyValueReader, blockNum uint64) (*BlockCommitments, error)
func Post0132Hash ¶ added in v0.12.0
func VerifyBlockHash ¶
func VerifyBlockHash(b *Block, network *utils.Network, stateDiff *StateDiff) (*BlockCommitments, error)
VerifyBlockHash verifies the block hash. Due to bugs in Starknet alpha, not all blocks have verifiable hashes.
type BuiltinInstanceCounter ¶
type CasmClass ¶ added in v0.15.9
type CasmClass struct {
Bytecode []*felt.Felt
PythonicHints json.RawMessage
CompilerVersion string
Hints json.RawMessage
Prime *big.Int
External []CasmEntryPoint
L1Handler []CasmEntryPoint
Constructor []CasmEntryPoint
BytecodeSegmentLengths SegmentLengths
}
type CasmEntryPoint ¶ added in v0.15.9
type CasmHashVersion ¶ added in v0.15.11
type CasmHashVersion int
CasmHashVersion represents the version of the hash function used to compute the compiled class hash
const ( // HashVersionV1 uses Poseidon hash HashVersionV1 CasmHashVersion = iota + 1 // HashVersionV2 uses Blake2s hash HashVersionV2 )
type ClassDefinition ¶ added in v0.15.9
type ContractUpdater ¶ added in v0.7.5
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 ¶ added in v0.2.1
func DeployContract(addr, classHash *felt.Felt, txn db.IndexedBatch) (*ContractUpdater, error)
DeployContract sets up the database for a new contract.
func NewContractUpdater ¶ added in v0.7.5
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 ¶ added in v0.7.5
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 ¶ added in v0.7.5
func (c *ContractUpdater) Replace(classHash *felt.Felt) error
Replace replaces the class that the contract instantiates
func (*ContractUpdater) UpdateNonce ¶ added in v0.7.5
func (c *ContractUpdater) UpdateNonce(nonce *felt.Felt) error
UpdateNonce updates the nonce value in the database.
func (*ContractUpdater) UpdateStorage ¶ added in v0.7.5
func (c *ContractUpdater) UpdateStorage(diff map[felt.Felt]*felt.Felt, cb OnValueChanged) error
UpdateStorage applies a change-set to the contract storage.
type DataAvailability ¶ added in v0.11.0
type DataAvailabilityMode ¶ added in v0.8.0
type DataAvailabilityMode uint32
const ( DAModeL1 DataAvailabilityMode = iota DAModeL2 )
type DeclareTransaction ¶
type DeclareTransaction struct {
TransactionHash *felt.Felt
// The class hash
ClassHash *felt.Felt
// The address of the account initiating the transaction.
SenderAddress *felt.Felt
// The maximum fee that the sender is willing to pay for the transaction.
// Available in versions 1, 2
MaxFee *felt.Felt
// Additional information given by the sender, used to validate the transaction.
TransactionSignature []*felt.Felt
// The transaction nonce.
Nonce *felt.Felt
// The transaction’s version. Possible values are 0, 1, 2, or 3.
// When the fields that comprise a transaction change,
// either with the addition of a new field or the removal of an existing field,
// then the transaction version increases.
// Transaction version 0 is deprecated and will be removed in a future version of Starknet.
Version *TransactionVersion
// Version 2 fields
CompiledClassHash *felt.Felt
// Version 3 fields
// See InvokeTransaction for descriptions of the fields.
ResourceBounds map[Resource]ResourceBounds
Tip uint64
PaymasterData []*felt.Felt
AccountDeploymentData []*felt.Felt
NonceDAMode DataAvailabilityMode
FeeDAMode DataAvailabilityMode
}
func (*DeclareTransaction) Hash ¶
func (d *DeclareTransaction) Hash() *felt.Felt
func (*DeclareTransaction) Signature ¶
func (d *DeclareTransaction) Signature() []*felt.Felt
func (*DeclareTransaction) TxVersion ¶ added in v0.8.0
func (d *DeclareTransaction) TxVersion() *TransactionVersion
type DeclaredClassDefinition ¶ added in v0.15.9
type DeclaredClassDefinition struct {
At uint64 // block number at which the class was declared
Class ClassDefinition
}
DeclaredClassDefinition represents a class definition and the block number where it was declared
func GetClass ¶ added in v0.14.4
func GetClass(r db.KeyValueReader, classHash *felt.Felt) (*DeclaredClassDefinition, error)
func (*DeclaredClassDefinition) MarshalBinary ¶ added in v0.15.9
func (d *DeclaredClassDefinition) MarshalBinary() ([]byte, error)
func (*DeclaredClassDefinition) UnmarshalBinary ¶ added in v0.15.9
func (d *DeclaredClassDefinition) UnmarshalBinary(data []byte) error
type DeployAccountTransaction ¶
type DeployAccountTransaction struct {
DeployTransaction
// The maximum fee that the sender is willing to pay for the transaction.
MaxFee *felt.Felt
// Additional information given by the sender, used to validate the transaction.
TransactionSignature []*felt.Felt
// The transaction nonce.
Nonce *felt.Felt
// Version 3 fields
// See InvokeTransaction for descriptions of the fields.
ResourceBounds map[Resource]ResourceBounds
Tip uint64
PaymasterData []*felt.Felt
NonceDAMode DataAvailabilityMode
FeeDAMode DataAvailabilityMode
}
func (*DeployAccountTransaction) Hash ¶
func (d *DeployAccountTransaction) Hash() *felt.Felt
func (*DeployAccountTransaction) Signature ¶
func (d *DeployAccountTransaction) Signature() []*felt.Felt
type DeployTransaction ¶
type DeployTransaction struct {
TransactionHash *felt.Felt
// A random number used to distinguish between different instances of the contract.
ContractAddressSalt *felt.Felt
// The address of the contract.
ContractAddress *felt.Felt
// The hash of the class which defines the contract’s functionality.
ClassHash *felt.Felt
// The arguments passed to the constructor during deployment.
ConstructorCallData []*felt.Felt
// The transaction’s version. Possible values are 1 or 0.
//
// When the fields that comprise a transaction change,
// either with the addition of a new field or the removal of an existing field,
// then the transaction version increases.
// Transaction version 0 is deprecated and will be removed in a future version of Starknet.
Version *TransactionVersion
}
func (*DeployTransaction) Hash ¶
func (d *DeployTransaction) Hash() *felt.Felt
func (*DeployTransaction) Signature ¶
func (d *DeployTransaction) Signature() []*felt.Felt
func (*DeployTransaction) TxVersion ¶ added in v0.8.0
func (d *DeployTransaction) TxVersion() *TransactionVersion
type DeprecatedCairoClass ¶ added in v0.15.9
type DeprecatedCairoClass struct {
Abi json.RawMessage
// External functions defined in the class.
Externals []DeprecatedEntryPoint
// Functions that receive L1 messages. See
// https://www.cairo-lang.org/docs/hello_starknet/l1l2.html#receiving-a-message-from-l1
L1Handlers []DeprecatedEntryPoint
// Constructors for the class. Currently, only one is allowed.
Constructors []DeprecatedEntryPoint
// Base64 encoding of compressed Program
Program string
}
func (*DeprecatedCairoClass) Hash ¶ added in v0.15.9
func (c *DeprecatedCairoClass) Hash() (felt.Felt, error)
func (*DeprecatedCairoClass) SierraVersion ¶ added in v0.15.9
func (c *DeprecatedCairoClass) SierraVersion() string
func (*DeprecatedCairoClass) Version ¶ added in v0.15.9
func (c *DeprecatedCairoClass) Version() uint64
type DeprecatedEntryPoint ¶ added in v0.15.9
type ExecutionResources ¶
type ExecutionResources struct {
BuiltinInstanceCounter BuiltinInstanceCounter
MemoryHoles uint64
Steps uint64
DataAvailability *DataAvailability
TotalGasConsumed *GasConsumed
}
type GasConsumed ¶ added in v0.12.0
type Hasher ¶ added in v0.15.11
Hasher wraps hash algorithm operations
func NewCasmHasher ¶ added in v0.15.11
func NewCasmHasher(version CasmHashVersion) Hasher
type Header ¶
type Header struct {
// The hash of this block
Hash *felt.Felt
// The hash of this block’s parent
ParentHash *felt.Felt
// The number (height) of this block
Number uint64
// The state commitment after this block
GlobalStateRoot *felt.Felt
// The Starknet address of the sequencer who created this block
SequencerAddress *felt.Felt
// The amount Transactions and Receipts stored in this block
TransactionCount uint64
// The amount of events stored in transaction receipts
EventCount uint64
// The time the sequencer created this block before executing transactions
Timestamp uint64
// Todo(rdr): It makes more sense for Protocol version to be stored in semver.Version instead
// The version of the Starknet protocol used when creating this block
ProtocolVersion string
// Bloom filter on the events emitted this block
EventsBloom *bloom.BloomFilter
// Amount of WEI charged per Gas spent on L1
L1GasPriceETH *felt.Felt `cbor:"gasprice"`
// Amount of STRK charged per Gas spent on L2
Signatures [][]*felt.Felt
// Amount of STRK charged per Gas spent on L1
L1GasPriceSTRK *felt.Felt `cbor:"gaspricestrk"`
// Amount of STRK charged per Gas spent on L2
L1DAMode L1DAMode
// The gas price for L1 data availability
L1DataGasPrice *GasPrice
L2GasPrice *GasPrice
}
func GetBlockHeaderByHash ¶ added in v0.14.4
func GetBlockHeaderByNumber ¶ added in v0.14.4
func GetBlockHeaderByNumber(r db.KeyValueReader, blockNum uint64) (*Header, error)
type InvokeTransaction ¶
type InvokeTransaction struct {
TransactionHash *felt.Felt
// The arguments that are passed to the validated and execute functions.
CallData []*felt.Felt
// Additional information given by the sender, used to validate the transaction.
TransactionSignature []*felt.Felt
// The maximum fee that the sender is willing to pay for the transaction
// Available in version 1 only
MaxFee *felt.Felt
// The address of the contract invoked by this transaction.
ContractAddress *felt.Felt
// When the fields that comprise a transaction change,
// either with the addition of a new field or the removal of an existing field,
// then the transaction version increases.
Version *TransactionVersion
// Version 0 fields
// The encoding of the selector for the function invoked (the entry point in the contract)
EntryPointSelector *felt.Felt
// Version 1 fields
// The transaction nonce.
Nonce *felt.Felt
// The address of the sender of this transaction
SenderAddress *felt.Felt
// Version 3 fields (there was no version 2)
ResourceBounds map[Resource]ResourceBounds
Tip uint64
// From the RPC spec: data needed to allow the paymaster to pay for the transaction in native tokens
PaymasterData []*felt.Felt
// From RPC spec: data needed to deploy the account contract from which this tx will be initiated
AccountDeploymentData []*felt.Felt
// From RPC spec: The storage domain of the account's nonce (an account has a nonce per DA mode)
NonceDAMode DataAvailabilityMode
// From RPC spec: The storage domain of the account's balance from which fee will be charged
FeeDAMode DataAvailabilityMode
}
func (*InvokeTransaction) Hash ¶
func (i *InvokeTransaction) Hash() *felt.Felt
func (*InvokeTransaction) Signature ¶
func (i *InvokeTransaction) Signature() []*felt.Felt
func (*InvokeTransaction) TxVersion ¶ added in v0.8.0
func (i *InvokeTransaction) TxVersion() *TransactionVersion
type L1HandlerTransaction ¶
type L1HandlerTransaction struct {
TransactionHash *felt.Felt
// The address of the contract.
ContractAddress *felt.Felt
// The encoding of the selector for the function invoked (the entry point in the contract)
EntryPointSelector *felt.Felt
// The transaction nonce.
Nonce *felt.Felt
// The arguments that are passed to the validated and execute functions.
CallData []*felt.Felt
// When the fields that comprise a transaction change,
// either with the addition of a new field or the removal of an existing field,
// then the transaction version increases.
Version *TransactionVersion
}
func (*L1HandlerTransaction) Hash ¶
func (l *L1HandlerTransaction) Hash() *felt.Felt
func (*L1HandlerTransaction) MessageHash ¶ added in v0.7.0
func (l *L1HandlerTransaction) MessageHash() []byte
func (*L1HandlerTransaction) Signature ¶
func (l *L1HandlerTransaction) Signature() []*felt.Felt
func (*L1HandlerTransaction) TxVersion ¶ added in v0.8.0
func (l *L1HandlerTransaction) TxVersion() *TransactionVersion
type L1ToL2Message ¶
type L2ToL1Message ¶
type OnValueChanged ¶ added in v0.3.0
type Pending ¶ added in v0.15.5
type Pending struct {
Block *Block
StateUpdate *StateUpdate
NewClasses map[felt.Felt]ClassDefinition
}
func NewPending ¶ added in v0.15.5
func NewPending( block *Block, stateUpdate *StateUpdate, newClasses map[felt.Felt]ClassDefinition, ) Pending
func (*Pending) GetCandidateTransaction ¶ added in v0.15.5
func (p *Pending) GetCandidateTransaction() []Transaction
func (*Pending) GetNewClasses ¶ added in v0.15.5
func (p *Pending) GetNewClasses() map[felt.Felt]ClassDefinition
func (*Pending) GetPreLatest ¶ added in v0.15.6
func (*Pending) GetStateUpdate ¶ added in v0.15.5
func (p *Pending) GetStateUpdate() *StateUpdate
func (*Pending) GetTransactionStateDiffs ¶ added in v0.15.5
func (*Pending) GetTransactions ¶ added in v0.15.5
func (p *Pending) GetTransactions() []Transaction
func (*Pending) PendingState ¶ added in v0.15.9
func (p *Pending) PendingState(baseState StateReader) StateReader
func (*Pending) PendingStateBeforeIndex ¶ added in v0.15.9
func (p *Pending) PendingStateBeforeIndex(baseState StateReader, index uint) (StateReader, error)
func (*Pending) ReceiptByHash ¶ added in v0.15.8
func (*Pending) TransactionByHash ¶ added in v0.15.8
func (p *Pending) TransactionByHash(hash *felt.Felt) (Transaction, error)
func (*Pending) Variant ¶ added in v0.15.5
func (p *Pending) Variant() PendingDataVariant
type PendingData ¶ added in v0.15.0
type PendingData interface {
GetBlock() *Block
GetHeader() *Header
GetTransactions() []Transaction
GetStateUpdate() *StateUpdate
GetNewClasses() map[felt.Felt]ClassDefinition
GetCandidateTransaction() []Transaction
GetTransactionStateDiffs() []*StateDiff
GetPreLatest() *PreLatest
// Validate returns true if pendingData is valid for given predecessor,
// otherwise returns false
Validate(parent *Header) bool
Variant() PendingDataVariant
TransactionByHash(hash *felt.Felt) (Transaction, error)
ReceiptByHash(hash *felt.Felt) (*TransactionReceipt, *felt.Felt, uint64, error)
// PendingStateBeforeIndex returns the state obtained by applying all transaction state diffs
// up to given index in the pre-confirmed block.
PendingStateBeforeIndex(baseState StateReader, index uint) (StateReader, error)
// PendingState returns the state resulting from execution of the pending data
PendingState(baseState StateReader) StateReader
}
type PendingDataVariant ¶ added in v0.15.0
type PendingDataVariant uint8
const ( PendingBlockVariant PendingDataVariant = iota + 1 PreConfirmedBlockVariant )
type PendingState ¶ added in v0.15.9
type PendingState struct {
// contains filtered or unexported fields
}
func NewPendingState ¶ added in v0.15.9
func NewPendingState( stateDiff *StateDiff, newClasses map[felt.Felt]ClassDefinition, head StateReader, ) *PendingState
func (*PendingState) Class ¶ added in v0.15.9
func (p *PendingState) Class(classHash *felt.Felt) (*DeclaredClassDefinition, error)
func (*PendingState) ClassTrie ¶ added in v0.15.9
func (p *PendingState) ClassTrie() (commontrie.Trie, error)
func (*PendingState) CompiledClassHash ¶ added in v0.15.11
func (p *PendingState) CompiledClassHash( classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func (*PendingState) CompiledClassHashV2 ¶ added in v0.15.11
func (p *PendingState) CompiledClassHashV2( classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func (*PendingState) ContractClassHash ¶ added in v0.15.9
func (*PendingState) ContractNonce ¶ added in v0.15.9
func (*PendingState) ContractStorage ¶ added in v0.15.9
func (*PendingState) ContractStorageTrie ¶ added in v0.15.9
func (p *PendingState) ContractStorageTrie(addr *felt.Felt) (commontrie.Trie, error)
func (*PendingState) ContractTrie ¶ added in v0.15.9
func (p *PendingState) ContractTrie() (commontrie.Trie, error)
func (*PendingState) StateDiff ¶ added in v0.15.9
func (p *PendingState) StateDiff() *StateDiff
type PendingStateWriter ¶ added in v0.15.9
type PendingStateWriter struct {
*PendingState
}
func NewPendingStateWriter ¶ added in v0.15.9
func NewPendingStateWriter( stateDiff *StateDiff, newClasses map[felt.Felt]ClassDefinition, head StateReader, ) PendingStateWriter
func (*PendingStateWriter) IncrementNonce ¶ added in v0.15.9
func (p *PendingStateWriter) IncrementNonce(contractAddress *felt.Felt) error
func (*PendingStateWriter) SetClassHash ¶ added in v0.15.9
func (p *PendingStateWriter) SetClassHash(contractAddress, classHash *felt.Felt) error
func (*PendingStateWriter) SetCompiledClassHash ¶ added in v0.15.9
func (p *PendingStateWriter) SetCompiledClassHash(classHash, compiledClassHash *felt.Felt) error
SetCompiledClassHash writes CairoV1 classes to the pending state Assumption: SetContractClass was called for classHash and succeeded
func (*PendingStateWriter) SetContractClass ¶ added in v0.15.9
func (p *PendingStateWriter) SetContractClass(classHash *felt.Felt, class ClassDefinition) error
SetContractClass writes a new CairoV0 class to the PendingState Assumption: SetCompiledClassHash should be called for CairoV1 contracts
func (*PendingStateWriter) SetStateDiff ¶ added in v0.15.9
func (p *PendingStateWriter) SetStateDiff(stateDiff *StateDiff)
func (*PendingStateWriter) SetStorage ¶ added in v0.15.9
func (p *PendingStateWriter) SetStorage(contractAddress, key, value *felt.Felt) error
func (*PendingStateWriter) StateDiffAndClasses ¶ added in v0.15.9
func (p *PendingStateWriter) StateDiffAndClasses() (StateDiff, map[felt.Felt]ClassDefinition)
StateDiffAndClasses returns the pending state's internal data. The returned objects will continue to be read and modified by the pending state.
type PreConfirmed ¶ added in v0.15.0
type PreConfirmed struct {
Block *Block
StateUpdate *StateUpdate
// Node does not fetch unknown classes. but we keep it for sequencer
NewClasses map[felt.Felt]ClassDefinition
TransactionStateDiffs []*StateDiff
CandidateTxs []Transaction
// Optional field, exists if pre_confirmed is N+2 when latest is N
PreLatest *PreLatest
}
func NewPreConfirmed ¶ added in v0.15.0
func NewPreConfirmed( block *Block, stateUpdate *StateUpdate, transactionStateDiffs []*StateDiff, candidateTxs []Transaction, ) PreConfirmed
func (*PreConfirmed) Copy ¶ added in v0.15.6
func (p *PreConfirmed) Copy() *PreConfirmed
func (*PreConfirmed) GetBlock ¶ added in v0.15.0
func (p *PreConfirmed) GetBlock() *Block
func (*PreConfirmed) GetCandidateTransaction ¶ added in v0.15.0
func (p *PreConfirmed) GetCandidateTransaction() []Transaction
func (*PreConfirmed) GetHeader ¶ added in v0.15.0
func (p *PreConfirmed) GetHeader() *Header
func (*PreConfirmed) GetNewClasses ¶ added in v0.15.0
func (p *PreConfirmed) GetNewClasses() map[felt.Felt]ClassDefinition
func (*PreConfirmed) GetPreLatest ¶ added in v0.15.6
func (p *PreConfirmed) GetPreLatest() *PreLatest
func (*PreConfirmed) GetStateUpdate ¶ added in v0.15.0
func (p *PreConfirmed) GetStateUpdate() *StateUpdate
func (*PreConfirmed) GetTransactionStateDiffs ¶ added in v0.15.0
func (p *PreConfirmed) GetTransactionStateDiffs() []*StateDiff
func (*PreConfirmed) GetTransactions ¶ added in v0.15.0
func (p *PreConfirmed) GetTransactions() []Transaction
func (*PreConfirmed) PendingState ¶ added in v0.15.9
func (p *PreConfirmed) PendingState(baseState StateReader) StateReader
func (*PreConfirmed) PendingStateBeforeIndex ¶ added in v0.15.9
func (p *PreConfirmed) PendingStateBeforeIndex( baseState StateReader, index uint, ) (StateReader, error)
func (*PreConfirmed) ReceiptByHash ¶ added in v0.15.8
func (p *PreConfirmed) ReceiptByHash( hash *felt.Felt, ) (*TransactionReceipt, *felt.Felt, uint64, error)
func (*PreConfirmed) TransactionByHash ¶ added in v0.15.8
func (p *PreConfirmed) TransactionByHash(hash *felt.Felt) (Transaction, error)
func (*PreConfirmed) Validate ¶ added in v0.15.6
func (p *PreConfirmed) Validate(parent *Header) bool
func (*PreConfirmed) Variant ¶ added in v0.15.0
func (p *PreConfirmed) Variant() PendingDataVariant
func (*PreConfirmed) WithNewClasses ¶ added in v0.15.6
func (p *PreConfirmed) WithNewClasses(newClasses map[felt.Felt]ClassDefinition) *PreConfirmed
func (*PreConfirmed) WithPreLatest ¶ added in v0.15.6
func (p *PreConfirmed) WithPreLatest(preLatest *PreLatest) *PreConfirmed
type ResourceBounds ¶ added in v0.8.0
type ResourceBounds struct {
MaxAmount uint64
// MaxPricePerUnit is technically a uint128
MaxPricePerUnit *felt.Felt
}
From the RPC spec: The max amount and max price per unit of gas used in this transaction.
func (ResourceBounds) Bytes ¶ added in v0.8.0
func (rb ResourceBounds) Bytes(resource Resource) []byte
func (ResourceBounds) IsZero ¶ added in v0.13.3
func (rb ResourceBounds) IsZero() bool
type RunningEventFilter ¶ added in v0.14.6
type RunningEventFilter struct {
// contains filtered or unexported fields
}
RunningEventFilter provides a thread-safe wrapper around AggregatedBloomFilter that automatically manages the creation of new filters when the current one reaches its capacity. It maintains the current state of event filtering across the blockchain.
func GetRunningEventFilter ¶ added in v0.14.6
func GetRunningEventFilter(r db.KeyValueReader) (*RunningEventFilter, error)
func NewRunningEventFilterHot ¶ added in v0.14.6
func NewRunningEventFilterHot(txn db.KeyValueStore, filter *AggregatedBloomFilter, nextBlock uint64) *RunningEventFilter
NewRunningFilter returns a RunningEventFilter that wraps the provided aggregated filter with the expected next block to process.
func NewRunningEventFilterLazy ¶ added in v0.14.6
func NewRunningEventFilterLazy(txn db.KeyValueStore) *RunningEventFilter
func (*RunningEventFilter) BlocksForKeys ¶ added in v0.14.6
func (f *RunningEventFilter) BlocksForKeys(keys [][]byte) *bitset.BitSet
BlocksForKeys returns a bitset indicating which blocks within the range might contain the given keys. If no keys are provided, returns a bitset with all bits set.
func (*RunningEventFilter) BlocksForKeysInto ¶ added in v0.14.6
func (f *RunningEventFilter) BlocksForKeysInto(keys [][]byte, out *bitset.BitSet) error
BlocksForKeysInto reuses a preallocated bitset (should be NumBlocksPerFilter bits).
func (*RunningEventFilter) Clone ¶ added in v0.14.6
func (f *RunningEventFilter) Clone() *RunningEventFilter
Clone returns a deep copy of the RunningEventFilter—including a full copy of its internal AggregatedBloomFilter window.
func (*RunningEventFilter) FromBlock ¶ added in v0.14.6
func (f *RunningEventFilter) FromBlock() uint64
FromBlock returns the starting block number of the current filter window.
func (*RunningEventFilter) InnerFilter ¶ added in v0.14.6
func (f *RunningEventFilter) InnerFilter() *AggregatedBloomFilter
InnerFilter returns a deep copy of the current AggregatedBloomFilter window.
func (*RunningEventFilter) Insert ¶ added in v0.14.6
func (f *RunningEventFilter) Insert( bloom *bloom.BloomFilter, blockNumber uint64, ) error
Insert adds a bloom filter for a single block, updating the internal aggregated filter. If the current window is full, it will be persisted using WriteAggregatedBloomFilter and a new window will be started. This implementation assumes blocks are not missed. Returns an error if the block cannot be inserted.
func (*RunningEventFilter) MarshalBinary ¶ added in v0.14.6
func (f *RunningEventFilter) MarshalBinary() ([]byte, error)
func (*RunningEventFilter) NextBlock ¶ added in v0.14.6
func (f *RunningEventFilter) NextBlock() uint64
NextBlock returns the next block number to be processed.
func (*RunningEventFilter) OnReorg ¶ added in v0.14.6
func (f *RunningEventFilter) OnReorg() error
Clear erases the bloom filter data for the specified block
func (*RunningEventFilter) ToBlock ¶ added in v0.14.6
func (f *RunningEventFilter) ToBlock() uint64
ToBlock returns the ending block number of the current filter window.
func (*RunningEventFilter) UnmarshalBinary ¶ added in v0.14.6
func (f *RunningEventFilter) UnmarshalBinary(data []byte) error
func (*RunningEventFilter) Write ¶ added in v0.14.6
func (f *RunningEventFilter) Write() error
Write writes the current state of the RunningEventFilter to persistent storage.
type SegmentLengths ¶ added in v0.11.0
type SegmentLengths struct {
Children []SegmentLengths
Length uint64
}
type SierraClass ¶ added in v0.15.9
type SierraClass struct {
Abi string
AbiHash *felt.Felt
EntryPoints SierraEntryPointsByType
Program []*felt.Felt
ProgramHash *felt.Felt
// TODO: Remove this semantic version on a follow up PR. Let's put Sierra version instead
SemanticVersion string
Compiled *CasmClass
}
func (*SierraClass) SierraVersion ¶ added in v0.15.9
func (c *SierraClass) SierraVersion() string
todo(rdr): Make the SierraVersion returned here a sem ver Returns the Sierra version for the Cairo 1 class
Sierra programs contain the version number in two possible formats. For pre-1.0-rc0 Cairo versions the program contains the Sierra version "0.1.0" as a shortstring in its first Felt (0x302e312e30 = "0.1.0"). For all subsequent versions the version number is the first three felts representing the three parts of a semantic version number.
func (*SierraClass) Version ¶ added in v0.15.9
func (c *SierraClass) Version() uint64
type SierraEntryPoint ¶ added in v0.2.1
type SierraEntryPointsByType ¶ added in v0.15.11
type SierraEntryPointsByType struct {
Constructor []SierraEntryPoint
External []SierraEntryPoint
L1Handler []SierraEntryPoint
}
type State ¶
type State struct {
// contains filtered or unexported fields
}
func NewState ¶
func NewState(txn db.IndexedBatch) *State
func (*State) Class ¶ added in v0.3.0
func (s *State) Class(classHash *felt.Felt) (*DeclaredClassDefinition, error)
Class returns the class object corresponding to the given classHash
func (*State) Commitment ¶ added in v0.15.10
Root returns the state commitment.
func (*State) CompiledClassHash ¶ added in v0.15.11
func (s *State) CompiledClassHash( classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func (*State) CompiledClassHashV2 ¶ added in v0.15.11
func (s *State) CompiledClassHashV2( classHash *felt.SierraClassHash, ) (felt.CasmClassHash, error)
func (*State) ContractClassHash ¶ added in v0.2.1
ContractClassHash returns class hash of a contract at a given address.
func (*State) ContractClassHashAt ¶ added in v0.6.0
func (*State) ContractDeployedAt ¶ added in v0.15.10
ContractDeployedAt returns if contract at given addr was deployed at blockNumber
func (*State) ContractNonce ¶ added in v0.2.1
ContractNonce returns nonce of a contract at a given address.
func (*State) ContractNonceAt ¶ added in v0.6.0
func (*State) ContractStorage ¶ added in v0.3.0
ContractStorage returns value of a key in the storage of the contract at the given address.
func (*State) ContractStorageAt ¶ added in v0.6.0
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) ContractStorageTrie ¶ added in v0.13.0
func (*State) ContractTrie ¶ added in v0.13.0
func (s *State) ContractTrie() (commontrie.Trie, error)
func (*State) GetReverseStateDiff ¶ added in v0.12.3
todo(rdr): return `StateDiff` by value
func (*State) Revert ¶ added in v0.4.0
func (s *State) Revert(blockNumber uint64, update *StateUpdate) error
func (*State) Update ¶
func (s *State) Update( blockNumber uint64, update *StateUpdate, declaredClasses map[felt.Felt]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.
type StateDiff ¶
type StateDiff struct {
// todo(rdr): replace felt.Felt for the right types (felt.Address to felt.What? to felt.What?)
// felt.What? means I'm not sure which type, but if it doesn't exist, create it.
StorageDiffs map[felt.Felt]map[felt.Felt]*felt.Felt // addr -> {key -> value, ...}
// todo(rdr): felt.Address to felt.Nonce (`Nonce` is a new type that should be created?)
Nonces map[felt.Felt]*felt.Felt
// todo(rdr): felt.Addr to felt.ClassHash (do we know if it will be `SierraClassHash or
// `CasmClassHash`)
DeployedContracts map[felt.Felt]*felt.Felt
// todo(rdr): an array of felt.ClassHash, or perhaps, felt.DeprecatedCairoClassHash
// Also, change the name from `DeclaredV0Classes` to `DeprecatedDeclaredClasses`
DeclaredV0Classes []*felt.Felt
// todo(rdr): felt.SierraClassHash to felt.CasmClassHash
DeclaredV1Classes map[felt.Felt]*felt.Felt // class hash -> compiled class hash
// todo(rdr): felt.Address to (felt.SierraClassHash or felt.CasmClassHash, I'm unsure)
ReplacedClasses map[felt.Felt]*felt.Felt // addr -> class hash
// Sierra Class definitions which had their compiled class hash definition (CASM)
// migrated from poseidon hash to blake2s hash (Starknet 0.14.1)
MigratedClasses map[felt.SierraClassHash]felt.CasmClassHash
}
func EmptyStateDiff ¶ added in v0.7.5
func EmptyStateDiff() StateDiff
func (*StateDiff) Commitment ¶ added in v0.7.0
type StateHistoryReader ¶ added in v0.3.0
type StateHistoryReader interface {
StateReader
ContractStorageAt(addr, key *felt.Felt, blockNumber uint64) (felt.Felt, error)
ContractNonceAt(addr *felt.Felt, blockNumber uint64) (felt.Felt, error)
ContractClassHashAt(addr *felt.Felt, blockNumber uint64) (felt.Felt, error)
ContractDeployedAt(addr *felt.Felt, blockNumber uint64) (bool, error)
}
type StateReader ¶ added in v0.3.0
type StateReader interface {
ContractClassHash(addr *felt.Felt) (felt.Felt, error)
ContractNonce(addr *felt.Felt) (felt.Felt, error)
ContractStorage(addr, key *felt.Felt) (felt.Felt, error)
Class(classHash *felt.Felt) (*DeclaredClassDefinition, error)
CompiledClassHash(classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
CompiledClassHashV2(classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
ClassTrie() (commontrie.Trie, error)
ContractTrie() (commontrie.Trie, error)
ContractStorageTrie(addr *felt.Felt) (commontrie.Trie, error)
}
type StateUpdate ¶
type StateUpdate struct {
BlockHash *felt.Felt
NewRoot *felt.Felt
OldRoot *felt.Felt
StateDiff *StateDiff
}
func GetStateUpdateByBlockNum ¶ added in v0.14.4
func GetStateUpdateByBlockNum(r db.KeyValueReader, blockNum uint64) (*StateUpdate, error)
func GetStateUpdateByHash ¶ added in v0.14.4
func GetStateUpdateByHash(r db.KeyValueReader, hash *felt.Felt) (*StateUpdate, error)
type Transaction ¶
type Transaction interface {
// TODO: This should be TransactionHash instead of Felt.
Hash() *felt.Felt
Signature() []*felt.Felt
TxVersion() *TransactionVersion
}
func GetTxByHash ¶ added in v0.14.4
func GetTxByHash(r db.KeyValueReader, hash *felt.TransactionHash) (Transaction, error)
func GetTxsByBlockNum ¶ added in v0.14.4
func GetTxsByBlockNum(r db.KeyValueReader, blockNum uint64) ([]Transaction, error)
Returns all transactions in a given block
type TransactionReceipt ¶
type TransactionReceipt struct {
Fee *felt.Felt
FeeUnit FeeUnit
Events []*Event
ExecutionResources *ExecutionResources
L1ToL2Message *L1ToL2Message
L2ToL1Message []*L2ToL1Message
TransactionHash *felt.Felt
Reverted bool
RevertReason string
}
func GetReceiptByHash ¶ added in v0.14.4
func GetReceiptByHash( r db.KeyValueReader, hash *felt.TransactionHash, ) (*TransactionReceipt, error)
TODO: Return TransactionReceipt instead of *TransactionReceipt.
func GetReceiptsByBlockNum ¶ added in v0.14.4
func GetReceiptsByBlockNum(r db.KeyValueReader, blockNum uint64) ([]*TransactionReceipt, error)
Returns all receipts in a given block
type TransactionVersion ¶ added in v0.6.2
Keep in mind that this is used as a storage type, make sure you migrate the DB if you change the underlying type
func (*TransactionVersion) AsFelt ¶ added in v0.6.2
func (v *TransactionVersion) AsFelt() *felt.Felt
func (*TransactionVersion) HasQueryBit ¶ added in v0.6.2
func (v *TransactionVersion) HasQueryBit() bool
func (*TransactionVersion) Is ¶ added in v0.6.2
func (v *TransactionVersion) Is(u64 uint64) bool
Is compares the version (without query bit) with the given value
func (*TransactionVersion) MarshalCBOR ¶ added in v0.6.2
func (v *TransactionVersion) MarshalCBOR() ([]byte, error)
func (*TransactionVersion) SetUint64 ¶ added in v0.6.2
func (v *TransactionVersion) SetUint64(u64 uint64) *TransactionVersion
func (*TransactionVersion) String ¶ added in v0.6.2
func (v *TransactionVersion) String() string
func (*TransactionVersion) UnmarshalCBOR ¶ added in v0.6.2
func (v *TransactionVersion) UnmarshalCBOR(data []byte) error
func (*TransactionVersion) WithoutQueryBit ¶ added in v0.6.2
func (v *TransactionVersion) WithoutQueryBit() TransactionVersion
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
|
Package trie implements a dense Merkle Patricia Trie.
|
Package trie implements a dense Merkle Patricia Trie. |