-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support RPC 0.8.0 #530
base: main
Are you sure you want to change the base?
Support RPC 0.8.0 #530
Conversation
…ructured-error-trace
/** | ||
* Get merkle paths in one of the state tries. | ||
* | ||
* Get merkle paths in one of the state tries: global state, classes, individual contract. | ||
* | ||
* @param classHashes list of class hashes for which we want to prove membership | ||
* @param contractAddresses list of contract addresses for which we want to prove membership | ||
* @param contractsStorageKeys list of contract address and storage keys pairs | ||
* | ||
* @throws RequestFailedException | ||
*/ | ||
fun getStorageProof(classHashes: List<Felt>? = null, contractAddresses: List<Felt>? = null, contractsStorageKeys: List<ContractStorageKey>? = null): Request<StorageProof> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: It's a bit exceptional situation, due to the fact that creating overloads would cause a conflict, e.g. for
fun getStorageProof(classHashes: List<Felt>, contractsStorageKeys: List<ContractStorageKey>): Request<StorageProof>
and
fun getStorageProof(contractAddresses: List<Felt>, contractsStorageKeys: List<ContractStorageKey>): Request<StorageProof>
(compiler won't know which method to use, contractAddresses
and classHashes
are of the same type). So unfortunately we need to add default values here.
note: This PR is still wip.
|
l1ResourceBounds: ResourceBounds, | ||
l2ResourceBounds: ResourceBounds, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should just go ahead and accept ResourceBoundsMapping
in all of these methods?
Previously, there was no reason to do so. Now, my rationale is:
- It would simplify the signature
- These methods will probably be often used with the same values, so might as well reduce boilerplate
- When estimating fee prior to executing transactions, we can right away run
EstimateFeeResponse.toResourceBounds
and pass the result, transforming this:
val resourceBounds = estimateFee.values.first().toResourceBounds()
executeV3(calls, resourceBounds.l1Gas, resourceBounds.l2Gas)
to more intuitive:
val resourceBounds = estimateFee.values.first().toResourceBounds()
executeV3(calls, resourceBounds)
that doesn't require any knowledge of l1 or l2 gas to execute txs with auto estimated fees
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, makes sense. Refactored.
I just don't fully like the fact that now the param of type ResourceBoundsMapping
is named resourceBounds
😆 , but looks like it's because of this, so we can leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just don't fully like the fact that now the param of type
ResourceBoundsMapping
is namedresourceBounds
😆 , but looks like it's because of this, so we can leave it.
That was the idea, but also the fact that resourceBoundsMapping
doesn't seem like a good argument name from UX point of view.
I think such naming convention also makes sense in this particular case:
ResourceBounds
-l1ResourceBounds
,l2ResourceBounds
ResourceBoundsMapping
-resourceBounds
lib/src/main/kotlin/com/swmansion/starknet/data/types/Payloads.kt
Outdated
Show resolved
Hide resolved
lib/src/main/kotlin/com/swmansion/starknet/data/types/Responses.kt
Outdated
Show resolved
Hide resolved
lib/src/main/kotlin/com/swmansion/starknet/data/types/Responses.kt
Outdated
Show resolved
Hide resolved
@@ -65,7 +65,7 @@ data class FunctionInvocation( | |||
val messages: List<OrderedMessageL2ToL1>, | |||
|
|||
@SerialName("execution_resources") | |||
val computationResources: ComputationResources, | |||
val computationResources: ExecutionResources, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the spec this still points to non-existent COMPUTATION_RESOURCES
:
https://github.com/starkware-libs/starknet-specs/blob/647caa00c0223e1daab1b2f3acc4e613ba2138aa/api/starknet_trace_api_openrpc.json#L448
Probably something we should clarify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it points correctly (to EXECUTION_RESOURCES
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name's also changed to Execution resources
there.
I wonder if we should keep try to keep the old name to avoid breaking change, or do it earlier than later, since the spec is expected to introduce some breaking changes anyways?
lib/src/main/kotlin/com/swmansion/starknet/data/types/TransactionReceipt.kt
Outdated
Show resolved
Hide resolved
lib/src/main/kotlin/com/swmansion/starknet/provider/Provider.kt
Outdated
Show resolved
Hide resolved
@SerialName("block_id") | ||
val blockId: BlockId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think BlockId
is needed:
https://github.com/starkware-libs/starknet-specs/blob/647caa00c0223e1daab1b2f3acc4e613ba2138aa/api/starknet_api_openrpc.json#L910
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, please look here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, was just checking out the changes from the tag, not branch 😅
lib/src/main/kotlin/com/swmansion/starknet/data/types/Responses.kt
Outdated
Show resolved
Hide resolved
…s.kt Co-authored-by: Maksim Zdobnikau <[email protected]>
Co-authored-by: Maksim Zdobnikau <[email protected]>
…ion/starknet-jvm into feat/519-rpc-0.8.0
Please check out spec on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like where this is going 👍🏻 Waiting for the tests
resourceBounds = ResourceBoundsMapping( | ||
ResourceBounds.ZERO, | ||
ResourceBounds.ZERO, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Should we introduce ResourceBoundsMapping.ZERO
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thinking about this, should be handy 👍 .
@SerialName("block_id") | ||
val blockId: BlockId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, was just checking out the changes from the tag, not branch 😅
@SerialName("node") | ||
val node: MerkleNode, | ||
) { | ||
@Serializable | ||
sealed interface MerkleNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that works?
Seems to me like some custom serializer is needed for node
🤔
Describe your changes
Support RPC 0.8.0.
starknet_getStorageProof
StorageProof
,GlobalRoots
,ContractsProof
,ContractLeafData
,NodeHashToNodeMappingItem
,BinaryNode
,EdgeNode
,ContractStorageKey
data classesgetStorageProof
method inProvider
andJsonRpcProvider
starknet_getMessagesStatus
MessageStatusList
,MessageStatus
data classesgetMessagesStatus
method inProvider
andJsonRpcProvider
Account
,StandardAccount
:signDeployAccountV3
andexecuteV3
have nowresourceBounds
param instead ofl1ResourceBounds
InvokeParamsV3
,DeclareParamsV3
,DeployAccountParamsV3
:l1ResourceBounds
param toresourceBounds
in constructorEstimateFeeResponse
:gasConsumed
tol1GasConsumed
gasPrice
tol1GasPrice
dataGasPrice
tol1DataGasPrice
dataGasConsumed
tol1DataGasConsumed
l2GasConsumed
,l2GasPrice
fieldsComputationResources
and updateExecutionResources
InnerCallExecutionResources
l1Gas
inResourceBoundsMapping
computationResources
toexecutionResources
inFunctionInvocation
and change its type toInnerCallExecutionResources
instead ofComputationResources
failureReason
toGetTransactionStatusResponse
Linked issues
Closes #519
Breaking changes
resourceBounds
instead ofl1ResourceBounds
paramComputationResources
has been removed;ExecutionResources
andEstimateFeeResponse
have been updated