Skip to content

Commit

Permalink
fix: get_transaction_count does not count pending transactions (#299)
Browse files Browse the repository at this point in the history
Fix a few issues resulting from merge and display errors properly
  • Loading branch information
piwonskp committed Oct 17, 2023
1 parent a1ce72a commit 2c64de0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mev_custom_flood/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
RECEIVER = os.getenv("RECEIVER_PUBLIC_KEY", "0x878705ba3f8Bc32FCf7F4CAa1A35E72AF65CF766")
EL_URI = os.getenv("EL_RPC_URI", 'http://0.0.0.0:53913')


def send_transaction():
# Setting w3 as constant causes recursion exceeded error after ~500 transactions
# Thus it's created everytime a transaction is sent
Expand All @@ -40,9 +41,10 @@ def send_transaction():
"to": RECEIVER,
"data": "0xabcd",
"gasPrice": w3.eth.gas_price,
"nonce": w3.eth.get_transaction_count(sender_account.address)
}

estimated_gas = w3.eth.estimate_gas(transaction)

transaction["gas"] = estimated_gas

tx_hash = w3.eth.send_transaction(transaction)
Expand All @@ -51,6 +53,7 @@ def send_transaction():
logging.info(tx_hash.hex())
assert tx["from"] == sender_account.address


def delayed_send(interval_between_transactions):
send_transaction()
time.sleep(interval_between_transactions)
Expand All @@ -65,7 +68,7 @@ def run_infinitely(interval_between_transactions):
try:
spam()
except Exception as e:
print("e")
print(e)
print("restarting flood as previous one failed")


Expand Down

0 comments on commit 2c64de0

Please sign in to comment.