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: nonce filling layer #276

Merged
merged 13 commits into from
Mar 12, 2024
Merged

feat: nonce filling layer #276

merged 13 commits into from
Mar 12, 2024

Conversation

onbjerg
Copy link
Member

@onbjerg onbjerg commented Mar 12, 2024

Motivation

This is a replacement for NonceManagerMiddleware in ethers

Solution

A layer that fills nonces for transaction requests. It does not require you to specify a sender address like in ethers, instead we use a dashmap internally.

I would like some ideas on how to test that this works with sending transaction requests for the same sender from multiple threads at the same time (i.e. a sanity check on the atomics)

Closes #275

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@onbjerg onbjerg added the enhancement New feature or request label Mar 12, 2024
crates/providers/src/layers/nonce.rs Outdated Show resolved Hide resolved
crates/providers/src/layers/nonce.rs Outdated Show resolved Hide resolved
crates/providers/src/layers/nonce.rs Outdated Show resolved Hide resolved
crates/provider/src/layers/nonce.rs Outdated Show resolved Hide resolved
crates/provider/src/layers/nonce.rs Outdated Show resolved Hide resolved
@onbjerg onbjerg requested a review from mattsse March 12, 2024 15:00
Copy link
Member

@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.

smol derive nit, lgtm otherwise

/// ```
///
/// [`SignerLayer`]: crate::layers::SignerLayer
pub struct ManagedNonceLayer;
Copy link
Member

Choose a reason for hiding this comment

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

  • debug + clone etc

@onbjerg onbjerg merged commit 09e90e8 into main Mar 12, 2024
15 checks passed
@onbjerg onbjerg deleted the onbjerg/nonce-layer branch March 12, 2024 16:14
@zerosnacks
Copy link
Member

@onbjerg could it be that the ManagedNonceLayer doesn't track contract deployments? I'm getting some strange errors where at once it complains that either the nonce is too high (1) or too low (0) after deploying a contract with the same provider.

For context see: https://github.com/alloy-rs/examples/pull/20/files

@onbjerg
Copy link
Member Author

onbjerg commented Mar 27, 2024

It should provided the function you use to deploy uses send_transaction. Where exactly are you getting the error?

@zerosnacks
Copy link
Member

It should provided the function you use to deploy uses send_transaction. Where exactly are you getting the error?

I've opened an issue on Alloy to explore this with a minimal reproduction example: #406 + https://github.com/zerosnacks/alloy-repro-406

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add nonce filler layer
4 participants