-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
fault_proving(headers): create new version of the block header, with tx_id_commitment #2648
Conversation
2633cdc
to
cc07609
Compare
e9374ea
to
cde0dc9
Compare
cde0dc9
to
bb0368e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff overall. I have some thoughts and questions, but the only blockers I can see is a dangling todo and a comment that should be updated.
Also it would be nice to have a test for the commitment computation.
/// fault proving relevant data | ||
pub fault_proving: FaultProvingHeader, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should put this within the ApplicationHeader
, but not in the GeneratedApplicationFields
. Because the ApplicationHeader
says: "/// Contains everything except consensus related data.". Otherwise, we should update the docs for the ApplicationHeader
. I'm okay either way, it's not obvious what's right here to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a design decision :) i find it cleaner to be separate and more evident about what the difference is between this header and the previous one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think it should be part of the Application header. Otherwise, you break the idea of AplicationHeader existence.
The application header exists to remove all fields related to the execution or the execution result from the header. All information that can be known only after the block is produced or executed go there.
ConsensusHeaders contains all the information to verify the validity of the block(that it was created with valid height, DA height, time). The application headers contain everything in the case if you want to verify the execution.
bb0368e
to
0306777
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating. Looks good to me!
b03734a
to
888cd03
Compare
} | ||
/// Helpful methods for all variants of the block header. | ||
#[enum_dispatch] | ||
pub(crate) trait GetBlockHeaderFields { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not include a:
#[cfg(feature = "fault-proving")]
fn fault_proving(&self) -> Option<FaultProvingHeader;
I assume this will still work with the #[enum_dispatch]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yagni, we just want to provide access to the tx_id_commitment and nothing else for now
#[cfg(feature = "fault-proving")] | ||
Block::V1(BlockV1 { | ||
header: | ||
BlockHeader::V2(crate::blockchain::header::BlockHeaderV2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern match is pretty big. Would it be easier to read if you just used the new getter traits here, and didn't bother matching on the the BlockHeader
variant?
I might be missing something that needs special attention, but that's kinda the point of my comment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh we have to do this, if we don't the compiler yells at us saying we haven't matched on a variant of the block header ;)
2fc9470
to
c1a4cc0
Compare
…fault proving fix: clippy fix: changelog
c1a4cc0
to
a6e4f34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
…ring compilation (#2653) ## Linked Issues/PRs <!-- List of related issues/PRs --> ## Description <!-- List of detailed changes --> found a lot of `SerdeDeCustom` errors while compiling #2648 without the fault-proving feature flag in [the build script](crates/services/upgradable-executor/build.rs) ## Checklist - [ ] Breaking changes are clearly marked as such in the PR description and changelog - [ ] New behavior is reflected in tests - [ ] [The specification](https://github.com/FuelLabs/fuel-specs/) 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] - [ ] [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?
## Linked Issues/PRs <!-- List of related issues/PRs --> - #2648 ## Description <!-- List of detailed changes --> We get rid of `enum_dispatch` because if you try to derive the impl on a trait with a generic, you also have to apply the generic to the enum ~ which we don't need. rather than having 2 traits, one generic and one not, opted to cut `enum_dispatch` altogether. idk why we were directly accessing the block header fields in the whole codebase without using accessor methods, even when we had defined an enum for block header. this PR fixes that. if `fault-proving` is enabled, we now generate `BlockV1` with `BlockHeaderV2`. `tx_id_commitment` has been moved to `GeneratedApplicationFieldsV2`, renamed `GeneratedApplicationFields` to `GeneratedApplicationFieldsV1`. maybe we can remove `pub` from a lot of fields and convert to `pub(crate)` but i can do that in a follow up PR. I still favour having a separate `FaultProvingHeader` field on the header, since we anyway have to define a new hash function for the `ApplicationHeader<GeneratedApplicationFieldsV2>`, it was less verbose before. ### Reviewers guide - all of the changes in crates other than `types` is just using getters/setters where necessary - in `types/header`, refactored, removed `enum_dispatch` due to generic usage that didn't apply on parent enum - moved `tx_id_commitment` from `fault_proving_header` to `application_header`. New struct `GeneratedApplicationFieldsV2` to accommodate it. ### AI generated desc This pull request includes several changes to improve the consistency and readability of the code by replacing direct field accesses with method calls for accessing block header fields. The most important changes include updates to the `BlockHeader` field access, test adjustments, and feature additions in the `Cargo.toml` file. ### Block Header Field Access Updates: * Updated `impl LastBlockConfig` in `crates/chain-config/src/config/state.rs` to use method calls for accessing block header fields instead of direct field accesses. * Modified `impl From<&BlockHeader> for CompressedBlockHeader` in `crates/compression/src/compressed_block_payload/v1.rs` to use method calls for accessing block header fields. * Updated `impl Header` in `crates/fuel-core/src/schema/block.rs` to use method calls for accessing block header fields. ### Test Adjustments: * Adjusted various test cases in `crates/fuel-core/src/executor.rs` to use method calls for accessing block header fields. [[1]](diffhunk://#diff-379b2602e8ed0e8048291c20eff0d6ab59d4cfc1e6c5c9c6d5513b33008ba1c1L366-R367) [[2]](diffhunk://#diff-379b2602e8ed0e8048291c20eff0d6ab59d4cfc1e6c5c9c6d5513b33008ba1c1L2715-R2715) [[3]](diffhunk://#diff-379b2602e8ed0e8048291c20eff0d6ab59d4cfc1e6c5c9c6d5513b33008ba1c1L2754-R2754) [[4]](diffhunk://#diff-379b2602e8ed0e8048291c20eff0d6ab59d4cfc1e6c5c9c6d5513b33008ba1c1L3389-R3389) * Updated test cases in `crates/fuel-core/src/service/adapters/consensus_parameters_provider.rs` to use method calls for setting consensus parameters version. ### Feature Additions: * Added new feature `fault-proving` in `Cargo.toml` for `crates/services/consensus_module`. * Updated imports and function implementations in `crates/services/consensus_module/poa/src/verifier.rs` to support the new feature and improve code structure. [[1]](diffhunk://#diff-bffa43e1ce0d3b4c653637fd70da7d6321dd2528d4bbf496dce57ed2488c552fL8-R11) [[2]](diffhunk://#diff-bffa43e1ce0d3b4c653637fd70da7d6321dd2528d4bbf496dce57ed2488c552fL64-R67) [[3]](diffhunk://#diff-bffa43e1ce0d3b4c653637fd70da7d6321dd2528d4bbf496dce57ed2488c552fR76-R83) ## Checklist - [ ] Breaking changes are clearly marked as such in the PR description and changelog - [ ] New behavior is reflected in tests - [ ] [The specification](https://github.com/FuelLabs/fuel-specs/) 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] - [ ] [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?
Linked Issues/PRs
closes #2569
Description
This pull request introduces a new feature called "fault-proving" across various modules and files. It includes modifications to configuration files, schema updates, and changes to the handling of block generation and transaction IDs.
Reviewers guide
fault-proving
features with depscrates/types/src/blockchain
for changes to the block headercrates/client
for breaking change to the graphql apiyou may filter the non-toml files by filtering them here -
![image](https://private-user-images.githubusercontent.com/43716372/408510470-f8ed3f61-1390-4775-8e79-cc47515b4974.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MTU3MzcsIm5iZiI6MTczOTQxNTQzNywicGF0aCI6Ii80MzcxNjM3Mi80MDg1MTA0NzAtZjhlZDNmNjEtMTM5MC00Nzc1LThlNzktY2M0NzUxNWI0OTc0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDAyNTcxN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM1YWZhMjdmNTZmN2E0ODBiOTBmZGYyMzZhOGZmYmU5MDJiNDU1Nzc4YzdhODc5YjljZmQxYWZjODUyMmMxZTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.CU_yIYIE44JCXWEwepLNmiU0TObgzc5UWFtF6U889aY)
Fault-Proving Feature Integration:
benches/Cargo.toml
,crates/chain-config/Cargo.toml
,crates/client/Cargo.toml
,crates/compression/Cargo.toml
,crates/database/Cargo.toml
,crates/fuel-core/Cargo.toml
: Addedfault-proving
feature dependencies. [1] [2] [3] [4] [5] [6]Code Updates for Fault-Proving:
benches/src/db_lookup_times_utils/seed.rs
,crates/chain-config/src/config/randomize.rs
,crates/fuel-core/src/database/block.rs
,crates/fuel-core/src/executor.rs
,crates/fuel-core/src/query/message/test.rs
: Updated block generation code to conditionally includefault-proving
feature parameters. [1] [2] [3] [4] [5]Schema and Type Changes:
crates/client/assets/schema.sdl
,crates/client/src/client/schema/block.rs
,crates/client/src/client/types/block.rs
,crates/fuel-core/src/schema/block.rs
: AddedtxIdCommitment
field andHeaderVersion::V2
to support thefault-proving
feature. [1] [2] [3] [4]Snapshot and Test Updates:
crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap
,crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_id_query_gql_output.snap
,crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__blocks_connection_query_gql_output.snap
,crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap
: Updated snapshots to includetxIdCommitment
field. [1] [2] [3] [4]Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]