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

feat(sequencer)!: allow configuring base address prefix #1201

Merged
merged 41 commits into from
Jun 26, 2024

Conversation

SuperFluffy
Copy link
Member

@SuperFluffy SuperFluffy commented Jun 20, 2024

Summary

This patch allows configuring the base address prefix in sequencer's genesis file and enforces this prefix in all actions.

Similar to the native fee, the base prefix is set once during init-chain and is then available globally and never changed.

Background

#1124 changed astria addresses from opaque bytes to bech32m addresses, which themselves are encoded as strings on the wire. Where previously sequencer implicitly assumed that all addresses were "astria" prefixed bech32m addresses, this is now enforced.

Changes

  • Update sequencer GenesisState to use the canonical serde implementation of all astria-core types.
  • Add a field .address_prefixes.base to the GenesisState.
  • Ensure that all addresses in GenesisState are consistenst with the prefix.
  • Inject the genesis base address prefix into sequencer's global state.
  • Add a check for the global address prefix to all sequencer actions that carry a astria.primitive.v1.core.Address (this is done via AppHandler::check_stateless). These are specifically:
    • TransferAction
    • SudoAddressChangeAction
    • BridgeLockAction
    • BridgeSudoChangeAction
    • BridgeUnlockAction
    • InitBridgeAccountAction
    • IbcRelayerChangeAction
  • Slightly change all storage keys that use addresses to be explicit about using bytes and provide snapshot tests (specifically in accounts::state_ext, bridge::state_ext, ibc::state_ext)
  • Removed: unsigned transaction parameters no longer require a bech32m chain ID name
  • Update composer, bridge-withdrawer to have a configurable address prefix:
    • ASTRIA_BRIDGE_WITHDRAWER_SEQUENCER_ADDRESS_PREFIX
    • ASTRIA_COMPOSER_SEQUENCER_ADDRESS_PREFIX
  • Update all astria-cli commands to take a configurable prefix.

Testing

  • Update all tests and ensure they still run.
  • Add tests for genesis construction.
  • Add genesis snapshot tests.
  • Add snapshots tests for IBC denoms (to accompany the genesis snapshot)

Breaking Changelist

This change is breaking at the network level requiring sequencer re-genesis. Non-bech32m addresses in actions are now rejected, as well as addresses that have a prefix other then the one set at genesis. In addition, the storage key for all collections involving an address have changed.

@github-actions github-actions bot added sequencer pertaining to the astria-sequencer crate composer pertaining to composer labels Jun 20, 2024
@SuperFluffy SuperFluffy marked this pull request as ready for review June 20, 2024 16:36
@SuperFluffy SuperFluffy requested review from a team, joroshiba and noot as code owners June 20, 2024 16:36
@SuperFluffy SuperFluffy changed the title feat(sequencer!): allow configuring base address prefix feat(sequencer)!: allow configuring base address prefix Jun 20, 2024
@SuperFluffy SuperFluffy requested a review from a team as a code owner June 21, 2024 13:47
@github-actions github-actions bot added the cd label Jun 21, 2024
@SuperFluffy SuperFluffy force-pushed the superfluffy/bech32-aware-sequencer branch from 5efa37c to 3c67150 Compare June 21, 2024 21:21
@@ -119,6 +122,8 @@ fn event_to_bridge_unlock(
Ok(Action::BridgeUnlock(action))
}

// FIXME: Get this to work for now, but replace this with a builder.
Copy link
Collaborator

@noot noot Jun 24, 2024

Choose a reason for hiding this comment

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

i'm refactoring/removing this function in my next PR, so this is fine to leave

Copy link
Collaborator

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good to me!

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.

A general note on composer & withdrawer is that we could get the prefix from genesis fetch.

Some nits through out but mostly looks good, didn't comment on each repeat but the stateless checks all just say "invalid" when they are specifically invalid because of wrong prefix.

Note that the ibc name stuff seems unrelated, is that artifact from other work?

crates/astria-cli/src/cli/sequencer.rs Show resolved Hide resolved
crates/astria-sequencer/src/accounts/state_ext.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/address/mod.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/authority/action.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/bridge/bridge_lock_action.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/bridge/state_ext.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/ibc/state_ext.rs Outdated Show resolved Hide resolved
@SuperFluffy SuperFluffy enabled auto-merge June 24, 2024 20:32
@SuperFluffy SuperFluffy disabled auto-merge June 24, 2024 20:54
Copy link
Member Author

Choose a reason for hiding this comment

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

This and the other snapshots have changed because the base prefix is now written to app storage.

# NOTE - the following address matches the privKey that funds the sequencer-faucet
- address: 00d75b270542084a54fcf0d0f6eab0402982d156
balance: "333333333333333333"
- address: 1c0c490f1b5528d8173c5de46d131160e4b2c0c3
Copy link
Collaborator

Choose a reason for hiding this comment

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

just to confirm - does the genesis support both hex and bech32 now?

Copy link
Member

Choose a reason for hiding this comment

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

So the chart is indifferent, when you run in dev mode it builds the old genesis that is intended to work with the latest release. When you run in dev mode it builds the new genesis which works on this PR and latest after this is merged.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah to chime in: this is only for CI. The sequencer genesis itself only supports proper bech32m addresses.

Ok(())
}

#[cfg(not(test))]
Copy link
Member

Choose a reason for hiding this comment

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

Can we get a follow up issue?

@SuperFluffy
Copy link
Member Author

@joroshiba #1208 for a follow-up for the cfg(not(test)) business. It doens't explicitly mention it, but that change would make the compile-time shenanigans unnecessary.

@SuperFluffy SuperFluffy added this pull request to the merge queue Jun 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 26, 2024
@SuperFluffy SuperFluffy force-pushed the superfluffy/bech32-aware-sequencer branch from cf7437d to 435c9ac Compare June 26, 2024 13:55
@SuperFluffy SuperFluffy enabled auto-merge June 26, 2024 13:56
@SuperFluffy SuperFluffy added this pull request to the merge queue Jun 26, 2024
Merged via the queue into main with commit d35271d Jun 26, 2024
38 checks passed
@SuperFluffy SuperFluffy deleted the superfluffy/bech32-aware-sequencer branch June 26, 2024 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bridging cd composer pertaining to composer sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants