Skip to content
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

Contract: Native function to retrieve entire call input bytes array #112

Closed
2 tasks done
shunsukew opened this issue Apr 4, 2023 · 1 comment
Closed
2 tasks done
Labels
I5-enhancement An additional feature request. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@shunsukew
Copy link

shunsukew commented Apr 4, 2023

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Motivation

In certain scenarios involving Wasm contracts, there is a desire to transmit data as extra bytes within the ExecutionInput of cross-contract calls and subsequently access this data within the callee contracts. Unfortunately, as long as I know, there is presently no capability to read the complete array of call input bytes within contracts, making it impractical to accomplish this objective without changing the signature of the functions within the callee contracts.

For example,
ERC2771-like meta transaction use case, Forwarder contract append extra 32bytes array representing AccountId of Transaction Signer to the ExecutionInput of cross-contract call.

build_call::<<Self as ::ink::env::ContractEnv>::Env>()
                .call(req.callee)
                .gas_limit(req.gas_limit)
                .transferred_value(req.transferred_value)
                .call_flags(CallFlags::default().set_allow_reentry(req.allow_reentry))
                .exec_input(
                    // Add signer's account_id as extra input bytes
                    // SCALE encoded
                    ExecutionInput::new(req.selector.into())
                        .push_arg(CallInput(&req.input))
                        .push_arg(req.from.encode()), // <- **HERE**
                )
                .returns::<()>()
                .try_invoke();

Since there are currently no built-in mechanisms to read the complete array of ExecutionInput bytes, it is necessary to modify the function signatures of the callee contracts in order to read extra bytes. Specifically, the function signatures of these contracts will need to be adjusted to include a parameter of type Vec, which will be used to decode any additional bytes appended by the calling contracts.

#[ink(message)]
pub fn some_message(&mut self, input: String, _data: Vec<u8>) {}

If pallet-contracts had this feature, modifying the function signatures of the callee contracts to transmit additional data wouldn't be required.

Request

The same feature as Solidity's calldataload, calldatasize (Doc: https://docs.soliditylang.org/en/v0.8.16/yul.html#evm-dialect, Example usage: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7e7060e00e107460fc57c178859d3cf0c6ac64ef/contracts/metatx/ERC2771Context.sol#LL29C35-L29C47) in pallet-contracts and available in contracts language such as ink!.

Solution

No response

Are you willing to help with this request?

Yes!

@shunsukew shunsukew changed the title Contract: Native function to take entire call input bytes array Contract: Native function to retrieve entire call input bytes array Apr 4, 2023
@athei athei transferred this issue from paritytech/substrate Aug 24, 2023
@the-right-joyce the-right-joyce added I5-enhancement An additional feature request. I10-unconfirmed Issue might be valid, but it's not yet known. and removed J0-enhancement labels Aug 25, 2023
lexnv pushed a commit that referenced this issue Apr 3, 2024
chainHead_unstable_unpin: hash_or_hash -> hashOrHashes
claravanstaden added a commit to claravanstaden/polkadot-sdk that referenced this issue Sep 19, 2024
* pallet order

* fmt

* adds test for bridge order

* revert unintended change

---------

Co-authored-by: claravanstaden <Cats 4 life!>
@athei
Copy link
Member

athei commented Nov 28, 2024

It is possible to read the whole input data. It seems to just not be exposed by ink. Closing as this is an ink! issue.

@athei athei closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2024
@github-project-automation github-project-automation bot moved this from Backlog 🗒 to Done ✅ in Smart Contracts Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I5-enhancement An additional feature request. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
Status: No status
Development

No branches or pull requests

3 participants