Skip to content

update to arraylist implementation of ssz list#221

Merged
g11tech merged 4 commits intoblockblaz:mainfrom
chetanyb:boundedArray2arrayList
Sep 22, 2025
Merged

update to arraylist implementation of ssz list#221
g11tech merged 4 commits intoblockblaz:mainfrom
chetanyb:boundedArray2arrayList

Conversation

@chetanyb
Copy link
Copy Markdown
Contributor

Summary

Migrate SSZ types from BoundedArray to ArrayList for dynamic memory management

Changes

  • Updated SSZ dependency to latest version with ArrayList support
  • Migrated BeamState lists (justifications_roots, justifications_validators, historical_block_hashes, justified_slots) from stack-allocated BoundedArray to heap-allocated ArrayList
  • Fixed memory management in flattenJustifications() - now properly deinits existing lists before reinitializing to prevent memory leaks
  • Updated BeamState.deinit() to clean up all ArrayList fields without requiring allocator parameter

@chetanyb chetanyb requested a review from g11tech September 22, 2025 00:19
@g11tech g11tech changed the title BoundedArray -> ArrayList SSZ integration update to arraylist implementation of ssz list Sep 22, 2025
// the init to max size will fill the list and works because the list doesn't store delimiter
// else one needs to go through the append route
.justifications_validators = try ssz.utils.Bitlist(params.HISTORICAL_ROOTS_LIMIT * params.VALIDATOR_REGISTRY_LIMIT).init(params.HISTORICAL_ROOTS_LIMIT * params.VALIDATOR_REGISTRY_LIMIT),
.justifications_validators = try ssz.utils.Bitlist(params.HISTORICAL_ROOTS_LIMIT * params.VALIDATOR_REGISTRY_LIMIT).init(std.testing.allocator),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original test case had some data inserted into it, so add some data

break :blk roots;
},
.justifications_validators = try ssz.utils.Bitlist(params.HISTORICAL_ROOTS_LIMIT * params.VALIDATOR_REGISTRY_LIMIT).init(params.HISTORICAL_ROOTS_LIMIT * params.VALIDATOR_REGISTRY_LIMIT),
.justifications_validators = try ssz.utils.Bitlist(params.HISTORICAL_ROOTS_LIMIT * params.VALIDATOR_REGISTRY_LIMIT).init(std.testing.allocator),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fill some data into this list

},
.signature = [_]u8{2} ** SIGSIZE,
};
defer block.message.body.attestations.deinit();
Copy link
Copy Markdown
Member

@g11tech g11tech Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a deinit fn to block and do this deinit there and call block.deinit

@g11tech g11tech added the stf label Sep 22, 2025
// even beam run command results into core dumped
.HISTORICAL_ROOTS_LIMIT = 1 << 10, // 2^18 = 262144
.VALIDATOR_REGISTRY_LIMIT = 1 << 4, // 2^12 = 4096
.HISTORICAL_ROOTS_LIMIT = 1 << 18, // 2^18 = 262144
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restored to original limits as per spec since lists aren't stack allocated anymore

@chetanyb chetanyb force-pushed the boundedArray2arrayList branch from 1feab49 to 877c3b7 Compare September 22, 2025 18:54
@chetanyb chetanyb force-pushed the boundedArray2arrayList branch from 877c3b7 to 3af4b61 Compare September 22, 2025 19:15
@g11tech g11tech merged commit 2b60b08 into blockblaz:main Sep 22, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants