-
Notifications
You must be signed in to change notification settings - Fork 12
chore: use treeview getAll in inactivity_scores #193
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
Changes from all commits
3ee0cc3
4b2fd98
1bd6cab
8c2b1dd
b80bba7
1e37e44
011ea81
064c413
a13ffb1
ab58507
1876bfe
600beaa
a689e5f
fbbb1a3
71b16d8
a951492
8616e50
9f754ff
5a7c541
d64dee1
31bf8b3
4aa4969
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ const Node = @import("persistent_merkle_tree").Node; | |
|
|
||
| pub fn processInactivityUpdates( | ||
| comptime fork: ForkSeq, | ||
| allocator: std.mem.Allocator, | ||
| config: *const BeaconConfig, | ||
| epoch_cache: *const EpochCache, | ||
| state: *BeaconState(fork), | ||
|
|
@@ -30,12 +31,16 @@ pub fn processInactivityUpdates( | |
| const FLAG_PREV_TARGET_ATTESTER_UNSLASHED = attester_status_utils.FLAG_PREV_TARGET_ATTESTER_UNSLASHED; | ||
| const FLAG_ELIGIBLE_ATTESTER = attester_status_utils.FLAG_ELIGIBLE_ATTESTER; | ||
|
|
||
| // TODO for TreeView, we may want to convert to value and back | ||
| var inactivity_scores = try state.inactivityScores(); | ||
| try inactivity_scores.commit(); | ||
| const inactivity_scores_values = try inactivity_scores.getAll(allocator); | ||
| defer allocator.free(inactivity_scores_values); | ||
|
|
||
| std.debug.assert(flags.len <= inactivity_scores_values.len); | ||
| for (0..flags.len) |i| { | ||
| const flag = flags[i]; | ||
| if (hasMarkers(flag, FLAG_ELIGIBLE_ATTESTER)) { | ||
| var inactivity_score = try inactivity_scores.get(i); | ||
| var inactivity_score = inactivity_scores_values[i]; | ||
|
Comment on lines
+39
to
+43
|
||
|
|
||
| const prev_inactivity_score = inactivity_score; | ||
| if (hasMarkers(flag, FLAG_PREV_TARGET_ATTESTER_UNSLASHED)) { | ||
|
|
@@ -66,6 +71,7 @@ test "processInactivityUpdates - sanity" { | |
|
|
||
| try processInactivityUpdates( | ||
| .electra, | ||
| allocator, | ||
| test_state.cached_state.config, | ||
| test_state.cached_state.getEpochCache(), | ||
| test_state.cached_state.state.castToFork(.electra), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve readability and make resource management clearer, the repository style guide recommends visually separating resource allocation and deallocation blocks with newlines.
References