Skip to content

Commit

Permalink
update genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Oct 18, 2023
1 parent b3597d3 commit 827999a
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 35 deletions.
6 changes: 3 additions & 3 deletions e2e/genesis.toml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ implicit_vp = "vp_implicit"
# Expected number of epochs per year (also sets the min duration of an epoch in seconds).
# Remember to set this to a more reasonable number for production networks. Also, expect most masp
# txs to fail due to epoch boundary errors.
epochs_per_year = 525_600
epochs_per_year = 3153600 # equals epoch every 10 sec
# The P gain factor in the Proof of Stake rewards controller
pos_gain_p = "0.1"
# The D gain factor in the Proof of Stake rewards controller
Expand All @@ -190,10 +190,10 @@ max_signatures_per_transaction = 15
max_validator_slots = 128
# Pipeline length (in epochs). Any change in the validator set made in
# epoch 'n' will become active in epoch 'n + pipeline_len'.
pipeline_len = 0
pipeline_len = 2
# Unbonding length (in epochs). Validators may have their stake slashed
# for a fault in epoch 'n' up through epoch 'n + unbonding_len'.
unbonding_len = 0
unbonding_len = 2
# Votes per fundamental staking token (namnam) - for testnets this should be 1. For e2e toml, a decimal is used for testing purposes.
tm_votes_per_token = "0.1"
# Reward for proposing a block.
Expand Down
55 changes: 50 additions & 5 deletions packages/shared/lib/Cargo.lock

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

17 changes: 8 additions & 9 deletions packages/shared/lib/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use masp_primitives::transaction::components::I128Sum;
use masp_primitives::zip32::ExtendedFullViewingKey;
use namada::ledger::eth_bridge::bridge_pool::query_signed_bridge_pool;
use namada::ledger::queries::RPC;
use namada::sdk::masp::{MaspAmount, ShieldedContext};
use namada::sdk::rpc::{
use namada::namada_sdk::masp::ShieldedContext;
use namada::namada_sdk::rpc::{
format_denominated_amount, get_public_key_at, get_token_balance, query_epoch,
};
use namada::types::control_flow::ProceedOrElse;
Expand Down Expand Up @@ -257,7 +257,7 @@ impl Query {
&self,
xvk: ExtendedViewingKey,
) -> Result<Vec<(Address, token::Amount)>, JsError> {
let _viewing_key = ExtendedFullViewingKey::from(xvk).fvk.vk;
let viewing_key = ExtendedFullViewingKey::from(xvk).fvk.vk;
// We are recreating shielded context to avoid multiple mutable borrows
let mut shielded: ShieldedContext<masp::WebShieldedUtils> = ShieldedContext::default();

Expand All @@ -271,7 +271,7 @@ impl Query {

let epoch = query_epoch(&self.client).await?;
let balance = shielded
.compute_exchanged_balance(&self.client, &viewing_key, epoch)
.compute_exchanged_balance(&self.client, &WebIo, &viewing_key, epoch)
.await?
.expect("context should contain viewing key");
let decoded_balance = shielded
Expand All @@ -291,13 +291,12 @@ impl Query {
}?;

let mut mapped_result: Vec<(Address, String)> = vec![];
for (token, _amount) in result {
for (token, amount) in result {
mapped_result.push((
token.clone(),
// format_denominated_amount(&self.client, &token, amount)
// .await
// .clone(),
"0".to_string(),
format_denominated_amount(&self.client, &WebIo, &token, amount)
.await
.clone(),
))
}

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/src/sdk/masp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use async_trait::async_trait;
use borsh::{BorshDeserialize, BorshSerialize};
use masp_proofs::prover::LocalTxProver;
use namada::sdk::masp::{ShieldedContext, ShieldedUtils};
use namada::namada_sdk::masp::{ShieldedContext, ShieldedUtils};
use wasm_bindgen::{prelude::wasm_bindgen, JsValue};

use crate::utils::{to_bytes, to_io_error};
Expand Down
16 changes: 8 additions & 8 deletions packages/shared/lib/src/sdk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use crate::{
};
use borsh::{BorshDeserialize, BorshSerialize};
use namada::ledger::eth_bridge::bridge_pool::build_bridge_pool_tx;
use namada::ledger::{Namada, NamadaImpl};
use namada::sdk::masp::ShieldedContext;
use namada::sdk::signing::{sign_tx, SigningTxData};
use namada::sdk::tx::{
use namada::namada_sdk::masp::ShieldedContext;
use namada::namada_sdk::signing::{sign_tx, SigningTxData};
use namada::namada_sdk::tx::{
build_bond, build_ibc_transfer, build_reveal_pk, build_transfer, build_unbond, build_withdraw,
is_reveal_pk_needed, process_tx,
};
use namada::sdk::wallet::{Store, Wallet};
use namada::namada_sdk::wallet::{Store, Wallet};
use namada::namada_sdk::{Namada, NamadaImpl};
use namada::types::address::Address;
use namada::{proto::Tx, types::key::common::PublicKey};
use wasm_bindgen::{prelude::wasm_bindgen, JsError, JsValue};
Expand Down Expand Up @@ -82,9 +82,9 @@ impl Sdk {
&self.client,
&mut self.wallet,
&mut self.shielded_ctx,
//TODO: replace
&WebIo,
Address::from_str("TODO").unwrap(),
//NAM address
Address::from_str("atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5").unwrap(),
)
}

Expand Down Expand Up @@ -162,7 +162,7 @@ impl Sdk {
let mut w = namada.wallet_mut().await;

let reveal_pk_tx_bytes = if !is_faucet_transfer
&& is_reveal_pk_needed(&namada.client(), &address, false).await?
&& is_reveal_pk_needed(namada.client(), &address, false).await?
{
let (mut tx, _, _) = build_reveal_pk(&namada, &args, &pk).await?;
sign_tx(&mut w, &args, &mut tx, signing_data.clone())?;
Expand Down
10 changes: 4 additions & 6 deletions packages/shared/lib/src/sdk/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{path::PathBuf, str::FromStr};
use borsh::{BorshDeserialize, BorshSerialize};
use namada::{
ibc::core::ics24_host::identifier::{ChannelId, PortId},
sdk::args::{self, InputAmount},
namada_sdk::args::{self, InputAmount},
types::{
address::Address,
chain::ChainId,
Expand Down Expand Up @@ -150,10 +150,7 @@ pub fn withdraw_tx_args(
) -> Result<(args::Withdraw, Option<Address>), JsError> {
let withdraw_msg = SubmitWithdrawMsg::try_from_slice(withdraw_msg)?;

let SubmitWithdrawMsg {
source,
validator,
} = withdraw_msg;
let SubmitWithdrawMsg { source, validator } = withdraw_msg;

let source = Address::from_str(&source)?;
let validator = Address::from_str(&validator)?;
Expand Down Expand Up @@ -329,7 +326,8 @@ pub fn eth_bridge_transfer_tx_args(
tx_msg: &[u8],
password: Option<String>,
) -> Result<(args::EthereumBridgePool, Option<Address>), JsError> {
let eth_bridge_transfer_msg = SubmitEthBridgeTransferMsg::try_from_slice(eth_bridge_transfer_msg)?;
let eth_bridge_transfer_msg =
SubmitEthBridgeTransferMsg::try_from_slice(eth_bridge_transfer_msg)?;
let SubmitEthBridgeTransferMsg {
nut,
asset,
Expand Down
12 changes: 9 additions & 3 deletions packages/shared/lib/src/sdk/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;

use masp_primitives::zip32::ExtendedFullViewingKey;
use namada::{
sdk::wallet::{alias::Alias, Store, StoredKeypair, Wallet, WalletIo, WalletStorage},
namada_sdk::wallet::{alias::Alias, Store, StoredKeypair, Wallet, WalletIo, WalletStorage},
types::{
address::{Address, ImplicitAddress},
key::{self, common::SecretKey, PublicKeyHash, RefTo},
Expand All @@ -21,11 +21,17 @@ impl WalletIo for BrowserWalletUtils {

//TODO: check if we need to impl those
impl WalletStorage for BrowserWalletUtils {
fn save<U>(&self, _wallet: &Wallet<U>) -> Result<(), namada::sdk::wallet::LoadStoreError> {
fn save<U>(
&self,
_wallet: &Wallet<U>,
) -> Result<(), namada::namada_sdk::wallet::LoadStoreError> {
todo!()
}

fn load<U>(&self, _wallet: &mut Wallet<U>) -> Result<(), namada::sdk::wallet::LoadStoreError> {
fn load<U>(
&self,
_wallet: &mut Wallet<U>,
) -> Result<(), namada::namada_sdk::wallet::LoadStoreError> {
todo!()
}
}
Expand Down

0 comments on commit 827999a

Please sign in to comment.