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

Bug: improper typing of contract execution result #5993

Open
3 of 7 tasks
TorstenStueber opened this issue Oct 1, 2024 · 1 comment
Open
3 of 7 tasks

Bug: improper typing of contract execution result #5993

TorstenStueber opened this issue Oct 1, 2024 · 1 comment
Labels
Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. P2 - Medium Important but not urgent. Enhances functionality and value, scheduled after higher priorities.

Comments

@TorstenStueber
Copy link

TorstenStueber commented Oct 1, 2024

I'm submitting a ...

  • Bug report

What is the current behavior and expected behavior?

The return result of executing a smart contract of pallet-contracts via the RPC method call is of type ContractExecResult.

This type contains an entry of type ContractReturnFlags. This type is defined as

export interface ContractReturnFlags extends Set {
  readonly isRevert: boolean;
}

However, the actual value returned changed between version 13.1.1 and version 13.2.1. Given a value flags of type ContractReturnFlags and executing the following line:

console.log(flags.toHuman(), flags.bits?.toNumber(), flags.isRevert)

results in the following output:

  • at version 13.1.1

    • if the contract did not revert: [] undefined false
    • if the contract reverted: [ 'Revert' ] undefined true
  • On version 13.2.1 I get the output instead:

    • if the contract did not revert: { bits: '0' } 0 undefined
    • if the contract reverted: { bits: '1' } 1 undefined

This suggests that the decoding has an unintended breaking change or the typings should be adapted. Possibly other bitflag types are affected as well.

Please tell us about your environment:

  • Version: 13.1.1 and 13.2.1

  • Environment:

    • Node.js
    • Browser
    • Other (limited support for other environments)
  • Language:

    • JavaScript
    • TypeScript (include tsc --version)
    • Other
@TarikGul TarikGul added P2 - Medium Important but not urgent. Enhances functionality and value, scheduled after higher priorities. Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. labels Oct 29, 2024
@TarikGul
Copy link
Member

I haven't reproduced this myself, but there might be a discrepency between the pallet-contract static types. The substrate-node-contracts metadata hasn't been updated in a while and can use some TLC.

I will be taking a shot at this when I add the assethub system parachains to the static type generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. P2 - Medium Important but not urgent. Enhances functionality and value, scheduled after higher priorities.
Projects
Development

No branches or pull requests

2 participants