rpccore

package
v0.15.21 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxEventChunkSize             = 10240
	MaxEventFilterKeys            = 1024
	TraceCacheSize                = 128
	ThrottledVMErr                = "VM throughput limit reached"
	MaxBlocksBack                 = 1024
	EntrypointNotFoundFelt string = "0x454e545259504f494e545f4e4f545f464f554e44"
	ErrEPSNotFound                = "Entry point EntryPointSelector(%s) not found in contract."
)
View Source
const BlockCacheCapacity = 3

Cache is expected to at most hold 3 blocks at a time. latest block, pre-latest block, and the pre-confirmed block.

View Source
const (
	NumTimeBuckets = 3
)

Variables

View Source
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 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 L1Client

type L1Client interface {
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
}

type Limit added in v0.15.8

type Limit interface {
	Limit() int
}

type LimitSlice added in v0.15.8

type LimitSlice[T any, L Limit] struct {
	Data []T `validate:"dive"`
}

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 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 SubscriptionCache added in v0.15.10

type SubscriptionCache[K comparable, V comparable] struct {
	// contains filtered or unexported fields
}

SubscriptionCache is a minimal cache for subscription notifications deduplication. Stores notifications by block number and key, with automatic eviction.

The cache is designed to hold at most 3 blocks: - up to 2 non-committed blocks (pre-latest and pre-confirmed) - and 1 committed block. The finalised block will always have the smallest block number. When the cache reaches capacity, it evicts the slot with the lowest block number, which always corresponds to the oldest finalised block.

func NewSubscriptionCache added in v0.15.10

func NewSubscriptionCache[
	K comparable,
	V comparable,
]() *SubscriptionCache[K, V]

NewSubscriptionCache creates a new cache.

func (*SubscriptionCache[K, V]) Clear added in v0.15.10

func (c *SubscriptionCache[K, V]) Clear()

Clear removes all cached data.

func (*SubscriptionCache[K, V]) Put added in v0.15.10

func (c *SubscriptionCache[K, V]) Put(blockNum uint64, key *K, value *V)

Put stores a notification for the given block number and key. Evicts the lowest block number when cache is full.

func (*SubscriptionCache[K, V]) ShouldSend added in v0.15.10

func (c *SubscriptionCache[K, V]) ShouldSend(blockNum uint64, key *K, value *V) bool

ShouldSend returns true if the notification should be sent. Returns false if already cached for this block and key.

type TraceCacheKey

type TraceCacheKey struct {
	BlockHash felt.Felt
}

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.

Jump to

Keyboard shortcuts

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