Skip to content

chore!: do not use dynamic types in interfaces#14203

Merged
LHerskind merged 9 commits intonextfrom
md/no-dynamic-types-in-interfaces
Jun 9, 2025
Merged

chore!: do not use dynamic types in interfaces#14203
LHerskind merged 9 commits intonextfrom
md/no-dynamic-types-in-interfaces

Conversation

@Maddiaa0
Copy link
Member

Overview

Rollup:

  • migrates propose interface to use the Header object directly, not bytes as will always know its type
  • re instantes the state commitment type rather than using bytes, as it is a fixed size object

Tests:

  • Load the header from the block snapshots directly, instead of working on the bytes object as we KNOW its type
    • does this by shimming the alphabetical json into the real object in the load block section
    • removes functions that set the header values based on bytes offsets, instead, just manipulate the object directly

Copy link
Member Author

Maddiaa0 commented May 10, 2025

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just delete?

Copy link
Collaborator

@just-mitch just-mitch left a comment

Choose a reason for hiding this comment

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

Beautiful.

Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

Need a rebase for the conflicts but I like it 👍

header = DecoderBase.updateHeaderFeeRecipient(header, address(0));
header = DecoderBase.updateHeaderBaseFee(header, manaBaseFee);
header = DecoderBase.updateHeaderManaUsed(header, manaSpent);
header.lastArchiveRoot = archiveRoot;
Copy link
Contributor

Choose a reason for hiding this comment

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

Much better 🙏

];

const header = ProposedBlockHeader.fromBuffer(Buffer.from(hexToBytes(decodedArgs.header)));
// TODO(md): why is the proposed block header different to the actual block header?
Copy link
Contributor

Choose a reason for hiding this comment

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

Costs I believe. But I agree, foot gun territory

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah it's mainly for reducing cost - it's 316 bytes vs 592 bytes calldata and sha hashing. But if we prefer a more consistent type to reducing a little bit of cost, I can change it back!

},
slotNumber: `0x${block.header.globalVariables.slotNumber.toBuffer().toString('hex').padStart(64, '0')}`,
timestamp: Number(block.header.globalVariables.timestamp.toBigInt()),
slotNumber: block.header.globalVariables.slotNumber.toBigInt(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Would kinda have expected this to blow up. As I recall, we were doing the throwing around because json stringify were not too happy about the bigints 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

In process of rebasing and yes. This completely explodes all over the place.

'uint8, ' + //domainSeperator
'(' +
'bytes32, ' + // archive
'((bytes32,uint32),((bytes32,uint32),(bytes32,uint32),(bytes32,uint32))), ' + // stateReference
Copy link
Contributor

Choose a reason for hiding this comment

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

Thats one ugly looking line 😬 Don't we have any neat way we could get this thing directly from the abis or so instead 🤔 Or guess it would just explode so maybe not too big a deal if easy to spot.

@LHerskind LHerskind changed the base branch from master to next June 5, 2025 10:43
@LHerskind
Copy link
Contributor

LHerskind commented Jun 5, 2025

@Maddiaa0 can you take a look again at this? It seems like it was broken in #14466 because the data generation used the now changed defaults or so 🤷 @sirasistant running into some pain as it have been broken and it only popped up along with his changes.

@LHerskind LHerskind changed the title chore(contracts): do not use dynamic types in interfaces chore!(contracts): do not use dynamic types in interfaces Jun 6, 2025
@LHerskind LHerskind changed the title chore!(contracts): do not use dynamic types in interfaces chore!: do not use dynamic types in interfaces Jun 6, 2025
@LHerskind LHerskind force-pushed the md/no-dynamic-types-in-interfaces branch 3 times, most recently from df9126f to 2370e77 Compare June 6, 2025 11:46
@LHerskind LHerskind added this pull request to the merge queue Jun 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 6, 2025
@LHerskind LHerskind force-pushed the md/no-dynamic-types-in-interfaces branch from 2370e77 to 2626607 Compare June 6, 2025 13:43
@LHerskind
Copy link
Contributor

Throwing this onto the queue again even if @charlielye call it a crime, as it seems like it failed to be merged, but no test failed 😅 so not sure why it did not make it.

Doing a rebase first though.

@LHerskind LHerskind added this pull request to the merge queue Jun 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 6, 2025
@LHerskind LHerskind force-pushed the md/no-dynamic-types-in-interfaces branch from 2626607 to be74542 Compare June 6, 2025 19:01
@LHerskind LHerskind self-assigned this Jun 8, 2025
@LHerskind
Copy link
Contributor

Latest failure on the merge queue was due to a sporadic issue in Anvil that Alex have dealt with in foundry-rs/foundry#10714

@LHerskind LHerskind force-pushed the md/no-dynamic-types-in-interfaces branch from be74542 to 945751e Compare June 8, 2025 22:36
@LHerskind LHerskind enabled auto-merge June 8, 2025 22:36
@LHerskind LHerskind added this pull request to the merge queue Jun 9, 2025
Merged via the queue into next with commit 403b1a8 Jun 9, 2025
5 checks passed
@LHerskind LHerskind deleted the md/no-dynamic-types-in-interfaces branch June 9, 2025 08:17
danielntmd pushed a commit to danielntmd/aztec-packages that referenced this pull request Jul 16, 2025
## Overview

Rollup:
- migrates propose interface to use the Header object directly, not
bytes as will always know its type
- re instantes the state commitment type rather than using bytes, as it
is a fixed size object

Tests:
- Load the header from the block snapshots directly, instead of working
on the bytes object as we KNOW its type
- does this by shimming the alphabetical json into the real object in
the load block section
- removes functions that set the header values based on bytes offsets,
instead, just manipulate the object directly

---------

Co-authored-by: LHerskind <16536249+LHerskind@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants