Skip to content

Commit

Permalink
Merge pull request #174 from starkware-libs/refactor_simulate_and_est…
Browse files Browse the repository at this point in the history
…iamte

Refactor traceTransactions and estimateFee, and rename STRK to FRI (#174)
  • Loading branch information
ArielElp authored Nov 27, 2023
2 parents 237fe16 + aee94e6 commit bec6939
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 34 deletions.
66 changes: 51 additions & 15 deletions api/starknet_api_openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@
{
"name": "starknet_estimateFee",
"summary": "estimate the fee for of StarkNet transactions",
"description": "estimates the resources required by transactions when applyed on a given state",
"description": "Estimates the resources required by a given sequence of transactions when applied on a given state. If one of the transaction reverts, a TRANSACTION_EXECUTION_ERROR is returned.",
"params": [
{
"name": "request",
Expand All @@ -597,6 +597,17 @@
},
"required": true
},
{
"name": "simulation_flags",
"description": "describes what parts of the transaction should be executed",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SIMULATION_FLAG_FOR_ESTIMATE_FEE"
}
}
},
{
"name": "block_id",
"description": "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.",
Expand All @@ -621,10 +632,7 @@
},
"errors": [
{
"$ref": "#/components/errors/CONTRACT_NOT_FOUND"
},
{
"$ref": "#/components/errors/CONTRACT_ERROR"
"$ref": "#/components/errors/TRANSACTION_EXECUTION_ERROR"
},
{
"$ref": "#/components/errors/BLOCK_NOT_FOUND"
Expand Down Expand Up @@ -662,9 +670,6 @@
}
},
"errors": [
{
"$ref": "#/components/errors/CONTRACT_NOT_FOUND"
},
{
"$ref": "#/components/errors/CONTRACT_ERROR"
},
Expand Down Expand Up @@ -3626,6 +3631,13 @@
"type"
]
},
"SIMULATION_FLAG_FOR_ESTIMATE_FEE": {
"type": "string",
"enum": [
"SKIP_VALIDATE"
],
"description": "Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is replicated locally"
},
"FEE_ESTIMATE": {
"title": "Fee estimation",
"type": "object",
Expand All @@ -3637,12 +3649,12 @@
},
"gas_price": {
"title": "Gas price",
"description": "The gas price (in gwei) that was used in the cost estimation",
"description": "The gas price (in gwei or fri, depending on the tx version) that was used in the cost estimation",
"$ref": "#/components/schemas/FELT"
},
"overall_fee": {
"title": "Overall fee",
"description": "The estimated fee for the transaction (in gwei), product of gas_consumed and gas_price",
"description": "The estimated fee for the transaction (in gwei or fri, depending on the tx version), product of gas_consumed and gas_price",
"$ref": "#/components/schemas/FELT"
}
},
Expand All @@ -3667,7 +3679,7 @@
"type": "string",
"enum": [
"WEI",
"STRK"
"FRI"
]
}
},
Expand Down Expand Up @@ -3726,9 +3738,9 @@
"RESOURCE_PRICE": {
"type": "object",
"properties": {
"price_in_strk": {
"title": "price in strk",
"description": "the price of one unit of the given resource, denominated in strk",
"price_in_fri": {
"title": "price in fri",
"description": "the price of one unit of the given resource, denominated in fri (10^-18 strk)",
"$ref": "#/components/schemas/FELT"
},
"price_in_wei": {
Expand All @@ -3739,7 +3751,7 @@
},
"required": [
"price_in_wei",
"price_in_strk"
"price_in_fri"
]
},
"EXECUTION_RESOURCES": {
Expand Down Expand Up @@ -3889,6 +3901,30 @@
},
"required": "revert_error"
}
},
"TRANSACTION_EXECUTION_ERROR": {
"code": 41,
"message": "Transaction execution error",
"data": {
"type": "object",
"description": "More data about the execution failure",
"properties": {
"transaction_index": {
"title": "Transaction index",
"description": "The index of the first transaction failing in a sequence of given transactions",
"type": "integer"
},
"execution_error": {
"title": "revert error",
"description": "a string encoding the execution trace up to the point of failure",
"type": "string"
}
},
"required": [
"transaction_index",
"revert_error"
]
}
}
}
}
Expand Down
28 changes: 9 additions & 19 deletions api/starknet_trace_api_openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"errors": [
{
"$ref": "#/components/errors/INVALID_TXN_HASH"
"$ref": "#/components/errors/TXN_HASH_NOT_FOUND"
},
{
"$ref": "#/components/errors/NO_TRACE_AVAILABLE"
Expand All @@ -39,7 +39,7 @@
},
{
"name": "starknet_simulateTransactions",
"summary": "simulate a given sequence of transactions on the requested state, and generate the execution traces. If one of the transactions is reverted, raises CONTRACT_ERROR.",
"summary": "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.",
"params": [
{
"name": "block_id",
Expand Down Expand Up @@ -97,13 +97,10 @@
},
"errors": [
{
"$ref": "#/components/errors/CONTRACT_NOT_FOUND"
},
{
"$ref": "#/components/errors/CONTRACT_ERROR"
"$ref": "#/components/errors/BLOCK_NOT_FOUND"
},
{
"$ref": "#/components/errors/BLOCK_NOT_FOUND"
"$ref": "#/components/errors/TRANSACTION_EXECUTION_ERROR"
}
]
},
Expand Down Expand Up @@ -478,21 +475,14 @@
}
}
},
"CONTRACT_NOT_FOUND": {
"code": 20,
"message": "Contract not found"
},
"INVALID_TXN_HASH": {
"code": 25,
"message": "Invalid transaction hash"
"TXN_HASH_NOT_FOUND": {
"$ref": "./api/starknet_api_openrpc.json#/components/errors/TXN_HASH_NOT_FOUND"
},
"BLOCK_NOT_FOUND": {
"code": 24,
"message": "Block not found"
"$ref": "./api/starknet_api_openrpc.json#/components/errors/BLOCK_NOT_FOUND"
},
"CONTRACT_ERROR": {
"code": 40,
"message": "Contract error"
"TRANSACTION_EXECUTION_ERROR": {
"$ref": "./api/starknet_api_openrpc.json#/components/errors/TRANSACTION_EXECUTION_ERROR"
}
}
}
Expand Down

0 comments on commit bec6939

Please sign in to comment.