Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deploy-destruct scenario #5

Merged
merged 2 commits into from
Jul 31, 2024
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
29 changes: 18 additions & 11 deletions cmd/spamoor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ import (
)

type CliArgs struct {
verbose bool
trace bool
rpchosts []string
rpchostsFile string
privkey string
seed string
verbose bool
trace bool
rpchosts []string
rpchostsFile string
privkey string
seed string
refillAmount uint64
refillBalance uint64
refillInterval uint64
}

func main() {
Expand All @@ -35,6 +38,9 @@ func main() {
flags.StringVar(&cliArgs.rpchostsFile, "rpchost-file", "", "File with a list of RPC hosts to send transactions to.")
flags.StringVarP(&cliArgs.privkey, "privkey", "p", "", "The private key of the wallet to send funds from.")
flags.StringVarP(&cliArgs.seed, "seed", "s", "", "The child wallet seed.")
flags.Uint64Var(&cliArgs.refillAmount, "refill-amount", 5, "Amount of ETH to fund/refill each child wallet with.")
flags.Uint64Var(&cliArgs.refillBalance, "refill-balance", 2, "Min amount of ETH each child wallet should hold before refilling.")
flags.Uint64Var(&cliArgs.refillInterval, "refill-interval", 300, "Interval for child wallet rbalance check and refilling if needed (in sec).")

flags.Parse(os.Args)

Expand Down Expand Up @@ -98,11 +104,12 @@ func main() {
}

testerConfig := &tester.TesterConfig{
RpcHosts: rpcHosts,
WalletPrivkey: cliArgs.privkey,
WalletCount: 100,
WalletPrefund: utils.EtherToWei(uint256.NewInt(5)),
WalletMinfund: utils.EtherToWei(uint256.NewInt(2)),
RpcHosts: rpcHosts,
WalletPrivkey: cliArgs.privkey,
WalletCount: 100,
WalletPrefund: utils.EtherToWei(uint256.NewInt(cliArgs.refillAmount)),
WalletMinfund: utils.EtherToWei(uint256.NewInt(cliArgs.refillBalance)),
RefillInterval: cliArgs.refillInterval,
}
err := scenario.Init(testerConfig)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions scenarios/blob-combined/blob_combined.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *Scenario) Flags(flags *pflag.FlagSet) error {

func (s *Scenario) Init(testerCfg *tester.TesterConfig) error {
if s.options.TotalCount == 0 && s.options.Throughput == 0 {
return fmt.Errorf("neither total count nor throughput limit set, must define at least one of them")
return fmt.Errorf("neither total count nor throughput limit set, must define at least one of them (see --help for list of all flags)")
}

if s.options.MaxWallets > 0 {
Expand Down Expand Up @@ -305,7 +305,7 @@ func (s *Scenario) awaitTx(txIdx uint64, tx *types.Transaction, client *txbuilde
totalAmount := new(big.Int).Add(tx.Value(), feeAmount)
wallet.SubBalance(totalAmount)

gweiTotalFee := new(big.Int).Div(totalAmount, big.NewInt(1000000000))
gweiTotalFee := new(big.Int).Div(feeAmount, big.NewInt(1000000000))
gweiBaseFee := new(big.Int).Div(effectiveGasPrice, big.NewInt(1000000000))
gweiBlobFee := new(big.Int).Div(blobGasPrice, big.NewInt(1000000000))

Expand Down
6 changes: 3 additions & 3 deletions scenarios/blob-conflicting/blob_conflicting.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s *Scenario) Flags(flags *pflag.FlagSet) error {

func (s *Scenario) Init(testerCfg *tester.TesterConfig) error {
if s.options.TotalCount == 0 && s.options.Throughput == 0 {
return fmt.Errorf("neither total count nor throughput limit set, must define at least one of them")
return fmt.Errorf("neither total count nor throughput limit set, must define at least one of them (see --help for list of all flags)")
}

if s.options.MaxWallets > 0 {
Expand Down Expand Up @@ -286,7 +286,7 @@ func (s *Scenario) sendBlobTx(txIdx uint64) (*types.Transaction, *txbuilder.Clie
return tx1, client, nil
}

func (s *Scenario) awaitTxs(txIdx uint64, tx *types.Transaction, client *txbuilder.Client, wallet *txbuilder.Wallet, replacementIdx uint64, txLabel string) {
func (s *Scenario) awaitTxs(txIdx uint64, tx *types.Transaction, client *txbuilder.Client, wallet *txbuilder.Wallet, _ uint64, txLabel string) {
var awaitConfirmation bool = true
defer func() {
awaitConfirmation = false
Expand Down Expand Up @@ -320,7 +320,7 @@ func (s *Scenario) awaitTxs(txIdx uint64, tx *types.Transaction, client *txbuild
totalAmount := new(big.Int).Add(tx.Value(), feeAmount)
wallet.SubBalance(totalAmount)

gweiTotalFee := new(big.Int).Div(totalAmount, big.NewInt(1000000000))
gweiTotalFee := new(big.Int).Div(feeAmount, big.NewInt(1000000000))
gweiBaseFee := new(big.Int).Div(effectiveGasPrice, big.NewInt(1000000000))
gweiBlobFee := new(big.Int).Div(blobGasPrice, big.NewInt(1000000000))

Expand Down
4 changes: 2 additions & 2 deletions scenarios/blob-replacements/blob_replacements.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *Scenario) Flags(flags *pflag.FlagSet) error {

func (s *Scenario) Init(testerCfg *tester.TesterConfig) error {
if s.options.TotalCount == 0 && s.options.Throughput == 0 {
return fmt.Errorf("neither total count nor throughput limit set, must define at least one of them")
return fmt.Errorf("neither total count nor throughput limit set, must define at least one of them (see --help for list of all flags)")
}

if s.options.MaxWallets > 0 {
Expand Down Expand Up @@ -305,7 +305,7 @@ func (s *Scenario) awaitTx(txIdx uint64, tx *types.Transaction, client *txbuilde
totalAmount := new(big.Int).Add(tx.Value(), feeAmount)
wallet.SubBalance(totalAmount)

gweiTotalFee := new(big.Int).Div(totalAmount, big.NewInt(1000000000))
gweiTotalFee := new(big.Int).Div(feeAmount, big.NewInt(1000000000))
gweiBaseFee := new(big.Int).Div(effectiveGasPrice, big.NewInt(1000000000))
gweiBlobFee := new(big.Int).Div(blobGasPrice, big.NewInt(1000000000))

Expand Down
4 changes: 2 additions & 2 deletions scenarios/blobs/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s *Scenario) Flags(flags *pflag.FlagSet) error {

func (s *Scenario) Init(testerCfg *tester.TesterConfig) error {
if s.options.TotalCount == 0 && s.options.Throughput == 0 {
return fmt.Errorf("neither total count nor throughput limit set, must define at least one of them")
return fmt.Errorf("neither total count nor throughput limit set, must define at least one of them (see --help for list of all flags)")
}

if s.options.MaxWallets > 0 {
Expand Down Expand Up @@ -273,7 +273,7 @@ func (s *Scenario) awaitTx(txIdx uint64, tx *types.Transaction, client *txbuilde
totalAmount := new(big.Int).Add(tx.Value(), feeAmount)
wallet.SubBalance(totalAmount)

gweiTotalFee := new(big.Int).Div(totalAmount, big.NewInt(1000000))
gweiTotalFee := new(big.Int).Div(feeAmount, big.NewInt(1000000000))
gweiBaseFee := new(big.Int).Div(effectiveGasPrice, big.NewInt(1000000))
gweiBlobFee := new(big.Int).Div(blobGasPrice, big.NewInt(1000000))

Expand Down
117 changes: 117 additions & 0 deletions scenarios/deploy-destruct/contract/DeployTest.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "seed",
"type": "uint256"
}
],
"name": "TestSeed",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "childAddresses",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "childCode",
"outputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "childIdx",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "count",
"type": "uint256"
}
],
"name": "clean",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "counter",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "addr",
"type": "address"
},
{
"internalType": "bool",
"name": "destroy",
"type": "bool"
}
],
"name": "notify",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "seed",
"type": "uint256"
}
],
"name": "test",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
]
Loading
Loading