Documentation
¶
Overview ¶
TODO(remove once migrated from geth): once l1.Subscriber.TransactionReceipt returns *eth.Receipt directly, the adapter and this whole file go away.
Index ¶
Constants ¶
const ( MaxEventChunkSize = 10240 MaxEventFilterKeys = 1024 TraceCacheSize = 128 ThrottledVMErr = "VM throughput limit reached" ThrottledCompilerErr = "Compiler throughput limit reached" MaxBlocksBack = 1024 EntrypointNotFoundFelt string = "0x454e545259504f494e545f4e4f545f464f554e44" ErrEPSNotFound = "Entry point EntryPointSelector(%s) not found in contract." )
const (
NumTimeBuckets = 3
)
Variables ¶
var ( ErrContractNotFound = &jsonrpc.Error{Code: 20, Message: "Contract not found"} ErrEntrypointNotFound = &jsonrpc.Error{ Code: 21, Message: "Requested entrypoint does not exist in the contract", } ErrEntrypointNotFoundV0_10 = &jsonrpc.Error{ Code: 21, Message: "Requested entry point does not exist in the contract", } ErrBlockNotFound = &jsonrpc.Error{Code: 24, Message: "Block not found"} ErrInvalidTxHash = &jsonrpc.Error{Code: 25, Message: "Invalid transaction hash"} ErrInvalidBlockHash = &jsonrpc.Error{Code: 26, Message: "Invalid block hash"} ErrInvalidTxIndex = &jsonrpc.Error{Code: 27, Message: "Invalid transaction index in a block"} ErrClassHashNotFound = &jsonrpc.Error{Code: 28, Message: "Class hash not found"} ErrTxnHashNotFound = &jsonrpc.Error{Code: 29, Message: "Transaction hash not found"} ErrPageSizeTooBig = &jsonrpc.Error{Code: 31, Message: "Requested page size is too big"} ErrNoBlock = &jsonrpc.Error{Code: 32, Message: "There are no blocks"} ErrInvalidContinuationToken = &jsonrpc.Error{Code: 33, Message: "The supplied continuation token is invalid or unknown"} ErrTooManyKeysInFilter = &jsonrpc.Error{Code: 34, Message: "Too many keys provided in a filter"} ErrContractError = &jsonrpc.Error{Code: 40, Message: "Contract error"} ErrTransactionExecutionError = &jsonrpc.Error{Code: 41, Message: "Transaction execution error"} ErrStorageProofNotSupported = &jsonrpc.Error{Code: 42, Message: "the node doesn't support storage proofs for blocks that are too far in the past"} //nolint:lll ErrInvalidContractClass = &jsonrpc.Error{Code: 50, Message: "Invalid contract class"} ErrClassAlreadyDeclared = &jsonrpc.Error{Code: 51, Message: "Class already declared"} ErrInternal = &jsonrpc.Error{Code: jsonrpc.InternalError, Message: "Internal error"} ErrInvalidTransactionNonce = &jsonrpc.Error{Code: 52, Message: "Invalid transaction nonce"} ErrInsufficientMaxFee = &jsonrpc.Error{Code: 53, Message: "Max fee is smaller than the minimal transaction cost (validation plus fee transfer)"} //nolint:lll ErrInsufficientResourcesForValidate = &jsonrpc.Error{Code: 53, Message: "The transaction’s resources don’t cover validation or the minimal transaction fee"} //nolint:lll ErrInsufficientAccountBalance = &jsonrpc.Error{Code: 54, Message: "Account balance is smaller than the transaction's max_fee"} ErrInsufficientAccountBalanceV0_8 = &jsonrpc.Error{Code: 54, Message: "Account balance is smaller than the transaction's " + "maximal fee (calculated as the sum of each resource's limit x max price)"} ErrValidationFailure = &jsonrpc.Error{Code: 55, Message: "Account validation failed"} ErrCompilationFailed = &jsonrpc.Error{Code: 56, Message: "Compilation failed"} ErrContractClassSizeTooLarge = &jsonrpc.Error{Code: 57, Message: "Contract class size is too large"} ErrNonAccount = &jsonrpc.Error{Code: 58, Message: "Sender address is not an account contract"} ErrDuplicateTx = &jsonrpc.Error{Code: 59, Message: "A transaction with the same hash already exists in the mempool"} ErrCompiledClassHashMismatch = &jsonrpc.Error{Code: 60, Message: "the compiled class hash did not match the one supplied in the transaction"} //nolint:lll ErrUnsupportedTxVersion = &jsonrpc.Error{Code: 61, Message: "the transaction version is not supported"} ErrUnsupportedContractClassVersion = &jsonrpc.Error{Code: 62, Message: "the contract class version is not supported"} ErrUnexpectedError = &jsonrpc.Error{Code: 63, Message: "An unexpected error occurred"} ErrReplacementTransactionUnderPriced = &jsonrpc.Error{Code: 64, Message: "Replacement transaction is underpriced"} ErrFeeBelowMinimum = &jsonrpc.Error{Code: 65, Message: "Transaction fee below minimum"} ErrInvalidSubscriptionID = &jsonrpc.Error{Code: 66, Message: "Invalid subscription id"} ErrTooManyAddressesInFilter = &jsonrpc.Error{Code: 67, Message: "Too many addresses in filter sender_address filter"} ErrTooManyBlocksBack = &jsonrpc.Error{Code: 68, Message: fmt.Sprintf("Cannot go back more than %v blocks", MaxBlocksBack)} ErrInvalidProof = &jsonrpc.Error{Code: 69, Message: "The proof field in the invoke v3 transaction is invalid"} ErrCallOnPreConfirmed = &jsonrpc.Error{ Code: 70, Message: "This method does not support being called on the pre_confirmed block", } // TODO: This error is not present in the spec and should be removed. // Giving it a temporary code 71 for now to avoid conflicts with existing errors. ErrCallOnPending = &jsonrpc.Error{Code: 71, Message: "This method does not support being called on the pending block"} // These errors can be only be returned by Juno-specific methods. ErrSubscriptionNotFound = &jsonrpc.Error{Code: 100, Message: "Subscription not found"} )
Functions ¶
This section is empty.
Types ¶
type EthReceiptAdapter ¶ added in v0.16.3
type EthReceiptAdapter struct {
Sub gethTxReceiptFetcher
}
EthReceiptAdapter wraps an l1.Subscriber (returns *geth/types.Receipt) and exposes the L1Client interface (returns *eth.Receipt). It exists only because the L1 subscriber interface still speaks geth types.
func (*EthReceiptAdapter) TransactionReceipt ¶ added in v0.16.3
type FunctionCalldataLimit ¶ added in v0.15.8
type FunctionCalldataLimit struct{}
func (FunctionCalldataLimit) Limit ¶ added in v0.15.8
func (l FunctionCalldataLimit) Limit() int
type Gateway ¶
type Gateway interface {
AddTransaction(context.Context, json.RawMessage) (json.RawMessage, error)
}
type LimitSlice ¶ added in v0.15.8
func (LimitSlice[T, L]) MarshalJSON ¶ added in v0.15.8
func (l LimitSlice[T, L]) MarshalJSON() ([]byte, error)
func (*LimitSlice[T, L]) UnmarshalJSON ¶ added in v0.15.8
func (l *LimitSlice[T, L]) UnmarshalJSON(data []byte) error
type PreConfirmedDeduper ¶ added in v0.16.5
type PreConfirmedDeduper[K comparable] struct { // contains filtered or unexported fields }
PreConfirmedDeduper suppresses duplicate live pre_confirmed notifications (events, receipts, transactions). The tip is re-published in full on every delta, so the keys already sent this round are all that is needed; a new block number or round identifier (same-height replacement) discards them and re-emits. Committed blocks bypass it.
Not safe for concurrent use: each subscription owns one instance, touched only from its single dispatch goroutine. Don't share an instance or add a goroutine without restoring synchronisation.
func NewPreConfirmedDeduper ¶ added in v0.16.5
func NewPreConfirmedDeduper[K comparable]() *PreConfirmedDeduper[K]
NewPreConfirmedDeduper creates a pre_confirmed tip deduper.
func (*PreConfirmedDeduper[K]) Clear ¶ added in v0.16.5
func (c *PreConfirmedDeduper[K]) Clear()
Clear removes all cached data.
func (*PreConfirmedDeduper[K]) MarkSent ¶ added in v0.16.5
func (c *PreConfirmedDeduper[K]) MarkSent(blockNum uint64, identifier string, key *K) bool
MarkSent records key for the given pre_confirmed round (blockNum + identifier) and reports whether it was newly added — i.e. whether it should be sent. Advancing to a different block number or round identifier discards the previous round's keys first.
type SenderAddressLimit ¶ added in v0.15.8
type SenderAddressLimit struct{}
func (SenderAddressLimit) Limit ¶ added in v0.15.8
func (l SenderAddressLimit) Limit() int
type SimulationLimit ¶ added in v0.15.8
type SimulationLimit struct{}
func (SimulationLimit) Limit ¶ added in v0.15.8
func (l SimulationLimit) Limit() int
type TraceCacheKey ¶
type TransactionCache ¶ added in v0.15.2
type TransactionCache struct {
// contains filtered or unexported fields
}
The cache divides time into 3 fixed-size buckets (NumTimeBuckets), each representing one TTL interval. It tracks a `curTimeBucket` index, which points to the active bucket for new entries.
The three buckets can be interpreted as: - Bucket (curTimeBucket - 1) % 3: the previous bucket — entries may be valid or expired, depending on timestamp. - Bucket (curTimeBucket ) % 3: the current bucket — new entries are added here. - Bucket (curTimeBucket + 1) % 3: the next bucket — cleared by the evictor-routine before reuse.
On every tick (i.e., TTL duration), the index advances and the evictor clears the oldest bucket in-place.
func NewTransactionCache ¶ added in v0.15.2
func NewTransactionCache(ttl time.Duration, cacheSizeHint uint) *TransactionCache
NewTransactionCache creates the cache with a default 1 s eviction ticker.
func (*TransactionCache) Add ¶ added in v0.15.2
func (c *TransactionCache) Add(key *felt.Felt)
func (*TransactionCache) Contains ¶ added in v0.15.2
func (c *TransactionCache) Contains(key *felt.Felt) bool
func (*TransactionCache) Run ¶ added in v0.15.2
func (c *TransactionCache) Run(ctx context.Context) error
func (*TransactionCache) WithTicker ¶ added in v0.15.2
func (c *TransactionCache) WithTicker(tickC <-chan time.Time) *TransactionCache
Call this _before_ Run. Should only be used for tests.