Skip to content

XEN Spam Scenario #169

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

XEN Spam Scenario #169

wants to merge 6 commits into from

Conversation

fahimahmedx
Copy link

@fahimahmedx fahimahmedx commented Mar 28, 2025

Added a XEN spam scenario. Note that state impact of XEN comes from deploying contracts, not claiming XEN tokens, so this spam scenario only focuses on deploying tokens.

Motivation

XEN spam has caused concerns for state growth on major L2s like Base. This script helps measure the state growth cased by XEN spam. #140

Testing

On terminal 1, run:

  1. anvil

On terminal 2, run:

  1. Take a private key from terminal 1, and export it to the environment variable PRV_KEY.
  2. contender setup ./scenarios/xen.toml http://127.0.0.1:8545 --min-balance 1
  3. contender spam ./scenarios/xen.toml http://127.0.0.1:8545 --tps 1 -d 1 -p $PRV_KEY --min-balance 0.01

How I generated my XENCrypto bytecode
I generated the XENCrypto bytecode using the latest master release from https://github.com/FairCrypto/XEN-crypto, and used the "adding foundry to a hardhat project" so I could add foundry to its repo & run the command forge build, cat out/XENCrypto.sol/XENCrypto.json | jq .bytecode.object, and cat out/XENMath.sol/XENMath.json | jq .bytecode.object.

Note that since the hardhat.config is in typescript, use import "@nomicfoundation/hardhat-foundry"; instead of require("@nomicfoundation/hardhat-foundry"); in the hardhat to foundry guide.

In the bytecode or XENCrypto, I replaced all instances of __$e50d57b7f0af7faa838eeefa2a76c9e08d$__ (this is the only weird text that shows up) with {XENMath}, because that was the only other solidity file in the repo

Issue

So far, my XENTorrent bytecode has an issue where running contender spam ./scenarios/xen.toml http://127.0.0.1:8545 --tps 1 -d 1 -p $PRV_KEY --min-balance 0.01 produces an error of:

opening DB at /Users/user/.contender/contender.db
adding 'admin' signers to wallet map
Error: failed to prepare tx failed to estimate gas for tx ErrorResp(ErrorPayload { code: 3, message: "execution reverted", data: Some(RawValue("0x")) })

I generated my XENTorrent bytecode by taking the latest master commit of the XENFT repo, converting the repo from Truffle into Hardhat via this guide, and then converting from hardhat to foundry via the guide I used for XENCrypto's bytecode.
Lastly, I ran forge build --optimizer-runs 2000 and cat out/XENFT.sol/XENTorrent.json | jq .bytecode.object

Without --optimizer-runs 2000, your bytecode will be too long and you will have the following error:

deploying contract: "XENTorrent"
thread 'tokio-runtime-worker' panicked at /Users/user/.cargo/git/checkouts/contender-3d6f185a9aeefd48/9fecda8/crates/core/src/test_scenario.rs:308:22:
failed to estimate gas: ErrorResp(ErrorPayload { code: -32603, message: "EVM error CreateContractSizeLimit", data: None })
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Error: join error; callback crashed JoinError::Panic(Id(59), "failed to estimate gas: ErrorResp(ErrorPayload { code: -32603, message: "EVM error CreateContractSizeLimit", data: None })", ...)

I then appended the constructor arguments bytecode of:
000000000000000000000000{XENCrypto}{burnRates_}{tokenLimits_}{startBlockNumber_}{forwarder_}{royalty_Receiver_}00000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cecb8f27f4200f3a0000000000000000000000000000000000000000000000019d971e4fe8401e740000000000000000000000000000000000000000000000033b2e3c9fd0803ce800000000000000000000000000000000000000000000000813f3978f8940984400000000000000000000000000000000000000000000001027e72f1f128130880000000000000000000000000000000000000000000000204fce5e3e25026110000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000017700000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000000000000000064

since that was the constructor arguments used in the contract deployment tx on base: https://basescan.org/token/0x379002701bf6f2862e3dfdd1f96d3c5e1bf450b6#code

In our original build bytecode, there were two instances of __${insert data here}$__, so in one trial I replaced one with {XENMath} and {XENCrypto}, and in another trial I did the other order. Neither worked at the end as I had the same error message when running spam.

I then tried creating a forge test file for the XENTorrent.sol file with the arguments above, and those worked.
So unsure if the constructor arguments section of the bytecode is an issue. But my bytecode definitely has an issue.

@fahimahmedx fahimahmedx changed the title xen spam scenario XEN Spam Scenario Mar 28, 2025
Copy link
Contributor

github-actions bot commented Apr 24, 2025

Preview Report

An example contender report preview is available here.

@fahimahmedx fahimahmedx mentioned this pull request Apr 30, 2025
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.

1 participant