Skip to content

Commit b32592d

Browse files
Add evm transfer noop (#16)
- transfer of 0 to sender's account (minimum action)
1 parent 6f144d0 commit b32592d

2 files changed

Lines changed: 69 additions & 1 deletion

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package scenarios
2+
3+
import (
4+
"math/big"
5+
6+
"github.com/ethereum/go-ethereum/common"
7+
ethtypes "github.com/ethereum/go-ethereum/core/types"
8+
9+
"github.com/sei-protocol/sei-load/config"
10+
types2 "github.com/sei-protocol/sei-load/types"
11+
)
12+
13+
const EVMTransferNoop = "evmtransfernoop"
14+
15+
// EVMTransferNoopScenario implements the TxGenerator interface for simple ETH transfers of 0 value
16+
type EVMTransferNoopScenario struct {
17+
*ScenarioBase
18+
}
19+
20+
// NewEVMTransferNoopScenario creates a new ETH transfer scenario
21+
func NewEVMTransferNoopScenario() TxGenerator {
22+
scenario := &EVMTransferNoopScenario{}
23+
scenario.ScenarioBase = NewScenarioBase(scenario)
24+
return scenario
25+
}
26+
27+
// Name returns the name of the scenario.
28+
func (s *EVMTransferNoopScenario) Name() string {
29+
return EVMTransfer
30+
}
31+
32+
// DeployScenario implements ScenarioDeployer interface - no deployment needed for ETH transfers
33+
func (s *EVMTransferNoopScenario) DeployScenario(config *config.LoadConfig, deployer *types2.Account) common.Address {
34+
// No deployment needed for simple ETH transfers
35+
// Return zero address to indicate no contract deployment
36+
return common.Address{}
37+
}
38+
39+
// AttachScenario implements ScenarioDeployer interface - no attachment needed for ETH transfers.
40+
func (s *EVMTransferNoopScenario) AttachScenario(config *config.LoadConfig, address common.Address) common.Address {
41+
// No attachment needed for simple ETH transfers
42+
// Return zero address to indicate no contract deployment
43+
return common.Address{}
44+
}
45+
46+
// CreateTransaction implements ScenarioDeployer interface - creates ETH transfer transaction
47+
func (s *EVMTransferNoopScenario) CreateTransaction(config *config.LoadConfig, scenario *types2.TxScenario) (*ethtypes.Transaction, error) {
48+
// Create transaction with value transfer
49+
tx := &ethtypes.DynamicFeeTx{
50+
Nonce: scenario.Nonce,
51+
To: &scenario.Sender.Address,
52+
Value: big.NewInt(0),
53+
Gas: 21000, // Standard gas limit for ETH transfer
54+
GasTipCap: big.NewInt(2000000000), // 2 gwei
55+
GasFeeCap: big.NewInt(20000000000), // 20 gwei
56+
Data: nil, // No data for simple transfer
57+
}
58+
59+
// Sign the transaction
60+
signer := ethtypes.NewCancunSigner(config.GetChainID())
61+
signedTx, err := ethtypes.SignTx(ethtypes.NewTx(tx), signer, scenario.Sender.PrivKey)
62+
if err != nil {
63+
return nil, err
64+
}
65+
66+
return signedTx, nil
67+
}

generator/scenarios/factory.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ type ScenarioFactory func() TxGenerator
88
// scenarioFactories maps scenario names to their factory functions
99
var scenarioFactories = map[string]ScenarioFactory{
1010
// Manual entries for non-contract scenarios
11-
EVMTransfer: NewEVMTransferScenario,
11+
EVMTransfer: NewEVMTransferScenario,
12+
EVMTransferNoop: NewEVMTransferNoopScenario,
1213

1314
// Auto-generated entries will be added below this line by make generate
1415
// DO NOT EDIT BELOW THIS LINE - AUTO-GENERATED CONTENT

0 commit comments

Comments
 (0)