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

[pallet-revive] allow delegate calls to non-contract accounts #7729

Merged
merged 3 commits into from
Feb 26, 2025

Conversation

xermicus
Copy link
Member

This PR changes the behavior of delegate calls when the callee is not a contract account: Instead of returning a CodeNotFound error, this is allowed and the caller observes a successful call with empty output.

The change makes for example the following contract behave the same as on EVM:

contract DelegateCall {
    function delegateToLibrary() external returns (bool) {
        address testAddress = 0x0000000000000000000000000000000000000000;
        (bool success, ) = testAddress.delegatecall(
            abi.encodeWithSignature("test()")
        );
        return success;
    }
}

Closes paritytech/revive#235

@xermicus
Copy link
Member Author

/cmd prdoc --audience runtime_dev --bump major

@xermicus xermicus added T7-smart_contracts This PR/Issue is related to smart contracts. R0-silent Changes should not be mentioned in any release notes labels Feb 26, 2025
@xermicus
Copy link
Member Author

/cmd fmt

Comment on lines +1501 to +1503
// Delegate-calls to non-contract accounts are considered success.
let Some(info) = ContractInfoOf::<T>::get(&address) else { return Ok(()) };
let executable = E::from_storage(info.code_hash, self.gas_meter_mut())?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we might be missing reporting call traces for these early failure / returns
but the issue was here before this PR, will follow up in another PR if needed.

@athei athei enabled auto-merge February 26, 2025 16:38
@athei athei added this pull request to the merge queue Feb 26, 2025
Merged via the queue into master with commit c29e72a Feb 26, 2025
262 of 269 checks passed
@athei athei deleted the cl/delegate-call-nonexistant branch February 26, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes T7-smart_contracts This PR/Issue is related to smart contracts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delegatecall causes execution error.
3 participants