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

Remove _with_configurables functions from Bytecode Library and use Option instead #285

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

bitzoic
Copy link
Member

@bitzoic bitzoic commented Aug 26, 2024

Type of change

  • Improvement (refactoring, restructuring repository, cleaning tech debt, ...)
  • Breaking

Breaking

The following demonstrates the breaking change:

Before:

fn foo(my_bytecode: Vec<u8>, my_configurables: ContractConfigurables, my_contract_id: ContractId, my_predicate_address: Address) {
     // Compute bytecode root
     let root_no_configurables: BytecodeRoot = compute_bytecode_root(my_bytecode);
     let root_with_configurables: BytecodeRoot = compute_bytecode_root_with_configurables(my_bytecode, my_configurables);

     // Compute predicate address
     let address_no_configurables: Address = compute_predicate_address(my_bytecode);
     let address_with_configurables: Address = compute_predicate_address_with_configurables(my_bytecode, my_configurables);

     // Verify contract bytecode
     verify_contract_bytecode(my_contract_id, my_bytecode); // No configurables
     verify_contract_bytecode_with_configurables(my_contract_id, my_bytecode, my_configurables); // With configurables

     // Verify predicate address
     verify_predicate_address(my_predicate_address, my_bytecode); // No configurables
     verify_predicate_address_with_configurables(my_predicate_address, my_bytecode, my_configurables); // With configurables
}

After:

fn foo(my_bytecode: Vec<u8>, my_configurables: ContractConfigurables, my_contract_id: ContractId, my_predicate_address: Address) {
     // Compute bytecode root
     let root_no_configurables: BytecodeRoot = compute_bytecode_root(my_bytecode, None);
     let root_with_configurables: BytecodeRoot = compute_bytecode_root(my_bytecode, Some(my_configurables));

     // Compute predicate address
     let address_no_configurables: Address = compute_predicate_address(my_bytecode, None);
     let address_with_configurables: Address = compute_predicate_address(my_bytecode, Some(my_configurables));

     // Verify contract bytecode
     verify_contract_bytecode(my_contract_id, my_bytecode, None); // No configurables
     verify_contract_bytecode(my_contract_id, my_bytecode, Some(my_configurables)); // With configurables

     // Verify predicate address
     verify_predicate_address(my_predicate_address, my_bytecode, None); // No configurables
     verify_predicate_address(my_predicate_address, my_bytecode, Some(my_configurables)); // With configurables
}

Changes

The following changes have been made:

  • compute_bytecode_root_with_configurables() has been removed in place of compute_bytecode_root() with an Option argument for configurables
  • compute_predicate_address_with_configurables() has been removed in place of compute_predicate_address() with an Option argument for configurables
  • verify_contract_bytecode_with_configurables() has been removed in place of verify_contract_bytecode() with an Option argument for configurables
  • verify_predicate_address_with_configurables() has been removed in place of verify_predicate_address() with an Option argument for configurables
  • The BytecodeRoot type has been added
  • The ContractConfigurables type has been added

Related Issues

Closes #219

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • 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.
  • I have updated the changelog to reflect the changes on this PR.

@bitzoic bitzoic added Improvement Enhancing a feature that already exists Breaking This will break user's code Bytecode Solver Label used to filter for the library issue labels Aug 26, 2024
@bitzoic bitzoic self-assigned this Aug 26, 2024
@bitzoic bitzoic requested a review from a team as a code owner August 26, 2024 06:45
@K1-R1 K1-R1 requested a review from a team August 26, 2024 14:46
@bitzoic bitzoic merged commit afb9fcd into master Aug 28, 2024
10 checks passed
@bitzoic bitzoic deleted the bitzoic-use-option-bytecode-lib branch August 28, 2024 01:59
bitzoic added a commit that referenced this pull request Aug 30, 2024
… use Option instead (#293)

## Type of change

<!--Delete points that do not apply-->

- Improvement (refactoring, restructuring repository, cleaning tech
debt, ...)

## Changes

The following changes have been made:

- Removes the breaking changes from
#285
- Leaves the `BytecodeRoot` and `Contractconfigurables` types

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
- [ ] I have updated the changelog to reflect the changes on this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking This will break user's code Bytecode Solver Label used to filter for the library issue Improvement Enhancing a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Option to function arguments in Bytecode Library
3 participants