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

Add expiration policy #871

Merged
merged 12 commits into from
Dec 2, 2024
Merged

Add expiration policy #871

merged 12 commits into from
Dec 2, 2024

Conversation

AurelienFT
Copy link
Contributor

@AurelienFT AurelienFT commented Nov 16, 2024

FuelLabs/fuel-specs#593

Spec PR : FuelLabs/fuel-specs#616

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • If performance characteristic of an instruction change, update gas costs as well or make a follow-up PR for that
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

@AurelienFT AurelienFT marked this pull request as ready for review November 17, 2024 13:05
@AurelienFT AurelienFT requested a review from a team November 17, 2024 13:11
@AurelienFT AurelienFT self-assigned this Nov 17, 2024
Copy link
Member

@MitchTurner MitchTurner left a comment

Choose a reason for hiding this comment

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

About time we added the expiration :) Both maturity and expiration are important for predicate writing.

fuel-tx/src/tests/valid_cases/transaction.rs Outdated Show resolved Hide resolved
fuel-tx/src/tests/valid_cases/transaction/upgrade.rs Outdated Show resolved Hide resolved
fuel-tx/src/tests/valid_cases/transaction/upload.rs Outdated Show resolved Hide resolved
fuel-vm/src/tests/validation.rs Outdated Show resolved Hide resolved
fuel-tx/src/transaction.rs Outdated Show resolved Hide resolved
@Voxelot
Copy link
Member

Voxelot commented Nov 18, 2024

We might want to beef up the tests around da_compression.rs to cover policy compression/decompression, as right now it is only testing randomly generated txs without any policies.

cc @Dentosal

MitchTurner
MitchTurner previously approved these changes Nov 18, 2024
Copy link
Member

@MitchTurner MitchTurner left a comment

Choose a reason for hiding this comment

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

LGTM!

@AurelienFT AurelienFT requested a review from a team November 19, 2024 13:34
Co-authored-by: Andrea Cerone <22031682+acerone85@users.noreply.github.com>
fuel-tx/src/transaction/policies.rs Outdated Show resolved Hide resolved
let rng = &mut StdRng::seed_from_u64(2322u64);

// Given
const EXPIRATION: BlockHeight = BlockHeight::new(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const EXPIRATION: BlockHeight = BlockHeight::new(2);
const EXPIRATION: BlockHeight = BlockHeight::new(1);

to clearly show that transactions expire only when the current block height is higher than the specified expiry block (if the match, the transaction is still ok).

Copy link
Contributor

Choose a reason for hiding this comment

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

For the record, I'd also add a similar test fn transaction__execution__doesn_not_work_after_expiration() and use, for example:

    const EXPIRATION: BlockHeight = BlockHeight::new(9);
    const BLOCK_HEIGHT: BlockHeight = BlockHeight::new(10);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a new test to test the current height. However it seems that for maturiy we only test correct case here (failed cases are test elsewhere) but I tried to make one here but finalize_checked is panicking on error.

Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

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

I think we can also update the into_ready function to verify the expiration policy as well. Because this function exists to verify stuff that can change after verification.

fuel-tx/src/tests/valid_cases/transaction.rs Outdated Show resolved Hide resolved
fuel-tx/src/tests/valid_cases/transaction.rs Show resolved Hide resolved
@@ -358,6 +361,10 @@ where
Err(ValidityError::TransactionMaturity)?;
}

if tx.expiration() < block_height {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@dmihal @bajpai244 What do we expect when tx.expiration == block_height? Should it fail or should it pass?

Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
@AurelienFT
Copy link
Contributor Author

@xgreenx Do we agree that if I add it to the into_ready function it will require everyone to update to add the block_height parameters which creates a big breaking change ?

@AurelienFT AurelienFT requested a review from xgreenx November 28, 2024 10:46
AurelienFT added a commit to FuelLabs/fuel-specs that referenced this pull request Nov 28, 2024
#593

VM PR : FuelLabs/fuel-vm#871

### Before requesting review
- [x] I have reviewed the code myself

### After merging, notify other teams

[Add or remove entries as needed]

- [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/)
- [ ] [Sway compiler](https://github.com/FuelLabs/sway/)
- [ ] [Platform
documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+)
(for out-of-organization contributors, the person merging the PR will do
this)
- [ ] Someone else?
@xgreenx
Copy link
Collaborator

xgreenx commented Nov 28, 2024

into_ready only used in the fuel-vm, so I think we can do that=)

xgreenx
xgreenx previously approved these changes Dec 2, 2024
let result = tx.check(block_height, &test_params());

// Then
assert_eq!(Err(ValidityError::TransactionExpiration), result);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we check the happy and sad paths for script and create, but not for blob, upgrade, and upload?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It follows the same pattern as the others policies, the correct cas is only tested in valid_cases.rs file.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should take the existing coverage as cannon. I think we should cover happy and sad for all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okeyyyy, added :)

@AurelienFT AurelienFT added this pull request to the merge queue Dec 2, 2024
Merged via the queue into master with commit 767f4e6 Dec 2, 2024
40 checks passed
@AurelienFT AurelienFT deleted the add_expiration_policy branch December 2, 2024 22:44
@xgreenx xgreenx mentioned this pull request Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants