Skip to content

add offline EVM load scenarios - #57

Merged
codchen merged 2 commits into
mainfrom
codex/evmonly-offline-scenarios
Aug 6, 2026
Merged

add offline EVM load scenarios#57
codchen merged 2 commits into
mainfrom
codex/evmonly-offline-scenarios

Conversation

@codchen

@codchen codchen commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a backend-neutral generator/offline scenario API for executors that consume raw Ethereum transactions and explicit genesis state
  • support signed native transfers and ERC20 transfers without requiring an RPC endpoint
  • derive ERC20 runtime code from the committed sei-load creation bytecode and seed the real _balances mapping slot
  • validate configuration and return isolated copies of mutable runtime/configuration values

Why

The existing TxGenerator scenarios are designed around RPC deployment and submission. Direct executor load tests also need contract code, account balances, and storage available before execution begins. This package exposes that offline setup without coupling sei-load to a particular executor implementation.

The first consumer is sei-protocol/sei-chain#3658, replacing its duplicated native/ERC20 transaction construction and hand-written ERC20 runtime.

Verification

  • go test ./...
  • go test -race -count=1 ./generator/offline
  • golangci-lint v2.12.2 run
  • ERC20 runtime test executes transfer in geth's EVM and verifies sender debit and recipient credit

@codchen
codchen marked this pull request as ready for review August 5, 2026 05:00
@cursor

cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
New isolated package for load-test tooling with tests; no changes to existing RPC generator paths or production runtime behavior.

Overview
Introduces generator/offline, a backend-neutral API for load executors that take signed raw transactions and pre-seeded genesis state instead of RPC-based TxGenerator flows.

NewScenario wires transfer (native ETH) and erc20-transfer. Each scenario implements SetupGenesis, SeedSender, and BuildTransaction against a small GenesisWriter surface (balance, code, storage). Shared Config is validated (including uint256 bounds) and cloned so callers cannot mutate internal big.Int values.

The ERC20 path deploys runtime from the committed sei-load creation bytecode via geth’s runtime.Create, exposes ERC20RuntimeCode and ERC20BalanceSlot for the real _balances mapping, and seeds the sender’s token balance in storage. Tests cover signing, genesis seeding, config rejection, and an in-process transfer call that checks sender/recipient balances.

go.mod / go.sum pick up indirect geth EVM/runtime dependencies and drop unused github.com/pkg/errors.

Reviewed by Cursor Bugbot for commit 455f927. Bugbot is set up for automated code reviews on this repo. Configure here.

case cfg.ChainID == nil || cfg.ChainID.Sign() <= 0:
return fmt.Errorf("chain ID must be positive")
case cfg.GasPrice == nil || cfg.GasPrice.Sign() < 0:
return fmt.Errorf("gas price must be non-negative")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for max is missing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(oops sorry for leaving these as comment instead of PR review comment)

case cfg.SenderBalance == nil || cfg.SenderBalance.Sign() < 0:
return fmt.Errorf("sender balance must be non-negative")
case cfg.TransferValue == nil || cfg.TransferValue.Sign() < 0:
return fmt.Errorf("transfer value must be non-negative")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto re checking for maximum.

}

func (s *erc20TransferScenario) SeedSender(state GenesisWriter, sender common.Address) {
state.SetBalance(sender, s.cfg.SenderBalance)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker but passing around a mutable clone the big int could cause subtle bugs that are hard to debug.

I see this pattern across the repo, which is worth addressing in a separate body of work.

@codchen
codchen merged commit 7d1e752 into main Aug 6, 2026
4 checks passed
@codchen
codchen deleted the codex/evmonly-offline-scenarios branch August 6, 2026 03:20
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.

2 participants