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

Lock in-use keys to prevent nonce race condition #55

Open
encody opened this issue Nov 30, 2023 · 0 comments
Open

Lock in-use keys to prevent nonce race condition #55

encody opened this issue Nov 30, 2023 · 0 comments

Comments

@encody
Copy link
Contributor

encody commented Nov 30, 2023

Currently, payloads are signed using a KeyRotatingSigner as soon as they are ready to be relayed. However, this results in a race condition wherein keys that have in-transit transactions (which will update the corresponding key's nonce upon resolution) may be used to sign multiple payloads before the one resolves, causing a nonce race condition.

One way to solve this would be to put all of the keys in a key pool. When a signature request arrives, the handler requests a lock on a key from the pool. If all of the keys in the pool are locked, then the handler waits until a lock is released. A key lock is released after a payload has been signed, transmitted to the network, finalized in a block, and the key's nonce has been appropriately updated.

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

No branches or pull requests

1 participant