-
Notifications
You must be signed in to change notification settings - Fork 323
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
Represent signer as a String and use account prefix from the config #711
Conversation
Great stuff @andynog! While I understand the need to represent the signer as a string rather than a fixed length byte array like #[derive(Clone, Debug, Display, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Signer(String); |
Thanks @romac, just thinking should we use a |
Right, then yeah something like #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Signer(Vec<u8>);
impl Display for Signer {
// use bech32 encoding
} This then gives you |
@romac I've been looking into this suggestion to wrap the In the end, the signer basically is retrieved from the |
Trying to follow this, why can't we leave it as
but it is not clear to me what we gain as we should never look at signer or make any assumptions about it. |
@andynog @ancazamfir Yeah good points! So let's represent it as a |
Codecov Report
@@ Coverage Diff @@
## master informalsystems/hermes#711 +/- ##
=========================================
+ Coverage 13.6% 44.1% +30.5%
=========================================
Files 69 156 +87
Lines 3752 10288 +6536
Branches 1374 0 -1374
=========================================
+ Hits 513 4546 +4033
- Misses 2618 5742 +3124
+ Partials 621 0 -621
Continue to review full report at Codecov.
|
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 is great work, things are a lot cleaner!
I only left one comment worth discussing: the lock file which seems added by accident.
@@ -30,8 +29,8 @@ pub struct MsgConnectionOpenTry { | |||
pub counterparty: Counterparty, | |||
pub counterparty_versions: Vec<Version>, | |||
pub proofs: Proofs, | |||
pub delay_period: u64, | |||
pub signer: AccountId, | |||
pub delay_period: u64, // FIXME(romac): Introduce newtype for `delay_period` |
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.
Yus! Probably the todo should be fixed alongside #640.
@@ -18,22 +18,23 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgRecvPacket"; | |||
#[derive(Clone, Debug, PartialEq)] | |||
pub struct MsgRecvPacket { | |||
pub packet: Packet, | |||
proofs: Proofs, | |||
signer: AccountId, | |||
pub proofs: Proofs, |
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.
fn get_signers(&self) -> Vec<AccountId>; | ||
fn get_sign_bytes(self) -> Vec<u8> { | ||
let mut buf = Vec::new(); | ||
let raw_msg: Self::Raw = self.into(); |
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.
Hmm interesting that we're now avoiding a clone
here. It used to be let raw_msg: M = self.clone().into();
. Perhaps cloning is no longer necessary because we're not using generics anymore?
Later edit: I now see that we're consuming self
in the call to to_any
and get_sign_bytes
, which explains the lack of cloning.
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.
…nformalsystems#711) * Refactoring of signer from AccountId into String (informalsystems#219) * Logic to add the account_prefix from config to signer (informalsystems#219) * Uncomment tests that are failing * Move bech32 encoding of accounts to cosmos chain impl * Use a newtype for the signer * Allow empty signer in tests * Add plain constructor to all ICS04 messages * Remove default implementation of Msg::type_url * Use associated type on Msg trait instead of type parameter on Msg::to_any * Formatting * Remove proto-compiler lockfile Co-authored-by: Romain Ruetschi <romain@informal.systems>
Closes: cosmos/ibc-rs#88
Description
Major refactoring of signer logic to switch it from
AccountId
toSigner(String)
. Also includes logic to use theaccount_prefix
from the config to use in the signer account (#635) so the transactions can be submitted to chains that don't usecosmos
as the bech32 prefix.NOTE: Currently there are 3 failing tests that might be related to this changes but I couldn't fix them yet, so just creating a draft PR for now to check if it also passes e2e test.
For contributor use:
docs/
) and code comments.Files changed
in the Github PR explorer.