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

bump astria and penumbra deps #5

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 37 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ ibc-proto = { version = "0.41.0", features = ["serde"] }
ibc-telemetry = { version = "0.26.4", path = "../telemetry", optional = true }
ibc-relayer-types = { version = "0.26.4", path = "../relayer-types", features = ["mocks"] }

astria-core = { git = "https://github.com/astriaorg/astria", rev = "21cc874ca499c1f4afa8576f8640a9c8deac7690" }
astria-sequencer-client = { git = "https://github.com/astriaorg/astria", rev = "21cc874ca499c1f4afa8576f8640a9c8deac7690", features = [ "http" ] }
astria-core = { git = "https://github.com/astriaorg/astria", rev = "e73db6304c0146c9891a77fbc24b92d49f3eb211" }
astria-sequencer-client = { git = "https://github.com/astriaorg/astria", rev = "e73db6304c0146c9891a77fbc24b92d49f3eb211", features = [ "http" ] }
ed25519-consensus = "2.1.0"
ibc-types = "0.12.0"
jmt = "0.6"
penumbra-ibc = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.69.1", default-features = false }
penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.69.1" }
penumbra-ibc = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.78.0", default-features = false }
penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.78.0" }
pbjson-types = "0.6"

subtle-encoding = "0.5"
Expand Down
48 changes: 35 additions & 13 deletions crates/relayer/src/chain/astria/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,16 @@ impl AstriaEndpoint {

async fn broadcast_messages(&mut self, tracked_msgs: TrackedMsgs) -> Result<TxResponse, Error> {
use astria_core::{
generated::sequencer::v1::Ics20Withdrawal as RawIcs20Withdrawal,
sequencer::v1::{
transaction::{
action::Ics20Withdrawal,
Action,
},
Address,
crypto::{
SigningKey,
VerificationKey,
},
generated::protocol::transaction::v1alpha1::Ics20Withdrawal as RawIcs20Withdrawal,
primitive::v1::Address,
protocol::transaction::v1alpha1::{
action::Ics20Withdrawal,
Action,
TransactionParams,
UnsignedTransaction,
},
};
Expand Down Expand Up @@ -270,19 +273,28 @@ impl AstriaEndpoint {

let signing_key: ed25519_consensus::SigningKey =
(*self.get_key()?.signing_key().as_bytes()).into(); // TODO cache this
let address = Address::from_verification_key(signing_key.verification_key());
let verification_key = VerificationKey::try_from(signing_key.verification_key().to_bytes())
.map_err(|e| Error::other(e.into()))?;
let address = Address::builder()
.verification_key(&verification_key)
.prefix("astria")
.try_build()
.map_err(|e| Error::other(e.into()))?;
let nonce = self
.sequencer_client
.get_latest_nonce(address)
.await
.map_err(|e| Error::other(Box::new(e)))?;

let unsigned_tx = UnsignedTransaction {
nonce: nonce.nonce,
params: TransactionParams::builder()
.nonce(nonce.nonce)
.chain_id(self.id().to_string())
.build(),
actions,
};

let signed_tx = unsigned_tx.into_signed(&signing_key);
let signed_tx = unsigned_tx.into_signed(&SigningKey::from(signing_key.to_bytes()));
let tx_bytes = signed_tx.into_raw().encode_to_vec();

let resp = self
Expand Down Expand Up @@ -586,20 +598,30 @@ impl ChainEndpoint for AstriaEndpoint {
_key_name: Option<&str>,
denom: Option<&str>,
) -> Result<Balance, Error> {
use astria_core::sequencer::v1::account::AssetBalance;
use astria_core::{
crypto::VerificationKey,
protocol::account::v1alpha1::AssetBalance,
};
use astria_sequencer_client::{
Address,
SequencerClientExt as _,
};

let signing_key: ed25519_consensus::SigningKey =
(*self.get_key()?.signing_key().as_bytes()).into(); // TODO cache this
let address = Address::from_verification_key(signing_key.verification_key());
let verification_key = VerificationKey::try_from(signing_key.verification_key().to_bytes())
.map_err(|e| Error::other(e.into()))?;
let address = Address::builder()
.verification_key(&verification_key)
.prefix("astria")
.try_build()
.map_err(|e| Error::other(e.into()))?;
let balance = self
.block_on(self.sequencer_client.get_latest_balance(address))
.map_err(|e| Error::other(Box::new(e)))?;

let denom = denom.unwrap_or(astria_core::sequencer::v1::asset::DEFAULT_NATIVE_ASSET_DENOM);
// TODO: set this via the config
let denom = denom.unwrap_or("nria");

let balance: Vec<AssetBalance> = balance
.balances
Expand Down
2 changes: 2 additions & 0 deletions crates/relayer/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,13 @@
decode_header,
AnyHeader,
},
ics04_channel::packet::Sequence,

Check warning on line 501 in crates/relayer/src/event.rs

View workflow job for this annotation

GitHub Actions / test-stable

unused imports: `ics04_channel::packet::Sequence`, `timestamp::Timestamp`
},
timestamp::Timestamp,
};

use super::*;

#[test]
fn extract_header() {
let header = get_dummy_ics07_header();
Expand Down
34 changes: 28 additions & 6 deletions crates/relayer/src/keyring/ed25519_key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,19 @@ impl SigningKeyPair for Ed25519KeyPair {
bs58::encode(&self.signing_key.verifying_key()).into_string()
}
Ed25519AddressType::Astria => {
hex::encode(astria_core::sequencer::v1::Address::from_verification_key(
ed25519_consensus::VerificationKey::try_from(
self.signing_key.verifying_key().to_bytes(),
)
.expect("can convert between ed25519 keys"),
))
use astria_core::{
crypto::VerificationKey,
primitive::v1::Address,
};
let verification_key =
VerificationKey::try_from(self.signing_key.verifying_key().to_bytes())
Copy link
Member

Choose a reason for hiding this comment

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

You could provide a unit test to ensure that this will keep on working.

.expect("can convert ed25519 public key bytes to astria verification key");
let address = Address::builder()
.array(verification_key.address_bytes())
.prefix("astria")
.try_build()
.expect("can build astria address from ed25519 public key");
address.to_string()
}
}
}
Expand All @@ -176,3 +183,18 @@ impl SigningKeyPair for Ed25519KeyPair {
self
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn ed25519_keypair_astria_account() {
let signing_key = ed25519_dalek::SigningKey::from_bytes(&[99u8; 32]);
let keypair = Ed25519KeyPair {
signing_key,
address_type: Ed25519AddressType::Astria,
};
let _address = keypair.account();
}
}
Loading
Loading