paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.89k stars 696 forks source link

[pallet-revive] last call return data API #5779

Closed xermicus closed 1 month ago

xermicus commented 1 month ago

This PR introduces 2 new syscalls: return_data_size and return_data_copy, resembling the semantics of the EVM RETURNDATASIZE and RETURNDATACOPY opcodes.

The ownership of ExecReturnValue (the return data) has moved to the Frame. This allows implementing the new contract API functionality in ext with no additional copies. Returned data is passed via contract memory, memory is (will be) metered, hence the amount of returned data can not be statically known, so we should avoid storing copies of the returned data if we can. By moving the ownership of the exectuables return value into the Frame struct we achieve this.

A zero-copy implementation of those APIs would be technically possible without that internal change by making the callsite in the runtime responsible for moving the returned data into the frame after any call. However, resetting the stored output needs to be handled in ext, since plain transfers will not affect the stored return data (and we don't want to handle this special call case inside the runtime API). This has drawbacks:

The returned output is reset each time before running any executable in a nested stack. This change should not incur any overhead to the overall memory usage as only the returned data from the last executed frame will be kept around at any time.

xermicus commented 1 month ago

bot fmt

command-bot[bot] commented 1 month ago

@xermicus https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7398794 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 5-936aad13-b847-43cd-8d31-72960ecb926d to cancel this command or bot cancel to cancel all commands in this pull request.

command-bot[bot] commented 1 month ago

@xermicus Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7398794 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7398794/artifacts/download.

xermicus commented 1 month ago

bot fmt

command-bot[bot] commented 1 month ago

@xermicus https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7419963 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 1-038c7e72-1bef-41fd-9040-453901231bb6 to cancel this command or bot cancel to cancel all commands in this pull request.

command-bot[bot] commented 1 month ago

@xermicus Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7419963 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7419963/artifacts/download.

xermicus commented 1 month ago

bot fmt

command-bot[bot] commented 1 month ago

@xermicus https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7432068 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 5-a508ee1a-95b8-45e7-8af5-ad912219182d to cancel this command or bot cancel to cancel all commands in this pull request.

command-bot[bot] commented 1 month ago

@xermicus Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7432068 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7432068/artifacts/download.