Skip to content

Commit

Permalink
Migration commit, will be reverted after the testnet contract is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
neacsu committed Aug 18, 2021
1 parent 34c9725 commit 38d868b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/mixnet-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ pub use gateway::{Gateway, GatewayBond, GatewayOwnershipResponse, PagedGatewayRe
pub use mixnode::{Layer, MixNode, MixNodeBond, MixOwnershipResponse, PagedMixnodeResponse};
pub use msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
pub use types::{IdentityKey, IdentityKeyRef, LayerDistribution, SphinxKey, StateParams};

pub use types::default_delegation_reward;
6 changes: 6 additions & 0 deletions common/mixnet-contract/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ impl LayerDistribution {
}
}

pub fn default_delegation_reward() -> Decimal {
Decimal::percent(110)
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct StateParams {
pub epoch_length: u32, // length of an epoch, expressed in hours
Expand All @@ -34,7 +38,9 @@ pub struct StateParams {
pub minimum_gateway_bond: Uint128, // minimum amount a gateway must bond to get into the system
pub mixnode_bond_reward_rate: Decimal, // annual reward rate, expressed as a decimal like 1.25
pub gateway_bond_reward_rate: Decimal, // annual reward rate, expressed as a decimal like 1.25
#[serde(default = "default_delegation_reward")]
pub mixnode_delegation_reward_rate: Decimal, // annual reward rate, expressed as a decimal like 1.25
#[serde(default = "default_delegation_reward")]
pub gateway_delegation_reward_rate: Decimal, // annual reward rate, expressed as a decimal like 1.25
pub mixnode_active_set_size: u32,
}
Expand Down
6 changes: 4 additions & 2 deletions contracts/mixnet/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::helpers::calculate_epoch_reward_rate;
use crate::state::State;
use crate::storage::{config, layer_distribution};
use crate::storage::{config, config_read, layer_distribution};
use crate::{error::ContractError, queries, transactions};
use config::defaults::NETWORK_MONITOR_ADDRESS;
use cosmwasm_std::{
Expand Down Expand Up @@ -181,7 +181,9 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<QueryResponse, Cont
}

#[entry_point]
pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
let state = config_read(deps.storage).load().unwrap();
config(deps.storage).save(&state)?;
Ok(Default::default())
}

Expand Down
4 changes: 4 additions & 0 deletions contracts/mixnet/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use mixnet_contract::StateParams;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use mixnet_contract::default_delegation_reward;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct State {
pub owner: Addr, // only the owner account can update state
Expand All @@ -15,6 +17,8 @@ pub struct State {
// helper values to avoid having to recalculate them on every single payment operation
pub mixnode_epoch_bond_reward: Decimal, // reward per epoch expressed as a decimal like 0.05
pub gateway_epoch_bond_reward: Decimal, // reward per epoch expressed as a decimal like 0.05
#[serde(default = "default_delegation_reward")]
pub mixnode_epoch_delegation_reward: Decimal, // reward per epoch expressed as a decimal like 0.05
#[serde(default = "default_delegation_reward")]
pub gateway_epoch_delegation_reward: Decimal, // reward per epoch expressed as a decimal like 0.05
}

0 comments on commit 38d868b

Please sign in to comment.