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

feat(rpc): Replace TypedTransactionType #11089

Merged
merged 8 commits into from
Sep 25, 2024

Conversation

jenpaff
Copy link
Collaborator

@jenpaff jenpaff commented Sep 21, 2024

Towards closing #7490

Quick vibe check if I'm going the right way here

@jenpaff jenpaff force-pushed the jenpaff/replace-typed-transaction-type branch from 628af0d to 5a2d892 Compare September 23, 2024 09:22
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.

cool, this looks pretty good already

some suggestions

@@ -21,7 +21,7 @@ reth-evm.workspace = true
reth-primitives.workspace = true
reth-provider.workspace = true
reth-revm.workspace = true
reth-rpc-types.workspace = true
# reth-rpc-types.workspace = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

cool, can we remove this entirely?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes after I rebased seems like it's not used anymore at all- will have a go at removing entirely

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mattsse I feel like this reth-rpc-types doesn't do much anymore, should I give it a go to remove it fully ? (in this or separate pr)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yep: #11198

crates/rpc/rpc-eth-api/src/helpers/transaction.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-types/src/eth/transaction/typed.rs Outdated Show resolved Hide resolved
crates/rpc/rpc/src/eth/helpers/signer.rs Outdated Show resolved Hide resolved
Comment on lines 90 to 94
// create local signer wallet from signing key
let sk_bytes = self.accounts.get(address).ok_or(SignError::NoAccount)?.secret_bytes();
let wallet =
PrivateKeySigner::from_bytes(&sk_bytes.into()).map_err(|_| SignError::NoAccount)?;
let signer = EthereumWallet::from(wallet);
Copy link
Collaborator

@mattsse mattsse Sep 23, 2024

Choose a reason for hiding this comment

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

perhaps we can simplify this by changing SecretKey to

PrivateKeySigner?

https://github.com/alloy-rs/alloy/blob/8b57b52f8c796ce785e4530bf9e6fc73ea743ecc/crates/signer-local/src/lib.rs#L36-L37

see also PrivateKeySigner::random_{with}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated now using signer api

@mattsse mattsse marked this pull request as ready for review September 23, 2024 11:28
@jenpaff jenpaff force-pushed the jenpaff/replace-typed-transaction-type branch from b188cea to cd23c92 Compare September 24, 2024 14:35
@mattsse mattsse changed the title WIP: Replace TypedTransactionType feat(rpc): Replace TypedTransactionType Sep 24, 2024
@mattsse mattsse added C-debt Refactor of code section that is hard to understand or maintain A-rpc Related to the RPC implementation labels Sep 24, 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.

cool, one more suggestion

Comment on lines 60 to 62
let sk = self.get_key(account)?.to_field_bytes();
let signature = sign_message(B256::from_slice(sk.as_ref()), hash);
signature.map_err(|_| SignError::CouldNotSign)
Copy link
Collaborator

@mattsse mattsse Sep 24, 2024

Choose a reason for hiding this comment

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

you can use the signer API here:

use alloy_signer::signer::SignerSync;

let sk = self.get_key(account)?.sign_hash_sync

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@jenpaff jenpaff force-pushed the jenpaff/replace-typed-transaction-type branch from d536c3b to 070debb Compare September 24, 2024 16:31
to_primitive_transaction(request).ok_or(SignError::InvalidTransactionRequest)?;
let tx_signature_hash = transaction.signature_hash();
let signature = self.sign_hash(tx_signature_hash, *address)?;
// create local signer wallet from signing key
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

update comment

#[cfg(feature = "jsonrpsee-types")]
pub use eth::{
engine,
engine::{
ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, PayloadError,
},
};

use alloy_primitives as _;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

possibly could be removed can look into it

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.

nice, I only removed the unused deps and made sure the features are updated accordingly

@mattsse mattsse added this pull request to the merge queue Sep 25, 2024
Merged via the queue into main with commit 5d2867f Sep 25, 2024
36 checks passed
@mattsse mattsse deleted the jenpaff/replace-typed-transaction-type branch September 25, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation 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.

2 participants