-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: testground test case not fast enough
Solution: - patch cronosd temporarily to disable nonce checking - optimise the load generator
- Loading branch information
Showing
13 changed files
with
161 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/app/app.go b/app/app.go | ||
index 678ccc0a..ba64a7fe 100644 | ||
--- a/app/app.go | ||
+++ b/app/app.go | ||
@@ -1060,6 +1060,7 @@ func (app *App) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64, bl | ||
}, | ||
ExtraDecorators: []sdk.AnteDecorator{blockAddressDecorator}, | ||
PendingTxListener: app.onPendingTx, | ||
+ UnsafeUnorderedTx: true, | ||
} | ||
|
||
anteHandler, err := evmante.NewAnteHandler(options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,56 @@ | ||
import time | ||
|
||
import web3 | ||
from eth_account import Account | ||
|
||
from .types import PeerPacket | ||
from .utils import send_transaction | ||
|
||
TX_AMOUNT = 1000 | ||
TEST_AMOUNT = 1000000000000000000 | ||
GAS_PRICE = 1000000000 | ||
|
||
|
||
def fund_test_accounts(w3, from_account, num_accounts) -> [Account]: | ||
accounts = [] | ||
for i in range(num_accounts): | ||
acct = Account.create() | ||
tx = { | ||
"to": acct.address, | ||
"value": TEST_AMOUNT, | ||
"gas": 21000, | ||
"gasPrice": GAS_PRICE, | ||
} | ||
receipt = send_transaction(w3, tx, from_account, wait=True) | ||
assert receipt.status == 1 | ||
print("fund test account", acct.address, "balance", TEST_AMOUNT) | ||
accounts.append(acct) | ||
return accounts | ||
|
||
|
||
def sendtx(cli, peer: PeerPacket): | ||
w3 = web3.Web3(web3.providers.HTTPProvider("http://localhost:8545")) | ||
assert w3.eth.chain_id == 777 | ||
acct = export_eth_account(cli, "account") | ||
def sendtx(w3: web3.Web3, acct: Account, tx_amount: int): | ||
print("test address", acct.address, "balance", w3.eth.get_balance(acct.address)) | ||
|
||
nonce = w3.eth.get_transaction_count(acct.address) | ||
for i in range(TX_AMOUNT): | ||
initial_nonce = w3.eth.get_transaction_count(acct.address) | ||
nonce = initial_nonce | ||
while nonce < initial_nonce + tx_amount: | ||
tx = { | ||
"to": "0x0000000000000000000000000000000000000000", | ||
"value": 1, | ||
"nonce": nonce, | ||
"gas": 21000, | ||
"gasPrice": GAS_PRICE, | ||
} | ||
try: | ||
send_transaction(w3, tx, acct, wait=False) | ||
except ValueError as e: | ||
if "invalid nonce" in str(e): | ||
# reset nonce and continue | ||
nonce = w3.eth.get_transaction_count(acct.address) | ||
msg = str(e) | ||
if "invalid nonce" in msg: | ||
print("invalid nonce and retry", nonce) | ||
time.sleep(1) | ||
continue | ||
raise | ||
nonce += 1 | ||
if "tx already in mempool" not in msg: | ||
raise | ||
|
||
nonce += 1 | ||
|
||
def export_eth_account(cli, name: str) -> Account: | ||
return Account.from_key( | ||
cli("keys", "unsafe-export-eth-key", name, keyring_backend="test") | ||
) | ||
if nonce % 100 == 0: | ||
print(f"{acct.address} sent {nonce} transactions") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.