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 alloy_chains #5952

Merged
merged 13 commits into from
Jan 12, 2024
Merged

add alloy_chains #5952

merged 13 commits into from
Jan 12, 2024

Conversation

1010adigupta
Copy link
Contributor

@1010adigupta 1010adigupta commented Jan 5, 2024

resolves #5429

@1010adigupta
Copy link
Contributor Author

1010adigupta commented Jan 5, 2024

Hey @mattsse I have just started the work of switching to alloy_chains, just added few lines now.
Actually I was getting the errors related to some traits which are used for Chain and NamedChain in reth earlier are not implemented for alloy_chains:
Screenshot 2024-01-05 at 5 10 46 PM
so should I simultaneously make a pr for this on alloy_chains repo as well?? implementing what is necessary there?
or is there any other solution?

@1010adigupta 1010adigupta changed the title Trial solution add alloy_chains Jan 5, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

the missing impls are hidden behind features

@@ -101,7 +102,7 @@ pub enum EthHandshakeError {
MismatchedProtocolVersion(GotExpected<u8>),
#[error("mismatched chain in status message: {0}")]
/// Mismatch in chain details in status messages.
MismatchedChain(GotExpected<Chain>),
MismatchedChain(GotExpected<ChainKind>),
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should remain Chain

@@ -24,7 +25,7 @@ pub struct Status {

/// The chain id, as introduced in
/// [EIP155](https://eips.ethereum.org/EIPS/eip-155#list-of-chain-ids).
pub chain: Chain,
pub chain: ChainKind,
Copy link
Collaborator

Choose a reason for hiding this comment

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

should remain Chain

Cargo.toml Outdated
@@ -150,6 +150,7 @@ alloy-primitives = "0.5"
alloy-dyn-abi = "0.5"
alloy-sol-types = "0.5"
alloy-rlp = "0.3"
alloy-chains = "0.1.7"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay got it

@mattsse mattsse added the C-debt Refactor of code section that is hard to understand or maintain label Jan 5, 2024
@@ -12,8 +12,8 @@ use std::{
/// Constructs a string to be used as a path for configuration and db paths.
pub fn config_path_prefix(chain: Chain) -> String {
match chain {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here whether I use Named of from_named, I am getting the same errror, need some help here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be used

pub fn config_path_prefix(chain: Chain) -> String {
    if let Some(named) = chain.named() {
        named.to_string()
    } else {
        chain.id().to_string()
    }
}

Copy link
Member

Choose a reason for hiding this comment

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

should we move this to a Display / ToString impl?

Copy link
Member

Choose a reason for hiding this comment

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

seems like Chain already implements Display (which gets us ToString)

@1010adigupta 1010adigupta requested a review from mattsse January 6, 2024 17:30
@DaniPopes DaniPopes self-requested a review January 8, 2024 16:54
@mattsse mattsse marked this pull request as ready for review January 9, 2024 14:36
Rjected
Rjected previously requested changes Jan 9, 2024
Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

needs rebase and some changes to pass tests and satisfy clippy.

for parse test errors this should work: .parse::<alloy_chains::Chain>().unwrap()

crates/net/eth-wire/src/types/status.rs Show resolved Hide resolved
crates/trie/src/proof.rs Show resolved Hide resolved
bin/reth/src/init.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

great, one more nit

bin/reth/src/dirs.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

there are lots of unrelated changes (semicolon), please discard those.

and we don't want to add the alloy chains dep everywhere instead we should continue to re-export Chain from the primitives crate

bin/reth/src/args/network_args.rs Outdated Show resolved Hide resolved
bin/reth/Cargo.toml Show resolved Hide resolved
@@ -101,7 +101,7 @@ impl DatabaseInstance {
#[cfg(test)]
mod tests {
use super::*;
use reth_primitives::Chain;
use alloy_chains::Chain;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should still use from pritimitives

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ig but the db functions are using alloy_chains::Chain, if I use reth_primitives::Chain it will give a mismatch type error

Copy link
Collaborator

Choose a reason for hiding this comment

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

it should be the same exact type.

bin/reth/src/commands/debug_cmd/merkle.rs Outdated Show resolved Hide resolved
bin/reth/src/commands/import.rs Outdated Show resolved Hide resolved
bin/reth/src/commands/node/mod.rs Outdated Show resolved Hide resolved
@1010adigupta
Copy link
Contributor Author

there are lots of unrelated changes (semicolon), please discard those.

and we don't want to add the alloy chains dep everywhere instead we should continue to re-export Chain from the primitives crate

I have removed the semicolon issue, can you give more details on the second one?

@1010adigupta 1010adigupta requested a review from mattsse January 10, 2024 11:41
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

sorry I overlooked that this PR didn't actually remove the all the reth_primitive::Chain types:

https://github.com/paradigmxyz/reth/blob/main/crates/primitives/src/chain/mod.rs#L99-L99

which was the actual goal of this PR

@@ -101,7 +101,7 @@ impl DatabaseInstance {
#[cfg(test)]
mod tests {
use super::*;
use reth_primitives::Chain;
use alloy_chains::Chain;
Copy link
Collaborator

Choose a reason for hiding this comment

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

it should be the same exact type.

bin/reth/Cargo.toml Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

great!

I simply removed the reth-primitive chain def and replaced it with the reexport.

now this is complete, ty!

@mattsse mattsse added this pull request to the merge queue Jan 12, 2024
Merged via the queue into paradigmxyz:main with commit 3ce9fcf Jan 12, 2024
28 checks passed
pub const SUPPORTED_CHAINS: &[&str] = &["base", "base_goerli", "base_sepolia"];
pub const SUPPORTED_CHAINS: &[&str] = &["base", "base-goerli", "base-sepolia"];
Copy link
Member

Choose a reason for hiding this comment

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

this is a breaking change in the CLI right, we should communicate that in the release notes

Copy link
Collaborator

@mattsse mattsse Jan 12, 2024

Choose a reason for hiding this comment

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

yeah but this now mirrors what op-geth accepts so this is a good change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt Refactor of code section that is hard to understand or maintain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use alloy_chains::Chain instead of vendoring own implementation
5 participants