Skip to content

Conversation

@alindima
Copy link

@alindima alindima commented Sep 10, 2025

Implements #240.

@alindima alindima marked this pull request as draft September 10, 2025 13:33
Copy link

@skunert skunert left a 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 {
Copy link

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?

Copy link
Author

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 😅

@alindima alindima marked this pull request as ready for review October 9, 2025 15:25
Copy link

@re-gius re-gius left a 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 {
Copy link

@re-gius re-gius Oct 13, 2025

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, ...)

Copy link

@AlexandruCihodaru AlexandruCihodaru left a 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")]

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.

Comment on lines +70 to +76
assert_matches!(
node.send_transaction(tx, None).await,
Err(RpcError {code, message, ..}) => {
assert_eq!(code, ErrorCode::InternalError);
message.contains("Invalid Transaction")
}
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use unwrap_err

@alindima alindima merged commit 4ef8860 into master Oct 15, 2025
57 of 61 checks passed
@alindima alindima deleted the alindima/state-injector-prototype branch October 15, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants