Skip to content

feat: require chain_id be 32 bytes#436

Merged
SuperFluffy merged 13 commits into
mainfrom
superfluffy/chain-id-fixed-array
Nov 24, 2023
Merged

feat: require chain_id be 32 bytes#436
SuperFluffy merged 13 commits into
mainfrom
superfluffy/chain-id-fixed-array

Conversation

@SuperFluffy

@SuperFluffy SuperFluffy commented Sep 27, 2023

Copy link
Copy Markdown
Contributor

Summary

Make chain IDs 32 bytes and construct them from sha256-hashed names.

Background

At the moment chain IDs sent as part of sequence actions can be arbitrarily long. The only place where an upper limit on chain IDs is enforced is in SequencerBlockData, which however is constructed in sequencer relayer and after cometbft/sequencer have come to a consensus over new data.

Using a chain ID of 32 bytes as opposed to a vec is desirable for the these reasons:

  • it allows it to be Copy so that unnecessary vec-allocations are avoided
  • it minimizes the likelihood of rollup namespace clashes because it suggests to use sha256 (although it cannot prevent it)
  • it allows to deterministically calculate the overhead for each transaction allowing to take it into account when calculating tx submission fees

Changes

  • Make ChainId a think wrapper over [u8; 32] (away from Vec<u8>)
  • Move ChainId to astria-proto
  • Reimplement all services in terms of it (sequencer now enforces the length through ChainId being a part of SequenceAction, whereas before it was just a byte vector)
  • Adjust all tests

Testing

All tests still pass or have been adjusted. The snapshot test for calculating the merkle tree hash over the actions had to be updated.

Breaking Changelist

This breaks all public APIs because chain IDs are now expected to be 32 bytes (whereas they were arbitrary length before).

@github-actions github-actions Bot added conductor pertaining to the astria-conductor crate proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate sequencer-relayer pertaining to the astria-sequencer-relayer crate composer pertaining to composer labels Sep 27, 2023
@SuperFluffy SuperFluffy force-pushed the superfluffy/chain-id-fixed-array branch from 59d0b0f to 53014b4 Compare September 27, 2023 14:40
@SuperFluffy SuperFluffy force-pushed the superfluffy/chain-id-fixed-array branch 2 times, most recently from 0d8bc9a to 5e9c9b3 Compare November 22, 2023 16:07
@SuperFluffy SuperFluffy force-pushed the superfluffy/chain-id-fixed-array branch from 5e9c9b3 to c50cd78 Compare November 22, 2023 16:09
@SuperFluffy SuperFluffy changed the title require chain_id be 32 bytes feat: require chain_id be 32 bytes Nov 22, 2023
@SuperFluffy SuperFluffy marked this pull request as ready for review November 22, 2023 17:52

@noot noot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

composer pertaining to composer conductor pertaining to the astria-conductor crate proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate sequencer-relayer pertaining to the astria-sequencer-relayer crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants