-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fault_proving(merklized_registry): add merklized registry tables #2719
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a15f9e3
fault_proving(merklized_registry): add merklized registry tables
rymnc 3f3ac9d
fix: unused re-exports
rymnc 37a92f4
fix: evictor cache and registry index
rymnc ffd9098
fix: reorder all trait impls to be the same throughout v2 modules, ti…
rymnc 684089f
fix: changelog
rymnc 4560027
fix: rename v2 to fault_proving_extra_storage
rymnc b878f61
Merge branch 'master' into chore/merklize-temporal-registry
rymnc e54635b
Revert "fix: rename v2 to fault_proving_extra_storage"
rymnc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Merklized DA compression temporal registry tables. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
crates/fuel-core/src/graphql_api/storage/da_compression/v2.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| pub mod address; | ||
| pub mod asset_id; | ||
| pub mod contract_id; | ||
| pub mod evictor_cache; | ||
| pub mod predicate_code; | ||
| pub mod registry_index; | ||
| pub mod script_code; | ||
| pub mod timestamps; |
119 changes: 119 additions & 0 deletions
119
crates/fuel-core/src/graphql_api/storage/da_compression/v2/address.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| use crate::graphql_api::storage::{ | ||
| da_compression::RegistryKey, | ||
| Column, | ||
| }; | ||
| use core::borrow::Borrow; | ||
| use fuel_core_storage::{ | ||
| blueprint::{ | ||
| merklized::Merklized, | ||
| plain::Plain, | ||
| }, | ||
| codec::{ | ||
| postcard::Postcard, | ||
| primitive::Primitive, | ||
| raw::Raw, | ||
| }, | ||
| structured_storage::TableWithBlueprint, | ||
| tables::merkle::{ | ||
| DenseMerkleMetadata, | ||
| DenseMetadataKey, | ||
| }, | ||
| Mappable, | ||
| }; | ||
| use fuel_core_types::{ | ||
| fuel_merkle::binary, | ||
| fuel_tx::{ | ||
| Address, | ||
| Bytes32, | ||
| }, | ||
| }; | ||
|
|
||
| pub struct TemporalRegistryAddressMerkleData; | ||
|
|
||
| impl Mappable for TemporalRegistryAddressMerkleData { | ||
| type Key = u64; | ||
| type OwnedKey = Self::Key; | ||
| type Value = binary::Primitive; | ||
| type OwnedValue = Self::Value; | ||
| } | ||
|
|
||
| impl TableWithBlueprint for TemporalRegistryAddressMerkleData { | ||
| type Blueprint = Plain<Primitive<8>, Postcard>; | ||
| type Column = Column; | ||
|
|
||
| fn column() -> Column { | ||
| Column::DaCompressionTemporalAddressMerkleData | ||
| } | ||
| } | ||
|
|
||
| /// The metadata table for [`TemporalRegistryAddressMerkleData`] table. | ||
| pub struct TemporalRegistryAddressMerkleMetadata; | ||
|
|
||
| impl Mappable for TemporalRegistryAddressMerkleMetadata { | ||
| type Key = DenseMetadataKey<RegistryKey>; | ||
| type OwnedKey = Self::Key; | ||
| type Value = DenseMerkleMetadata; | ||
| type OwnedValue = Self::Value; | ||
| } | ||
|
|
||
| impl TableWithBlueprint for TemporalRegistryAddressMerkleMetadata { | ||
| type Blueprint = Plain<Postcard, Postcard>; | ||
| type Column = Column; | ||
|
|
||
| fn column() -> Column { | ||
| Column::DaCompressionTemporalAddressMerkleMetadata | ||
| } | ||
| } | ||
|
|
||
| /// Encoder for the V2 version of the DaCompressionTemporalRegistry for Address. | ||
| pub struct DaCompressionTemporalRegistryAddressV2Encoder; | ||
|
|
||
| impl fuel_core_storage::codec::Encode<Address> | ||
| for DaCompressionTemporalRegistryAddressV2Encoder | ||
| { | ||
| type Encoder<'a> = [u8; Bytes32::LEN]; | ||
|
|
||
| fn encode(value: &Address) -> Self::Encoder<'_> { | ||
| *Borrow::<[u8; Bytes32::LEN]>::borrow(value) | ||
| } | ||
| } | ||
|
|
||
| /// V2 table for storing Address with Merklized encoding. | ||
| pub struct DaCompressionTemporalRegistryAddressV2; | ||
|
|
||
| impl Mappable for DaCompressionTemporalRegistryAddressV2 { | ||
| type Key = Self::OwnedKey; | ||
| type OwnedKey = RegistryKey; | ||
| type Value = Self::OwnedValue; | ||
| type OwnedValue = Address; | ||
| } | ||
|
|
||
| impl TableWithBlueprint for DaCompressionTemporalRegistryAddressV2 { | ||
| type Blueprint = Merklized< | ||
| Postcard, | ||
| Raw, | ||
| TemporalRegistryAddressMerkleMetadata, | ||
| TemporalRegistryAddressMerkleData, | ||
| DaCompressionTemporalRegistryAddressV2Encoder, | ||
| >; | ||
| type Column = Column; | ||
|
|
||
| fn column() -> Self::Column { | ||
| Column::DaCompressionTemporalRegistryAddressV2 | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use crate::fuel_core_graphql_api::storage::da_compression::tests::generate_key; | ||
|
|
||
| #[cfg(test)] | ||
| fuel_core_storage::basic_merklelized_storage_tests!( | ||
| DaCompressionTemporalRegistryAddressV2, | ||
| RegistryKey::ZERO, | ||
| <DaCompressionTemporalRegistryAddressV2 as Mappable>::Value::default(), | ||
| <DaCompressionTemporalRegistryAddressV2 as Mappable>::Value::default(), | ||
| generate_key | ||
| ); | ||
| } |
117 changes: 117 additions & 0 deletions
117
crates/fuel-core/src/graphql_api/storage/da_compression/v2/asset_id.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| use crate::graphql_api::storage::{ | ||
| da_compression::RegistryKey, | ||
| Column, | ||
| }; | ||
| use core::borrow::Borrow; | ||
| use fuel_core_storage::{ | ||
| blueprint::{ | ||
| merklized::Merklized, | ||
| plain::Plain, | ||
| }, | ||
| codec::{ | ||
| postcard::Postcard, | ||
| primitive::Primitive, | ||
| raw::Raw, | ||
| }, | ||
| structured_storage::TableWithBlueprint, | ||
| tables::merkle::{ | ||
| DenseMerkleMetadata, | ||
| DenseMetadataKey, | ||
| }, | ||
| Mappable, | ||
| }; | ||
| use fuel_core_types::{ | ||
| fuel_merkle::binary, | ||
| fuel_tx::{ | ||
| AssetId, | ||
| Bytes32, | ||
| }, | ||
| }; | ||
|
|
||
| pub struct TemporalRegistryAssetIdMerkleData; | ||
|
|
||
| impl Mappable for TemporalRegistryAssetIdMerkleData { | ||
| type Key = u64; | ||
| type OwnedKey = Self::Key; | ||
| type Value = binary::Primitive; | ||
| type OwnedValue = Self::Value; | ||
| } | ||
|
|
||
| impl TableWithBlueprint for TemporalRegistryAssetIdMerkleData { | ||
| type Blueprint = Plain<Primitive<8>, Postcard>; | ||
| type Column = Column; | ||
|
|
||
| fn column() -> Column { | ||
| Column::DaCompressionTemporalAssetIdMerkleData | ||
| } | ||
| } | ||
|
|
||
| /// The metadata table for [`TemporalRegistryAssetIdMerkleData`] table. | ||
| pub struct TemporalRegistryAssetIdMerkleMetadata; | ||
|
|
||
| impl Mappable for TemporalRegistryAssetIdMerkleMetadata { | ||
| type Key = DenseMetadataKey<RegistryKey>; | ||
| type OwnedKey = Self::Key; | ||
| type Value = DenseMerkleMetadata; | ||
| type OwnedValue = Self::Value; | ||
| } | ||
|
|
||
| impl TableWithBlueprint for TemporalRegistryAssetIdMerkleMetadata { | ||
| type Blueprint = Plain<Postcard, Postcard>; | ||
| type Column = Column; | ||
|
|
||
| fn column() -> Column { | ||
| Column::DaCompressionTemporalAssetIdMerkleMetadata | ||
| } | ||
| } | ||
|
|
||
| /// Encoder for the V2 version of the DaCompressionTemporalRegistry for AssetId. | ||
| pub struct DaCompressionTemporalRegistryAssetIdV2Encoder; | ||
|
|
||
| impl fuel_core_storage::codec::Encode<AssetId> | ||
| for DaCompressionTemporalRegistryAssetIdV2Encoder | ||
| { | ||
| type Encoder<'a> = [u8; Bytes32::LEN]; | ||
| fn encode(value: &AssetId) -> Self::Encoder<'_> { | ||
| *Borrow::<[u8; Bytes32::LEN]>::borrow(value) | ||
| } | ||
| } | ||
|
|
||
| /// V2 table for storing AssetId with Merklized encoding. | ||
| pub struct DaCompressionTemporalRegistryAssetIdV2; | ||
|
|
||
| impl Mappable for DaCompressionTemporalRegistryAssetIdV2 { | ||
| type Key = Self::OwnedKey; | ||
| type OwnedKey = RegistryKey; | ||
| type Value = Self::OwnedValue; | ||
| type OwnedValue = AssetId; | ||
| } | ||
|
|
||
| impl TableWithBlueprint for DaCompressionTemporalRegistryAssetIdV2 { | ||
| type Blueprint = Merklized< | ||
| Postcard, | ||
| Raw, | ||
| TemporalRegistryAssetIdMerkleMetadata, | ||
| TemporalRegistryAssetIdMerkleData, | ||
| DaCompressionTemporalRegistryAssetIdV2Encoder, | ||
| >; | ||
| type Column = Column; | ||
| fn column() -> Self::Column { | ||
| Self::Column::DaCompressionTemporalRegistryAssetIdV2 | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use crate::fuel_core_graphql_api::storage::da_compression::tests::generate_key; | ||
|
|
||
| #[cfg(test)] | ||
| fuel_core_storage::basic_merklelized_storage_tests!( | ||
| DaCompressionTemporalRegistryAssetIdV2, | ||
| RegistryKey::ZERO, | ||
| <DaCompressionTemporalRegistryAssetIdV2 as Mappable>::Value::default(), | ||
| <DaCompressionTemporalRegistryAssetIdV2 as Mappable>::Value::default(), | ||
| generate_key | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should this be named something more specific to the feature. I'm not sure I understand what
v2means if it's always going to be hidden behind thefault-provingflag (I assume we are always going to keep it behind the flag because only the fault-proving nodes are going to want to track the extra state).Perhaps we name it
fault-proving-extra-storageor something specific like that?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 won't always be behind the fault-proving flag :) we plan to remove the flag once the feature is done, but you're right, da-compression is enabled only on a few nodes.
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.
addressed in 4560027
I like the previous naming better though :/
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'm willing to hear you out. If the flag is getting removed in the future, then maybe versioning like that makes more sense.
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 okay, will revert the commit with the name change then :)
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.
reverted in e54635b