Skip to content

Commit 1c1957d

Browse files
committed
fix: simulator config on devnet
1 parent a91c49a commit 1c1957d

3 files changed

Lines changed: 185 additions & 49 deletions

File tree

configs/mainnet-cross-section.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
payloads:
2+
- name: Simulator
3+
id: base-mainnet-simulation
4+
type: simulator
5+
account_loaded: 12.382
6+
account_deleted: 0.0127
7+
accounts_updated: 4.6117
8+
accounts_created: 0.16
9+
storage_loaded: 49.405
10+
storage_deleted: 0.4651
11+
storage_updated: 9.439
12+
storage_created: 2
13+
code_size_loaded: 662473.15
14+
num_contracts_loaded: 4.330
15+
avg_gas_used: 35000000
16+
calls_per_block: 100
17+
opcodes:
18+
EXP: 626.30
19+
KECCAK256: 29.21
20+
precompiles:
21+
bls12381MapG2: 0.6981
22+
ecrecover: 0.0733
23+
bls12381G1Add: 0.0244
24+
bls12381G1MultiExp: 0.0218
25+
- name: account create (full block)
26+
id: account-create-full-block
27+
type: simulator
28+
accounts_created: 100
29+
- name: account update (full block)
30+
id: account-update-full-block
31+
type: simulator
32+
accounts_updated: 100
33+
- name: storage create (full block)
34+
id: storage-create-full-block
35+
type: simulator
36+
storage_created: 100
37+
- name: storage update (full block)
38+
id: storage-update-full-block
39+
type: simulator
40+
storage_updated: 100
41+
- name: ecrecover (full block)
42+
id: ecrecover-full-block
43+
type: simulator
44+
precompiles:
45+
ecrecover: 100
46+
- name: sha256hash (full block)
47+
id: sha256hash-full-block
48+
type: simulator
49+
precompiles:
50+
sha256hash: 100
51+
- name: ripemd160hash (full block)
52+
id: ripemd160hash-full-block
53+
type: simulator
54+
precompiles:
55+
ripemd160hash: 100
56+
- name: bigModExp (full block)
57+
id: bigModExp-full-block
58+
type: simulator
59+
precompiles:
60+
bigModExp: 100
61+
- name: bn256Add (full block)
62+
id: bn256Add-full-block
63+
type: simulator
64+
precompiles:
65+
bn256Add: 100
66+
- name: bn256ScalarMul (full block)
67+
id: bn256ScalarMul-full-block
68+
type: simulator
69+
precompiles:
70+
bn256ScalarMul: 100
71+
- name: bn256Pairing (full block)
72+
id: bn256Pairing-full-block
73+
type: simulator
74+
precompiles:
75+
bn256Pairing: 100
76+
- name: blake2F (full block)
77+
id: blake2F-full-block
78+
type: simulator
79+
precompiles:
80+
blake2F: 100
81+
- name: bls12381G1Add (full block)
82+
id: bls12381G1Add-full-block
83+
type: simulator
84+
precompiles:
85+
bls12381G1Add: 100
86+
- name: bls12381G1MultiExp (full block)
87+
id: bls12381G1MultiExp-full-block
88+
type: simulator
89+
precompiles:
90+
bls12381G1MultiExp: 100
91+
- name: bls12381G2Add (full block)
92+
id: bls12381G2Add-full-block
93+
type: simulator
94+
precompiles:
95+
bls12381G2Add: 100
96+
- name: bls12381G2MultiExp (full block)
97+
id: bls12381G2MultiExp-full-block
98+
type: simulator
99+
precompiles:
100+
bls12381G2MultiExp: 100
101+
- name: bls12381Pairing (full block)
102+
id: bls12381Pairing-full-block
103+
type: simulator
104+
precompiles:
105+
bls12381Pairing: 100
106+
- name: bls12381MapG1 (full block)
107+
id: bls12381MapG1-full-block
108+
type: simulator
109+
precompiles:
110+
bls12381MapG1: 100
111+
- name: bls12381MapG2 (full block)
112+
id: bls12381MapG2-full-block
113+
type: simulator
114+
precompiles:
115+
bls12381MapG2: 100
116+
- name: p256Verify (full block)
117+
id: p256Verify-full-block
118+
type: simulator
119+
precompiles:
120+
p256Verify: 100
121+
122+
benchmarks:
123+
- name: Base mainnet snapshot test
124+
description: Base mainnet snapshot test
125+
metrics:
126+
warning:
127+
sequencer/latency/get_payload: 1000000000
128+
validator/latency/new_payload: 1000000000
129+
error:
130+
sequencer/latency/get_payload: 1500000000
131+
validator/latency/new_payload: 1500000000
132+
variables:
133+
- type: payload
134+
values:
135+
- base-mainnet-simulation
136+
- account-create-full-block
137+
# - account-update-full-block
138+
- storage-create-full-block
139+
- storage-update-full-block
140+
- ecrecover-full-block
141+
- sha256hash-full-block
142+
- ripemd160hash-full-block
143+
- bigModExp-full-block
144+
- bn256Add-full-block
145+
- bn256ScalarMul-full-block
146+
- bn256Pairing-full-block
147+
- blake2F-full-block
148+
- bls12381G1Add-full-block
149+
- bls12381G1MultiExp-full-block
150+
- bls12381G2Add-full-block
151+
- bls12381G2MultiExp-full-block
152+
- bls12381Pairing-full-block
153+
- bls12381MapG1-full-block
154+
- bls12381MapG2-full-block
155+
- p256Verify-full-block
156+
- type: node_type
157+
values:
158+
# - reth
159+
- geth
160+
- type: num_blocks
161+
value: 20
162+
- type: gas_limit
163+
values:
164+
- 25000000
165+
- 50000000
166+
- 75000000
167+
- 100000000

contracts/src/Simulator.sol

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -65,75 +65,51 @@ contract Simulator {
6565
}
6666

6767
function num_storage_slots_needed(SimulatorConfig calldata config) public view returns (uint256) {
68-
return current_storage_slot_index +
69-
config.load_storage +
70-
config.update_storage;
68+
return current_storage_slot_index + config.load_storage + config.update_storage;
7169
}
7270

7371
function num_accounts_needed(SimulatorConfig calldata config) public view returns (uint160) {
74-
return current_address_index +
75-
config.load_accounts +
76-
config.update_accounts;
72+
return current_address_index + config.load_accounts + config.update_accounts;
7773
}
7874

7975
function run(SimulatorConfig calldata config) public {
8076
require(
81-
current_storage_slot_index +
82-
config.load_storage +
83-
config.update_storage <=
84-
num_storage_initialized,
77+
current_storage_slot_index + config.load_storage + config.update_storage <= num_storage_initialized,
8578
"Not enough storage slots to load/update"
8679
);
8780

8881
require(
89-
current_address_index +
90-
config.load_accounts +
91-
config.update_accounts <=
92-
num_address_initialized,
82+
current_address_index + config.load_accounts + config.update_accounts <= num_address_initialized,
9383
"Not enough accounts to load/update"
9484
);
9585

9686
// load storage slots using SLOAD in a loop. Ensure we're loading a unique storage slot each time.
9787
uint256 total = 0;
98-
for (
99-
uint256 i = current_storage_slot_index;
100-
i < current_storage_slot_index + config.load_storage;
101-
i++
102-
) {
103-
total += uint256(IExtsload(address(0x498581fF718922c3f8e6A244956aF099B2652b2b)).extsload(bytes32(i)));
88+
for (uint256 i = current_storage_slot_index; i < current_storage_slot_index + config.load_storage; i++) {
89+
assembly {
90+
total := add(total, sload(i))
91+
}
10492
}
10593
current_storage_slot_index += config.load_storage;
10694

10795
// starting from current_storage_slot_index, update existing storage slots in a loop (using SSTORE)
108-
for (
109-
uint256 i = current_storage_slot_index;
110-
i < current_storage_slot_index + config.update_storage;
111-
i++
112-
) {
96+
for (uint256 i = current_storage_slot_index; i < current_storage_slot_index + config.update_storage; i++) {
11397
assembly {
11498
sstore(i, i)
11599
}
116100
}
117101
current_storage_slot_index += config.update_storage;
118102

119103
// starting from num_storage_initialized, create new storage slots in a loop (using SSTORE)
120-
for (
121-
uint256 i = num_storage_initialized;
122-
i < num_storage_initialized + config.create_storage;
123-
i++
124-
) {
104+
for (uint256 i = num_storage_initialized; i < num_storage_initialized + config.create_storage; i++) {
125105
assembly {
126106
sstore(i, i)
127107
}
128108
}
129109
num_storage_initialized += config.create_storage;
130110

131111
// starting from 0, delete storage slots in a loop (using SSTORE)
132-
for (
133-
uint256 i = num_storage_deleted;
134-
i < num_storage_deleted + config.delete_storage;
135-
i++
136-
) {
112+
for (uint256 i = num_storage_deleted; i < num_storage_deleted + config.delete_storage; i++) {
137113
assembly {
138114
sstore(i, 0)
139115
}
@@ -161,17 +137,11 @@ contract Simulator {
161137
current_address_index += config.update_accounts;
162138

163139
for (uint256 i = 0; i < config.precompiles.length; i++) {
164-
run_precompile(
165-
config.precompiles[i].precompile_address,
166-
config.precompiles[i].num_calls
167-
);
140+
run_precompile(config.precompiles[i].precompile_address, config.precompiles[i].num_calls);
168141
}
169142
}
170143

171-
function run_precompile(
172-
address precompile_address,
173-
uint256 num_calls
174-
) private {
144+
function run_precompile(address precompile_address, uint256 num_calls) private {
175145
if (precompile_address == address(1)) {
176146
run_ecrecover(num_calls);
177147
} else if (precompile_address == address(2)) {
@@ -211,7 +181,6 @@ contract Simulator {
211181
}
212182
}
213183

214-
215184
function hashLongString() public pure returns (string memory) {
216185
string memory longInput = string(
217186
abi.encodePacked(
@@ -287,7 +256,7 @@ contract Simulator {
287256
function run_modexp(uint256 num_iterations, bool use_long) private {
288257
bytes memory base = "8";
289258
bytes memory exponent = "9";
290-
259+
291260
for (uint256 i = 0; i < num_iterations; i++) {
292261
if (use_long) {
293262
bytes memory modulus = abi.encodePacked(hashLongString(), i);
@@ -367,7 +336,8 @@ contract Simulator {
367336

368337
for (uint256 i = 0; i < num_iterations; i++) {
369338
uint32 rounds = uint32(i);
370-
(bool ok,) = address(9).staticcall(abi.encodePacked(rounds, h[0], h[1], m[0], m[1], m[2], m[3], t[0], t[1], f));
339+
(bool ok,) =
340+
address(9).staticcall(abi.encodePacked(rounds, h[0], h[1], m[0], m[1], m[2], m[3], t[0], t[1], f));
371341
require(ok, "Blake2f failed");
372342
}
373343
}
@@ -449,7 +419,6 @@ contract Simulator {
449419
}
450420
}
451421

452-
453422
function run_g2msm(uint256 num_iterations) private {
454423
bytes32[8] memory p1;
455424
p1[0] = 0x00000000000000000000000000000000103121a2ceaae586d240843a39896732;
@@ -486,7 +455,7 @@ contract Simulator {
486455
p1[1] = 0xc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb;
487456
p1[2] = 0x0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4;
488457
p1[3] = 0xfcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1;
489-
458+
490459
bytes32[8] memory p2;
491460
p2[0] = 0x00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051;
492461
p2[1] = 0xc6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8;

runner/payload/simulator/abi/Simulator.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)