Skip to content

Commit 424ac29

Browse files
committed
fix: fix code style
Signed-off-by: Chen Kai <281165273grape@gmail.com>
1 parent 9ce21ac commit 424ac29

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

bench/state_transition/process_block.zig

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fn ProcessBlockHeaderBench(comptime fork: ForkSeq) type {
4242
cloned.deinit();
4343
allocator.destroy(cloned);
4444
}
45+
4546
state_transition.processBlockHeader(
4647
fork,
4748
allocator,
@@ -110,6 +111,7 @@ fn ProcessExecutionPayloadBench(comptime fork: ForkSeq) type {
110111
cloned.deinit();
111112
allocator.destroy(cloned);
112113
}
114+
113115
const external_data = BlockExternalData{ .execution_payload_status = .valid, .data_availability_status = .available };
114116
state_transition.processExecutionPayload(
115117
fork,
@@ -137,6 +139,7 @@ fn ProcessRandaoBench(comptime fork: ForkSeq, comptime opts: BenchOpts) type {
137139
cloned.deinit();
138140
allocator.destroy(cloned);
139141
}
142+
140143
state_transition.processRandao(
141144
fork,
142145
cloned.config,
@@ -162,6 +165,7 @@ fn ProcessEth1DataBench(comptime fork: ForkSeq) type {
162165
cloned.deinit();
163166
allocator.destroy(cloned);
164167
}
168+
165169
state_transition.processEth1Data(
166170
fork,
167171
cloned.state.castToFork(fork),
@@ -182,6 +186,7 @@ fn ProcessOperationsBench(comptime fork: ForkSeq, comptime opts: BenchOpts) type
182186
cloned.deinit();
183187
allocator.destroy(cloned);
184188
}
189+
185190
state_transition.processOperations(
186191
fork,
187192
allocator,
@@ -208,6 +213,7 @@ fn ProcessSyncAggregateBench(comptime fork: ForkSeq, comptime opts: BenchOpts) t
208213
cloned.deinit();
209214
allocator.destroy(cloned);
210215
}
216+
211217
state_transition.processSyncAggregate(
212218
fork,
213219
allocator,
@@ -232,6 +238,7 @@ fn ProcessBlockBench(comptime fork: ForkSeq, comptime opts: BenchOpts) type {
232238
cloned.deinit();
233239
allocator.destroy(cloned);
234240
}
241+
235242
const external_data = BlockExternalData{ .execution_payload_status = .valid, .data_availability_status = .available };
236243
state_transition.processBlock(
237244
fork,
@@ -433,6 +440,7 @@ fn ProcessBlockSegmentedBench(comptime fork: ForkSeq) type {
433440
pub fn main() !void {
434441
var gpa: std.heap.DebugAllocator(.{}) = .init;
435442
defer std.debug.assert(gpa.deinit() == .ok);
443+
436444
const allocator = gpa.allocator();
437445
const stdout = std.io.getStdOut().writer();
438446
var pool = try Node.Pool.init(allocator, 10_000_000);
@@ -479,9 +487,18 @@ pub fn main() !void {
479487
return error.NoBenchmarkRan;
480488
}
481489

482-
fn runBenchmark(comptime fork: ForkSeq, allocator: std.mem.Allocator, pool: *Node.Pool, stdout: anytype, state_bytes: []const u8, block_bytes: []const u8, chain_config: config.ChainConfig) !void {
490+
fn runBenchmark(
491+
comptime fork: ForkSeq,
492+
allocator: std.mem.Allocator,
493+
pool: *Node.Pool,
494+
stdout: anytype,
495+
state_bytes: []const u8,
496+
block_bytes: []const u8,
497+
chain_config: config.ChainConfig,
498+
) !void {
483499
var signed_beacon_block = try loadBlock(fork, allocator, block_bytes);
484500
defer signed_beacon_block.deinit(allocator);
501+
485502
const any_block = signed_beacon_block.beaconBlock();
486503
const block = any_block.castToFork(.full, fork);
487504
const body = block.body();

bench/state_transition/process_epoch.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ fn ProcessEth1DataResetBench(comptime fork: ForkSeq) type {
147147
cloned.deinit();
148148
allocator.destroy(cloned);
149149
}
150+
150151
var cache = EpochTransitionCache.init(allocator, cloned.config, cloned.getEpochCache(), cloned.state) catch unreachable;
151152
defer cache.deinit();
153+
152154
state_transition.processEth1DataReset(
153155
fork,
154156
cloned.state.castToFork(fork),
@@ -168,8 +170,10 @@ fn ProcessPendingDepositsBench(comptime fork: ForkSeq) type {
168170
cloned.deinit();
169171
allocator.destroy(cloned);
170172
}
173+
171174
var cache = EpochTransitionCache.init(allocator, cloned.config, cloned.getEpochCache(), cloned.state) catch unreachable;
172175
defer cache.deinit();
176+
173177
state_transition.processPendingDeposits(
174178
fork,
175179
allocator,
@@ -192,8 +196,10 @@ fn ProcessPendingConsolidationsBench(comptime fork: ForkSeq) type {
192196
cloned.deinit();
193197
allocator.destroy(cloned);
194198
}
199+
195200
var cache = EpochTransitionCache.init(allocator, cloned.config, cloned.getEpochCache(), cloned.state) catch unreachable;
196201
defer cache.deinit();
202+
197203
state_transition.processPendingConsolidations(
198204
fork,
199205
cloned.getEpochCache(),
@@ -214,8 +220,10 @@ fn ProcessEffectiveBalanceUpdatesBench(comptime fork: ForkSeq) type {
214220
cloned.deinit();
215221
allocator.destroy(cloned);
216222
}
223+
217224
var cache = EpochTransitionCache.init(allocator, cloned.config, cloned.getEpochCache(), cloned.state) catch unreachable;
218225
defer cache.deinit();
226+
219227
_ = state_transition.processEffectiveBalanceUpdates(
220228
fork,
221229
allocator,
@@ -237,8 +245,10 @@ fn ProcessSlashingsResetBench(comptime fork: ForkSeq) type {
237245
cloned.deinit();
238246
allocator.destroy(cloned);
239247
}
248+
240249
var cache = EpochTransitionCache.init(allocator, cloned.config, cloned.getEpochCache(), cloned.state) catch unreachable;
241250
defer cache.deinit();
251+
242252
state_transition.processSlashingsReset(
243253
fork,
244254
cloned.getEpochCache(),
@@ -259,8 +269,10 @@ fn ProcessRandaoMixesResetBench(comptime fork: ForkSeq) type {
259269
cloned.deinit();
260270
allocator.destroy(cloned);
261271
}
272+
262273
var cache = EpochTransitionCache.init(allocator, cloned.config, cloned.getEpochCache(), cloned.state) catch unreachable;
263274
defer cache.deinit();
275+
264276
state_transition.processRandaoMixesReset(
265277
fork,
266278
cloned.state.castToFork(fork),
@@ -280,8 +292,10 @@ fn ProcessHistoricalSummariesUpdateBench(comptime fork: ForkSeq) type {
280292
cloned.deinit();
281293
allocator.destroy(cloned);
282294
}
295+
283296
var cache = EpochTransitionCache.init(allocator, cloned.config, cloned.getEpochCache(), cloned.state) catch unreachable;
284297
defer cache.deinit();
298+
285299
state_transition.processHistoricalSummariesUpdate(
286300
fork,
287301
cloned.state.castToFork(fork),
@@ -301,6 +315,7 @@ fn ProcessParticipationFlagUpdatesBench(comptime fork: ForkSeq) type {
301315
cloned.deinit();
302316
allocator.destroy(cloned);
303317
}
318+
304319
state_transition.processParticipationFlagUpdates(
305320
fork,
306321
cloned.state.castToFork(fork),
@@ -319,6 +334,7 @@ fn ProcessSyncCommitteeUpdatesBench(comptime fork: ForkSeq) type {
319334
cloned.deinit();
320335
allocator.destroy(cloned);
321336
}
337+
322338
state_transition.processSyncCommitteeUpdates(
323339
fork,
324340
allocator,
@@ -339,8 +355,10 @@ fn ProcessProposerLookaheadBench(comptime fork: ForkSeq) type {
339355
cloned.deinit();
340356
allocator.destroy(cloned);
341357
}
358+
342359
var cache = EpochTransitionCache.init(allocator, cloned.config, cloned.getEpochCache(), cloned.state) catch unreachable;
343360
defer cache.deinit();
361+
344362
state_transition.processProposerLookahead(
345363
fork,
346364
allocator,
@@ -609,6 +627,7 @@ fn ProcessEpochSegmentedBench(comptime fork: ForkSeq) type {
609627
pub fn main() !void {
610628
var gpa: std.heap.DebugAllocator(.{}) = .init;
611629
defer std.debug.assert(gpa.deinit() == .ok);
630+
612631
const allocator = gpa.allocator();
613632
const stdout = std.io.getStdOut().writer();
614633
var pool = try Node.Pool.init(allocator, 10_000_000);
@@ -653,11 +672,13 @@ fn runBenchmark(
653672
chain_config: config.ChainConfig,
654673
) !void {
655674
defer state_transition.deinitStateTransition();
675+
656676
var beacon_state: ?*AnyBeaconState = try loadState(fork, allocator, pool, state_bytes);
657677
defer if (beacon_state) |state| {
658678
state.deinit();
659679
allocator.destroy(state);
660680
};
681+
661682
try stdout.print("State deserialized: slot={}, validators={}\n", .{
662683
try beacon_state.?.slot(),
663684
try beacon_state.?.validatorsCount(),
@@ -667,6 +688,7 @@ fn runBenchmark(
667688

668689
const pubkey_index_map = try PubkeyIndexMap.init(allocator);
669690
defer pubkey_index_map.deinit();
691+
670692
const index_pubkey_cache = try allocator.create(state_transition.Index2PubkeyCache);
671693
index_pubkey_cache.* = state_transition.Index2PubkeyCache.init(allocator);
672694
defer {

0 commit comments

Comments
 (0)