-
Notifications
You must be signed in to change notification settings - Fork 687
/
main.go
61 lines (52 loc) · 1.65 KB
/
main.go
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
package main
import (
"flag"
"fmt"
"time"
"github.com/0xPolygonHermez/zkevm-node/test/benchmarks/sequencer/scripts/environment"
"github.com/0xPolygonHermez/zkevm-node/pool"
"github.com/0xPolygonHermez/zkevm-node/test/benchmarks/sequencer/common/params"
"github.com/0xPolygonHermez/zkevm-node/test/benchmarks/sequencer/common/metrics"
"github.com/0xPolygonHermez/zkevm-node/test/benchmarks/sequencer/common/transactions"
uniswaptransfers "github.com/0xPolygonHermez/zkevm-node/test/benchmarks/sequencer/e2e/uniswap-transfers"
uniswap "github.com/0xPolygonHermez/zkevm-node/test/scripts/uniswap/pkg"
)
func main() {
var (
err error
)
numOps := flag.Uint64("num-ops", 200, "The number of operations to run. Default is 200.")
flag.Parse()
if numOps == nil {
panic("numOps is nil")
}
pl, l2Client, auth := environment.Init()
initialCount, err := pl.CountTransactionsByStatus(params.Ctx, pool.TxStatusSelected)
if err != nil {
panic(err)
}
start := time.Now()
deployments := uniswap.DeployContractsAndAddLiquidity(l2Client, auth)
deploymentTxsCount := uniswap.GetExecutedTransactionsCount()
elapsedTimeForDeployments := time.Since(start)
allTxs, err := transactions.SendAndWait(
auth,
l2Client,
pl.GetTxsByStatus,
*numOps,
nil,
&deployments,
uniswaptransfers.TxSender,
)
if err != nil {
panic(err)
}
// Wait for Txs to be selected
err = transactions.WaitStatusSelected(pl.CountTransactionsByStatus, initialCount, *numOps)
if err != nil {
panic(err)
}
metrics.PrintUniswapDeployments(elapsedTimeForDeployments, deploymentTxsCount)
totalGas := metrics.GetTotalGasUsedFromTxs(l2Client, allTxs)
fmt.Println("Total Gas: ", totalGas)
}