Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ifeq ($(GOPATH),)
endif

# Tools
SOLC := solc
SOLC := /tmp/solc
ABIGEN := abigen
NVM_DIR := $(HOME)/.nvm
NODE_VERSION := 20
Expand Down Expand Up @@ -63,8 +63,8 @@ setup-node:
nvm install $(NODE_VERSION) && \
nvm use $(NODE_VERSION)
@echo "📦 Installing native solc binary..."
@curl -L https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux -o /usr/local/bin/solc && \
chmod +x /usr/local/bin/solc
@curl -L https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux -o /tmp/solc && \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is to avoid installing the compiler into the shared fs (for local development - on the vm it doesn't matter). Lmk if you have a better idea

chmod +x /tmp/solc
@echo "✅ Node.js environment setup complete"
@echo "ℹ️ Note: You may need to restart your shell or run 'source ~/.bashrc' to use nvm in new sessions"

Expand Down
6 changes: 3 additions & 3 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/ethereum/go-ethereum/common"

"seiload/config"
"seiload/generator/scenarios"
"seiload/types"
"github.com/sei-protocol/sei-load/config"
"github.com/sei-protocol/sei-load/generator/scenarios"
"github.com/sei-protocol/sei-load/types"
)

// Generator interface defines the contract for transaction generators
Expand Down
6 changes: 3 additions & 3 deletions generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/stretchr/testify/require"

"seiload/config"
"seiload/generator"
"seiload/generator/scenarios"
"github.com/sei-protocol/sei-load/config"
"github.com/sei-protocol/sei-load/generator"
"github.com/sei-protocol/sei-load/generator/scenarios"
)

func TestScenarioWeightsAndAccountDistribution(t *testing.T) {
Expand Down
46 changes: 23 additions & 23 deletions generator/prewarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,85 @@ package generator
import (
"sync"

"seiload/config"
"seiload/generator/scenarios"
"seiload/types"
"github.com/sei-protocol/sei-load/config"
"github.com/sei-protocol/sei-load/generator/scenarios"
"github.com/sei-protocol/sei-load/types"
)

// PrewarmGenerator generates self-transfer transactions to prewarm account nonces
type PrewarmGenerator struct {
accountPools []types.AccountPool
evmScenario scenarios.TxGenerator
currentPoolIdx int
finished bool
mu sync.RWMutex
accountPools []types.AccountPool
evmScenario scenarios.TxGenerator
currentPoolIdx int
finished bool
mu sync.RWMutex
}

// NewPrewarmGenerator creates a new prewarm generator using all account pools from the main generator
func NewPrewarmGenerator(config *config.LoadConfig, mainGenerator Generator) *PrewarmGenerator {
// Get all account pools from the main generator
accountPools := mainGenerator.GetAccountPools()

// Create EVMTransfer scenario for prewarming
evmScenario := scenarios.NewEVMTransferScenario()

// Deploy/initialize the scenario (EVMTransfer doesn't need actual deployment)
deployerAccounts := types.GenerateAccounts(1)
deployer := deployerAccounts[0]
evmScenario.Deploy(config, deployer)

return &PrewarmGenerator{
accountPools: accountPools,
evmScenario: evmScenario,
accountPools: accountPools,
evmScenario: evmScenario,
currentPoolIdx: 0,
finished: false,
finished: false,
}
}

// Generate generates self-transfer transactions until all accounts are prewarmed
func (pg *PrewarmGenerator) Generate() (*types.LoadTx, bool) {
pg.mu.Lock()
defer pg.mu.Unlock()

// Check if we're already finished
if pg.finished || pg.currentPoolIdx >= len(pg.accountPools) {
return nil, false
}

// Get current pool
currentPool := pg.accountPools[pg.currentPoolIdx]
account := currentPool.NextAccount()

// If this account has nonce > 0, we've already prewarmed it (round-robin means we're done with this pool)
if account.Nonce > 0 {
// Move to next pool
pg.currentPoolIdx++

// Check if we've finished all pools
if pg.currentPoolIdx >= len(pg.accountPools) {
pg.finished = true
return nil, false
}

// Get account from next pool
currentPool = pg.accountPools[pg.currentPoolIdx]
account = currentPool.NextAccount()

// If this account also has nonce > 0, we're completely done
if account.Nonce > 0 {
pg.finished = true
return nil, false
}
}

// Create self-transfer transaction
scenario := &types.TxScenario{
Name: "EVMTransfer",
Sender: account,
Receiver: account.Address, // Send to self
Nonce: account.GetAndIncrementNonce(),
}

// Generate the transaction using EVMTransfer scenario
return pg.evmScenario.Generate(scenario), true
}
Expand All @@ -103,7 +103,7 @@ func (pg *PrewarmGenerator) GenerateN(n int) []*types.LoadTx {
func (pg *PrewarmGenerator) GetAccountPools() []types.AccountPool {
pg.mu.RLock()
defer pg.mu.RUnlock()

// Return a copy to prevent external modification
pools := make([]types.AccountPool, len(pg.accountPools))
copy(pools, pg.accountPools)
Expand Down
4 changes: 2 additions & 2 deletions generator/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package generator
import (
"sync"

"seiload/generator/scenarios"
"seiload/types"
"github.com/sei-protocol/sei-load/generator/scenarios"
"github.com/sei-protocol/sei-load/types"
)

type scenarioGenerator struct {
Expand Down
6 changes: 3 additions & 3 deletions generator/scenarios/ERC20.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"

"seiload/config"
"seiload/generator/bindings"
"seiload/types"
"github.com/sei-protocol/sei-load/config"
"github.com/sei-protocol/sei-load/generator/bindings"
"github.com/sei-protocol/sei-load/types"
)

const ERC20 = "ERC20"
Expand Down
6 changes: 3 additions & 3 deletions generator/scenarios/ERC20Conflict.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"

"seiload/config"
"seiload/generator/bindings"
"seiload/types"
"github.com/sei-protocol/sei-load/config"
"github.com/sei-protocol/sei-load/generator/bindings"
"github.com/sei-protocol/sei-load/types"
)

const ERC20Conflict = "ERC20Conflict"
Expand Down
6 changes: 3 additions & 3 deletions generator/scenarios/ERC20Noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"

"seiload/config"
"seiload/generator/bindings"
"seiload/types"
"github.com/sei-protocol/sei-load/config"
"github.com/sei-protocol/sei-load/generator/bindings"
"github.com/sei-protocol/sei-load/types"
)

const ERC20Noop = "ERC20Noop"
Expand Down
6 changes: 3 additions & 3 deletions generator/scenarios/ERC721.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"

"seiload/config"
"seiload/generator/bindings"
"seiload/types"
"github.com/sei-protocol/sei-load/config"
"github.com/sei-protocol/sei-load/generator/bindings"
"github.com/sei-protocol/sei-load/types"
)

const ERC721 = "ERC721"
Expand Down
4 changes: 2 additions & 2 deletions generator/scenarios/EVMTransfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"

"seiload/config"
types2 "seiload/types"
"github.com/sei-protocol/sei-load/config"
types2 "github.com/sei-protocol/sei-load/types"
)

const EVMTransfer = "EVMTransfer"
Expand Down
6 changes: 3 additions & 3 deletions generator/scenarios/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"

"seiload/config"
"seiload/generator/utils"
"seiload/types"
"github.com/sei-protocol/sei-load/config"
"github.com/sei-protocol/sei-load/generator/utils"
"github.com/sei-protocol/sei-load/types"
)

// bigOne is 1 in big.Int.
Expand Down
6 changes: 3 additions & 3 deletions generator/scenarios/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ var scenarioFactories = map[string]ScenarioFactory{
// Auto-generated entries will be added below this line by make generate
// DO NOT EDIT BELOW THIS LINE - AUTO-GENERATED CONTENT
ERC20Conflict: NewERC20ConflictScenario,
ERC20Noop: NewERC20NoopScenario,
ERC20: NewERC20Scenario,
ERC721: NewERC721Scenario,
ERC20Noop: NewERC20NoopScenario,
ERC20: NewERC20Scenario,
ERC721: NewERC721Scenario,

// DO NOT EDIT ABOVE THIS LINE - AUTO-GENERATED CONTENT
}
Expand Down
4 changes: 2 additions & 2 deletions generator/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"

"seiload/config"
loadtypes "seiload/types"
"github.com/sei-protocol/sei-load/config"
loadtypes "github.com/sei-protocol/sei-load/types"
)

type DeployFunc[T any] func(
Expand Down
6 changes: 3 additions & 3 deletions generator/weighted.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package generator

import (
"context"
"github.com/sei-protocol/sei-load/types"
"math/rand"
"seiload/types"
"sync"
)

Expand Down Expand Up @@ -69,7 +69,7 @@ func (w *weightedGenerator) nextGenerator() Generator {
// GenerateN generates n transactions.
func (w *weightedGenerator) GenerateN(n int) []*types.LoadTx {
txs := make([]*types.LoadTx, 0, n)
for i := 0; i < n; i++ {
for range n {
if tx, ok := w.Generate(); ok {
txs = append(txs, tx)
} else {
Expand Down Expand Up @@ -108,7 +108,7 @@ func NewWeightedGenerator(cfgs ...*WeightedCfg) Generator {
}
var weighted []Generator
for _, cfg := range cfgs {
for i := 0; i < cfg.Weight; i++ {
for range cfg.Weight {
weighted = append(weighted, cfg.Generator)
}
}
Expand Down
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
module seiload
module github.com/sei-protocol/sei-load

go 1.24.1
go 1.24.5

require (
github.com/ethereum/go-ethereum v1.16.1
github.com/google/go-cmp v0.5.5
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.9.1
github.com/stretchr/testify v1.10.0
golang.org/x/sync v0.16.0
golang.org/x/time v0.9.0
google.golang.org/protobuf v1.34.2
)

require (
Expand Down Expand Up @@ -33,7 +38,7 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
Expand Down Expand Up @@ -201,6 +203,8 @@ golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
Loading
Loading