-
Notifications
You must be signed in to change notification settings - Fork 992
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
Multisignature (rebase) #1741
Multisignature (rebase) #1741
Conversation
…added max_signature_per_transaction genesis parameter
…ifiation, rebuild wasm_for_tests
core/src/types/account.rs
Outdated
} | ||
|
||
/// Return an empty AccountPublicKeysMap | ||
pub fn empty() -> Self { |
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.
I think you can derive(Default)
for this
matches!(&key.segments[..], [ | ||
DbKeySeg::AddressSeg(addr), | ||
DbKeySeg::StringSeg(max_signatures_per_transaction), | ||
] if addr == &ADDRESS && max_signatures_per_transaction == Keys::VALUES.max_signatures_per_transaction) |
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.
matches!(&key.segments[..], [ | |
DbKeySeg::AddressSeg(addr), | |
DbKeySeg::StringSeg(max_signatures_per_transaction), | |
] if addr == &ADDRESS && max_signatures_per_transaction == Keys::VALUES.max_signatures_per_transaction) | |
is_max_signatures_per_transaction_key_at_addr(key, &ADDRESS) |
generated from derive(StorageKeys)
Key { | ||
segments: vec![ | ||
DbKeySeg::AddressSeg(ADDRESS), | ||
DbKeySeg::StringSeg( | ||
Keys::VALUES.max_signatures_per_transaction.to_string(), | ||
), | ||
], | ||
} |
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.
Key { | |
segments: vec![ | |
DbKeySeg::AddressSeg(ADDRESS), | |
DbKeySeg::StringSeg( | |
Keys::VALUES.max_signatures_per_transaction.to_string(), | |
), | |
], | |
} | |
get_max_signatures_per_transaction_key_at_addr(ADDRESS) |
storage.read(&threshold_key) | ||
} | ||
|
||
/// Get the public keys index map associated with an account |
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.
/// Get the public keys index map associated with an account | |
/// Get the public keys associated with an account |
let vp_key = Key::validity_predicate(owner); | ||
storage.has_key(&vp_key) |
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.
let vp_key = Key::validity_predicate(owner); | |
storage.has_key(&vp_key) | |
match owner { | |
Address::Established(_) => { | |
let vp_key = Key::validity_predicate(owner); | |
storage.has_key(&vp_key) | |
} | |
Address::Implicit(_) | Address::Internal(_) => Ok(true), | |
} |
|
||
impl Ord for SignatureIndex { | ||
fn cmp(&self, other: &Self) -> Ordering { | ||
self.index.cmp(&other.index) |
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.
I think if you put the index
field first in the struct then you can derive the impl as it will be sorted by the index (you might need to add Ord
to common::Signature
which is fine)
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.
I think we can't, because the ed25519_consensus::Signature
doesn't implement Ord
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.
ah, I see. I think we can add it, we already have a manual PartialOrd using the bytes:
impl Ord for Signature {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.0.to_bytes().cmp(&other.0.to_bytes())
}
}
core/src/proto/types.rs
Outdated
@@ -722,6 +869,7 @@ impl borsh::BorshSchema for MaspBuilder { | |||
Serialize, | |||
Deserialize, | |||
)] | |||
#[allow(clippy::large_enum_variant)] |
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.
#[allow(clippy::large_enum_variant)] |
it looks like this is not needed
core/src/proto/types.rs
Outdated
let tx_filename_clone_error = tx_filename.clone(); | ||
let tx_filename_clone_ok = tx_filename.clone(); | ||
let out = File::create(path.join(tx_filename)).unwrap(); | ||
serde_json::to_writer_pretty(out, &self) | ||
.map_err(|_| { | ||
Error::InvalidJSONDeserialization(tx_filename_clone_error) | ||
}) | ||
.map(|_| path.join(tx_filename_clone_ok)) |
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.
let tx_filename_clone_error = tx_filename.clone(); | |
let tx_filename_clone_ok = tx_filename.clone(); | |
let out = File::create(path.join(tx_filename)).unwrap(); | |
serde_json::to_writer_pretty(out, &self) | |
.map_err(|_| { | |
Error::InvalidJSONDeserialization(tx_filename_clone_error) | |
}) | |
.map(|_| path.join(tx_filename_clone_ok)) | |
let out = File::create(path.join(&tx_filename)).unwrap(); | |
serde_json::to_writer_pretty(out, &self) | |
.map_err(|_| Error::InvalidJSONDeserialization(tx_filename.clone())) | |
.map(|_| path.join(tx_filename)) |
@@ -4,7 +4,7 @@ | |||
|
|||
genesis_time = "2021-09-30T10:00:00Z" | |||
native_token = "NAM" | |||
faucet_pow_difficulty = 1 | |||
faucet_pow_difficulty = 0 |
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.
do we need to switch it off here?
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.
not at all, but it would speed up e2e test a little
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.
I see - we can do this change, but let's override it to 1
in ledger_txs_and_queries
e2e test to still cover this
/// A tx that attempts to mint tokens in the transfer's target without debiting | ||
/// the tokens from the source. This tx is expected to be rejected by the | ||
/// token's VP. | ||
#[cfg(feature = "tx_mint_tokens")] |
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.
was this unused? Let's also remove it from the Makefile and Cargo.toml
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.
yep
@@ -0,0 +1,2 @@ | |||
- Introduce multisignature account and transaction format. |
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 would be nice to write a little bit more about this and/or link to docs for anyone who'll want to try it in the new release
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.
we have docs almost ready, should I link them here?
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.
yes pls!
shared/src/ledger/tx.rs
Outdated
@@ -241,13 +253,29 @@ pub async fn prepare_tx< | |||
wallet: &mut Wallet<U>, | |||
args: &args::Tx, | |||
tx: Tx, | |||
owner: Option<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.
it looks like this arg is not needed here - it's just returned untouched
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 requires a higher refactor of the client methods I was planning to do in the next multisig PR. Should I continue here? maybe I should.
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.
let's please refactor it here so we don't have to add this arg only to remove it later
shared/src/ledger/signing.rs
Outdated
client: &C, | ||
owner: Option<Address>, | ||
public_keys: Vec<common::PublicKey>, | ||
) -> (AccountPublicKeysMap, u8) { |
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.
I think this function is not very clear - the default threshold 0
when there's no owner doesn't seem right, is it? In e.g. init_account
that doesn't have an owner beforehand it should respect the tx arg.
I suggest that we change this and use it for all txs except for reveal_pk
, init_account
and init_validator
to only take owner: &Address
without the public_keys
and fail if the account info cannot be queried.
For the reveal_pk
, init_account
and init_validator
, we can call AccountPublicKeysMap::from_iter(public_keys)
directly and take the threshold from the tx arg (with the logic where we set it to 1 when the length of the keys == 1 for new accounts and 1 for reveal_pk
)
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.
I think you are right, it would be clearer. I think the approach here should be:
aux_signing_data
prepare_tx
sign
process_tx
Ill push another commit to refactor this whole thing.
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.
thank you!
Namada 0.20.0 is a minor release addressing several improvements to the PoS system and the ledger stability. * tag 'v0.20.0': (113 commits) Namada 0.20.0 refator e2e masp tests fix tx_transfer ci: fix github colon parsing changelog: add #1693 channgelog: add #1738 [feat]: Moved cli commands common to testing, cli, and sdk out into apps ci: pre-download masp parameters changelog: add #1733 pos/epoched: keep 2 past epochs of data by default changelog: add #1729 test/ledger/finalize_block: fix slashing tests pos/slash: fix the validator state update to be in sync with set changes app/ledger/finalize_block: log block rewards before recording slashes test/e2e/slashing: extend the test to discover rewards issues pos: error out if validator is not in expected state for rewards changelog: add #1717 test/shell/finalize_block: add some txs to DB commit test refactor: rename function refactor: rename method remove test_invalid_sender remove negative check ci: clean up fix formatting don't use flaky sleep refactor creation of namada nodes make Who clonable refactor: use immutable reference refactor: use immutable reference refactor: remove duplicated code test/e2e/slashing: wait for wasm on original validator add changelog fix changes in finalize_block remove vp_token changelog: add #1173 client/rpc: use the new token balance method shared/ledger/queries: add token balance client-only method changelog: add #1692 changelog: add #1670 changelog: add #1667 [fix]: Fixing errors introduced by merging in main [chore]: Incorporating in review comments Update core/src/types/uint.rs Update apps/src/lib/config/genesis.rs [fix]: Fixed the faucet to use uint instead of amount. This makes it portable across different assets converts faucet_withdrawal_limit to be correct changelog: add #1656 pos: return sorted validator sets and code re-use for queries Expanding and fixing slashes query CLI query a validator's state query bonded-stake and order fix client_connections encoding handle errors for unjail-validator tx in the client expand and fix e2e test `double_signing_gets_slashed` add unjail tx at CLI changelog: add #1621 ci/test/e2e: add new test apps: move epoch-sleep client cmd under utils changelog: add #1656 pos: return sorted validator sets and code re-use for queries Expanding and fixing slashes query CLI query a validator's state update pr template test/e2e/proposal_submission: wait for proposal to be committed test/e2e/double_signing: path for validator copy that keeps logs in CI add comments fix according to feedback refactor: fix formatting add changelog refactor: simplify code refactor: introduce name for magic constant add test case feat: store total consensus stake; garbage collect validator sets query bonded-stake and order wait for wasm-precompile before expecting block hash changelog: add #1605 apps: use fd-lock instead of file-lock for cross-platform support changelog: add #1695 deps: update sysinfo to latest 0.29.4 improve error handling for `set_initial_validators` changelog: add #1686 app/ledger/finalize_block: refactor validator set update for re-use app/ledger/init_chain: get genesis validator set using the new fn pos: add a function to get genesis validator consensus set for TM fix a test fix for tx signing for clippy fix multitoken vp to check the minter for clippy modify EthBridge VP and EthBridgePool VP for multitoken revert unexpected changes change eth_bridge balance keys to multitoken keys add unit tests remove InternalAddress::Minted rename fix token decoding fix balance print add multitoken VP file change to multitokens change multitoken ...
Describe your changes
Took #1606 and rebased on 0.19.0.
Close #1178 and #81
Indicate on which release or other PRs this topic is based on
Based on 0.19.0
Checklist before merging to
draft