-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEVMTransferFast.go
More file actions
90 lines (77 loc) · 2.99 KB
/
EVMTransferFast.go
File metadata and controls
90 lines (77 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package scenarios
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/sei-protocol/sei-load/config"
types2 "github.com/sei-protocol/sei-load/types"
)
const EVMTransferFast = "evmtransferfast"
// EVMTransferFastScenario implements the TxGenerator interface for simple ETH transfers
// that only involve values that are multiples of 10^12 and no tipping.
type EVMTransferFastScenario struct {
*ScenarioBase
}
// NewEVMTransferScenario creates a new ETH transfer scenario
func NewEVMTransferFastScenario(cfg config.Scenario) TxGenerator {
scenario := &EVMTransferFastScenario{}
scenario.ScenarioBase = NewScenarioBase(scenario, cfg)
return scenario
}
// Name returns the name of the scenario.
func (s *EVMTransferFastScenario) Name() string {
return EVMTransfer
}
// DeployScenario implements ScenarioDeployer interface - no deployment needed for ETH transfers
func (s *EVMTransferFastScenario) DeployScenario(config *config.LoadConfig, deployer *types2.Account) common.Address {
// No deployment needed for simple ETH transfers
// Return zero address to indicate no contract deployment
return common.Address{}
}
// AttachScenario implements ScenarioDeployer interface - no attachment needed for ETH transfers.
func (s *EVMTransferFastScenario) AttachScenario(config *config.LoadConfig, address common.Address) common.Address {
// No attachment needed for simple ETH transfers
// Return zero address to indicate no contract deployment
return common.Address{}
}
// CreateTransaction EVMTransferFastScenario ScenarioDeployer interface - creates ETH transfer transaction
func (s *EVMTransferFastScenario) CreateTransaction(config *config.LoadConfig, scenario *types2.TxScenario) (*ethtypes.Transaction, error) {
// Create transaction with value transfer
tx := ðtypes.DynamicFeeTx{
Nonce: scenario.Sender.GetAndIncrementNonce(),
To: &scenario.Receiver,
Value: big.NewInt(1_000_000_000_000),
Gas: 21000, // Standard gas limit for ETH transfer
GasTipCap: big.NewInt(0), // 2 gwei
GasFeeCap: big.NewInt(200000000000), // 200 gwei
Data: nil, // No data for simple transfer
}
if s.scenarioConfig.GasPicker != nil {
var err error
tx.Gas, err = s.scenarioConfig.GasPicker.GenerateGas()
if err != nil {
return nil, err
}
}
if s.scenarioConfig.GasTipCapPicker != nil {
gasTipCap, err := s.scenarioConfig.GasTipCapPicker.GenerateGas()
if err != nil {
return nil, err
}
tx.GasTipCap = big.NewInt(int64(gasTipCap))
}
if s.scenarioConfig.GasFeeCapPicker != nil {
gasFeeCap, err := s.scenarioConfig.GasFeeCapPicker.GenerateGas()
if err != nil {
return nil, err
}
tx.GasFeeCap = big.NewInt(int64(gasFeeCap))
}
// Sign the transaction
signer := ethtypes.NewCancunSigner(config.GetChainID())
signedTx, err := ethtypes.SignTx(ethtypes.NewTx(tx), signer, scenario.Sender.PrivKey)
if err != nil {
return nil, err
}
return signedTx, nil
}