|
| 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 := ðtypes.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 | +} |
0 commit comments