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

Refactor/Simplify validation logic #1847

Merged
merged 63 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
c1e0f54
Naively remove `Validation` exectution variant
MitchTurner Apr 17, 2024
5dfb4a3
Remove all uses of `Validation` execution type in tests, break tests …
MitchTurner Apr 17, 2024
777212d
WIP getting tests to pass
MitchTurner Apr 18, 2024
4a311e5
Implement validate route and get most of tests passing again
MitchTurner Apr 18, 2024
94bff04
Implement `validate` and fix other tests
MitchTurner Apr 18, 2024
8ba0235
Merge branch 'master' into refactor/separate-validation-from-other-ex…
MitchTurner Apr 18, 2024
74f5e1f
Update CHANGELOG
MitchTurner Apr 18, 2024
cc78682
Fix checks
MitchTurner Apr 18, 2024
cebe68b
Merge branch 'master' into refactor/separate-validation-from-other-ex…
MitchTurner Apr 18, 2024
70d672b
Fix most of the Wasm tests
MitchTurner Apr 18, 2024
7d37d04
Merge branch 'master' into refactor/separate-validation-from-other-ex…
MitchTurner Apr 18, 2024
1cdc886
Refactor and DRY up executor code
MitchTurner Apr 19, 2024
28a6118
Appease Clippy-sama
MitchTurner Apr 19, 2024
fbfa9de
Replace relayed tx stuff
MitchTurner Apr 19, 2024
41a1a37
Merge branch 'master' into refactor/separate-validation-from-other-ex…
MitchTurner Apr 19, 2024
363c2c4
Merge branch 'master' into refactor/separate-validation-from-other-ex…
MitchTurner Apr 19, 2024
54b6c05
Merge branch 'master' into refactor/separate-validation-from-other-ex…
MitchTurner Apr 19, 2024
aad5b63
Update CHANGELOG.md
MitchTurner Apr 19, 2024
ce6d907
Have `validate_block` take `Block` instead of the components
MitchTurner Apr 19, 2024
f4cfb1d
Cleanup
MitchTurner Apr 19, 2024
57c5c78
Simplify `BlockExecutor`
MitchTurner Apr 19, 2024
03b5d03
Cleanup
MitchTurner Apr 19, 2024
a5c0ff0
DRY up some code
MitchTurner Apr 19, 2024
6e1762e
Cleanup more, update CHANGELOG
MitchTurner Apr 19, 2024
947d5d6
Merge branch 'master' into refactor/separate-validation-from-other-ex…
Dentosal Apr 22, 2024
2639ba6
Cleanup, make suggested changes from PR review
MitchTurner Apr 22, 2024
3324742
Merge branch 'refactor/separate-validation-from-other-executions' int…
MitchTurner Apr 22, 2024
0b814c0
Remove Validation `ExecutionKind`
MitchTurner Apr 22, 2024
77933a5
Appease Clippy-sama
MitchTurner Apr 22, 2024
efb5d02
Update CHANGELOG
MitchTurner Apr 22, 2024
c022c95
Remove block id calc stuff
MitchTurner Apr 22, 2024
9da0103
Dry up tx check code
MitchTurner Apr 22, 2024
31c7ea0
Refactor mint contract stuff
MitchTurner Apr 22, 2024
52d1a64
Refactor mint storage stuff
MitchTurner Apr 22, 2024
02e4569
Merge remote-tracking branch 'origin/master' into refactor/remove-pro…
MitchTurner Apr 22, 2024
42ade01
Remove duplicate function from merge
MitchTurner Apr 22, 2024
eea719a
Remove superfluous trait bound
MitchTurner Apr 22, 2024
8aa19c2
Start refactoring chargeable tx methods
MitchTurner Apr 22, 2024
801059c
More refactoring
MitchTurner Apr 22, 2024
b86b2b7
Refactor more
MitchTurner Apr 23, 2024
e244c4c
Tidy up a little
MitchTurner Apr 23, 2024
ba938e4
Appease Clippy-sama
MitchTurner Apr 23, 2024
eb81d5f
Rearrange mint processing to include missed validation check
MitchTurner Apr 23, 2024
abcef1e
Appease Clippy-sama
MitchTurner Apr 23, 2024
407ae30
WIP addressing PR feedback
MitchTurner Apr 23, 2024
668773d
Use execution stuff in validation, fix tests accordingly
MitchTurner Apr 24, 2024
643a140
Remove a bunch of unnecessary validation stuff
MitchTurner Apr 24, 2024
887afd0
Cleanup function signature
MitchTurner Apr 24, 2024
761e40c
Merge branch 'master' into refactor/remove-production-logic-from-vali…
MitchTurner Apr 24, 2024
731ce9c
Rename function
MitchTurner Apr 24, 2024
dd3f54c
Appease Clippy-sama
MitchTurner Apr 24, 2024
7e423a5
Fix prod compilation
MitchTurner Apr 24, 2024
e22f56d
Cleanup trait constraints
MitchTurner Apr 25, 2024
60b3902
Rename `utxo_validation` to appropriately vague name
MitchTurner Apr 25, 2024
0bc7cbb
Replace debug statement, return reference instead of cloning tx
MitchTurner Apr 25, 2024
e55120b
Minimize footprint of partial header creation in `validate_block`
MitchTurner Apr 25, 2024
ad5edbe
Inspect the txs individually when comparing the blocks
MitchTurner Apr 25, 2024
1af7c51
Pass single mint input instead of slice
MitchTurner Apr 25, 2024
8d0bfca
Move output updates into execute function
MitchTurner Apr 25, 2024
73daef5
Avoid cloning entire tx and just get what we need
MitchTurner Apr 25, 2024
761be3d
Replace old debug statement
MitchTurner Apr 25, 2024
74297fc
Use `core` instead of `std`, move check
MitchTurner Apr 26, 2024
44a880a
Merge branch 'master' into refactor/remove-production-logic-from-vali…
xgreenx Apr 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- [#1847](https://github.com/FuelLabs/fuel-core/pull/1847): Simplify the validation interface to use `Block`. Remove `Validation` variant of `ExecutionKind`.
- [#1832](https://github.com/FuelLabs/fuel-core/pull/1832): Snapshot generation can be cancelled. Progress is also reported.
- [#1837](https://github.com/FuelLabs/fuel-core/pull/1837): Refactor the executor and separate validation from the other use cases

Expand All @@ -22,10 +23,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [#1844](https://github.com/FuelLabs/fuel-core/pull/1844): Fixed the publishing of the `fuel-core 0.25.1` release.
- [1842](https://github.com/FuelLabs/fuel-core/pull/1842): Ignore RUSTSEC-2024-0336: `rustls::ConnectionCommon::complete_io` could fall into an infinite loop based on network

### Changed

- [#1837](https://github.com/FuelLabs/fuel-core/pull/1837): Refactor the executor and separate validation from the other use cases

## [Version 0.25.1]

### Fixed
Expand All @@ -49,7 +46,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- [#1837](https://github.com/FuelLabs/fuel-core/pull/1837): Refactor the executor and separate validation from the other use cases
- [#1833](https://github.com/FuelLabs/fuel-core/pull/1833): Regenesis of `SpentMessages` and `ProcessedTransactions`.
- [#1830](https://github.com/FuelLabs/fuel-core/pull/1830): Use versioning enum for WASM executor input and output.
- [#1816](https://github.com/FuelLabs/fuel-core/pull/1816): Updated the upgradable executor to fetch the state transition bytecode from the database when the version doesn't match a native one. This change enables the WASM executor in the "production" build and requires a `wasm32-unknown-unknown` target.
Expand Down
35 changes: 18 additions & 17 deletions crates/fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ mod tests {
let tx = Transaction::default_test_tx();

let mut block = Block::default();
*block.transactions_mut() = vec![mint.into(), tx];
*block.transactions_mut() = vec![mint.clone().into(), tx, mint.into()];
block.header_mut().recalculate_metadata();

let mut validator = create_executor(Default::default(), Default::default());
Expand Down Expand Up @@ -1176,8 +1176,8 @@ mod tests {
.transaction()
.clone()
.into();

let tx_id = tx.id(&ChainId::default());
let chain_id = ConsensusParameters::default().chain_id();
let transaction_id = tx.id(&chain_id);

let mut producer = create_executor(Default::default(), Default::default());

Expand All @@ -1197,11 +1197,12 @@ mod tests {
}
}

let verify_result = verifier.validate_and_commit(block);
assert!(matches!(
verify_result,
Err(ExecutorError::InvalidTransactionOutcome { transaction_id }) if transaction_id == tx_id
));
// then
let err = verifier.validate_and_commit(block).unwrap_err();
assert_eq!(
err,
ExecutorError::InvalidTransactionOutcome { transaction_id }
);
}

// corrupt the merkle sum tree commitment from a produced block and verify that the
Expand Down Expand Up @@ -1233,9 +1234,9 @@ mod tests {
block.header_mut().set_transaction_root(rng.gen());
block.header_mut().recalculate_metadata();

let verify_result = verifier.validate_and_commit(block);
let err = verifier.validate_and_commit(block).unwrap_err();

assert!(matches!(verify_result, Err(ExecutorError::InvalidBlockId)))
assert_eq!(err, ExecutorError::BlockMismatch)
}

// invalidate a block if a tx is missing at least one coin input
Expand Down Expand Up @@ -2177,14 +2178,14 @@ mod tests {
}

let verifier = create_executor(db, Default::default());
let verify_result = verifier.validate_without_commit(second_block);
let err = verifier.validate_without_commit(second_block).unwrap_err();

assert!(matches!(
verify_result,
Err(ExecutorError::InvalidTransactionOutcome {
transaction_id
}) if transaction_id == tx_id
));
assert_eq!(
err,
ExecutorError::InvalidTransactionOutcome {
transaction_id: tx_id
}
);
}

#[test]
Expand Down
Loading
Loading