-
Couldn't load subscription status.
- Fork 6
anvil: state injector #296
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
Conversation
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.
Took a first look, general approach looks okay to me, will come back to it.
| call_data: &[u8], | ||
| context: CallContext, | ||
| ) -> sp_blockchain::Result<Vec<u8>> { | ||
| if context == CallContext::Offchain { |
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.
Hmm why is this? You will need to apply the overlay also in Onchain context such as block building and so on, right?
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.
On chain, we always use contextual_call (since it needs the in-memory overlay), as far as I've seen. Otherwise I would have hit the infinite recursion I accidentally added 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.
Review part 1
| use substrate_runtime::Balance; | ||
|
|
||
| #[derive(Debug, thiserror::Error)] | ||
| pub enum BackendError { |
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.
What about a NotFound error with a string/enum saying what's missing (total issuance, chain id, ...) and a DecodingFailed error with a string/enum saying what's failing (total issuance, chain id, ...)
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.
🚀
| NonceOverflow, | ||
| #[error(transparent)] | ||
| RuntimeApi(#[from] sp_api::ApiError), | ||
| #[error("Error encountered while creating a BalanceWithDust from a U256 balance")] |
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: I would not specify the internal types in the error message.
| assert_matches!( | ||
| node.send_transaction(tx, None).await, | ||
| Err(RpcError {code, message, ..}) => { | ||
| assert_eq!(code, ErrorCode::InternalError); | ||
| message.contains("Invalid Transaction") | ||
| } | ||
| ); |
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: use unwrap_err
Implements #240.