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(proto, sequencer)!: use full IBC ICS20 denoms instead of IDs #1209

Merged
merged 9 commits into from
Jun 27, 2024

Conversation

SuperFluffy
Copy link
Member

Summary

Replaces the bare asset ID bytes by full IBC ICS20 denoms.

Background

Bare denom IDs in public APIs are difficult to understand. While IBC ICS20 denoms are prescribed to either contain strings of the form port/channel/denom or ibc/<sha256-hex>, due to protobuf-to-json mapping protobuf bytes are always encoded as base64. With #1181 we parse denoms into either of the two forms and can thus allow users to provide assets as protobuf strings which are then parsed by sequencer.

In addition, since denominations of the form port/channel/denom can always be converted to ibc/<sha256>, this allows for more elegant fetching of denom-related data from storage.

Changes

  • Replace protobuf message fields from bytes to string (mostly in transaction/action types):
    • bytes asset_id -> string asset
    • bytes fee_asset_id -> string fee_asset
    • repeated bytes fee_asset_ids -> repeated string fee_assets (and rename AllowedFeeAssetIdsResponse to AllowedFeeAsssetsRersponse)
  • Update all affected checked astria-core types to parse the asset strings to astria_core::primitive::v1::asset::Denoms instead of [u8; 32] arrays.
  • Remove the astria_core::primitive::v1::asset::Id type
  • Remove all notion of a default native asset type from astria_core (all services and tests are now expected to have their own notion of asset types; either through config/genesis or by defining their tests accordingly)
  • Update all sequencer StateWriteExt and StateWriteRead types that read or write assets to disk:
    • instead of writing asset::Ids (in practice [u8; 32]), they now write asset::IbcPrefixed
    • make all trait methods generic over a parameter TAsset: Into<asset::IbcPrefixed> which allows fetching data using astria::Denoms, astria::TracePrefixed, or astria::IbcPrecixed
  • update all storage keys that used IDs to use ibc-prefixed denoms instead
  • provide snapshot tests for all such storage keys
  • update all astria-cli subcommands that construct actions with assets to have arguments --asset or --fee-asset (using "nria" as the default if not provided)
  • update astria-composer to have an config env var ASTRIA_COMPOSER_FEE_ASSET

Testing

All tests that involve fees were updated and pass again.

Breaking Changelist

  • This is a network breaking change because all transaction/action messages that took bytes now take strings

@SuperFluffy SuperFluffy requested review from a team, joroshiba and noot as code owners June 26, 2024 14:13
@github-actions github-actions bot added proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate composer pertaining to composer cd labels Jun 26, 2024
@SuperFluffy SuperFluffy marked this pull request as draft June 26, 2024 14:14
@SuperFluffy SuperFluffy marked this pull request as ready for review June 26, 2024 14:15
@@ -69,6 +69,9 @@ ASTRIA_COMPOSER_METRICS_HTTP_LISTENER_ADDR="127.0.0.1:9000"
# The address at which the gRPC collector and health services are listening.
ASTRIA_COMPOSER_GRPC_ADDR="0.0.0.0:0"

# The asset to use for paying for transactions submitted to sequencer.
ASTRIA_COMPOSER_FEE_ASSET="nria"
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this sets the payment fee for all actions to nria - the same as was previously hard coded. This might not be exactly what we want to do in the future.

seq_action: SequenceAction,
},
#[error(transparent)]
FinishedQueueFull(Box<FinishedQueueFull>),
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 is a clippy-fix because the variant was too big.

@@ -1,19 +1,22 @@
#[cfg(test)]
Copy link
Member Author

Choose a reason for hiding this comment

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

The structure of these modules was extremely strange and needed to be updated.

@@ -96,18 +99,16 @@ fn preprocess_request(params: &[(String, String)]) -> anyhow::Result<asset::Id,
..response::Query::default()
});
};
let asset_id = hex::decode(asset_id)
let asset = <[u8; 32]>::from_hex(asset_id)
Copy link
Member Author

Choose a reason for hiding this comment

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

I am torn on this one. The request still has the form asset/denom/<hex>. So asset/denom/ibc/<hex> isn't allowed, and neither is asset/denom/port/channel/base.

@@ -369,7 +369,7 @@ pub struct SequenceAction {
pub rollup_id: RollupId,
pub data: Vec<u8>,
/// asset to use for fee payment.
pub fee_asset_id: asset::Id,
pub fee_asset: asset::Denom,
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should enforce for all actions that if the denom trace is >32 bytes, it must be in ibc/ prefixed form. ie don't accept traces that are excessively long as it's a DOS vector

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean we should enforce this when parsing string fee_asset -> asset::Denom? Technically the upper limit for protobuf payloads is 4MB and sequencer just rejects payloads >200KB, but I can add an additional limit on the type of course.

@SuperFluffy
Copy link
Member Author

@noot I have changed all keys that in some form employ ibc-prefixed assets to use the hex encoded sha256 in e968da4, in a new module crate::storage_keys::hunks::Asset.

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, great change!

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.

approval for infra components

@SuperFluffy SuperFluffy added this pull request to the merge queue Jun 27, 2024
Merged via the queue into main with commit f05e829 Jun 27, 2024
38 checks passed
@SuperFluffy SuperFluffy deleted the superfluffy/no-ids branch June 27, 2024 18:41
steezeburger added a commit that referenced this pull request Jul 11, 2024
* main: (27 commits)
  refactor(sequencer): fix prepare proposal metrics (#1211)
  refactor(bridge-withdrawer): move generated contract bindings to crate (#1237)
  fix(sequencer) fix wrong metric and remove unused metric (#1240)
  feat(sequencer): implement transaction fee query (#1196)
  chore(cli)!: remove unmaintained rollup subcommand (#1235)
  release(sequencer): 0.14.1 patch release (#1233)
  feat(sequencer-utils): generate example genesis state (#1224)
  feat(sequencer): implement abci query for bridge account info (#1189)
  feat(charts): bridge-withdrawer, smoke test, various chart improvements (#1141)
  chore(charts): update for new geth update (#1226)
  chore(chart)!: dusk-8 chart version updates (#1223)
  release(conductor): fix conductor release version (#1222)
  release: dusk-8 versions (#1219)
  fix(core): revert `From` ed25519_consensus types for crypto mod (#1220)
  Refactor(chart, sequencer): restructure sequencer chart, adjust configs (#1193)
  refactor(withdrawer): read from block subscription stream and get events on each block (#1207)
  feat(core): implement with verification key for address builder and crypto improvements (#1218)
  feat(proto, sequencer)!: use full IBC ICS20 denoms instead of IDs (#1209)
  chore(chart): update evm chart for new prefix field (#1214)
  chore: bump penumbra deps (#1216)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cd composer pertaining to composer 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.

3 participants