Skip to content

Commit

Permalink
Merge pull request #17 from octopus-network/v1.3.1
Browse files Browse the repository at this point in the history
Upgrade to v1.3.1
  • Loading branch information
riversyang authored May 11, 2022
2 parents e7077e2 + 7faa27f commit 21b7336
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion appchain-anchor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "appchain-anchor"
version = "1.3.0"
version = "1.3.1"
authors = ["Octopus Network"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion appchain-anchor/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ pub trait SudoActions {
///
fn set_latest_applied_appchain_message_nonce(&mut self, nonce: u32);
///
fn remove_appchain_messages_before(&mut self, nonce: u32);
fn clear_appchain_messages(&mut self) -> MultiTxsOperationProcessingResult;
///
fn try_complete_switching_era(&mut self) -> MultiTxsOperationProcessingResult;
}
Expand Down
2 changes: 1 addition & 1 deletion appchain-anchor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use validator_set::ValidatorSetViewer;
register_custom_getrandom!(get_random_in_near);

/// Version of this contract (the same as in Cargo.toml)
const ANCHOR_VERSION: &str = "v1.3.0";
const ANCHOR_VERSION: &str = "v1.3.1";
/// Constants for gas.
const T_GAS: u64 = 1_000_000_000_000;
const GAS_FOR_FT_TRANSFER: u64 = 10 * T_GAS;
Expand Down
2 changes: 1 addition & 1 deletion appchain-anchor/src/user_actions/settings_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use core::convert::From;
impl Default for ProtocolSettings {
fn default() -> Self {
Self {
minimum_validator_deposit: U128::from(10_000 * OCT_DECIMALS_VALUE),
minimum_validator_deposit: U128::from(5_000 * OCT_DECIMALS_VALUE),
minimum_validator_deposit_changing_amount: U128::from(1000 * OCT_DECIMALS_VALUE),
maximum_validator_stake_percent: 25,
minimum_delegator_deposit: U128::from(200 * OCT_DECIMALS_VALUE),
Expand Down
17 changes: 16 additions & 1 deletion appchain-anchor/src/user_actions/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,23 @@ impl AppchainAnchor {
let protocol_settings = self.protocol_settings.get().unwrap();
assert!(
next_validator_set.validator_count() < protocol_settings.maximum_validator_count.0,
"Too many validators registered."
"The count of registered validators exceeds the upper limit."
);
//
if self.appchain_state.eq(&AppchainState::Active) {
let validator_set_histories = self.validator_set_histories.get().unwrap();
let latest_validator_set = validator_set_histories
.get(&validator_set_histories.end_index)
.unwrap();
if latest_validator_set.validator_count() >= 12 {
assert!(
next_validator_set.validator_count()
<= latest_validator_set.validator_count() * 5 / 4,
"Too many new validators in this era. Please try again in the next era."
);
}
}
//
let staking_history = self.record_staking_fact(StakingFact::ValidatorRegistered {
validator_id: validator_id.clone(),
validator_id_in_appchain: formatted_validator_id_in_appchain.to_string(),
Expand Down
5 changes: 3 additions & 2 deletions appchain-anchor/src/user_actions/sudo_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,12 @@ impl SudoActions for AppchainAnchor {
.set(&permissionless_actions_status);
}
//
fn remove_appchain_messages_before(&mut self, nonce: u32) {
fn clear_appchain_messages(&mut self) -> MultiTxsOperationProcessingResult {
self.assert_owner();
let mut appchain_messages = self.appchain_messages.get().unwrap();
appchain_messages.remove_messages_before(&nonce);
let result = appchain_messages.clear();
self.appchain_messages.set(&appchain_messages);
result
}
//
fn try_complete_switching_era(&mut self) -> MultiTxsOperationProcessingResult {
Expand Down
2 changes: 1 addition & 1 deletion appchain-anchor/tests/test_anchor_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn test_normal_actions(
// user0 register validator (error)
//
let user0_balance = token_viewer::get_oct_balance_of(&users[0], &oct_token);
let amount0 = common::to_oct_amount(9999);
let amount0 = common::to_oct_amount(4999);
let result = staking_actions::register_validator(
&users[0],
&oct_token,
Expand Down

0 comments on commit 21b7336

Please sign in to comment.