Skip to content

add offline EVM load scenarios - #57

Open
codchen wants to merge 1 commit into
mainfrom
codex/evmonly-offline-scenarios
Open

add offline EVM load scenarios#57
codchen wants to merge 1 commit 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 load-test helper package with no changes to existing RPC-based generators; behavior is covered by unit and EVM runtime tests.

Overview
Adds generator/offline, a backend-neutral API for executors that need signed Ethereum transactions and explicit genesis seeding without RPC.

NewScenario supports transfer (native ETH: balance seed + signed legacy transfer) and erc20-transfer (deploy runtime from committed sei-load ERC20 creation bytecode, seed _balances via ERC20BalanceSlot, build signed transfer calldata). Config is validated and big.Int fields are cloned so callers cannot mutate scenario state.

Tests cover signing, genesis writes, config rejection, and an in-geth EVM ERC20 transfer that checks sender/recipient storage. go.mod/go.sum pick up indirect geth test/runtime deps and drop unused github.com/pkg/errors.

Reviewed by Cursor Bugbot for commit e5d7c2f. 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.

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