Skip to content

Commit

Permalink
Merge remote-tracking branch 'namada/tomas+brent/core-crate-split' (#733
Browse files Browse the repository at this point in the history
) into main

* namada/tomas+brent/core-crate-split:
  [ci] wasm checksums update
  changelog: add #733
  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
juped committed Nov 30, 2022
2 parents 4f79b7a + 676184d commit dceaba5
Show file tree
Hide file tree
Showing 140 changed files with 5,028 additions and 5,392 deletions.
4 changes: 4 additions & 0 deletions .changelog/unreleased/improvements/733-core-crate-split.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Public parts of shared `namada` crate have been split up into a
`namada_core` crate. The `namada_proof_of_stake`, `namada_vp_prelude`
and `namada_tx_prelude` crates now depend on this `namada_core` crate.
([#733](https://github.com/anoma/namada/pull/733))
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 @@ -72,8 +72,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
24 changes: 8 additions & 16 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 @@ -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
Loading

0 comments on commit dceaba5

Please sign in to comment.