Skip to content

Commit

Permalink
Merge branch 'tomas+brent/core-crate-split' (#733)
Browse files Browse the repository at this point in the history
* tomas+brent/core-crate-split:
  [ci] wasm checksums update
  [ci] wasm checksums update
  docs/overview: update deps graph and add a generated one too
  pos: replace generic types with concrete types from core
  update paths for core split and apply many small fixes
  add new crate "namada_core" for core types, storage_api, tx_env, vp_env
  • Loading branch information
tzemanovic committed Nov 25, 2022
2 parents fd70b38 + 311cfbb commit c10a1c2
Show file tree
Hide file tree
Showing 141 changed files with 5,026 additions and 5,408 deletions.
82 changes: 60 additions & 22 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resolver = "2"

members = [
"apps",
"core",
"proof_of_stake",
"shared",
"tests",
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ clippy-abcipp:
$(cargo) +$(nightly) clippy \
--all-targets \
--manifest-path ./vm_env/Cargo.toml \
--no-default-features \
--features "abcipp" && \
--no-default-features && \
make -C $(wasms) clippy && \
$(foreach wasm,$(wasm_templates),$(clippy-wasm) && ) true

Expand Down
10 changes: 6 additions & 4 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,27 @@ std = ["ed25519-consensus/std", "rand/std", "rand_core/std"]
testing = ["dev"]

abcipp = [
"namada/abcipp",
"namada/tendermint-rpc-abcipp",
"tendermint-abcipp",
"tendermint-config-abcipp",
"tendermint-proto-abcipp",
"tendermint-rpc-abcipp",
"tower-abci-abcipp",
"namada/abcipp"
]

abciplus = [
"namada/abciplus",
"namada/tendermint-rpc",
"tendermint",
"tendermint-config",
"tendermint-rpc",
"tendermint-proto",
"tower-abci",
"namada/abciplus"
]

[dependencies]
namada = {path = "../shared", features = ["wasm-runtime", "ferveo-tpke", "rand", "tendermint-rpc", "secp256k1-sign-verify"]}
namada = {path = "../shared", default-features = false, features = ["wasm-runtime", "ferveo-tpke"]}
ark-serialize = "0.3.0"
ark-std = "0.3.0"
# branch = "bat/arse-merkle-tree"
Expand Down Expand Up @@ -148,7 +150,7 @@ rust_decimal = "1.26.1"
rust_decimal_macros = "1.26.1"

[dev-dependencies]
namada = {path = "../shared", features = ["testing", "wasm-runtime"]}
namada = {path = "../shared", default-features = false, features = ["testing", "wasm-runtime"]}
bit-set = "0.5.2"
# A fork with state machime testing
proptest = {git = "https://github.com/heliaxdev/proptest", branch = "tomas/sm"}
Expand Down
26 changes: 9 additions & 17 deletions apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ use masp_primitives::zip32::ExtendedFullViewingKey;
use namada::ledger::events::Event;
use namada::ledger::governance::parameters::GovParams;
use namada::ledger::governance::storage as gov_storage;
use namada::ledger::governance::utils::Votes;
use namada::ledger::native_vp::governance::utils::Votes;
use namada::ledger::parameters::{storage as param_storage, EpochDuration};
use namada::ledger::pos::types::{
decimal_mult_u64, Epoch as PosEpoch, WeightedValidator,
};
use namada::ledger::pos::types::{decimal_mult_u64, WeightedValidator};
use namada::ledger::pos::{
self, is_validator_slashes_key, BondId, Bonds, PosParams, Slash, Unbonds,
};
Expand Down Expand Up @@ -131,7 +129,7 @@ pub async fn query_epoch(args: args::Query) -> Epoch {
/// Query the last committed block
pub async fn query_block(
args: args::Query,
) -> tendermint_rpc::endpoint::block::Response {
) -> crate::facade::tendermint_rpc::endpoint::block::Response {
let client = HttpClient::new(args.ledger_address).unwrap();
let response = client.latest_block().await.unwrap();
println!(
Expand Down Expand Up @@ -2012,8 +2010,8 @@ pub async fn known_address(
fn apply_slashes(
slashes: &[Slash],
mut delta: token::Amount,
epoch_start: PosEpoch,
withdraw_epoch: Option<PosEpoch>,
epoch_start: Epoch,
withdraw_epoch: Option<Epoch>,
mut w: Option<&mut std::io::StdoutLock>,
) -> token::Amount {
let mut slashed = token::Amount::default();
Expand Down Expand Up @@ -2065,8 +2063,7 @@ fn process_bonds_query(
.unwrap();
delta = apply_slashes(slashes, delta, *epoch_start, None, Some(w));
current_total += delta;
let epoch_start: Epoch = (*epoch_start).into();
if epoch >= &epoch_start {
if epoch >= epoch_start {
total_active += delta;
}
}
Expand Down Expand Up @@ -2121,8 +2118,7 @@ fn process_unbonds_query(
Some(w),
);
current_total += delta;
let epoch_end: Epoch = (*epoch_end).into();
if epoch > &epoch_end {
if epoch > epoch_end {
withdrawable += delta;
}
}
Expand Down Expand Up @@ -2640,11 +2636,8 @@ pub async fn get_proposal_offline_votes(
.await
.unwrap_or_default();
let mut delegated_amount: token::Amount = 0.into();
let epoch = namada::ledger::pos::types::Epoch::from(
proposal.tally_epoch.0,
);
let bond = epoched_bonds
.get(epoch)
.get(proposal.tally_epoch)
.expect("Delegation bond should be defined.");
let mut to_deduct = bond.neg_deltas;
for (start_epoch, &(mut delta)) in
Expand Down Expand Up @@ -2800,8 +2793,7 @@ pub async fn get_bond_amount_at(
None,
None,
);
let epoch_start: Epoch = (*epoch_start).into();
if epoch >= epoch_start {
if epoch >= *epoch_start {
delegated_amount += delta;
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ async fn is_safe_voting_window(

match proposal_end_epoch {
Some(proposal_end_epoch) => {
!namada::ledger::governance::utils::is_valid_validator_voting_period(
!namada::ledger::native_vp::governance::utils::is_valid_validator_voting_period(
current_epoch,
proposal_start_epoch,
proposal_end_epoch,
Expand Down Expand Up @@ -2486,7 +2486,7 @@ pub async fn submit_validator_commission_change(
match (commission_rates, max_change) {
(Some(rates), Some(max_change)) => {
// Assuming that pipeline length = 2
let rate_next_epoch = rates.get(epoch + 1).unwrap();
let rate_next_epoch = rates.get(epoch.next()).unwrap();
if (args.rate - rate_next_epoch).abs() > max_change {
eprintln!(
"New rate is too large of a change with respect to \
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/client/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use namada::types::masp::{TransferSource, TransferTarget};
use namada::types::storage::Epoch;
use namada::types::transaction::GasLimit;
use namada::types::{key, token};
use tendermint_config::net::Address as TendermintAddress;

use super::rpc;
use crate::cli::{args, Context};
use crate::client::tx::Conversions;
use crate::facade::tendermint_config::net::Address as TendermintAddress;

#[derive(Clone, Debug)]
pub struct ParsedTxArgs {
Expand Down
Loading

0 comments on commit c10a1c2

Please sign in to comment.