Skip to content

Support execution proofs with inputs bigger than 1MiB#2196

Merged
tomaka merged 5 commits intoparitytech:mainfrom
bkchr:bkchr-big-execution-proofs
Jan 12, 2026
Merged

Support execution proofs with inputs bigger than 1MiB#2196
tomaka merged 5 commits intoparitytech:mainfrom
bkchr:bkchr-big-execution-proofs

Conversation

@bkchr
Copy link
Copy Markdown
Member

@bkchr bkchr commented Jan 9, 2026

Right now execution proofs with an input bigger than 1MiB fail to execute. The problem is that the req-resp configuration only allows up to 1MiB for the initial request. Such a big input may happens for validate_transaction when doing for example a runtime upgrade.

This pull request fixes this by checking if the input is too big and if this is the case, it starts an on demand execution. This means it starts executing the function and requests storage entries on demand. This increases the latency when executing functions that require a big input, but these should not be that common any way. On the positive side this makes smoldot support these big inputs without requiring any protocol changes.

Closes: #1526
Closes: #2089

Right now execution proofs with an input bigger than 1MiB fail to execute. The
problem is that the req-resp configuration only allows up to 1MiB for the initial
request. Such a big input may happens for `validate_transaction` when doing for example a
runtime upgrade.

This pull request fixes this by checking if the input is too big and if this is the case, it
starts an on demand execution. This means it starts executing the function and requests storage
entries on demand. This increases the latency when executing functions that require a big input,
but these should not be that common any way. On the positive side this makes smoldot support these
big inputs without requiring any protocol changes.

Closes: paritytech#1526
Closes: paritytech#2089
@bkchr bkchr requested a review from tomaka as a code owner January 9, 2026 16:19
tomaka
tomaka previously approved these changes Jan 12, 2026
Copy link
Copy Markdown
Contributor

@tomaka tomaka left a comment

Choose a reason for hiding this comment

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

Thanks! The solution actually seems so obvious that I wonder why we didn't do this before.

I think it would have been easier to support child tries by just adding an child_trie: Option<Vec<u8>> field to the existing code for storage requests, but since you did the work already, it's fine as it is.

I couldn't really spot any mistake except for a few nits. I'm not a huge fan of the logic in runtime_service.rs (I feel like we could de-duplicate a lot of code), but it's hard to tell you how it should be done without trying myself to implement it differently, so I think it's fine as it is as well.

Did you try if it works? The logic in runtime_service is a bit hard to read, but if you tried if it worked then that's good enough for me.

Could you also add an entry at the top of CHANGELOG.md?

/// call proof requests. This avoids exceeding protocol limits for large transactions.
/// The light protocol has a 1 MiB request size limit, so we use 900 KiB to leave
/// room for the protobuf encoding overhead (block hash, method name, etc.).
const CALL_PROOF_REQUEST_PARAMETERS_SIZE_THRESHOLD: usize = 900 * 1024;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be better to add a constant with the actual limit (1MiB) to src/libp2p/network/codec/storage_call_proof.rs, and then do something like LIMIT.saturating_sub(1024) here.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
@bkchr
Copy link
Copy Markdown
Member Author

bkchr commented Jan 12, 2026

Did you try if it works? The logic in runtime_service is a bit hard to read, but if you tried if it worked then that's good enough for me.

Yes I have run it against some local node/.

@bkchr
Copy link
Copy Markdown
Member Author

bkchr commented Jan 12, 2026

@tomaka applied your comments.

@tomaka tomaka enabled auto-merge January 12, 2026 13:39
@tomaka tomaka added this pull request to the merge queue Jan 12, 2026
Merged via the queue into paritytech:main with commit cd891ae Jan 12, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants