From cc98e2fa22d371c80bc1a8396c8e7bf1be886670 Mon Sep 17 00:00:00 2001 From: Ariel Elperin Date: Fri, 24 Nov 2023 16:46:43 +0200 Subject: [PATCH 1/5] refactor simulateTransactions and estimateFee --- api/starknet_api_openrpc.json | 62 +++++++++++++++++++++++------ api/starknet_trace_api_openrpc.json | 5 +-- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/api/starknet_api_openrpc.json b/api/starknet_api_openrpc.json index 91f92ac..445be5a 100644 --- a/api/starknet_api_openrpc.json +++ b/api/starknet_api_openrpc.json @@ -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", @@ -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.", @@ -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" @@ -662,9 +670,6 @@ } }, "errors": [ - { - "$ref": "#/components/errors/CONTRACT_NOT_FOUND" - }, { "$ref": "#/components/errors/CONTRACT_ERROR" }, @@ -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", @@ -3667,7 +3679,7 @@ "type": "string", "enum": [ "WEI", - "STRK" + "FRI" ] } }, @@ -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": { @@ -3739,7 +3751,7 @@ }, "required": [ "price_in_wei", - "price_in_strk" + "price_in_fri" ] }, "EXECUTION_RESOURCES": { @@ -3889,6 +3901,30 @@ }, "required": "revert_error" } + }, + "TRANSACTION_EXECUTION_ERROR": { + "code": 40, + "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" + }, + "revert_error": { + "title": "revert error", + "description": "a string encoding the execution trace up to the point of failure", + "type": "string" + } + }, + "required": [ + "transaction_index", + "revert_error" + ] + } } } } diff --git a/api/starknet_trace_api_openrpc.json b/api/starknet_trace_api_openrpc.json index a1d50f1..fab3039 100644 --- a/api/starknet_trace_api_openrpc.json +++ b/api/starknet_trace_api_openrpc.json @@ -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.", "params": [ { "name": "block_id", @@ -99,9 +99,6 @@ { "$ref": "#/components/errors/CONTRACT_NOT_FOUND" }, - { - "$ref": "#/components/errors/CONTRACT_ERROR" - }, { "$ref": "#/components/errors/BLOCK_NOT_FOUND" } From 7cdf65a2f03d302d42f51a4c2eb15a575fe7b6f1 Mon Sep 17 00:00:00 2001 From: Ariel Elperin Date: Fri, 24 Nov 2023 16:51:58 +0200 Subject: [PATCH 2/5] update error code --- api/starknet_api_openrpc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/starknet_api_openrpc.json b/api/starknet_api_openrpc.json index 445be5a..e260cf2 100644 --- a/api/starknet_api_openrpc.json +++ b/api/starknet_api_openrpc.json @@ -3903,7 +3903,7 @@ } }, "TRANSACTION_EXECUTION_ERROR": { - "code": 40, + "code": 41, "message": "Transaction execution error", "data": { "type": "object", From 137ae7c2f0ea4d0df3bb00f12fe6bb0fb179f7b9 Mon Sep 17 00:00:00 2001 From: Ariel Elperin Date: Fri, 24 Nov 2023 17:17:16 +0200 Subject: [PATCH 3/5] change invalid_txn_hash error --- api/starknet_trace_api_openrpc.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/starknet_trace_api_openrpc.json b/api/starknet_trace_api_openrpc.json index fab3039..12ce08e 100644 --- a/api/starknet_trace_api_openrpc.json +++ b/api/starknet_trace_api_openrpc.json @@ -30,7 +30,7 @@ }, "errors": [ { - "$ref": "#/components/errors/INVALID_TXN_HASH" + "$ref": "#/components/errors/TXN_HASH_NOT_FOUND" }, { "$ref": "#/components/errors/NO_TRACE_AVAILABLE" @@ -479,9 +479,9 @@ "code": 20, "message": "Contract not found" }, - "INVALID_TXN_HASH": { - "code": 25, - "message": "Invalid transaction hash" + "TXN_HASH_NOT_FOUND": { + "code": 29, + "message": "Transaction hash not found" }, "BLOCK_NOT_FOUND": { "code": 24, From 5b00ad28b4d2b3a31404ee53883c5e68b097efb3 Mon Sep 17 00:00:00 2001 From: Ariel Elperin Date: Mon, 27 Nov 2023 12:02:32 +0200 Subject: [PATCH 4/5] added TRANSACTION_EXECUTION_ERROR to simulate --- api/starknet_api_openrpc.json | 4 ++-- api/starknet_trace_api_openrpc.json | 21 +++++++-------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/api/starknet_api_openrpc.json b/api/starknet_api_openrpc.json index e260cf2..783d8bc 100644 --- a/api/starknet_api_openrpc.json +++ b/api/starknet_api_openrpc.json @@ -3649,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" } }, diff --git a/api/starknet_trace_api_openrpc.json b/api/starknet_trace_api_openrpc.json index 12ce08e..3b7c447 100644 --- a/api/starknet_trace_api_openrpc.json +++ b/api/starknet_trace_api_openrpc.json @@ -39,7 +39,7 @@ }, { "name": "starknet_simulateTransactions", - "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.", + "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", @@ -97,10 +97,10 @@ }, "errors": [ { - "$ref": "#/components/errors/CONTRACT_NOT_FOUND" + "$ref": "#/components/errors/BLOCK_NOT_FOUND" }, { - "$ref": "#/components/errors/BLOCK_NOT_FOUND" + "$ref": "#/components/errors/TRANSACTION_EXECUTION_ERROR" } ] }, @@ -475,21 +475,14 @@ } } }, - "CONTRACT_NOT_FOUND": { - "code": 20, - "message": "Contract not found" - }, "TXN_HASH_NOT_FOUND": { - "code": 29, - "message": "Transaction 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" } } } From aee94e636458c0971dfca69546eae79abea7ba7d Mon Sep 17 00:00:00 2001 From: Ariel Elperin Date: Mon, 27 Nov 2023 15:15:28 +0200 Subject: [PATCH 5/5] rename revert_error to execution_error --- api/starknet_api_openrpc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/starknet_api_openrpc.json b/api/starknet_api_openrpc.json index 783d8bc..0dce666 100644 --- a/api/starknet_api_openrpc.json +++ b/api/starknet_api_openrpc.json @@ -3914,7 +3914,7 @@ "description": "The index of the first transaction failing in a sequence of given transactions", "type": "integer" }, - "revert_error": { + "execution_error": { "title": "revert error", "description": "a string encoding the execution trace up to the point of failure", "type": "string"