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

Minor improvements to the compression crate #2254

Merged

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Sep 26, 2024

Minor improvements to the #1609 PR=) Requires decision from @Dentosal

@xgreenx xgreenx self-assigned this Sep 26, 2024
@xgreenx xgreenx added the no changelog Skip the CI check of the changelog modification label Sep 26, 2024
Comment on lines +21 to +24
fn read_registry(&self, key: &RegistryKey) -> anyhow::Result<T>;

/// Reads a value from the registry at its current height.
fn write_registry(&mut self, key: RegistryKey, value: &T) -> anyhow::Result<()>;
fn write_registry(&mut self, key: &RegistryKey, value: &T) -> anyhow::Result<()>;
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 understand why RegistryKey should be passed by reference. It's small enough to fit into a register so performance is likely not the reason here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just to avoid *key and &key in the code=) You can see that now everything just key

Comment on lines +30 to +32
impl<D, T> TemporalRegistry<T> for &mut D
where
D: TemporalRegistry<T>,
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It allows to use &mut Database as an input to CompressCtx instead of Database

Comment on lines -60 to -61
/// currently backed by a `DaCompressionTemporalRegistryEvictor*`
/// columns in the offchain database.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this is removed? It's quite helpful in finding the backing storage. I understand that it breaks the illusion of not depending on the other crate, but in reality they are tightly coupled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The trait should be defined without implementation details. The name of the table that is used under the hood inside of the fuel-core an be different in the future, or implementation can be different=) We don't need this information here.

We need to describe how this trait could be used, but not how it is used.

Comment on lines +279 to +285
tables!(
address: Address,
asset_id: AssetId,
contract_id: ContractId,
script_code: ScriptCode,
predicate_code: PredicateCode
);
Copy link
Member

Choose a reason for hiding this comment

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

I removed this so the macros are easier to work with. Do you think it makes sense to introduce the snake_case names just to get rid of the #[allow(non_snake_case)]? Or is there another reason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the tests you used type name as a field name to access it. Plus explicit address: Address means that somewhere there are fields inside of some types. For me it is easier to read and understand=)

image

Copy link
Member

Choose a reason for hiding this comment

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

My issue with this is that the field names do not and should not matter. They are only used because Rust generics are not powerful enough. Even though they are implemented as field names, they alway refer to the types.

@Dentosal Dentosal merged commit 34bfcd9 into dento/da-compression Sep 26, 2024
33 of 35 checks passed
@Dentosal Dentosal deleted the feature/small-improvments-to-comrpession-crate branch September 26, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog Skip the CI check of the changelog modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants