Skip to content

Commit

Permalink
rm dkg with ferveo
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Nov 7, 2023
1 parent 9f4ebc7 commit 17d8e48
Show file tree
Hide file tree
Showing 54 changed files with 394 additions and 2,633 deletions.
366 changes: 38 additions & 328 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ ethers = "2.0.0"
expectrl = "0.7.0"
eyre = "0.6.5"
fd-lock = "3.0.12"
ferveo = {git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"}
ferveo-common = {git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"}
flate2 = "1.0.22"
fs_extra = "1.2.0"
futures = "0.3"
Expand Down
4 changes: 1 addition & 3 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ integration = []


[dependencies]
namada = {path = "../shared", features = ["ferveo-tpke", "masp-tx-gen", "multicore", "http-client", "tendermint-rpc"]}
namada = {path = "../shared", features = ["masp-tx-gen", "multicore", "http-client", "tendermint-rpc"]}
namada_sdk = {path = "../sdk", default-features = false, features = ["wasm-runtime", "masp-tx-gen"]}
namada_test_utils = {path = "../test_utils", optional = true}
ark-serialize.workspace = true
Expand Down Expand Up @@ -90,8 +90,6 @@ ethbridge-bridge-events.workspace = true
ethbridge-events.workspace = true
eyre.workspace = true
fd-lock.workspace = true
ferveo-common.workspace = true
ferveo.workspace = true
flate2.workspace = true
futures.workspace = true
itertools.workspace = true
Expand Down
6 changes: 0 additions & 6 deletions apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,6 @@ pub async fn submit_init_validator<'a>(
)
.unwrap();
let protocol_key = validator_keys.get_protocol_keypair().ref_to();
let dkg_key = validator_keys
.dkg_keypair
.as_ref()
.expect("DKG sessions keys should have been created")
.public();

let validator_vp_code_hash =
query_wasm_code_hash(namada, validator_vp_code_path.to_str().unwrap())
Expand Down Expand Up @@ -387,7 +382,6 @@ pub async fn submit_init_validator<'a>(
eth_hot_key: key::secp256k1::PublicKey::try_from_pk(&eth_hot_pk)
.unwrap(),
protocol_key,
dkg_key,
commission_rate,
max_commission_rate_change,
validator_vp_code_hash: extra_section_hash,
Expand Down
12 changes: 2 additions & 10 deletions apps/src/lib/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use namada::ledger::parameters::EpochDuration;
use namada::ledger::pos::{Dec, GenesisValidator, OwnedPosParams};
use namada::types::address::Address;
use namada::types::chain::ProposalBytes;
use namada::types::key::dkg_session_keys::DkgPublicKey;
use namada::types::key::*;
use namada::types::time::{DateTimeUtc, DurationSecs};
use namada::types::token::Denomination;
Expand Down Expand Up @@ -75,8 +74,6 @@ pub struct Validator {
/// this key on a transaction signature.
/// Note that this is distinct from consensus key used in the PoS system.
pub account_key: common::PublicKey,
/// The public DKG session key used during the DKG protocol
pub dkg_public_key: DkgPublicKey,
/// These tokens are not staked and hence do not contribute to the
/// validator's voting power
pub non_staked_balance: token::Amount,
Expand Down Expand Up @@ -374,8 +371,7 @@ pub fn make_dev_genesis(
);
let eth_cold_keypair =
common::SecretKey::try_from_sk(&secp_eth_cold_keypair).unwrap();
let (protocol_keypair, eth_bridge_keypair, dkg_keypair) =
defaults::validator_keys();
let (protocol_keypair, eth_bridge_keypair) = defaults::validator_keys();
let alias = Alias::from_str(&format!("validator-{}", val + 1))
.expect("infallible");
// add the validator
Expand All @@ -384,9 +380,6 @@ pub fn make_dev_genesis(
address,
tx: transactions::ValidatorAccountTx {
alias: alias.clone(),
dkg_key: StringEncoded {
raw: dkg_keypair.public(),
},
vp: "vp_validator".to_string(),
commission_rate: Dec::new(5, 2).expect("This can't fail"),
max_commission_rate_change: Dec::new(1, 2)
Expand Down Expand Up @@ -477,7 +470,7 @@ pub mod tests {
let keypair: common::SecretKey =
ed25519::SigScheme::generate(&mut rng).try_to_sk().unwrap();
let kp_arr = keypair.serialize_to_vec();
let (protocol_keypair, _eth_hot_bridge_keypair, dkg_keypair) =
let (protocol_keypair, _eth_hot_bridge_keypair) =
wallet::defaults::validator_keys();

// TODO: derive validator eth address from an eth keypair
Expand All @@ -493,7 +486,6 @@ pub mod tests {
println!("address: {}", address);
println!("keypair: {:?}", kp_arr);
println!("protocol_keypair: {:?}", protocol_keypair);
println!("dkg_keypair: {:?}", dkg_keypair.serialize_to_vec());
println!(
"eth_cold_gov_keypair: {:?}",
eth_cold_gov_keypair.serialize_to_vec()
Expand Down
15 changes: 0 additions & 15 deletions apps/src/lib/config/genesis/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use namada::proto::{
standalone_signature, verify_standalone_sig, SerializeWithBorsh,
};
use namada::types::dec::Dec;
use namada::types::key::dkg_session_keys::DkgPublicKey;
use namada::types::key::{common, RefTo, VerifySigError};
use namada::types::time::{DateTimeUtc, MIN_UTC};
use namada::types::token;
Expand Down Expand Up @@ -137,15 +136,6 @@ pub fn init_validator(
.protocol_keypair
.ref_to(),
),
dkg_key: StringEncoded::new(
validator_wallet
.store
.validator_keys
.dkg_keypair
.as_ref()
.expect("Missing validator DKG key")
.public(),
),
tendermint_node_key: StringEncoded::new(
validator_wallet.tendermint_node_key.ref_to(),
),
Expand Down Expand Up @@ -251,7 +241,6 @@ pub fn sign_validator_account_tx(
account_key,
consensus_key,
protocol_key,
dkg_key,
tendermint_node_key,
vp,
commission_rate,
Expand Down Expand Up @@ -293,7 +282,6 @@ pub fn sign_validator_account_tx(
account_key,
consensus_key,
protocol_key,
dkg_key,
tendermint_node_key,
vp,
commission_rate,
Expand Down Expand Up @@ -547,7 +535,6 @@ pub type SignedValidatorAccountTx = ValidatorAccountTx<SignedPk>;
)]
pub struct ValidatorAccountTx<PK> {
pub alias: Alias,
pub dkg_key: StringEncoded<DkgPublicKey>,
pub vp: String,
/// Commission rate charged on rewards for delegators (bounded inside
/// 0-1)
Expand Down Expand Up @@ -1439,7 +1426,6 @@ impl From<&SignedValidatorAccountTx> for UnsignedValidatorAccountTx {
fn from(tx: &SignedValidatorAccountTx) -> Self {
let SignedValidatorAccountTx {
alias,
dkg_key,
vp,
commission_rate,
max_commission_rate_change,
Expand All @@ -1454,7 +1440,6 @@ impl From<&SignedValidatorAccountTx> for UnsignedValidatorAccountTx {

Self {
alias: alias.clone(),
dkg_key: dkg_key.clone(),
vp: vp.clone(),
commission_rate: *commission_rate,
max_commission_rate_change: *max_commission_rate_change,
Expand Down
11 changes: 0 additions & 11 deletions apps/src/lib/node/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,6 @@ impl Shell {
Request::RevertProposal(_req) => {
Ok(Response::RevertProposal(self.revert_proposal(_req)))
}
#[cfg(feature = "abcipp")]
Request::ExtendVote(_req) => {
Ok(Response::ExtendVote(self.extend_vote(_req)))
}
#[cfg(feature = "abcipp")]
Request::VerifyVoteExtension(_req) => {
tracing::debug!("Request VerifyVoteExtension");
Ok(Response::VerifyVoteExtension(
self.verify_vote_extension(_req),
))
}
Request::FinalizeBlock(finalize) => {
tracing::debug!("Request FinalizeBlock");
self.load_proposals();
Expand Down
15 changes: 1 addition & 14 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,6 @@ where
None,
)
}
ref protocol_tx_type => {
tracing::error!(
?protocol_tx_type,
"Internal logic error: FinalizeBlock received \
an unsupported TxType::Protocol transaction: \
{:?}",
protocol_tx
);
continue;
}
},
};

Expand Down Expand Up @@ -1100,8 +1090,6 @@ mod test_finalize_block {
.unwrap();
shell.enqueue_tx(outer_tx.clone(), gas_limit);
outer_tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted));
outer_tx.decrypt(<EllipticCurve as PairingEngine>::G2Affine::prime_subgroup_generator())
.expect("Test failed");
ProcessedTx {
tx: outer_tx.to_bytes().into(),
result: TxResult {
Expand Down Expand Up @@ -1686,8 +1674,7 @@ mod test_finalize_block {
transfers: vec![transfer],
relayer: bertha,
};
let (protocol_key, _, _) =
crate::wallet::defaults::validator_keys();
let (protocol_key, _) = crate::wallet::defaults::validator_keys();
let validator_addr = crate::wallet::defaults::validator_address();
let ext = {
let ext = ethereum_events::Vext {
Expand Down
7 changes: 0 additions & 7 deletions apps/src/lib/node/ledger/shell/init_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ where
ValidatorAccountTx {
alias,
vp,
dkg_key,
commission_rate,
max_commission_rate_change,
net_address: _,
Expand Down Expand Up @@ -448,12 +447,6 @@ where
.write(&protocol_pk_key(address), &protocol_key.pk.raw)
.expect("Unable to set genesis user protocol public key");

self.wl_storage
.write(&dkg_session_keys::dkg_pk_key(address), &dkg_key.raw)
.expect(
"Unable to set genesis user public DKG session key",
);

// TODO: replace pos::init_genesis validators arg with
// init_genesis_validator from here
if let Err(err) = pos::namada_proof_of_stake::become_validator(
Expand Down
12 changes: 4 additions & 8 deletions apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ use namada::types::key::*;
use namada::types::storage::{BlockHeight, Key, TxIndex};
use namada::types::time::DateTimeUtc;
use namada::types::transaction::protocol::EthereumTxData;
use namada::types::transaction::{
hash_tx, verify_decrypted_correctly, AffineCurve, DecryptedTx,
EllipticCurve, PairingEngine, TxType, WrapperTx,
};
use namada::types::transaction::{DecryptedTx, TxType, WrapperTx};
use namada::types::{address, token};
use namada::vm::wasm::{TxCache, VpCache};
use namada::vm::{WasmCacheAccess, WasmCacheRwAccess};
Expand Down Expand Up @@ -501,7 +498,7 @@ where
}
#[cfg(test)]
{
let (protocol_keypair, eth_bridge_keypair, dkg_keypair) =
let (protocol_keypair, eth_bridge_keypair) =
crate::wallet::defaults::validator_keys();
ShellMode::Validator {
data: ValidatorData {
Expand All @@ -510,7 +507,6 @@ where
keys: ValidatorKeys {
protocol_keypair,
eth_bridge_keypair,
dkg_keypair: Some(dkg_keypair),
},
},
broadcast_sender,
Expand Down Expand Up @@ -2341,7 +2337,7 @@ mod shell_tests {

let (shell, _recv, _, _) = test_utils::setup_at_height(LAST_HEIGHT);

let (protocol_key, _, _) = wallet::defaults::validator_keys();
let (protocol_key, _) = wallet::defaults::validator_keys();
let validator_addr = wallet::defaults::validator_address();

let ethereum_event = EthereumEvent::TransfersToNamada {
Expand Down Expand Up @@ -2374,7 +2370,7 @@ mod shell_tests {

let (shell, _recv, _, _) = test_utils::setup_at_height(LAST_HEIGHT);

let (protocol_key, _, _) = wallet::defaults::validator_keys();
let (protocol_key, _) = wallet::defaults::validator_keys();
let validator_addr = wallet::defaults::validator_address();

let ethereum_event = EthereumEvent::TransfersToNamada {
Expand Down
31 changes: 6 additions & 25 deletions apps/src/lib/node/ledger/shell/prepare_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ use namada::types::address::Address;
use namada::types::internal::TxInQueue;
use namada::types::key::tm_raw_hash_to_string;
use namada::types::time::DateTimeUtc;
use namada::types::transaction::wrapper::wrapper_tx::PairingEngine;
use namada::types::transaction::{
AffineCurve, DecryptedTx, EllipticCurve, TxType,
};
use namada::types::transaction::{DecryptedTx, TxType};
use namada::vm::wasm::{TxCache, VpCache};
use namada::vm::WasmCacheAccess;

Expand Down Expand Up @@ -265,9 +262,6 @@ where
&self,
mut alloc: BlockAllocator<BuildingDecryptedTxBatch>,
) -> (Vec<TxBytes>, BlockAllocator<BuildingProtocolTxBatch>) {
// TODO: This should not be hardcoded
let privkey =
<EllipticCurve as PairingEngine>::G2Affine::prime_subgroup_generator();
let pos_queries = self.wl_storage.pos_queries();
let txs = self
.wl_storage
Expand All @@ -280,21 +274,8 @@ where
gas: _,
}| {
let mut tx = tx.clone();
match tx.decrypt(privkey).ok()
{
Some(_) => {
tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted));
tx
},
// An absent or undecryptable inner_tx are both
// treated as undecryptable
None => {
tx.update_header(TxType::Decrypted(
DecryptedTx::Undecryptable
));
tx
},
}.to_bytes().into()
tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted));
tx.to_bytes().into()
},
)
// TODO: make sure all decrypted txs are accepted
Expand Down Expand Up @@ -499,7 +480,7 @@ mod test_prepare_proposal {
let (shell, _recv, _, _) = test_utils::setup_at_height(LAST_HEIGHT);

let signed_vote_extension = {
let (protocol_key, _, _) = wallet::defaults::validator_keys();
let (protocol_key, _) = wallet::defaults::validator_keys();
let validator_addr = wallet::defaults::validator_address();

// generate a valid signature
Expand Down Expand Up @@ -531,7 +512,7 @@ mod test_prepare_proposal {
const LAST_HEIGHT: BlockHeight = BlockHeight(3);

fn check_invalid(shell: &TestShell, height: BlockHeight) {
let (protocol_key, _, _) = wallet::defaults::validator_keys();
let (protocol_key, _) = wallet::defaults::validator_keys();
let validator_addr = wallet::defaults::validator_address();

let signed_vote_extension = {
Expand Down Expand Up @@ -704,7 +685,7 @@ mod test_prepare_proposal {
);

// test prepare proposal
let (protocol_key, _, _) = wallet::defaults::validator_keys();
let (protocol_key, _) = wallet::defaults::validator_keys();
let validator_addr = wallet::defaults::validator_address();

let ethereum_event = EthereumEvent::TransfersToNamada {
Expand Down
Loading

0 comments on commit 17d8e48

Please sign in to comment.