-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat!: reintroduce RPC provider agreement logic #100
Changes from 15 commits
88f5520
2d365a2
aa42699
60526ab
eb52b95
116835d
aecdbf2
b199bd2
ae340aa
696ca47
4ce9bee
e58401c
9edefce
1b7c3ed
f9fda2a
e5a9a45
6290509
ab4cf9d
8525525
802802b
e75e784
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,8 @@ type BlockTag = variant { | |
Pending; | ||
}; | ||
type CandidRpcSource = variant { | ||
EthSepolia : opt EthSepoliaService; | ||
EthMainnet : opt EthMainnetService; | ||
EthSepolia : opt vec EthSepoliaService; | ||
EthMainnet : opt vec EthMainnetService; | ||
}; | ||
type EthMainnetService = variant { BlockPi; Cloudflare; PublicNode; Ankr }; | ||
type EthSepoliaService = variant { BlockPi; PublicNode; Ankr }; | ||
|
@@ -76,6 +76,30 @@ type LogEntry = record { | |
removed : bool; | ||
}; | ||
type Message = variant { Data : vec nat8; Hash : vec nat8 }; | ||
type MultiRpcResult = variant { | ||
Consistent : Result; | ||
Inconsistent : vec record { RpcService; Result }; | ||
}; | ||
type MultiRpcResult_1 = variant { | ||
Consistent : Result_1; | ||
Inconsistent : vec record { RpcService; Result_1 }; | ||
}; | ||
type MultiRpcResult_2 = variant { | ||
Consistent : Result_2; | ||
Inconsistent : vec record { RpcService; Result_2 }; | ||
}; | ||
type MultiRpcResult_3 = variant { | ||
Consistent : Result_3; | ||
Inconsistent : vec record { RpcService; Result_3 }; | ||
}; | ||
type MultiRpcResult_4 = variant { | ||
Consistent : Result_4; | ||
Inconsistent : vec record { RpcService; Result_4 }; | ||
}; | ||
type MultiRpcResult_5 = variant { | ||
Consistent : Result_5; | ||
Inconsistent : vec record { RpcService; Result_5 }; | ||
}; | ||
type ProviderError = variant { | ||
TooFewCycles : record { expected : nat; received : nat }; | ||
ProviderNotFound; | ||
|
@@ -121,6 +145,10 @@ type RpcError = variant { | |
ValidationError : ValidationError; | ||
HttpOutcallError : HttpOutcallError; | ||
}; | ||
type RpcService = variant { | ||
EthSepolia : EthSepoliaService; | ||
EthMainnet : EthMainnetService; | ||
}; | ||
type SendRawTransactionResult = variant { | ||
Ok; | ||
NonceTooLow; | ||
|
@@ -172,14 +200,14 @@ type ValidationError = variant { | |
service : { | ||
authorize : (principal, Auth) -> (); | ||
deauthorize : (principal, Auth) -> (); | ||
eth_feeHistory : (CandidRpcSource, FeeHistoryArgs) -> (Result); | ||
eth_getBlockByNumber : (CandidRpcSource, BlockTag) -> (Result_1); | ||
eth_getLogs : (CandidRpcSource, GetLogsArgs) -> (Result_2); | ||
eth_feeHistory : (CandidRpcSource, FeeHistoryArgs) -> (MultiRpcResult); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: from an interface perspective the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original intent was to distinguish from what is currently called |
||
eth_getBlockByNumber : (CandidRpcSource, BlockTag) -> (MultiRpcResult_1); | ||
eth_getLogs : (CandidRpcSource, GetLogsArgs) -> (MultiRpcResult_2); | ||
eth_getTransactionCount : (CandidRpcSource, GetTransactionCountArgs) -> ( | ||
Result_3, | ||
MultiRpcResult_3, | ||
); | ||
eth_getTransactionReceipt : (CandidRpcSource, text) -> (Result_4); | ||
eth_sendRawTransaction : (CandidRpcSource, text) -> (Result_5); | ||
eth_getTransactionReceipt : (CandidRpcSource, text) -> (MultiRpcResult_4); | ||
eth_sendRawTransaction : (CandidRpcSource, text) -> (MultiRpcResult_5); | ||
getAccumulatedCycleCount : (nat64) -> (nat) query; | ||
getAuthorized : (Auth) -> (vec text) query; | ||
getNodesInSubnet : () -> (nat32) query; | ||
|
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'm a bit puzzled by the naming
MultiRpcResult_1
/Result_1
,MultiRpcResult_2
/Result_2
, which is not really indicative of what it represents. I'm guessing that candid doesn't really have a concept for generics and that's why such tricks are necessary but maybe we could have something a bot more user friendly, e.g. with fee history,Does this make sense?
PS: I would also drop the
Rpc
inMultiRpcResult
to have 2 types of resultsMultiResult
/Result
.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.
Makes sense for sure. This Candid file is automatically generated, but we could manually overwrite these names. The missing piece is a way to statically verify that the Candid interface matches the Rust source code. @dfx-json mentioned that a solution is currently in progress for this (as of a month or two ago).
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 way it was done for ckETH and some other canisters is to have the 2 (candid and Rust code) not auto-generated but then there is a unit test that controls that both are equivalent. Ideally, the candid file should be the source of truth and it should be able to generate the boilerplate Rust code, but I think that's out-of-scope for now. Maybe one easy way to modify this would be to avoid Rust generics in the types involved in the Candid interface and use struct like
MultiFeeHistoryResult
/FeeHistoryResult
so that the generated Candid file is fixed.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.
Thanks! This unit test is exactly what I was looking for. Included in #105.