Skip to content
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

Manually pack initialValidators for subnetConversion ID hash-preimage #564

Merged
merged 6 commits into from
Sep 20, 2024

Conversation

iansuvak
Copy link
Contributor

Why this should be merged

Addresses #559 partially

How this works

  • Manually packs the subnetConversionData message
  • Makes all other manual packings into abi.encodePacked since that's what they are.

How this was tested

Existing CI

How is this documented

pure
returns (bytes memory)
{
bytes memory res = new bytes(92 + subnetConversionData.initialValidators.length * 88);
Copy link
Collaborator

Choose a reason for hiding this comment

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

From the comment above, it wasn't immediately clear to me why the constant was 92 here rather than 72. Mind adding a comment explaining the address is known to be 20 bytes long?

}
// Pack the address
bytes20 addrBytes = bytes20(subnetConversionData.validatorManagerAddress);
for (uint256 i = 0; i < 20; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Lets use pre-increment like each of the other loops here.

}

return res;
return abi.encodePacked(CODEC_ID, SUBNET_CONVERSION_MESSAGE_TYPE_ID, subnetConversionID);
Copy link
Collaborator

Choose a reason for hiding this comment

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

While we're here, would you mind removing the TODO from line 46 above?

@iansuvak iansuvak self-assigned this Sep 19, 2024
@iansuvak iansuvak merged commit 4149155 into staking-contract Sep 20, 2024
12 checks passed
@michaelkaplan13 michaelkaplan13 deleted the iv-packing branch September 20, 2024 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants