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

Upgrade to fuel-core 0.18.1 and fuels-rs 0.41 #4525

Merged
merged 26 commits into from
May 31, 2023
Merged

Conversation

xgreenx
Copy link
Contributor

@xgreenx xgreenx commented May 3, 2023

The PR fixes breakings changes from the fuel-core 0.18.1 and fuels-rs 0.41.

  • The __smo is reworked and doesn't require an output index because we removed the Output::Message variant.
  • Replaced the old deploy API with a new one, Contract::deploy -> Contract::load_from().deploy().
  • The signing of the transaction and predicate id calculation requires ChainId now. It breaks the API in some places. In tests, I used the default chain id, but from the forc perspective we need to add the ability to specify it.
  • fuels-signers was renamed into fuels-accounts.
  • We reworked fuel_tx::Input and now each variant of the enum has a named type.
  • Replaced all unsafe code from fuel-crypto with safe analog.
  • On the fuel-tx/fuel-core side now, there is a difference in whether the message contains data. If data is empty, it is MessageCoin that acts like a Coin(has the same rules during execution). If the data field is not empty, then it is a retryable message(or MessageData). Messages like this can't be used to pay a transaction fee, and if the execution fails, the message is not consumed(you can use it again in the next transactions). More about them you can read in Retryable Messages fuel-core#946. Also, the API changed for resources and not it is Coins again. Because of that, some tests now require messages with empty data to be able to spend them.
  • Removed redundant usage of MessageId and corresponding fields. Now the identifier of the message is a Nonce.
  • Removed Output::Message. Now you don't need to specify it in the outputs. Because of that SMO opcode doesn't require a message output index anymore.
  • We unified block height(in some places it was u32 in some u64) by introducing the BlockHeight type.
  • The nonce in the Message is a Bytes32 now instead of u64(affected input_message_nonce GTF).
  • Reworked the handling of the Intrinsic::Smo. Previously fuel-vm expected smo(r1: receipt_and_message_ptr, r2: size_of_the_message, r3: output_index, r4: amount) but we updated that to be smo(r1: receipt_ptr, r2: message_ptr, r3: size_of_the_message, r4: amount) - according to the specification.
  • Removed input_message_msg_id GTF.
  • Now tokens should be transferred to the contract first, and after you can transfer them via SMO or another transfer. So in some tests first we need to transfer money to the contract first.
  • The fuels-rs now generates a separate structure for encoder {Contract_name}Encoder.

This PR is based on the FuelLabs/fuels-rs#950 and causes cycle dependencies. The fuels-rs should be released first and after we can apply it.

@kayagokalp
Copy link
Member

this one supersedes #4428

@xgreenx xgreenx marked this pull request as ready for review May 3, 2023 18:35
@xgreenx xgreenx requested review from nfurfaro, mitchmindtree and AlicanC and removed request for nfurfaro May 3, 2023 18:36
@kayagokalp kayagokalp requested review from a team May 3, 2023 19:57
kayagokalp
kayagokalp previously approved these changes May 3, 2023
Copy link
Member

@kayagokalp kayagokalp left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It is a huge help. Left couple of questions here and there but tooling changes looks good to me!

ci_checks.sh Outdated Show resolved Hide resolved
forc-pkg/src/pkg.rs Show resolved Hide resolved
@xgreenx xgreenx changed the title Upgrade to fuel-core 0.18.0 and fuels-rs 0.41 Upgrade to fuel-core 0.18.1 and fuels-rs 0.41 May 4, 2023
sdankel
sdankel previously approved these changes May 4, 2023
Copy link
Member

@sdankel sdankel 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!

ci_checks.sh Outdated Show resolved Hide resolved
sway-core/src/ir_generation/function.rs Show resolved Hide resolved
sway-ir/src/verify.rs Show resolved Hide resolved
sway-ir/src/verify.rs Outdated Show resolved Hide resolved
iqdecay added a commit to FuelLabs/fuels-rs that referenced this pull request May 25, 2023
BREAKING CHANGES: 
- `Predicate::from_code` and `Predicate::load_from` use default `ConsensusParameters` for instantiation of the predicate address. To use non-default `ConsensusParameters`, the user should use `Predicate::from_code(...).with_provider()`, that will use the provider's `ConsensusParameters`. 
- `Provider::new` now takes a `ConsensusParameters` argument, so we can
avoid changing the API of downstream clients.
- `setup_test_client` now returns `ConsensusParameters` of the client. It is less used than `setup_test_provider` so it's its API that was changed. 
- `produce_block` API now takes in a `start_time` as an `Option<DateTime<Utc>>` (no need for the `TimeParameters` struct)
- To produce blocks, the user now needs to set `block_production` to `Trigger::Interval` (see docs) in `ChainConfig`


Internal changes: 
- The signing of the transaction and predicate id generation requires
`ChainId`(`ConsensusParameters`).
- Now tokens should be transferred to the contract first, and after you
can transfer them via `SMO` or another transfer. So in some tests first
we need to transfer money to the contract first.
- Replaced all unsafe code from `fuel-crypto` with safe analog.
- On the `fuel-tx`/`fuel-core` side now, there is a difference in
whether the message contains data. If data is empty, it is `MessageCoin`
that acts like a `Coin`(has the same rules during execution). If the
data field is not empty, then it is a retryable message(or
`MessageData`). Messages like this can't be used to pay a transaction
fee, and if the execution fails, the message is not consumed(you can use
it again in the next transactions). More about them you can read in
FuelLabs/fuel-core#946. Also, the API changed
for resources and not it is `Coins` again. Because of that, some tests
now require messages with empty data to be able to spend them.
- Removed redundant usage of `MessageId`. Now the identifier of the
message is a `Nonce`.
- Removed `Output::Message`. Now you don't need to specify it in the
outputs. Because of that `SMO` opcode doesn't require a message output
index anymore.
- The proof API is updated with a new design:
FuelLabs/fuel-core#1046. If you want to prove
the block at height `X` you need at least a committed `X + 1` block.

Because some of opcodes were updated the examples require a new `sway`.
The corresponding PR: FuelLabs/sway#4525. It
creates a cycle of dependencies with this PR.

Closes #829
#933
---------

Co-authored-by: iqdecay <victor@berasconsulting.com>
Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
Co-authored-by: Ahmed Sagdati <37515857+segfault-magnet@users.noreply.github.com>
Co-authored-by: Halil Beglerović <git@hal3e.io>
Co-authored-by: hal3e <hal3e.git@gmail.com>
@iqdecay
Copy link
Contributor

iqdecay commented May 25, 2023

FuelLabs/fuels-rs#950 has been merged

# Conflicts:
#	sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
kayagokalp
kayagokalp previously approved these changes May 26, 2023
@xgreenx
Copy link
Contributor Author

xgreenx commented May 29, 2023

The PR is ready for the final review. It uses SDK 0.42 release. The CI fails because the book uses the last available sway to compile examples.

@kayagokalp
Copy link
Member

The PR is ready for the final review. It uses SDK 0.42 release. The CI fails because the book uses the last available sway to compile examples.

Taking care of it, opened #4595

kayagokalp added a commit that referenced this pull request May 29, 2023
…ay reference examples (#4597)

## Description

closes #4595.
unblocks #4525.

Once #4596 is fixed we can remove std declarations in each manifest file
with a single patch statement in the workspace level manifest file. That
will also open the way to re-enable the disabled member (reentrancy) as
the example depends on sway-lib and sway-lib depends on latest released
std. So without the patch table it is not useable.

follow-up: #4596.
@kayagokalp
Copy link
Member

Merged the fix here, it should clear CI stuff

@kayagokalp kayagokalp mentioned this pull request May 30, 2023
7 tasks
@IGI-111 IGI-111 merged commit 999410c into master May 31, 2023
28 checks passed
@IGI-111 IGI-111 deleted the feature/fuel-core-0.18 branch May 31, 2023 09:08
IGI-111 added a commit that referenced this pull request May 31, 2023
## Description

Waiting for:
- #4525.

@Dhaiwat10 was waiting for a release with the linked PR merged.

@IGI-111 I had the PR ready, leaving it up to you when to merge & cut
the release. Made this a major bump as we had a breaking change merged
(#4574).

## 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](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

Co-authored-by: IGI-111 <igi-111@protonmail.com>
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.

None yet

8 participants