Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Oct 18, 2024
1 parent ac810de commit c65af0f
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 12 deletions.
4 changes: 4 additions & 0 deletions testground/benchmark/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 88
extend-ignore = E203
exclude = .git,__pycache__,./integration_tests/contracts,./integration_tests/**/*_pb2.py
29 changes: 18 additions & 11 deletions testground/benchmark/benchmark/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def erc20_transfer_tx(nonce: int):


Job = namedtuple(
"Job", ["chunk", "global_seq", "num_accounts", "num_txs", "tx_type", "create_tx", "batch"]
"Job",
["chunk", "global_seq", "num_accounts", "num_txs", "tx_type", "create_tx", "batch"],
)
EthTx = namedtuple("EthTx", ["tx", "raw", "sender"])

Expand All @@ -75,7 +76,10 @@ def _do_job(job: Job):
print("generated", total, "txs for node", job.global_seq)

# to keep it simple, only build batch inside the account
txs = [build_cosmos_tx(*txs[start, end]) for start, end in split_batch(len(txs), job.batch)]
txs = [
build_cosmos_tx(*txs[start:end])
for start, end in split_batch(len(txs), job.batch)
]
acct_txs.append(txs)
return acct_txs

Expand Down Expand Up @@ -120,15 +124,18 @@ def build_cosmos_tx(*txs: EthTx) -> str:
"""
return base64 encoded cosmos tx, support batch
"""
msgs = [cosmostx.build_any(
"/ethermint.evm.v1.MsgEthereumTx",
cosmostx.MsgEthereumTx(
from_=tx.sender,
raw=tx.raw,
),
) for tx in txs]
fee = sum(tx["gas"] * tx["gasPrice"] for tx in txs)
gas = sum(tx["gas"] for tx in txs)
msgs = [
cosmostx.build_any(
"/ethermint.evm.v1.MsgEthereumTx",
cosmostx.MsgEthereumTx(
from_=tx.sender,
raw=tx.raw,
),
)
for tx in txs
]
fee = sum(tx.tx["gas"] * tx.tx["gasPrice"] for tx in txs)
gas = sum(tx.tx["gas"] for tx in txs)
body = cosmostx.TxBody(
messages=msgs,
extension_options=[
Expand Down
2 changes: 2 additions & 0 deletions testground/benchmark/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ let
pyunormalize = [ "setuptools" ];
pytest-github-actions-annotate-failures = [ "setuptools" ];
cprotobuf = [ "setuptools" ];
flake8-black = [ "setuptools" ];
flake8-isort = [ "hatchling" ];
};
in
lib.mapAttrs
Expand Down
183 changes: 182 additions & 1 deletion testground/benchmark/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions testground/benchmark/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ cprotobuf = "^0.1.11"
[tool.poetry.group.dev.dependencies]
pytest = "^8.2"
pytest-github-actions-annotate-failures = "^0.2.0"
black = "^24.10.0"
flake8 = "^7.1.1"
flake8-black = "^0.3.6"
flake8-isort = "^6.1.1"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit c65af0f

Please sign in to comment.