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

feat: experimental encoding for contracts, scripts and predicates #1303

Merged
merged 38 commits into from
Apr 2, 2024

Conversation

hal3e
Copy link
Contributor

@hal3e hal3e commented Mar 21, 2024

closes: #1278, #1279, #1046

This PR adds support for the new encoding scheme for contracts, scripts and predicates.

I have added a new ExperimentalBoundedEncoder which can be activated with the experimental cfg flag.
I have tried to minimize the impact of the new encoder as much as possible to make it easier for review. A full refactor of the whole sdk is necessary once the new encoding becomes the default one.

  • The function selector changed and now it is the name of the method.
  • The CALL opcode changed with the new encoding and is expecting the following call data: ContractID, pointer to fn_selector (name of the method), pointer to encoded arguments, number of coins, asset_id, gas_forwarded.

To run the tests, first install forc: 0.52.0 and build the projects with:
forc build --path packages/fuels --experimental-new-encoding then run the tests with:
cargo test --all-targets --workspace --features experimental

Checklist

  • I have linked to any relevant issues.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary labels.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

Copy link
Contributor

@MujkicA MujkicA left a comment

Choose a reason for hiding this comment

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

Great work! Thanks for the effort you put into making this PR easily digestible.
The new encoding will make things a lot simpler on our side, looking forward to making it stable.

Copy link
Contributor

@segfault-magnet segfault-magnet left a comment

Choose a reason for hiding this comment

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

Excellent work. Especially with the feature-gating, removing the old encoding is looking to be painless.

examples/contracts/src/lib.rs Outdated Show resolved Hide resolved
examples/debugging/src/lib.rs Outdated Show resolved Hide resolved
examples/debugging/src/lib.rs Outdated Show resolved Hide resolved
packages/fuels-core/src/codec/abi_encoder.rs Outdated Show resolved Hide resolved
examples/debugging/src/lib.rs Outdated Show resolved Hide resolved
packages/fuels-core/src/codec/abi_decoder.rs Outdated Show resolved Hide resolved
packages/fuels/Forc.toml Outdated Show resolved Hide resolved
@hal3e hal3e requested a review from digorithm April 2, 2024 10:05
Copy link
Member

@digorithm digorithm left a comment

Choose a reason for hiding this comment

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

Excellent work @hal3e! :shipit:

@hal3e hal3e merged commit 0e99f41 into master Apr 2, 2024
41 checks passed
@hal3e hal3e deleted the hal3e/exp-encoding branch April 2, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support new encoder/decoder for contracts
4 participants