-
Notifications
You must be signed in to change notification settings - Fork 86
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(core, proto)!: add bech32m addresses #1124
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are the app_hashes changing? I would expect the data hash to change but not the app_hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It contains a SudoAddressChangeAction
, which itself contains new_address: Address
. Hence the change.
… bytes and bech32m fields mutually exclusive
After the review comments I received from @joroshiba and @noot I went back to the drawing board and made the
All services assume a prefix of |
@@ -147,28 +140,28 @@ impl VerificationKey { | |||
// Silence the clippy lint because the function body asserts that the panic | |||
// cannot happen. | |||
#[allow(clippy::missing_panics_doc)] | |||
pub fn address(&self) -> &Address { | |||
self.address.get_or_init(|| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the memoization for the time being. We can bring it back later.
@@ -961,7 +961,7 @@ impl App { | |||
/// Executes a signed transaction. | |||
#[instrument(name = "App::execute_transaction", skip_all, fields( | |||
signed_transaction_hash = %telemetry::display::base64(&signed_tx.sha256_of_proto_encoding()), | |||
sender = %signed_tx.verification_key().address(), | |||
sender = %telemetry::display::base64(&signed_tx.verification_key().address_bytes()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this display as bech32?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't right now because all we have is the sender (and hence the verification key), but no prefix, and hence no bech32m.
I am not sure how to address this at this point.
@@ -62,13 +62,16 @@ impl PartialOrd for TransactionPriority { | |||
pub(crate) struct EnqueuedTransaction { | |||
tx_hash: [u8; 32], | |||
signed_tx: Arc<SignedTransaction>, | |||
address: Address, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems weird, is this for caching purposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So signed_tx.verification_key().address()
was used somewhere in this mempool module - I would need to read the code again, but basically I have replaced all instances of .address()
by this Address
. Maybe that's actually unnecessary and the new address_bytes()
would be sufficient.
* main: fix: ignore RUSTSEC-2021-0139 (#1171) chore(sequencer-relayer)!: remove functionality to restrict relaying blocks to only those proposed by a given validator (#1168) chore(metrics): update `metric_name` macro to handle a collection of names (#1163) fix(bridge-withdrawer): skip linting generated contract code (#1172) fix(core, sequencer): prefix removal source non-refund ics20 packet (#1162) chore(docs): add sequencer-relayer doc to specs (#1126) feat(bridge-withdrawer): sync logic (#1165) chore(withdrawer): replace contracts with `astria-bridge-contracts` submodule (#1164) feat(sequencer)!: implement bridge sudo and withdrawer addresses (#1142) feat(sequencer): implement refund to rollup logic upon ics20 transfer refund (#1161) feat(bridge-withdrawer): bridge withdrawer startup (#1160) feat(core, proto)!: add bech32m addresses (#1124) feat(withdrawer): bridged ERC20 token withdrawals (#1149) feat(sequencer-relayer)!: add chain IDs for sequencer and Celestia to config env vars (#1063) test(bridge-withdrawer): add submitter tests (#1133) chore: bump penumbra deps (#1159) feat(sequencer): implement `bridge/account_last_tx_hash` abci query (#1158) fix(withdrawer): use block subscription in batcher; send to destination_chain_address (#1157) fix(withdrawer): update AstriaWithdrawer to check that withdrawal value is sufficient (#1148) chore(ci): build bridge withdrawer images (#1156)
## 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. --------- Co-authored-by: Jordan Oroshiba <jordan@astria.org>
## Summary Removes the non-bech32m address bytes field. ## Background The change introduced in #1124 is a breaking change that ripples through the rest of the Astria stack. While in principle we can keep the non-bech32m address around for backward compatibility, in practice it's cleaner to regenesis. ## Changes - Remove `astria.primitive.v1.Address.inner`, reserving its number and name. ## Testing Updates and removed all unit tests. All blackbox tests that use addresses in some form still work. ## Breaking Changelist Since this is protobuf breaking it is also network breaking.
## Summary Added a lazily-initialized field `address_bytes` to `VerificationKey`. ## Background Testing showed that `address_bytes` was called multiple times on a given `VerificationKey` (up to 11 times in some cases). Each time the key's bytes were being hashed, so this change ensures that hashing only happens once for a given verification key instance. Note that this was implemented previously in #1111 and was then reverted in #1124. However, when reverted, the manual impls of `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash` were left as-is, as were the unit tests for these. Hence this PR doesn't need to make any changes to these trait impls or tests. ## Changes - Added `address_bytes: OnceLock<[u8; ADDRESS_LEN]>` to `VerificiationKey`. ## Testing No new tests required. ## Related Issues Closes #1351.
## Summary Added a lazily-initialized field `address_bytes` to `VerificationKey`. ## Background Testing showed that `address_bytes` was called multiple times on a given `VerificationKey` (up to 11 times in some cases). Each time the key's bytes were being hashed, so this change ensures that hashing only happens once for a given verification key instance. Note that this was implemented previously in #1111 and was then reverted in #1124. However, when reverted, the manual impls of `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash` were left as-is, as were the unit tests for these. Hence this PR doesn't need to make any changes to these trait impls or tests. ## Changes - Added `address_bytes: OnceLock<[u8; ADDRESS_LEN]>` to `VerificiationKey`. ## Testing No new tests required. ## Related Issues Closes #1351.
Summary
Adds bech32m addresses.
Background
bech32m encoded addresses are the de-facto standard in cosmos. By using a
"astria"
prefix (in the human readable prefix, bech32 HRP sense) we align astria with the rest of the cosmos ecosystem.Changes
bech32m
toastria.primitive.v1.Address
astria.primitive.v1.Address.inner
std::fmt::Display for Address
to use bech32m encodingAddress
in terms of its protobuf-json mappingAddress:try_from_raw
constructor to allow ingesting protobufs that have theirinner
orbech32m
or populated.inner
andbech32m
are mutually exclusive, only one may be set.inner
set are assumed to have prefix"astria"
.AddressBuilder
type state builder that requires both a prefix and array/byte slice be set."astria"
set everywhereSignedTransaction::address
method that constructs an address from the verification key and thechain_id
stored in the unsigned transaction'stransaction_params::chain_id
.TransactionParams
enforcing that chain IDs are have hrp compatible names.Testing
Address
type only havebech32m
populatedAddress
invariants (mainly maximum length of prefix + fixed-size address always being encodeable to a string)Breaking Changelist
This patch is marked breaking because the sequencer snapshot tests are triggered. They all contain actions that themselves contain protobuf address. This patch is backward but not forward compatible.
Related Issues
closes #943