Skip to content

Commit 82d4621

Browse files
committed
polycli, 60Mi gas
1 parent bed3f42 commit 82d4621

File tree

8 files changed

+352
-56
lines changed

8 files changed

+352
-56
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ engine-api-poc-test:
190190
ARCH=$(ARCH) bash ./engine-api-poc/run_test.sh
191191
.PHONY: engine-api-poc-test
192192

193-
engine-api-poc-install-test:
194-
ARCH=$(ARCH) npm install -g pandoras-box
193+
engine-api-poc-monitor-test:
194+
ARCH=$(ARCH) polycli monitor
195195
.PHONY: engine-api-poc-test
196196

197197
.PHONY: help

cmd/heimdalld/cmd/commands.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func initCometBFTConfig() *cmtcfg.Config {
118118
customCMTConfig.Consensus.TimeoutPrevoteDelta = 200 * time.Millisecond
119119
customCMTConfig.Consensus.TimeoutPrecommit = 500 * time.Millisecond
120120
customCMTConfig.Consensus.TimeoutPrecommitDelta = 200 * time.Millisecond
121-
customCMTConfig.Consensus.TimeoutCommit = 500 * time.Millisecond
121+
customCMTConfig.Consensus.TimeoutCommit = 1500 * time.Millisecond
122122
customCMTConfig.Consensus.PeerGossipSleepDuration = 25 * time.Millisecond
123123
customCMTConfig.Consensus.PeerQueryMaj23SleepDuration = 200 * time.Millisecond
124124

engine-api-poc/collect-tps/go.mod

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module collect-tps
2+
3+
go 1.23.6
4+
5+
require github.com/ethereum/go-ethereum v1.15.5
6+
7+
require (
8+
github.com/Microsoft/go-winio v0.6.2 // indirect
9+
github.com/StackExchange/wmi v1.2.1 // indirect
10+
github.com/bits-and-blooms/bitset v1.17.0 // indirect
11+
github.com/consensys/bavard v0.1.22 // indirect
12+
github.com/consensys/gnark-crypto v0.14.0 // indirect
13+
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
14+
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
15+
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
16+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
17+
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
18+
github.com/ethereum/go-verkle v0.2.2 // indirect
19+
github.com/go-ole/go-ole v1.3.0 // indirect
20+
github.com/gorilla/websocket v1.4.2 // indirect
21+
github.com/holiman/uint256 v1.3.2 // indirect
22+
github.com/mmcloughlin/addchain v0.4.0 // indirect
23+
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
24+
github.com/supranational/blst v0.3.14 // indirect
25+
github.com/tklauser/go-sysconf v0.3.12 // indirect
26+
github.com/tklauser/numcpus v0.6.1 // indirect
27+
golang.org/x/crypto v0.32.0 // indirect
28+
golang.org/x/sync v0.10.0 // indirect
29+
golang.org/x/sys v0.29.0 // indirect
30+
rsc.io/tmplfunc v0.0.3 // indirect
31+
)

engine-api-poc/collect-tps/go.sum

+179
Large diffs are not rendered by default.

engine-api-poc/collect-tps/main.go

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"flag"
6+
"fmt"
7+
"log"
8+
"math/big"
9+
10+
"github.com/ethereum/go-ethereum/ethclient"
11+
)
12+
13+
func main() {
14+
// Define command-line flags.
15+
rpcURL := flag.String("rpc", "", "RPC URL of Ethereum node")
16+
numBlocks := flag.Int("blocks", 0, "Number of blocks to fetch")
17+
flag.Parse()
18+
19+
if *rpcURL == "" || *numBlocks <= 0 {
20+
flag.Usage()
21+
return
22+
}
23+
24+
// Connect to the Ethereum node.
25+
client, err := ethclient.Dial(*rpcURL)
26+
if err != nil {
27+
log.Fatalf("Failed to connect to the Ethereum client: %v", err)
28+
}
29+
30+
// Retrieve the latest block header.
31+
latestHeader, err := client.HeaderByNumber(context.Background(), nil)
32+
if err != nil {
33+
log.Fatalf("Failed to get the latest block header: %v", err)
34+
}
35+
latestBlockNumber := latestHeader.Number
36+
37+
var totalTxs int
38+
var firstBlockTimestamp uint64 // timestamp of the latest block (first fetched)
39+
var lastBlockTimestamp uint64 // timestamp of the oldest block in our fetched list
40+
41+
// Fetch the latest block first.
42+
block, err := client.BlockByNumber(context.Background(), latestBlockNumber)
43+
if err != nil {
44+
log.Fatalf("Failed to get block %v: %v", latestBlockNumber, err)
45+
}
46+
firstBlockTimestamp = block.Time() // assumed to be in milliseconds
47+
totalTxs += len(block.Transactions())
48+
49+
// Iterate to fetch older blocks.
50+
// Starting from i=1 because the latest block is already fetched.
51+
for i := 1; i < *numBlocks; i++ {
52+
blockNumber := new(big.Int).Sub(latestBlockNumber, big.NewInt(int64(i)))
53+
block, err := client.BlockByNumber(context.Background(), blockNumber)
54+
if err != nil {
55+
log.Fatalf("Failed to get block %v: %v", blockNumber, err)
56+
}
57+
totalTxs += len(block.Transactions())
58+
// Keep updating lastBlockTimestamp; after loop, it will hold the oldest block's timestamp.
59+
lastBlockTimestamp = block.Time()
60+
}
61+
62+
// If only one block is fetched, assign lastBlockTimestamp to firstBlockTimestamp.
63+
if *numBlocks == 1 {
64+
lastBlockTimestamp = firstBlockTimestamp
65+
}
66+
67+
// Calculate the overall time interval between the first and last block.
68+
// Note: the latest block is expected to have a larger timestamp.
69+
var timeInterval uint64
70+
if firstBlockTimestamp > lastBlockTimestamp {
71+
timeInterval = firstBlockTimestamp - lastBlockTimestamp
72+
} else {
73+
timeInterval = lastBlockTimestamp - firstBlockTimestamp
74+
}
75+
76+
// Convert interval from milliseconds to seconds.
77+
timeIntervalSeconds := float64(timeInterval) / 1000.0
78+
79+
// Calculate TPS (transactions per second)
80+
var tps float64
81+
if timeIntervalSeconds > 0 {
82+
tps = float64(totalTxs) / timeIntervalSeconds
83+
} else {
84+
tps = 0
85+
}
86+
87+
fmt.Printf("Fetched %d blocks (from block %s to %s)\n", *numBlocks,
88+
new(big.Int).Sub(latestBlockNumber, big.NewInt(int64(*numBlocks-1))).String(),
89+
latestBlockNumber.String())
90+
fmt.Printf("Total transactions: %d\n", totalTxs)
91+
fmt.Printf("Time interval between first (latest) and last (oldest) block: %d ms (%.2f seconds)\n", timeInterval, timeIntervalSeconds)
92+
fmt.Printf("TPS (transactions per second): %.2f\n", tps)
93+
}

engine-api-poc/docker-compose.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ services:
5454
"--authrpc.addr", "0.0.0.0",
5555
"--authrpc.vhosts", "any",
5656
"--nodekeyhex", $ERIGON_NODE_PK_0,
57+
"--miner.gaslimit", "60000000"
5758
]
5859
healthcheck:
5960
test: curl --fail -X POST http://127.0.0.1:8545/health --data '{}' || exit 1
@@ -81,6 +82,7 @@ services:
8182
"--authrpc.addr", "0.0.0.0",
8283
"--authrpc.vhosts", "any",
8384
"--nodekeyhex", $ERIGON_NODE_PK_1,
85+
"--miner.gaslimit", "60000000",
8486
"--staticpeers", "enode://$ERIGON_NODE_P2P_KEY_0@erigon-0:30303"
8587
]
8688
healthcheck:
@@ -110,6 +112,7 @@ services:
110112
"--authrpc.addr", "0.0.0.0",
111113
"--authrpc.vhosts", "any",
112114
"--nodekeyhex", $ERIGON_NODE_PK_2,
115+
"--miner.gaslimit", "60000000",
113116
"--staticpeers", "enode://$ERIGON_NODE_P2P_KEY_0@erigon-0:30303,enode://$ERIGON_NODE_P2P_KEY_1@erigon-1:30303"
114117
]
115118
healthcheck:
@@ -139,6 +142,7 @@ services:
139142
"--authrpc.addr", "0.0.0.0",
140143
"--authrpc.vhosts", "any",
141144
"--nodekeyhex", $ERIGON_NODE_PK_3,
145+
"--miner.gaslimit", "60000000",
142146
"--staticpeers", "enode://$ERIGON_NODE_P2P_KEY_0@erigon-0:30303,enode://$ERIGON_NODE_P2P_KEY_1@erigon-1:30303"
143147
]
144148
healthcheck:
@@ -167,6 +171,7 @@ services:
167171
"--authrpc.addr", "0.0.0.0",
168172
"--authrpc.vhosts", "any",
169173
"--nodekeyhex", $ERIGON_NODE_PK_4,
174+
"--miner.gaslimit", "60000000",
170175
"--staticpeers", "enode://$ERIGON_NODE_P2P_KEY_0@erigon-0:30303,enode://$ERIGON_NODE_P2P_KEY_1@erigon-1:30303"
171176
]
172177
healthcheck:

engine-api-poc/genesis.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@
1818
},
1919
"alloc": {
2020
"0x67b1d87101671b127f5f8714789C7192f7ad340e": {
21-
"balance": "0xEEBE0B40E8000000"
21+
"balance": "0xFFFEEBE0B40E8000000"
2222
},
2323
"0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B": {
24-
"balance": "0xEEBE0B40E8000000"
24+
"balance": "0xFFFEEBE0B40E8000000"
2525
},
2626
"0xf62242f0e2adcd6fba36292a073824fc7746d9bc": {
27-
"balance": "0xEEBE0B40E8000000"
27+
"balance": "0xFFFEEBE0B40E8000000"
2828
},
2929
"0x5f8fcc809e7deeea64a4001dac406ae89040afba": {
30-
"balance": "0xEEBE0B40E8000000"
30+
"balance": "0xFFFEEBE0B40E8000000"
3131
},
3232
"0xef5a53a5d3c2f51bd7aafede41045d129cd0aeef": {
33-
"balance": "0xEEBE0B40E8000000"
33+
"balance": "0xFFFEEBE0B40E8000000"
3434
},
3535
"0xb595514c011fb452a9a47ea038890d886e60e276": {
36-
"balance": "0xEEBE0B40E8000000"
36+
"balance": "0xFFFEEBE0B40E8000000"
3737
},
3838
"0xa1cb34f649ac6eb78734f24405a3fc935d2bf643": {
39-
"balance": "0xEEBE0B40E8000000"
39+
"balance": "0xFFFEEBE0B40E8000000"
4040
}
4141
},
4242
"coinbase": "0x0000000000000000000000000000000000000000",
4343
"difficulty": "0x01",
4444
"extraData": "",
45-
"gasLimit": "0x17D7840",
45+
"gasLimit": "0x3938700",
4646
"nonce": "0x1234",
4747
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
4848
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
49-
"timestamp": "1695902100"
49+
"timestamp": "1741807556"
5050
}

engine-api-poc/run_test.sh

+32-44
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,40 @@ folder="./engine-api-poc/test-output"
1212
rm -rf "$folder"
1313
mkdir "$folder"
1414

15-
echo "Starting pandoras-box processes..."
15+
# Check if polycli is installed and working
16+
if ! polycli version > /dev/null 2>&1; then
17+
echo "- polycli is not installed or not working properly. Please install polycli to continue."
18+
echo "- You can do this via this link: https://github.com/0xPolygon/polygon-cli?tab=readme-ov-file#install"
19+
exit 1
20+
fi
21+
22+
# Check if polycli is installed and working
23+
if ! cast --version > /dev/null 2>&1; then
24+
echo "- cast is not installed or not working properly. Please install cast to continue."
25+
echo "- You can do this via this link: https://github.com/foundry-rs/foundry?tab=readme-ov-file#installation"
26+
exit 1
27+
fi
28+
29+
echo "Starting testing rountines..."
1630

17-
# Run 10 iterations
18-
for iteration in {1..10}; do
19-
echo "=== Iteration $iteration ==="
2031

21-
# Launch 5 processes concurrently
22-
for i in {0..4}; do
23-
prefix=$((i + 8))
24-
port="${prefix}545"
25-
mnemonic="${mnemonics[i]}"
26-
temp_file="./engine-api-poc/test-output/temp_${i}.json"
27-
28-
# Run pandoras-box, writing its output to a temporary file
29-
pandoras-box -url "http://localhost:${port}" \
30-
-m "$mnemonic" \
31-
-t 200 -b 50 -o "$temp_file" > /dev/null 2>&1 &
32-
33-
pid=$!
34-
echo "Started pandoras-box on port $port with PID: $pid"
35-
done
32+
# Launch 5 processes concurrently
33+
for i in {0..4}; do
34+
prefix=$((i + 8))
35+
port="${prefix}545"
36+
mnemonic="${mnemonics[i]}"
37+
out_file="./engine-api-poc/test-output/test_${i}.json"
38+
private_key=$(cast wallet private-key "${mnemonics[i]}")
3639

37-
# Wait for all background processes to finish for this iteration
38-
wait
39-
echo "All processes finished for iteration $iteration."
40-
41-
# Append the new results to each cumulative JSON output file
42-
for i in {0..4}; do
43-
cumulative_file="./engine-api-poc/test-output/myOutput_${i}.json"
44-
temp_file="./engine-api-poc/test-output/temp_${i}.json"
45-
46-
# If the cumulative file doesn't exist, create it as an empty JSON array
47-
if [ ! -f "$cumulative_file" ]; then
48-
echo "[]" > "$cumulative_file"
49-
fi
50-
51-
# Append the new result to the cumulative array using jq
52-
jq --argjson new "$(cat "$temp_file")" '. += [$new]' "$cumulative_file" > "${cumulative_file}.tmp" \
53-
&& mv "${cumulative_file}.tmp" "$cumulative_file"
54-
55-
# Remove the temporary file
56-
rm -f "$temp_file"
57-
done
58-
59-
echo "Aggregated results for iteration $iteration."
60-
echo ""
40+
polycli loadtest -r "http://localhost:${port}" \
41+
--private-key "${private_key}" --verbosity 100 \
42+
--mode "t" --requests 50000 --rate-limit 350 > "$out_file" 2>&1 &
43+
44+
pid=$!
45+
echo "Started polycli on port $port with PID: $pid"
6146
done
6247

63-
echo "All iterations complete."
48+
# Wait for all background processes to finish for this iteration
49+
wait
50+
echo "All processes finished"
51+

0 commit comments

Comments
 (0)