From 564b7af13aa5d2596cf9e3c36851a66a804ff973 Mon Sep 17 00:00:00 2001 From: thiagodeev Date: Thu, 19 Dec 2024 11:45:47 -0300 Subject: [PATCH] Implements new changes --- rpc/contract.go | 12 +++++++++++- rpc/errors.go | 4 ++-- rpc/trace.go | 12 +++++++++++- rpc/types_executables.go | 4 ++-- rpc/types_transaction.go | 3 +++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/rpc/contract.go b/rpc/contract.go index 5653b59b..88ff3b67 100644 --- a/rpc/contract.go +++ b/rpc/contract.go @@ -135,6 +135,15 @@ func (provider *Provider) Nonce(ctx context.Context, blockID BlockID, contractAd // Estimates the resources required by a given sequence of transactions when applied on a given state. // If one of the transactions reverts or fails due to any reason (e.g. validation failure or an internal error), // a TRANSACTION_EXECUTION_ERROR is returned. For v0-2 transactions the estimate is given in wei, and for v3 transactions it is given in fri. +// +// Parameters: +// - ctx: The context of the function call +// - requests: A sequence of transactions to estimate, running each transaction on the state resulting from applying all the previous ones +// - simulationFlags: Describes what parts of the transaction should be executed +// - blockID: The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on +// Returns: +// - []FeeEstimation: A sequence of fee estimation where the i'th estimate corresponds to the i'th transaction +// - error: An error if any occurred during the execution func (provider *Provider) EstimateFee(ctx context.Context, requests []BroadcastTxn, simulationFlags []SimulationFlag, blockID BlockID) ([]FeeEstimation, error) { var raw []FeeEstimation if err := do(ctx, provider.c, "starknet_estimateFee", &raw, requests, simulationFlags, blockID); err != nil { @@ -168,7 +177,8 @@ func (provider *Provider) EstimateMessageFee(ctx context.Context, msg MsgFromL1, // - ctx: The context of the function call // - storageProofInput: an input containing at least one of the fields filled // Returns: -// - *StorageProofResult: the proofs of the field passed in the input +// - *StorageProofResult: The requested storage proofs. Note that if a requested leaf has the default value, +// the path to it may end in an edge node whose path is not a prefix of the requested leaf, thus effectively proving non-membership // - error: an error if any occurred during the execution func (provider *Provider) GetStorageProof(ctx context.Context, storageProofInput StorageProofInput) (*StorageProofResult, error) { var raw StorageProofResult diff --git a/rpc/errors.go b/rpc/errors.go index 1762e8d2..913a165e 100644 --- a/rpc/errors.go +++ b/rpc/errors.go @@ -257,8 +257,8 @@ var ( Message: "An unexpected error occurred", } ErrCompilationError = &RPCError{ - Code: 9999, //placeholder number as this error has no code so far. TODO: change this with the next updates - Message: "More data about the compilation failure", + Code: 100, + Message: "Failed to compile the contract", } ) diff --git a/rpc/trace.go b/rpc/trace.go index ad1d189e..d637866d 100644 --- a/rpc/trace.go +++ b/rpc/trace.go @@ -81,7 +81,17 @@ func (provider *Provider) TraceBlockTransactions(ctx context.Context, blockID Bl // SimulateTransactions simulates transactions on the blockchain. // Simulate a given sequence of transactions on the requested state, and generate the execution traces. // Note that some of the transactions may revert, in which case no error is thrown, but revert details can be seen on the returned trace object. -// Note that some of the transactions may revert, this will be reflected by the revert_error property in the trace. Other types of failures (e.g. unexpected error or failure in the validation phase) will result in TRANSACTION_EXECUTION_ERROR. +// Note that some of the transactions may revert, this will be reflected by the revert_error property in the trace. Other +// types of failures (e.g. unexpected error or failure in the validation phase) will result in TRANSACTION_EXECUTION_ERROR. +// +// Parameters: +// - ctx: The context of the function call +// - blockID: The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on. +// - txns: A sequence of transactions to simulate, running each transaction on the state resulting from applying all the previous ones +// - simulationFlags: Describes what parts of the transaction should be executed +// Returns: +// - []SimulatedTransaction: The execution trace and consumed resources of the required transactions +// - error: An error if any occurred during the execution func (provider *Provider) SimulateTransactions(ctx context.Context, blockID BlockID, txns []BroadcastTxn, simulationFlags []SimulationFlag) ([]SimulatedTransaction, error) { var output []SimulatedTransaction diff --git a/rpc/types_executables.go b/rpc/types_executables.go index b320e4f9..b7d23a5a 100644 --- a/rpc/types_executables.go +++ b/rpc/types_executables.go @@ -10,7 +10,7 @@ type CasmCompiledContractClass struct { Prime NumAsHex `json:"prime"` CompilerVersion string `json:"compiler_version"` Hints []Hints `json:"hints"` - // a list of sizes of segments in the bytecode, each segment is hashed invidually when computing the bytecode hash + // a list of sizes of segments in the bytecode, each segment is hashed individually when computing the bytecode hash BytecodeSegmentLengths []int `json:"bytecode_segment_lengths,omitempty"` } @@ -152,7 +152,7 @@ type ResOperand struct { type Deref CellRef -// A (CellRef, offsest) tuple, but adapted to a golang struct +// A (CellRef, offset) tuple, but adapted to a golang struct type DoubleDeref struct { CellRef CellRef Offset int diff --git a/rpc/types_transaction.go b/rpc/types_transaction.go index b36627e9..3235f9ae 100644 --- a/rpc/types_transaction.go +++ b/rpc/types_transaction.go @@ -145,10 +145,13 @@ type DeclareTxnV3 struct { type ResourceBoundsMapping struct { // The max amount and max price per unit of L1 gas used in this tx L1Gas ResourceBounds `json:"l1_gas"` + // The max amount and max price per unit of L1 blob gas used in this tx + L1DataGas ResourceBounds `json:"l1_data_gas"` // The max amount and max price per unit of L2 gas used in this tx L2Gas ResourceBounds `json:"l2_gas"` } +// DA_MODE: Specifies a storage domain in Starknet. Each domain has different guarantees regarding availability type DataAvailabilityMode string const (