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

Contracts/Revive: caller_is_root does not return bool #6767

Closed
2 tasks done
cmichi opened this issue Dec 5, 2024 · 1 comment · Fixed by #7086
Closed
2 tasks done

Contracts/Revive: caller_is_root does not return bool #6767

cmichi opened this issue Dec 5, 2024 · 1 comment · Fixed by #7086
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@cmichi
Copy link
Contributor

cmichi commented Dec 5, 2024

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.

Description of bug

In both pallet-revive + pallet-contracts the host fn caller_is_root returns u32, opposed as to what the comments state (bool):

/// A return value of `true` indicates that this contract is being called by a root origin,
/// and `false` indicates that the caller is a signed origin.
fn caller_is_root() -> u32;

The analog function caller_is_origin returns bool for everything.

The host fn has already been stabilized for pallet-contracts and also implemented this way in hyperledger-solang/solang#1620 (cc @xermicus). So changing it for pallet-contracts is probably tricky, for pallet-revive it would be good though.

cc @athei

Steps to reproduce

No response

@cmichi cmichi added I10-unconfirmed Issue might be valid, but it's not yet known. I2-bug The node fails to follow expected behavior. labels Dec 5, 2024
@athei
Copy link
Member

athei commented Dec 5, 2024

This is just the uapi wrapper which returns the wrong type. The host function itself will always return 1 or 0 in the output register. This can be changed easily. Just an oversight.

github-merge-queue bot pushed a commit that referenced this issue Jan 15, 2025
Closes #6767.

The return type of the host function `caller_is_root` was denoted as
`u32` in `pallet_revive_uapi`. This PR fixes the return type to `bool`.

As a drive-by, the PR re-exports `pallet_revive::exec::Origin` to extend
what can be tested externally.

---------

Co-authored-by: Cyrill Leutwiler <[email protected]>
Nathy-bajo pushed a commit to Nathy-bajo/polkadot-sdk that referenced this issue Jan 21, 2025
Closes paritytech#6767.

The return type of the host function `caller_is_root` was denoted as
`u32` in `pallet_revive_uapi`. This PR fixes the return type to `bool`.

As a drive-by, the PR re-exports `pallet_revive::exec::Origin` to extend
what can be tested externally.

---------

Co-authored-by: Cyrill Leutwiler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants