Skip to content

Commit

Permalink
Problem: benchmark txs have unexpected conflicts (crypto-org-chain#1652)
Browse files Browse the repository at this point in the history
* Problem: benchmark txs have unexpected conflicts

Solution:
- use different recipient addresses

* Update CHANGELOG.md

Signed-off-by: yihuang <[email protected]>

---------

Signed-off-by: yihuang <[email protected]>
  • Loading branch information
yihuang authored Oct 21, 2024
1 parent 9080ded commit ad53734
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* (testground)[1649](https://github.com/crypto-org-chain/cronos/pull/1649) Fix running single validator benchmark locally.
* (cli)[#1647](https://github.com/crypto-org-chain/cronos/pull/1647) Fix node can't shutdown by signal.
* (testground)[#1652](https://github.com/crypto-org-chain/cronos/pull/1652) Remove unexpected conflicts in benchmark transactions.

### Improvements

Expand Down
11 changes: 5 additions & 6 deletions testground/benchmark/benchmark/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
CHAIN_ID = 777
CONNECTION_POOL_SIZE = 1024
TXS_DIR = "txs"
RECIPIENT = "0x1" + "0" * 39


def simple_transfer_tx(nonce: int):
def simple_transfer_tx(sender: str, nonce: int):
return {
"to": RECIPIENT,
"to": sender,
"value": 1,
"nonce": nonce,
"gas": 21000,
Expand All @@ -34,9 +33,9 @@ def simple_transfer_tx(nonce: int):
}


def erc20_transfer_tx(nonce: int):
def erc20_transfer_tx(sender: str, nonce: int):
# data is erc20 transfer function call
data = "0xa9059cbb" + eth_abi.encode(["address", "uint256"], [RECIPIENT, 1]).hex()
data = "0xa9059cbb" + eth_abi.encode(["address", "uint256"], [sender, 1]).hex()
return {
"to": CONTRACT_ADDRESS,
"value": 0,
Expand Down Expand Up @@ -68,7 +67,7 @@ def _do_job(job: Job):
for acct in accounts:
txs = []
for i in range(job.num_txs):
tx = job.create_tx(i)
tx = job.create_tx(acct.address, i)
raw = acct.sign_transaction(tx).rawTransaction
txs.append(EthTx(tx, raw, HexBytes(acct.address)))
total += 1
Expand Down

0 comments on commit ad53734

Please sign in to comment.