Skip to content

refactor(core, proto)!: define app genesis state in proto#1346

Merged
SuperFluffy merged 1 commit intomainfrom
genesis-as-proto
Aug 22, 2024
Merged

refactor(core, proto)!: define app genesis state in proto#1346
SuperFluffy merged 1 commit intomainfrom
genesis-as-proto

Conversation

@SuperFluffy
Copy link
Contributor

@SuperFluffy SuperFluffy commented Aug 4, 2024

Summary

Defines astria.protocol.genesis.v1alpha1.GenesisAppState, replacing the Rust-as-JSON definition.

Background

All protocol relevant Astria types are supposed to be defined in Astria's protobuf spec. With #1285 having redefined the memos as protobuf message, this patch migrates the last type to protobuf spec.

Changes

  • Define astria.protocol.genesis.v1alpha1.GenesisAppState and related protobuf messages
  • Remove the astria-core::sequencer::GenesisState module
  • Update Sequencer in terms of the protobuf type
  • Update all charts and snapshots (especially the genesis template)

Testing

All tests have been updated to use the new types, including snapshot tests. The genesis state is only read at init-chain and does not affect the evaluation of the state machine. Hence no tests should change as long as the same data is passed in (which is reflected by tests-breaking-changes leading to the same hash).

Breaking Changelist

This is a breaking change because an old sequencer would not understand a new (json-formatted) genesis app state and vise versa.

Related issues

Closes #1347

@github-actions github-actions bot added proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate labels Aug 4, 2024
@SuperFluffy SuperFluffy changed the title Genesis as proto refactor(core, proto)!: define app genesis state in proto Aug 4, 2024
@SuperFluffy SuperFluffy marked this pull request as ready for review August 4, 2024 13:32
@SuperFluffy SuperFluffy requested review from a team, joroshiba and noot as code owners August 4, 2024 13:32
@SuperFluffy SuperFluffy added the docker-build used to trigger docker builds on PRs label Aug 4, 2024
@SuperFluffy SuperFluffy marked this pull request as draft August 4, 2024 13:39
@github-actions github-actions bot added the cd label Aug 4, 2024
@SuperFluffy SuperFluffy marked this pull request as ready for review August 4, 2024 15:43
@SuperFluffy SuperFluffy requested a review from a team as a code owner August 4, 2024 15:43
@SuperFluffy SuperFluffy requested a review from Fraser999 August 4, 2024 15:43
import "astria/primitive/v1/types.proto";

message GenesisAppState {
string chain_id = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This field is in preparation of a follow up refactoring sequencer to run init-chain with only the data provided by GenesisAppState.

Copy link
Member

Choose a reason for hiding this comment

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

With this change we wouldn't additionally add a new chainId field into the genesis app_state would we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we'd ultimately end up doing that. I had a dislike for extra configuration data being passed in "from the outside". I would like all genesis settings relevant to the app/sequencer to be in one place.

We would then either enforce that the cometbft chain ID match the sequencer chain ID - or ignore cometbft.

Copy link
Member

@joroshiba joroshiba Aug 20, 2024

Choose a reason for hiding this comment

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

The chain id is already part of the InitChain abci call, so this would be breaking expected abci conventions: https://github.com/cometbft/cometbft/blob/main/spec/abci/abci++_methods.md#initchain

This is inherently already a part of the call, I wouldn't want to override this core part of genesis definition and break the expected ABCI flow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, in my mind these fields would just be duplicates: sequencer would check if its genesis contains the same chain ID that cometbft reports.

Copy link
Contributor

@Fraser999 Fraser999 left a comment

Choose a reason for hiding this comment

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

One tiny nitpick, otherwise LGTM.

#[cfg_attr(
feature = "serde",
derive(serde::Deserialize, serde::Serialize),
serde(try_from = "raw::GenesisAppState", into = "raw::GenesisAppState")
Copy link
Contributor

Choose a reason for hiding this comment

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

I remain not a fan of this approach, but I guess if we do decide to avoid this in the future we can always deal with this instance along with the others :)

{
"address": {{ include "sequencer.address" $value.address }},
"balance": {{ toString $value.balance | replace "\"" "" }}
"balance": {{ include "sequencer.fee" ( toString $value.balance | replace "\"" "" ) }}
Copy link
Member

Choose a reason for hiding this comment

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

This change disallows some hight initial balances that were previously possible. Limited to uint64 balances effectively.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes indeed. For our current use cases this is fine. A followup should fix this. I wonder if there is a way to call out to a helper script using helm?

Copy link
Member

Choose a reason for hiding this comment

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

We could have an init script which does the generation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created #1388 as a followup.

import "astria/primitive/v1/types.proto";

message GenesisAppState {
string chain_id = 1;
Copy link
Member

Choose a reason for hiding this comment

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

With this change we wouldn't additionally add a new chainId field into the genesis app_state would we?

Copy link
Member

@joroshiba joroshiba left a comment

Choose a reason for hiding this comment

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

Approving, with assumption as discussed offline that the test fixes for astria-cli are moved into seperate PR before merge.

@SuperFluffy
Copy link
Contributor Author

Approving, with assumption as discussed offline that the test fixes for astria-cli are moved into seperate PR before merge.

Created a followup in #1392

@SuperFluffy SuperFluffy added this pull request to the merge queue Aug 22, 2024
Merged via the queue into main with commit acff940 Aug 22, 2024
@SuperFluffy SuperFluffy deleted the genesis-as-proto branch August 22, 2024 12:17
steezeburger added a commit that referenced this pull request Aug 22, 2024
* main:
  refactor(core, proto)!: define app genesis state in proto (#1346)
  fix(sequencer): bump penumbra dep to fix ibc state access bug (#1389)
  feat(conductor)!: support disabled celestia auth (#1372)
  fix(sequencer)!: fix block fees (#1343)
  perf(sequencer): add benchmark for prepare_proposal (ENG-660) (#1337)
  fix(proto): fix import name mismatch (#1380)
  fix(ci): enable bridge withdrawer building with tag (#1374)
  feat(sequencer): rewrite memool to have per-account transaction storage and maintenance  (#1323)
  refactor(core, sequencer)!: require that bridge unlock address always be set (#1339)
  fix(sequencer)!: take funds from bridge in ics20 withdrawals (#1344)
  fix(sequencer)!: fix TOCTOU issues by merging check and execution (#1332)
  fix: abci error code (#1280)
  refactor(core): shorten `try_from_block_info_and_data()` (#1371)
  fix(relayer): change `reqwest` for `isahc` in relayer blackbox tests (ENG-699) (#1366)
  fix(conductor): update for celestia-node v0.15.0 (#1367)
  Chore: Upgrade celestia-node to v0.14.1 (#1360)
  chore(charts): fix charts production templates (#1359)
  chore(core, proto): migrate byte slices from Vec to Bytes (#1319)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cd docker-build used to trigger docker builds on PRs proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move genesis app state to proto spec

3 participants