-
Notifications
You must be signed in to change notification settings - Fork 19
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
Starknet Chain Client: Add Block Methods #373
Conversation
Quality Gate passedIssues Measures |
Args: []interface{}{ | ||
starknetrpc.BlockID{Hash: h}, | ||
}, | ||
Result: &FinalizedBlock{}, |
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 learned the result is stored within the same BatchElem type.
and that you need to allocate the memory for the type you expect to be returned, which is json deserialized from the RPC
relayer/pkg/starknet/chain_client.go
Outdated
// used to create batch requests | ||
type StarknetBatchBuilder interface { | ||
RequestBlockByHash(h *felt.Felt) (StarknetBatchBuilder, error) | ||
// RequestBlockByNumber(id uint64) (StarknetBatchBuilder, error) |
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.
will be uncommented as the corresponding methods in the chain client are implemented
Provider: starknetrpc.NewProvider(c), | ||
lggr: lggr, | ||
Provider: starknetrpc.NewProvider(c), | ||
EthClient: c, |
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.
add the ethrpc client to the struct so we can take advantage of its batch call capabilities!
return b.args | ||
} | ||
|
||
type StarknetChainClient interface { |
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.
How different is this from using what we have in client.go
/Reader
? We should be able to share the interfaces
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.
there's definitely some possibility for re-using the reader client methods. but if you mean to combine the interfaces, we've made it a design decision that chain client interface is distinct and set apart because it is dictated by the customer (atlas now) needs.
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.
For this PR specifically, we introduced BlockByHash and BlockHashAndNumber.
In terms of replacing, re-using the existing calls, I didn't remove/replace BlockByHash (returns txs) with the already written BlockWithTxHashes (returns tx hashes) because we need the block with txs.
I can simplify the logic of LatestBlockHeight to call BlockHashAndNumber, though. Would you like me to do that?
e0dc340
to
a232540
Compare
Quality Gate passedIssues Measures |
https://smartcontract-it.atlassian.net/browse/BCI-2676
Adding 3 block-related methods so RTSP can begin playing around with fetching blocks and the Batch() method to lay the groundwork for the rest of the methods. Rest of the process should be straightforward after this PR.
Added the ChainId method as well. Turns out the starknet.go provider automatically caches the chainId after first request, so our implementation uses the batchCall always
Original Design Doc: https://docs.google.com/document/d/10jsfp7_VqDv2GFGILmTX2ey-p_yaFyvxPaVszL6kg6g/edit
Open Questions:
For batch calls, the user will need to iterate through the batchElem array and cast the Result interface to the expected return type. This seems like a weird user experience so I'm open to feedback on how to improve this.RESOLVED