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 gas bumping txmgr #284

Merged
merged 29 commits into from
Aug 9, 2024
Merged

Conversation

samlaf
Copy link
Collaborator

@samlaf samlaf commented Jun 28, 2024

Also in passing Fixes #153 .

What Changed?

Also updated chainio and signer READMEs + some code comments

Reviewer Checklist

  • Code is well-documented
  • Code adheres to Go naming conventions
  • Code deprecates any old functionality before removing it

@samlaf samlaf marked this pull request as draft June 28, 2024 03:05
chainio/txmgr/txmgr.go Outdated Show resolved Hide resolved
@samlaf samlaf changed the title Add txmgr Add gas bumping txmgr Jul 11, 2024
@samlaf samlaf force-pushed the samlaf-avs-588-upstream-tx-manager-to-eigensdk-go branch from 7c57f9c to ce05793 Compare July 13, 2024 00:26
@samlaf samlaf force-pushed the samlaf-avs-588-upstream-tx-manager-to-eigensdk-go branch from bb33f19 to c8fef0f Compare July 24, 2024 18:01
@samlaf samlaf force-pushed the samlaf-avs-588-upstream-tx-manager-to-eigensdk-go branch 2 times, most recently from b54c915 to 5616d83 Compare August 6, 2024 03:40
@samlaf samlaf marked this pull request as ready for review August 6, 2024 04:10
chainio/clients/wallet/READMD.md Outdated Show resolved Hide resolved
chainio/txmgr/geometric/geometric.go Outdated Show resolved Hide resolved
chainio/txmgr/geometric/geometric.go Outdated Show resolved Hide resolved
samlaf added 4 commits August 7, 2024 14:03
added gas oracle

refactored txmgr module

added geometric txmgr

make fmt

log -> logger in simple txmgr

add TODO + rename constructor

update geometric txmgr to use sync api

gasoracle refactor

chore: switch to pointer to gasoracle in geometric txmgr
Also added some comments

example: add example test for geometric txmgr

fix(geometric_example_test): start anvil container

refactor(geometric txmgr): delete gasoracle and add its methods to geometric txmgr directly

make fmt

fix(lint): remove no longer used variable hundred

wip moving geometric to its own subdir

simplify privatekey_wallet

delete old moved files

add geometric txmgr metrics interface + noop metrics

docs: add default values in geometric txmgr params comment

test(geometric txmgr): add first simple test for geometric txmgr

test(geometric txmgr): add some basic tx sending tests

feat(ecdsa): add KeyAndAddressFromHexKey helper function

feat(geometric txmgr): add integration test scaffold with 1 simple tx sending test

fix(geometric txmgr): remove unneeded mutex

test(geometric txmgr): add parallel mining logic to fakeEthBackend.SendTransaction to test parallel sending of txs

feat(geometrix txmgr): refactor queryTicketDuration to be a param instead of a fixed const

refactor(txmgr test harness): refactor into a mining goroutine

fix(geometric txmgr test): use mutex to get rid of race condition

refactor(geometric txmgr params): made all params public fields

feat(geometric txmgr test): added congestedBlocks field to test network congestion where txs need to get bumped
also made tests run fast by setting txmgr's GetTxReceiptTickerDuration to 100ms instead of the default 3s

fix(geometric txmgr): bug in ensureAnyTxBroadcasted
ethereum.NotFound errors were not handled properly, causing txs to never get bumped

feat(geometric txmgr test): added congested network test
@samlaf samlaf force-pushed the samlaf-avs-588-upstream-tx-manager-to-eigensdk-go branch from a302e22 to 4c94ecd Compare August 7, 2024 21:03
@samlaf samlaf requested a review from ian-shim August 8, 2024 04:46
crypto/ecdsa/utils.go Outdated Show resolved Hide resolved
chainio/txmgr/metrics.go Outdated Show resolved Hide resolved
chainio/txmgr/geometric/geometric.go Outdated Show resolved Hide resolved
chainio/txmgr/geometric/geometric.go Outdated Show resolved Hide resolved
chainio/txmgr/geometric/geometric.go Outdated Show resolved Hide resolved

// processTransaction sends the transaction and runs the monitoring loop which will bump the gasPrice until the tx get
// included.
func (t *GeometricTxManager) processTransaction(ctx context.Context, req *txnRequest) (*types.Receipt, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this method thread safe?
Could a transaction with higher nonce end up published before one with lower nonce?

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 it is. Added a test to show this: 549b045
Also added comment to explain how to send txs concurrently: e6ab890

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh btw also had to add 3a12fcc#diff-f3751b0e1d13e5e4c58c0ae0d936505427becc99a1c52514628bdaf32df6d370R488 to slow down the gas bumping loop, otherwise txs were getting bumped like crazy if a txs with the wrong (too-high) nonce was sent. Is that normal? Was there a better way to deal with this?

ian-shim
ian-shim previously approved these changes Aug 9, 2024
Copy link
Contributor

@ian-shim ian-shim left a comment

Choose a reason for hiding this comment

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

lgtm, I'd integrate this with some service (avssync?) and soak test it as there might be more issues when dealing with the real chain in different gas market

Comment on lines 331 to 332
// t.logger.Debug("Transaction not yet mined", "nonce", tx.Nonce(), "txID", txID, "txHash",
// tx.Hash().Hex(), "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

What do we want to do here? We can remove this block if nothing is being done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops commented while debugging and committed by mistake. Uncommented in 63832fc

// Remove the transaction from the list of transactions to query.
// go seemingly allows deleting from a map while iterating over it:
// https://groups.google.com/g/golang-nuts/c/rEmaoxi11_A
// although the official spec and faq don't seem to mention this anywhere...
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't seem to mention that deleting items while iterating is safe?

@samlaf samlaf merged commit bdeff56 into dev Aug 9, 2024
4 checks passed
@samlaf samlaf deleted the samlaf-avs-588-upstream-tx-manager-to-eigensdk-go branch August 9, 2024 18:18
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

Successfully merging this pull request may close these issues.

Update tx-manager-flow diagram
3 participants