From c32a69eaf027809768f0dc414fe0c9e017ed9094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 24 Jul 2023 12:48:39 +0300 Subject: [PATCH 01/27] Governance-v2: Add merkle proof support --- .../governance-v2/src/configurable.rs | 8 +- .../governance-v2/src/errors.rs | 10 +- energy-integration/governance-v2/src/lib.rs | 119 ++++++----- .../governance-v2/src/proposal.rs | 5 +- energy-integration/governance-v2/src/views.rs | 15 +- .../governance-v2/tests/gov_rust_test.rs | 30 +-- .../governance-v2/tests/gov_test_setup/mod.rs | 198 +++++++++++------- 7 files changed, 234 insertions(+), 151 deletions(-) diff --git a/energy-integration/governance-v2/src/configurable.rs b/energy-integration/governance-v2/src/configurable.rs index 5ed97fefc..c7982e68a 100644 --- a/energy-integration/governance-v2/src/configurable.rs +++ b/energy-integration/governance-v2/src/configurable.rs @@ -60,9 +60,9 @@ pub trait ConfigurablePropertiesModule: } #[only_owner] - #[endpoint(changeQuorum)] - fn change_quorum(&self, new_value: BigUint) { - self.try_change_quorum(new_value); + #[endpoint(changeQuorumPercentage)] + fn change_quorum_percentage(&self, new_value: BigUint) { + self.try_change_quorum_percentage(new_value); } #[only_owner] @@ -96,7 +96,7 @@ pub trait ConfigurablePropertiesModule: self.min_fee_for_propose().set(&new_value); } - fn try_change_quorum(&self, new_value: BigUint) { + fn try_change_quorum_percentage(&self, new_value: BigUint) { require!( new_value > MIN_QUORUM && new_value < MAX_QUORUM, "Not valid value for Quorum!" diff --git a/energy-integration/governance-v2/src/errors.rs b/energy-integration/governance-v2/src/errors.rs index ff552346b..f569688a8 100644 --- a/energy-integration/governance-v2/src/errors.rs +++ b/energy-integration/governance-v2/src/errors.rs @@ -1,6 +1,14 @@ pub const WRONG_TOKEN_ID: &[u8] = b"Wrong payment token id for fee"; pub const NOT_ENOUGH_FEE: &[u8] = b"Minimum fee required not reached"; -pub const NOT_ENOUGH_ENERGY: &[u8] = b"Not enough energy for propose"; pub const TOO_MUCH_GAS: &[u8] = b"Actions require too much gas to be executed"; pub const PROPOSAL_NOT_ACTIVE: &[u8] = b"Proposal is not active"; pub const ERROR_NOT_AN_ESDT: &[u8] = b"Not a valid esdt id"; +pub const ALREADY_VOTED_ERR_MSG: &[u8] = b"Already voted for this proposal"; +pub const INVALID_ROOT_HASH: &[u8] = b"Invalid root hash provided"; +pub const PROPOSAL_NO_ACTION: &[u8] = b"Proposal has no actions"; +pub const EXEEDED_MAX_ACTIONS: &[u8] = b"Exceeded max actions per proposal"; +pub const ONLY_PROPOSER_CANCEL: &[u8] = b"Only original proposer may cancel a pending proposal"; +pub const ONLY_PROPOSER_WITHDRAW: &[u8] = b"Only original proposer may cancel a pending proposal"; +pub const NO_PROPOSAL: &[u8] = b"Proposal does not exist"; +pub const WITHDRAW_NOT_ALLOWED: &[u8] = b"You may not withdraw funds from this proposal!"; +pub const INVALID_MERKLE_PROOF: &[u8] = b"Invalid merkle proof provided"; \ No newline at end of file diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index 39459c1b7..4035ef03d 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -12,15 +12,12 @@ pub mod views; use proposal::*; use proposal_storage::VoteType; -use weekly_rewards_splitting::events::Week; -use weekly_rewards_splitting::global_info::ProxyTrait as _; use crate::errors::*; use crate::proposal_storage::ProposalVotes; const MAX_GAS_LIMIT_PER_BLOCK: u64 = 600_000_000; const FULL_PERCENTAGE: u64 = 10_000; -static ALREADY_VOTED_ERR_MSG: &[u8] = b"Already voted for this proposal"; /// An empty contract. To be used as a template when starting a new contract from scratch. #[multiversx_sc::contract] @@ -33,34 +30,34 @@ pub trait GovernanceV2: + energy_query::EnergyQueryModule + permissions_module::PermissionsModule { - /// - `min_energy_for_propose` - the minimum energy required for submitting a proposal - /// - `min_fee_for_propose` - the minimum fee required for submitting a proposal - /// - `quorum` - the minimum number of (`votes` minus `downvotes`) at the end of voting period - /// - `maxActionsPerProposal` - Maximum number of actions (transfers and/or smart contract calls) that a proposal may have - /// - `votingDelayInBlocks` - Number of blocks to wait after a block is proposed before being able to vote/downvote that proposal - /// - `votingPeriodInBlocks` - Number of blocks the voting period lasts (voting delay does not count towards this) - /// - `lockTimeAfterVotingEndsInBlocks` - Number of blocks to wait before a successful proposal can be executed + /// - `min_energy_for_propose` - the minimum energy required for submitting a proposal; + /// - `min_fee_for_propose` - the minimum fee required for submitting a proposal; + /// - `quorum` - the minimum number of (`votes` minus `downvotes`) at the end of voting period; + /// - `votingDelayInBlocks` - Number of blocks to wait after a block is proposed before being able to vote/downvote that proposal; + /// - `votingPeriodInBlocks` - Number of blocks the voting period lasts (voting delay does not count towards this); + /// - `withdraw_percentage_defeated` - The percentage used to return in case of DownVetoVote; + /// - `energy_factory_address`; + /// - `fees_collector_address`; + /// - `fee_token` - The token used to pay the fee for governance proposal; #[init] fn init( &self, - min_energy_for_propose: BigUint, + // min_energy_for_propose: BigUint, min_fee_for_propose: BigUint, quorum_percentage: BigUint, voting_delay_in_blocks: u64, voting_period_in_blocks: u64, withdraw_percentage_defeated: u64, energy_factory_address: ManagedAddress, - fees_collector_address: ManagedAddress, fee_token: TokenIdentifier, ) { - self.try_change_min_energy_for_propose(min_energy_for_propose); + // self.try_change_min_energy_for_propose(min_energy_for_propose); self.try_change_min_fee_for_propose(min_fee_for_propose); - self.try_change_quorum(quorum_percentage); + self.try_change_quorum_percentage(quorum_percentage); self.try_change_voting_delay_in_blocks(voting_delay_in_blocks); self.try_change_voting_period_in_blocks(voting_period_in_blocks); self.try_change_withdraw_percentage_defeated(withdraw_percentage_defeated); self.set_energy_factory_address(energy_factory_address); - self.fees_collector_address().set(&fees_collector_address); self.try_change_fee_token_id(fee_token); } @@ -81,20 +78,23 @@ pub trait GovernanceV2: #[endpoint] fn propose( &self, + root_hash: ManagedByteArray, + total_voting_power: BigUint, description: ManagedBuffer, actions: MultiValueEncoded>, ) -> ProposalId { self.require_caller_not_self(); - require!(!actions.is_empty(), "Proposal has no actions"); + require!(!root_hash.is_empty(), INVALID_ROOT_HASH); + require!(!actions.is_empty(), PROPOSAL_NO_ACTION); require!( actions.len() <= MAX_GOVERNANCE_PROPOSAL_ACTIONS, - "Exceeded max actions per proposal" + EXEEDED_MAX_ACTIONS ); let proposer = self.blockchain().get_caller(); - let user_energy = self.get_energy_amount_non_zero(&proposer); - let min_energy_for_propose = self.min_energy_for_propose().get(); - require!(user_energy >= min_energy_for_propose, NOT_ENOUGH_ENERGY); + // let user_energy = self.get_energy_amount_non_zero(&proposer); + // let min_energy_for_propose = self.min_energy_for_propose().get(); + // require!(user_energy >= min_energy_for_propose, NOT_ENOUGH_ENERGY); let user_fee = self.call_value().single_esdt(); require!( @@ -134,13 +134,14 @@ pub trait GovernanceV2: proposal_id: self.proposals().len() + 1, proposer: proposer.clone(), description, + root_hash, actions: gov_actions, fee_payment: user_fee, minimum_quorum, voting_delay_in_blocks, voting_period_in_blocks, withdraw_percentage_defeated, - total_energy: BigUint::zero(), + total_voting_power, proposal_start_block: current_block, }; let proposal_id = self.proposals().push(&proposal); @@ -154,7 +155,7 @@ pub trait GovernanceV2: /// Vote on a proposal. The voting power depends on the user's energy. #[endpoint] - fn vote(&self, proposal_id: ProposalId, vote: VoteType) { + fn vote(&self, proposal_id: ProposalId, vote: VoteType, voting_power: BigUint, proof: ArrayVec, PROOF_LENGTH>) { self.require_caller_not_self(); self.require_valid_proposal_id(proposal_id); require!( @@ -166,59 +167,46 @@ pub trait GovernanceV2: let new_user = self.user_voted_proposals(&voter).insert(proposal_id); require!(new_user, ALREADY_VOTED_ERR_MSG); - let current_quorum = self.proposal_votes(proposal_id).get().quorum; - - // First voter -> update total_energy - if current_quorum == BigUint::zero() { - let fees_collector_addr = self.fees_collector_address().get(); - let last_global_update_week: Week = self - .fees_collector_proxy(fees_collector_addr.clone()) - .last_global_update_week() - .execute_on_dest_context(); - - let total_energy: BigUint = self - .fees_collector_proxy(fees_collector_addr) - .total_energy_for_week(last_global_update_week) - .execute_on_dest_context(); - - let mut proposal = self.proposals().get(proposal_id); - proposal.total_energy = total_energy; - self.proposals().set(proposal_id, &proposal); + match self.get_root_hash(proposal_id) { + OptionalValue::None => { + sc_panic!(NO_PROPOSAL); + } + OptionalValue::Some(root_hash) => { + require!(self.verify_merkle_proof(voting_power.clone(), proof, root_hash), INVALID_MERKLE_PROOF); + } } - let user_energy = self.get_energy_amount_non_zero(&voter); - let voting_power = user_energy.sqrt(); - match vote { VoteType::UpVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.up_votes += &voting_power.clone(); - proposal_votes.quorum += &user_energy.clone(); + proposal_votes.quorum += &voting_power.clone(); }); self.up_vote_cast_event(&voter, proposal_id, &voting_power); } VoteType::DownVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.down_votes += &voting_power.clone(); - proposal_votes.quorum += &user_energy.clone(); + proposal_votes.quorum += &voting_power.clone(); }); self.down_vote_cast_event(&voter, proposal_id, &voting_power); } VoteType::DownVetoVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.down_veto_votes += &voting_power.clone(); - proposal_votes.quorum += &user_energy.clone(); + proposal_votes.quorum += &voting_power.clone(); }); self.down_veto_vote_cast_event(&voter, proposal_id, &voting_power); } VoteType::AbstainVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.abstain_votes += &voting_power.clone(); - proposal_votes.quorum += &user_energy.clone(); + proposal_votes.quorum += &voting_power.clone(); }); self.abstain_vote_cast_event(&voter, proposal_id, &voting_power); } } + self.user_voted_proposals(&voter).insert(proposal_id); } /// Cancel a proposed action. This can be done: @@ -230,7 +218,7 @@ pub trait GovernanceV2: match self.get_proposal_status(proposal_id) { GovernanceProposalStatus::None => { - sc_panic!("Proposal does not exist"); + sc_panic!(NO_PROPOSAL); } GovernanceProposalStatus::Pending => { let proposal = self.proposals().get(proposal_id); @@ -238,7 +226,7 @@ pub trait GovernanceV2: require!( caller == proposal.proposer, - "Only original proposer may cancel a pending proposal" + ONLY_PROPOSER_CANCEL ); self.refund_proposal_fee(proposal_id, &proposal.fee_payment.amount); self.clear_proposal(proposal_id); @@ -259,14 +247,14 @@ pub trait GovernanceV2: match self.get_proposal_status(proposal_id) { GovernanceProposalStatus::None => { - sc_panic!("Proposal does not exist"); + sc_panic!(NO_PROPOSAL); } GovernanceProposalStatus::Succeeded | GovernanceProposalStatus::Defeated => { let proposal = self.proposals().get(proposal_id); require!( caller == proposal.proposer, - "Only original proposer may cancel a pending proposal" + ONLY_PROPOSER_WITHDRAW ); self.refund_proposal_fee(proposal_id, &proposal.fee_payment.amount); @@ -279,7 +267,7 @@ pub trait GovernanceV2: require!( caller == proposal.proposer, - "Only original proposer may cancel a pending proposal" + ONLY_PROPOSER_WITHDRAW ); self.refund_proposal_fee(proposal_id, &refund_amount); @@ -294,7 +282,7 @@ pub trait GovernanceV2: }); } _ => { - sc_panic!("You may not withdraw funds from this proposal!"); + sc_panic!(WITHDRAW_NOT_ALLOWED); } } self.proposal_withdraw_after_defeated_event(proposal_id); @@ -324,6 +312,31 @@ pub trait GovernanceV2: ); } + fn verify_merkle_proof(&self, power: BigUint, proof: ArrayVec, PROOF_LENGTH>, root_hash: ManagedByteArray) -> bool { + let caller = self.blockchain().get_caller(); + let mut leaf_bytes = caller.as_managed_buffer().clone(); + + let p = power.to_bytes_be_buffer(); + leaf_bytes.append(&p); + + let mut hash = self.crypto().sha256(&leaf_bytes); + for proof_item in proof { + if BigUint::from(hash.as_managed_buffer()) < BigUint::from(proof_item.as_managed_buffer()) { + let mut tst = hash.as_managed_buffer().clone(); + tst.append(proof_item.as_managed_buffer()); + + hash = self.crypto().sha256(tst); + } else { + let mut tst = proof_item.as_managed_buffer().clone(); + tst.append(hash.as_managed_buffer()); + + hash = self.crypto().sha256(tst); + } + } + + hash == root_hash + } + #[storage_mapper("proposalRemainingFees")] fn proposal_remaining_fees(&self) -> SingleValueMapper>>; diff --git a/energy-integration/governance-v2/src/proposal.rs b/energy-integration/governance-v2/src/proposal.rs index 9c4190b0e..ba12bfb4d 100644 --- a/energy-integration/governance-v2/src/proposal.rs +++ b/energy-integration/governance-v2/src/proposal.rs @@ -1,6 +1,8 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); +pub const HASH_LENGTH: usize = 32; +pub const PROOF_LENGTH: usize = 18; pub const MAX_GOVERNANCE_PROPOSAL_ACTIONS: usize = 4; pub type ProposalId = usize; @@ -56,11 +58,12 @@ pub struct GovernanceProposal { pub proposer: ManagedAddress, pub actions: ArrayVec, MAX_GOVERNANCE_PROPOSAL_ACTIONS>, pub description: ManagedBuffer, + pub root_hash: ManagedByteArray, pub fee_payment: EsdtTokenPayment, pub minimum_quorum: BigUint, pub voting_delay_in_blocks: u64, pub voting_period_in_blocks: u64, pub withdraw_percentage_defeated: u64, - pub total_energy: BigUint, + pub total_voting_power: BigUint, pub proposal_start_block: u64, } diff --git a/energy-integration/governance-v2/src/views.rs b/energy-integration/governance-v2/src/views.rs index f5e93b2aa..55200675f 100644 --- a/energy-integration/governance-v2/src/views.rs +++ b/energy-integration/governance-v2/src/views.rs @@ -1,7 +1,7 @@ multiversx_sc::imports!(); use crate::{ - proposal::{GovernanceProposalStatus, ProposalId}, + proposal::{GovernanceProposalStatus, ProposalId, HASH_LENGTH}, FULL_PERCENTAGE, }; @@ -45,6 +45,15 @@ pub trait ViewsModule: } } + #[view(getProposalRootHash)] + fn get_root_hash(&self, proposal_id: ProposalId) -> OptionalValue> { + if !self.proposal_exists(proposal_id) { + return OptionalValue::None; + } + + OptionalValue::Some(self.proposals().get(proposal_id).root_hash) + } + fn vote_reached(&self, proposal_id: ProposalId) -> bool { let proposal_votes = self.proposal_votes(proposal_id).get(); let total_votes = proposal_votes.get_total_votes(); @@ -81,13 +90,13 @@ pub trait ViewsModule: fn quorum_reached(&self, proposal_id: ProposalId) -> bool { let proposal = self.proposals().get(proposal_id); - let total_energy_for_proposal = proposal.total_energy; + let total_voting_power_for_proposal = proposal.total_voting_power; let required_minimum_percentage = proposal.minimum_quorum; let current_quorum = self.proposal_votes(proposal_id).get().quorum; let current_quorum_percentage = - current_quorum * FULL_PERCENTAGE / total_energy_for_proposal; + current_quorum * FULL_PERCENTAGE / total_voting_power_for_proposal; current_quorum_percentage >= required_minimum_percentage } diff --git a/energy-integration/governance-v2/tests/gov_rust_test.rs b/energy-integration/governance-v2/tests/gov_rust_test.rs index 50f88b42d..9e42178b8 100644 --- a/energy-integration/governance-v2/tests/gov_rust_test.rs +++ b/energy-integration/governance-v2/tests/gov_rust_test.rs @@ -17,7 +17,9 @@ fn init_gov_test() { fn gov_propose_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); + let first_user_power = gov_setup.get_first_user_voting_power(); + let first_user_proof = gov_setup.first_merkle_proof(); let second_user_addr = gov_setup.second_user.clone(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; @@ -38,19 +40,19 @@ fn gov_propose_test() { // vote too early gov_setup - .up_vote(&second_user_addr, proposal_id) + .up_vote(&second_user_addr) .assert_user_error("Proposal is not active"); gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr, proposal_id).assert_ok(); + gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup - .up_vote(&second_user_addr, proposal_id) + .up_vote(&second_user_addr) .assert_ok(); // user 2 try vote again gov_setup - .up_vote(&second_user_addr, proposal_id) + .up_vote(&second_user_addr) .assert_user_error("Already voted for this proposal"); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -118,9 +120,9 @@ fn gov_no_veto_vote_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr, proposal_id).assert_ok(); + gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup - .up_vote(&second_user_addr, proposal_id) + .up_vote(&second_user_addr) .assert_ok(); // Third User DownWithVetoVote = 1_100 @@ -166,7 +168,7 @@ fn gov_abstain_vote_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr, proposal_id).assert_ok(); + gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup .abstain_vote(&third_user_addr, proposal_id) .assert_ok(); @@ -208,7 +210,7 @@ fn gov_no_quorum_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr, proposal_id).assert_ok(); + gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -247,7 +249,7 @@ fn gov_modify_quorum_after_end_vote_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr, proposal_id).assert_ok(); + gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -258,7 +260,7 @@ fn gov_modify_quorum_after_end_vote_test() { sc.get_proposal_status(1) == GovernanceProposalStatus::Defeated, "Action should have been Defeated" ); - sc.try_change_quorum(managed_biguint!(QUORUM_PERCENTAGE / 2)); + sc.try_change_quorum_percentage(managed_biguint!(QUORUM_PERCENTAGE / 2)); assert!(sc.quorum_percentage().get() == managed_biguint!(QUORUM_PERCENTAGE / 2)); assert!( @@ -303,7 +305,7 @@ fn gov_withdraw_defeated_proposal_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr, proposal_id).assert_ok(); + gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup .down_vote(&third_user_addr, proposal_id) .assert_ok(); @@ -374,7 +376,7 @@ fn gov_modify_withdraw_defeated_proposal_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr, proposal_id).assert_ok(); + gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup .down_vote(&third_user_addr, proposal_id) .assert_ok(); @@ -449,7 +451,7 @@ fn gov_withdraw_no_with_veto_defeated_proposal_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr, proposal_id).assert_ok(); + gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup .down_veto_vote(&third_user_addr, proposal_id) .assert_ok(); diff --git a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs index 3c02e7e09..8683d41f6 100644 --- a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs +++ b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs @@ -1,14 +1,12 @@ use energy_factory_mock::EnergyFactoryMock; use energy_query::Energy; -use fees_collector::FeesCollector; use governance_v2::{ - configurable::ConfigurablePropertiesModule, proposal_storage::{ProposalStorageModule, VoteType}, GovernanceV2, }; use multiversx_sc::{ - codec::multi_types::OptionalValue, - types::{Address, BigInt, ManagedVec, MultiValueEncoded}, + hex_literal::hex, + types::{Address, BigInt, ManagedByteArray, ManagedVec, MultiValueEncoded, BigUint}, arrayvec::ArrayVec, }; use multiversx_sc_scenario::{ managed_address, managed_biguint, managed_buffer, managed_token_id, rust_biguint, @@ -16,18 +14,17 @@ use multiversx_sc_scenario::{ whitebox::{BlockchainStateWrapper, ContractObjWrapper}, DebugApi, }; -use num_bigint::BigUint; -pub const MIN_ENERGY_FOR_PROPOSE: u64 = 500_000; pub const MIN_FEE_FOR_PROPOSE: u64 = 3_000_000; pub const QUORUM_PERCENTAGE: u64 = 5000; pub const VOTING_DELAY_BLOCKS: u64 = 10; pub const VOTING_PERIOD_BLOCKS: u64 = 14_500; pub const LOCKING_PERIOD_BLOCKS: u64 = 30; pub const WITHDRAW_PERCENTAGE: u64 = 5_000; // 50% -pub static WXMEX_TOKEN_ID: &[u8] = b"WXMEX-123456"; +pub const WXMEX_TOKEN_ID: &[u8] = b"WXMEX-123456"; pub const LOCKED_TOKEN_ID: &[u8] = b"LOCKED-abcdef"; pub const DECIMALS_CONST: u64 = 1_000_000_000_000_000_000; +pub const QUORUM: u64 = 217_433_990_694; pub const USER_ENERGY: u64 = 1_000_000; pub const GAS_LIMIT: u64 = 1_000_000; @@ -48,6 +45,9 @@ where pub first_user: Address, pub second_user: Address, pub third_user: Address, + pub first_merkle_user: Address, + pub second_merkle_user: Address, + pub third_merkle_user: Address, pub gov_wrapper: ContractObjWrapper, GovBuilder>, pub current_block: u64, } @@ -63,6 +63,16 @@ where let first_user = b_mock.create_user_account(&rust_zero); let second_user = b_mock.create_user_account(&rust_zero); let third_user = b_mock.create_user_account(&rust_zero); + let first_merkle_user = Address::from(&hex!( + "25ee243280fc6e740424a28fa40c795458943b475cd77f3778f9c8e0b4a1e7f8" + )); + let second_merkle_user = Address::from(&hex!( + "0d5acc0ee5a229ae549dad903fb7bcbc1f80b67198949f02fd611d25d41689cb" + )); + let third_merkle_user = Address::from(&hex!( + "190c55b8f27547244c65ad13cbbe7457d5fb90481f34b84160a1cf6e44e0875c" + )); + b_mock.create_user_account_fixed_address(&first_merkle_user, &rust_zero); // init energy factory let energy_factory_wrapper = b_mock.create_sc_account( @@ -72,14 +82,6 @@ where "energy factory path", ); - // init fees collector - let fees_collector_wrapper = b_mock.create_sc_account( - &rust_biguint!(0), - None, - fees_collector::contract_obj, - "fees collector path", - ); - b_mock .execute_tx(&owner, &energy_factory_wrapper, &rust_zero, |sc| { sc.init(); @@ -104,48 +106,6 @@ where }) .assert_ok(); - b_mock - .execute_tx(&owner, &fees_collector_wrapper, &rust_biguint!(0), |sc| { - sc.init( - managed_token_id!(LOCKED_TOKEN_ID), - managed_address!(energy_factory_wrapper.address_ref()), - ); - }) - .assert_ok(); - - b_mock - .execute_tx( - &first_user, - &fees_collector_wrapper, - &rust_biguint!(0), - |sc| { - sc.claim_rewards(OptionalValue::None); - }, - ) - .assert_ok(); - - b_mock - .execute_tx( - &second_user, - &fees_collector_wrapper, - &rust_biguint!(0), - |sc| { - sc.claim_rewards(OptionalValue::None); - }, - ) - .assert_ok(); - - b_mock - .execute_tx( - &third_user, - &fees_collector_wrapper, - &rust_biguint!(0), - |sc| { - sc.claim_rewards(OptionalValue::None); - }, - ) - .assert_ok(); - // init governance sc let gov_wrapper = b_mock.create_sc_account(&rust_zero, Some(&owner), gov_builder, "gov path"); @@ -154,31 +114,26 @@ where b_mock .execute_tx(&owner, &gov_wrapper, &rust_zero, |sc| { sc.init( - managed_biguint!(MIN_ENERGY_FOR_PROPOSE), managed_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST, managed_biguint!(QUORUM_PERCENTAGE), VOTING_DELAY_BLOCKS, VOTING_PERIOD_BLOCKS, WITHDRAW_PERCENTAGE, managed_address!(energy_factory_wrapper.address_ref()), - managed_address!(fees_collector_wrapper.address_ref()), managed_token_id!(WXMEX_TOKEN_ID), ); }) .assert_ok(); - b_mock - .execute_tx(&owner, &gov_wrapper, &rust_zero, |sc| { - sc.fee_token_id().set(managed_token_id!(WXMEX_TOKEN_ID)); - }) - .assert_ok(); - Self { b_mock, owner, first_user, second_user, third_user, + first_merkle_user, + second_merkle_user, + third_merkle_user, gov_wrapper, current_block: 0, } @@ -186,8 +141,9 @@ where pub fn propose( &mut self, + root_hash: ManagedByteArray, proposer: &Address, - fee_amount: &BigUint, + fee_amount: &BigUint, dest_address: &Address, endpoint_name: &[u8], args: Vec>, @@ -216,38 +172,43 @@ where .into(), ); - proposal_id = sc.propose(managed_buffer!(b"changeTODO"), actions); + proposal_id = sc.propose( + root_hash, + managed_biguint!(QUORUM), + managed_buffer!(b"changeTODO"), + actions, + ); }, ); (result, proposal_id) } - pub fn up_vote(&mut self, voter: &Address, proposal_id: usize) -> TxResult { + pub fn up_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::UpVote); + sc.vote(proposal_id, VoteType::UpVote, power.clone(), proof.clone()); }) } - pub fn down_vote(&mut self, voter: &Address, proposal_id: usize) -> TxResult { + pub fn down_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::DownVote); + sc.vote(proposal_id, VoteType::DownVote, power.clone(), proof.clone()); }) } - pub fn down_veto_vote(&mut self, voter: &Address, proposal_id: usize) -> TxResult { + pub fn down_veto_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::DownVetoVote); + sc.vote(proposal_id, VoteType::DownVetoVote, power.clone(), proof.clone()); }) } - pub fn abstain_vote(&mut self, voter: &Address, proposal_id: usize) -> TxResult { + pub fn abstain_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::AbstainVote); + sc.vote(proposal_id, VoteType::AbstainVote, power.clone(), proof.clone()); }) } @@ -283,4 +244,91 @@ where self.current_block += inc_amount; self.b_mock.set_block_nonce(self.current_block); } + pub fn first_merkle_proof(&self) -> ArrayVec, 18> { + ArrayVec::from([ + ManagedByteArray::from(&hex!("5e9e904152b2a06dafc26aa02b8c55b2ec3370cdf55b06b15fe8c94bc56e43fc")), + ManagedByteArray::from(&hex!("47aa547fa524519bc946d0883591e9d273a65b4a8f06a37baf170c707c4fb782")), + ManagedByteArray::from(&hex!("da05a587448779b9368680f0ee745b3ff2df1132e309a2de518aa9814cc25de8")), + ManagedByteArray::from(&hex!("14ae69620e727d8e899119ef7a1f04191f15f7c704c2673445510a1bbce7edb2")), + ManagedByteArray::from(&hex!("449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533")), + ManagedByteArray::from(&hex!("fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66")), + ManagedByteArray::from(&hex!("889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc")), + ManagedByteArray::from(&hex!("5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f")), + ManagedByteArray::from(&hex!("ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c")), + ManagedByteArray::from(&hex!("781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82")), + ManagedByteArray::from(&hex!("5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0")), + ManagedByteArray::from(&hex!("2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059")), + ManagedByteArray::from(&hex!("9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c")), + ManagedByteArray::from(&hex!("b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4")), + ManagedByteArray::from(&hex!("95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2")), + ManagedByteArray::from(&hex!("39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838")), + ManagedByteArray::from(&hex!("b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad")), + ManagedByteArray::from(&hex!("bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1")), + ]) + } + + pub fn second_merkle_proof(&self) -> ArrayVec, 18> { + ArrayVec::from([ + ManagedByteArray::from(&hex!("b1d7a256ae6b35cce14497b3735d71dd205f099f1a035a7a5cb96e8bf5c32f31")), + ManagedByteArray::from(&hex!("81dc00d137001723d5654e3120d63601b08ca2b4b8dc41802476529e6d6ada9e")), + ManagedByteArray::from(&hex!("985e3554adfefea5d2c3f7c93d404fd547cfead9054ce313845656507037df40")), + ManagedByteArray::from(&hex!("14ae69620e727d8e899119ef7a1f04191f15f7c704c2673445510a1bbce7edb2")), + ManagedByteArray::from(&hex!("449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533")), + ManagedByteArray::from(&hex!("fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66")), + ManagedByteArray::from(&hex!("889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc")), + ManagedByteArray::from(&hex!("5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f")), + ManagedByteArray::from(&hex!("ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c")), + ManagedByteArray::from(&hex!("781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82")), + ManagedByteArray::from(&hex!("5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0")), + ManagedByteArray::from(&hex!("2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059")), + ManagedByteArray::from(&hex!("9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c")), + ManagedByteArray::from(&hex!("b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4")), + ManagedByteArray::from(&hex!("95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2")), + ManagedByteArray::from(&hex!("39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838")), + ManagedByteArray::from(&hex!("b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad")), + ManagedByteArray::from(&hex!("bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1")), + ]) + } + + pub fn third_merkle_proof(&self) -> ArrayVec, 18> { + ArrayVec::from([ + ManagedByteArray::from(&hex!("aa68ae7eac4de3cc643717d33ab7d2e1b098788b127f298f23a34e8720ec609d")), + ManagedByteArray::from(&hex!("e3db2cf9f85b49279eba44b0f62ac2c6bcdf870f198b9484344634a58860ba2d")), + ManagedByteArray::from(&hex!("64468b8481d2c1737977e7382eaaa12c8072ee76fda33c3b6aaa193b38d4f1f2")), + ManagedByteArray::from(&hex!("6159dc0c80183e89221a36db3fedfabe38933d0db73c1156ad32d8caf0537085")), + ManagedByteArray::from(&hex!("449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533")), + ManagedByteArray::from(&hex!("fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66")), + ManagedByteArray::from(&hex!("889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc")), + ManagedByteArray::from(&hex!("5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f")), + ManagedByteArray::from(&hex!("ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c")), + ManagedByteArray::from(&hex!("781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82")), + ManagedByteArray::from(&hex!("5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0")), + ManagedByteArray::from(&hex!("2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059")), + ManagedByteArray::from(&hex!("9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c")), + ManagedByteArray::from(&hex!("b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4")), + ManagedByteArray::from(&hex!("95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2")), + ManagedByteArray::from(&hex!("39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838")), + ManagedByteArray::from(&hex!("b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad")), + ManagedByteArray::from(&hex!("bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1")), + + ]) + } + + + pub fn get_first_user_voting_power(&self) -> BigUint { + managed_biguint!(217433990694) + } + + pub fn get_second_user_voting_power(&self) -> BigUint { + managed_biguint!(59024824840) + } + + pub fn get_third_user_voting_power(&self) -> BigUint { + managed_biguint!(40000000000) + } + + pub fn get_merkle_root_hash(&self) -> ManagedByteArray { + ManagedByteArray::from(&hex!("0fdb09afb35351d5becc3a79dd9bf03bae7c2366d186a6c8e8276f545d024ef5")) + } + } From 89ba184f52534da94d52df0dad712bd1f1d2e97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 26 Jul 2023 15:03:57 +0300 Subject: [PATCH 02/27] governance-v2: Fix tests --- .../governance-v2/tests/gov_rust_test.rs | 151 +++++++++++++----- .../governance-v2/tests/gov_test_setup/mod.rs | 43 ++--- 2 files changed, 137 insertions(+), 57 deletions(-) diff --git a/energy-integration/governance-v2/tests/gov_rust_test.rs b/energy-integration/governance-v2/tests/gov_rust_test.rs index 9e42178b8..c0b885c31 100644 --- a/energy-integration/governance-v2/tests/gov_rust_test.rs +++ b/energy-integration/governance-v2/tests/gov_rust_test.rs @@ -20,15 +20,19 @@ fn gov_propose_test() { let first_user_addr = gov_setup.first_merkle_user.clone(); let first_user_power = gov_setup.get_first_user_voting_power(); let first_user_proof = gov_setup.first_merkle_proof(); - let second_user_addr = gov_setup.second_user.clone(); + let second_user_addr = gov_setup.second_merkle_user.clone(); + let second_user_power = gov_setup.get_second_user_voting_power(); + let second_user_proof = gov_setup.second_merkle_proof(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; + // Give proposer the minimum fee gov_setup .b_mock .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -40,19 +44,41 @@ fn gov_propose_test() { // vote too early gov_setup - .up_vote(&second_user_addr) + .up_vote( + &second_user_addr, + &second_user_power, + &second_user_proof, + proposal_id, + ) .assert_user_error("Proposal is not active"); gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup - .up_vote(&second_user_addr) + .up_vote( + &first_user_addr, + &first_user_power, + &first_user_proof, + proposal_id, + ) + .assert_ok(); + gov_setup + .up_vote( + &second_user_addr, + &second_user_power, + &second_user_proof, + proposal_id, + ) .assert_ok(); // user 2 try vote again gov_setup - .up_vote(&second_user_addr) + .up_vote( + &second_user_addr, + &second_user_power, + &second_user_proof, + proposal_id, + ) .assert_user_error("Already voted for this proposal"); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -88,9 +114,16 @@ fn gov_propose_test() { fn gov_no_veto_vote_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); - let second_user_addr = gov_setup.second_user.clone(); - let third_user_addr = gov_setup.third_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); + let first_user_power = gov_setup.get_first_user_voting_power(); + let first_user_proof = gov_setup.first_merkle_proof(); + let second_user_addr = gov_setup.second_merkle_user.clone(); + let second_user_power = gov_setup.get_second_user_voting_power(); + let second_user_proof = gov_setup.second_merkle_proof(); + let third_user_addr = gov_setup.third_merkle_user.clone(); + let third_user_power = gov_setup.get_third_user_voting_power(); + let third_user_proof = gov_setup.third_merkle_proof(); + let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; // Give proposer the minimum fee @@ -99,6 +132,7 @@ fn gov_no_veto_vote_test() { .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -120,14 +154,26 @@ fn gov_no_veto_vote_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr).assert_ok(); gov_setup - .up_vote(&second_user_addr) + .down_veto_vote( + &first_user_addr, + &first_user_power, + &first_user_proof, + proposal_id, + ) + .assert_ok(); + gov_setup + .up_vote( + &second_user_addr, + &second_user_power, + &second_user_proof, + proposal_id, + ) .assert_ok(); // Third User DownWithVetoVote = 1_100 gov_setup - .down_veto_vote(&third_user_addr, proposal_id) + .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -147,8 +193,12 @@ fn gov_no_veto_vote_test() { fn gov_abstain_vote_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); - let third_user_addr = gov_setup.third_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); + let first_user_power = gov_setup.get_first_user_voting_power(); + let first_user_proof = gov_setup.first_merkle_proof(); + let third_user_addr = gov_setup.third_merkle_user.clone(); + let third_user_power = gov_setup.get_third_user_voting_power(); + let third_user_proof = gov_setup.third_merkle_proof(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; // Give proposer the minimum fee @@ -157,6 +207,7 @@ fn gov_abstain_vote_test() { .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -168,9 +219,9 @@ fn gov_abstain_vote_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr).assert_ok(); + gov_setup.abstain_vote(&first_user_addr, &first_user_power, &first_user_proof, proposal_id).assert_ok(); gov_setup - .abstain_vote(&third_user_addr, proposal_id) + .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -190,7 +241,10 @@ fn gov_abstain_vote_test() { fn gov_no_quorum_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); + let third_user_addr = gov_setup.third_merkle_user.clone(); + let third_user_power = gov_setup.get_third_user_voting_power(); + let third_user_proof = gov_setup.third_merkle_proof(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; // Give proposer the minimum fee @@ -199,6 +253,7 @@ fn gov_no_quorum_test() { .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -210,7 +265,7 @@ fn gov_no_quorum_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr).assert_ok(); + gov_setup.up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id).assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -229,7 +284,10 @@ fn gov_no_quorum_test() { fn gov_modify_quorum_after_end_vote_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); + let third_user_addr = gov_setup.third_merkle_user.clone(); + let third_user_power = gov_setup.get_third_user_voting_power(); + let third_user_proof = gov_setup.third_merkle_proof(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; // Give proposer the minimum fee @@ -238,6 +296,7 @@ fn gov_modify_quorum_after_end_vote_test() { .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -247,11 +306,11 @@ fn gov_modify_quorum_after_end_vote_test() { result.assert_ok(); assert_eq!(proposal_id, 1); - gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); + gov_setup.increment_block_nonce(VOTING_DELAY_BLOCKS); - gov_setup.up_vote(&first_user_addr).assert_ok(); + gov_setup.up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id).assert_ok(); - gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); + gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); gov_setup .b_mock @@ -275,8 +334,12 @@ fn gov_modify_quorum_after_end_vote_test() { fn gov_withdraw_defeated_proposal_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); - let third_user_addr = gov_setup.third_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); + let first_user_power = gov_setup.get_first_user_voting_power(); + let first_user_proof = gov_setup.first_merkle_proof(); + let third_user_addr = gov_setup.third_merkle_user.clone(); + let third_user_power = gov_setup.get_third_user_voting_power(); + let third_user_proof = gov_setup.third_merkle_proof(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; // Give proposer the minimum fee @@ -285,6 +348,7 @@ fn gov_withdraw_defeated_proposal_test() { .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -303,14 +367,14 @@ fn gov_withdraw_defeated_proposal_test() { None, ); - gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); + gov_setup.increment_block_nonce(VOTING_DELAY_BLOCKS); - gov_setup.up_vote(&first_user_addr).assert_ok(); + gov_setup.down_vote(&first_user_addr, &first_user_power, &first_user_proof, proposal_id).assert_ok(); gov_setup - .down_vote(&third_user_addr, proposal_id) + .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) .assert_ok(); - gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); + gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); gov_setup .b_mock @@ -346,8 +410,12 @@ fn gov_withdraw_defeated_proposal_test() { fn gov_modify_withdraw_defeated_proposal_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); - let third_user_addr = gov_setup.third_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); + let first_user_power = gov_setup.get_first_user_voting_power(); + let first_user_proof = gov_setup.first_merkle_proof(); + let third_user_addr = gov_setup.third_merkle_user.clone(); + let third_user_power = gov_setup.get_third_user_voting_power(); + let third_user_proof = gov_setup.third_merkle_proof(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; // Give proposer the minimum fee @@ -356,6 +424,7 @@ fn gov_modify_withdraw_defeated_proposal_test() { .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -376,9 +445,9 @@ fn gov_modify_withdraw_defeated_proposal_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr).assert_ok(); + gov_setup.down_vote(&first_user_addr, &first_user_power, &first_user_proof, proposal_id).assert_ok(); gov_setup - .down_vote(&third_user_addr, proposal_id) + .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -421,8 +490,12 @@ fn gov_modify_withdraw_defeated_proposal_test() { fn gov_withdraw_no_with_veto_defeated_proposal_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); - let third_user_addr = gov_setup.third_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); + let first_user_power = gov_setup.get_first_user_voting_power(); + let first_user_proof = gov_setup.first_merkle_proof(); + let third_user_addr = gov_setup.third_merkle_user.clone(); + let third_user_power = gov_setup.get_third_user_voting_power(); + let third_user_proof = gov_setup.third_merkle_proof(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; // Give proposer the minimum fee @@ -431,6 +504,7 @@ fn gov_withdraw_no_with_veto_defeated_proposal_test() { .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -451,9 +525,9 @@ fn gov_withdraw_no_with_veto_defeated_proposal_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&first_user_addr).assert_ok(); + gov_setup.down_veto_vote(&first_user_addr, &first_user_power, &first_user_proof, proposal_id).assert_ok(); gov_setup - .down_veto_vote(&third_user_addr, proposal_id) + .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -492,7 +566,7 @@ fn gov_withdraw_no_with_veto_defeated_proposal_test() { fn gov_propose_cancel_proposal_id_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); - let first_user_addr = gov_setup.first_user.clone(); + let first_user_addr = gov_setup.first_merkle_user.clone(); let sc_addr = gov_setup.gov_wrapper.address_ref().clone(); let min_fee = rust_biguint!(MIN_FEE_FOR_PROPOSE) * DECIMALS_CONST; // Give proposer the minimum fee @@ -505,6 +579,7 @@ fn gov_propose_cancel_proposal_id_test() { ); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -519,6 +594,7 @@ fn gov_propose_cancel_proposal_id_test() { // Proposal ID = 2 let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -533,6 +609,7 @@ fn gov_propose_cancel_proposal_id_test() { // Proposal ID = 3 let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -567,6 +644,7 @@ fn gov_propose_cancel_proposal_id_test() { // Proposal ID = 4 let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -583,6 +661,7 @@ fn gov_propose_cancel_proposal_id_test() { // Proposal ID = 5 let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, diff --git a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs index 8683d41f6..171888ec7 100644 --- a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs +++ b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs @@ -6,7 +6,7 @@ use governance_v2::{ }; use multiversx_sc::{ hex_literal::hex, - types::{Address, BigInt, ManagedByteArray, ManagedVec, MultiValueEncoded, BigUint}, arrayvec::ArrayVec, + types::{Address, BigInt, ManagedByteArray, ManagedVec, MultiValueEncoded}, arrayvec::ArrayVec, }; use multiversx_sc_scenario::{ managed_address, managed_biguint, managed_buffer, managed_token_id, rust_biguint, @@ -14,6 +14,7 @@ use multiversx_sc_scenario::{ whitebox::{BlockchainStateWrapper, ContractObjWrapper}, DebugApi, }; +use num_bigint::BigUint; pub const MIN_FEE_FOR_PROPOSE: u64 = 3_000_000; pub const QUORUM_PERCENTAGE: u64 = 5000; @@ -22,11 +23,10 @@ pub const VOTING_PERIOD_BLOCKS: u64 = 14_500; pub const LOCKING_PERIOD_BLOCKS: u64 = 30; pub const WITHDRAW_PERCENTAGE: u64 = 5_000; // 50% pub const WXMEX_TOKEN_ID: &[u8] = b"WXMEX-123456"; -pub const LOCKED_TOKEN_ID: &[u8] = b"LOCKED-abcdef"; pub const DECIMALS_CONST: u64 = 1_000_000_000_000_000_000; pub const QUORUM: u64 = 217_433_990_694; -pub const USER_ENERGY: u64 = 1_000_000; +pub const VOTING_POWER: u64 = 1_000_000; pub const GAS_LIMIT: u64 = 1_000_000; #[derive(Clone)] @@ -57,6 +57,7 @@ where GovBuilder: 'static + Copy + Fn() -> governance_v2::ContractObj, { pub fn new(gov_builder: GovBuilder) -> Self { + let _ = DebugApi::dummy(); let rust_zero = rust_biguint!(0); let mut b_mock = BlockchainStateWrapper::new(); let owner = b_mock.create_user_account(&rust_zero); @@ -87,19 +88,19 @@ where sc.init(); sc.user_energy(&managed_address!(&first_user)) .set(&Energy::new( - BigInt::from(managed_biguint!(USER_ENERGY)), + BigInt::from(managed_biguint!(VOTING_POWER)), 0, managed_biguint!(0), )); sc.user_energy(&managed_address!(&second_user)) .set(&Energy::new( - BigInt::from(managed_biguint!(USER_ENERGY)), + BigInt::from(managed_biguint!(VOTING_POWER)), 0, managed_biguint!(0), )); sc.user_energy(&managed_address!(&third_user)) .set(&Energy::new( - BigInt::from(managed_biguint!(USER_ENERGY + 210_000)), + BigInt::from(managed_biguint!(VOTING_POWER + 210_000)), 0, managed_biguint!(0), )); @@ -143,7 +144,7 @@ where &mut self, root_hash: ManagedByteArray, proposer: &Address, - fee_amount: &BigUint, + fee_amount: &BigUint, dest_address: &Address, endpoint_name: &[u8], args: Vec>, @@ -184,31 +185,31 @@ where (result, proposal_id) } - pub fn up_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { + pub fn up_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::UpVote, power.clone(), proof.clone()); + sc.vote(proposal_id, VoteType::UpVote, power.into(), proof.clone()); }) } - pub fn down_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { + pub fn down_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::DownVote, power.clone(), proof.clone()); + sc.vote(proposal_id, VoteType::DownVote, power.into(), proof.clone()); }) } - pub fn down_veto_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { + pub fn down_veto_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::DownVetoVote, power.clone(), proof.clone()); + sc.vote(proposal_id, VoteType::DownVetoVote, power.into(), proof.clone()); }) } - pub fn abstain_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { + pub fn abstain_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::AbstainVote, power.clone(), proof.clone()); + sc.vote(proposal_id, VoteType::AbstainVote, power.into(), proof.clone()); }) } @@ -315,16 +316,16 @@ where } - pub fn get_first_user_voting_power(&self) -> BigUint { - managed_biguint!(217433990694) + pub fn get_first_user_voting_power(&self) -> BigUint { + BigUint::from(217_433_990_694u64) } - pub fn get_second_user_voting_power(&self) -> BigUint { - managed_biguint!(59024824840) + pub fn get_second_user_voting_power(&self) -> BigUint { + BigUint::from(59_024_824_840u64) } - pub fn get_third_user_voting_power(&self) -> BigUint { - managed_biguint!(40000000000) + pub fn get_third_user_voting_power(&self) -> BigUint { + BigUint::from(40_000_000_000u64) } pub fn get_merkle_root_hash(&self) -> ManagedByteArray { From db6743c305940f1ca8645cbc977c96b5b2b750b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 27 Jul 2023 12:41:35 +0300 Subject: [PATCH 03/27] Governance-v2:voting power is sqrt of user balance Fix tests --- .../governance-v2/src/errors.rs | 2 +- energy-integration/governance-v2/src/lib.rs | 59 ++-- .../governance-v2/src/proposal.rs | 2 +- energy-integration/governance-v2/src/views.rs | 14 +- .../governance-v2/tests/gov_rust_test.rs | 93 +++++- .../governance-v2/tests/gov_test_setup/mod.rs | 315 ++++++++++++------ 6 files changed, 332 insertions(+), 153 deletions(-) diff --git a/energy-integration/governance-v2/src/errors.rs b/energy-integration/governance-v2/src/errors.rs index f569688a8..f1676ff79 100644 --- a/energy-integration/governance-v2/src/errors.rs +++ b/energy-integration/governance-v2/src/errors.rs @@ -11,4 +11,4 @@ pub const ONLY_PROPOSER_CANCEL: &[u8] = b"Only original proposer may cancel a pe pub const ONLY_PROPOSER_WITHDRAW: &[u8] = b"Only original proposer may cancel a pending proposal"; pub const NO_PROPOSAL: &[u8] = b"Proposal does not exist"; pub const WITHDRAW_NOT_ALLOWED: &[u8] = b"You may not withdraw funds from this proposal!"; -pub const INVALID_MERKLE_PROOF: &[u8] = b"Invalid merkle proof provided"; \ No newline at end of file +pub const INVALID_MERKLE_PROOF: &[u8] = b"Invalid merkle proof provided"; diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index e5964eba1..b0c924800 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -36,8 +36,6 @@ pub trait GovernanceV2: /// - `votingDelayInBlocks` - Number of blocks to wait after a block is proposed before being able to vote/downvote that proposal; /// - `votingPeriodInBlocks` - Number of blocks the voting period lasts (voting delay does not count towards this); /// - `withdraw_percentage_defeated` - The percentage used to return in case of DownVetoVote; - /// - `energy_factory_address`; - /// - `fees_collector_address`; /// - `fee_token` - The token used to pay the fee for governance proposal; #[init] fn init( @@ -48,7 +46,6 @@ pub trait GovernanceV2: voting_delay_in_blocks: u64, voting_period_in_blocks: u64, withdraw_percentage_defeated: u64, - energy_factory_address: ManagedAddress, fee_token: TokenIdentifier, ) { // self.try_change_min_energy_for_propose(min_energy_for_propose); @@ -57,7 +54,6 @@ pub trait GovernanceV2: self.try_change_voting_delay_in_blocks(voting_delay_in_blocks); self.try_change_voting_period_in_blocks(voting_period_in_blocks); self.try_change_withdraw_percentage_defeated(withdraw_percentage_defeated); - self.set_energy_factory_address(energy_factory_address); self.try_change_fee_token_id(fee_token); } @@ -79,7 +75,7 @@ pub trait GovernanceV2: fn propose( &self, root_hash: ManagedByteArray, - total_voting_power: BigUint, + total_balance: BigUint, description: ManagedBuffer, actions: MultiValueEncoded>, ) -> ProposalId { @@ -141,7 +137,7 @@ pub trait GovernanceV2: voting_delay_in_blocks, voting_period_in_blocks, withdraw_percentage_defeated, - total_voting_power, + total_balance, proposal_start_block: current_block, }; let proposal_id = self.proposals().push(&proposal); @@ -153,9 +149,15 @@ pub trait GovernanceV2: proposal_id } - /// Vote on a proposal. The voting power depends on the user's energy. + /// Vote on a proposal. The voting balance depends on the user's energy. #[endpoint] - fn vote(&self, proposal_id: ProposalId, vote: VoteType, voting_power: BigUint, proof: ArrayVec, PROOF_LENGTH>) { + fn vote( + &self, + proposal_id: ProposalId, + vote: VoteType, + user_balance: BigUint, + proof: ArrayVec, PROOF_LENGTH>, + ) { self.require_caller_not_self(); self.require_valid_proposal_id(proposal_id); require!( @@ -167,12 +169,17 @@ pub trait GovernanceV2: let new_user = self.user_voted_proposals(&voter).insert(proposal_id); require!(new_user, ALREADY_VOTED_ERR_MSG); + let voting_power = user_balance.sqrt(); + match self.get_root_hash(proposal_id) { OptionalValue::None => { sc_panic!(NO_PROPOSAL); } OptionalValue::Some(root_hash) => { - require!(self.verify_merkle_proof(voting_power.clone(), proof, root_hash), INVALID_MERKLE_PROOF); + require!( + self.verify_merkle_proof(voting_power.clone(), proof, root_hash), + INVALID_MERKLE_PROOF + ); } } @@ -182,28 +189,28 @@ pub trait GovernanceV2: proposal_votes.up_votes += &voting_power.clone(); proposal_votes.quorum += &voting_power.clone(); }); - self.up_vote_cast_event(&voter, proposal_id, &voting_power, &user_energy); + self.up_vote_cast_event(&voter, proposal_id, &voting_power, &user_balance); } VoteType::DownVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.down_votes += &voting_power.clone(); proposal_votes.quorum += &voting_power.clone(); }); - self.down_vote_cast_event(&voter, proposal_id, &voting_power, &user_energy); + self.down_vote_cast_event(&voter, proposal_id, &voting_power, &user_balance); } VoteType::DownVetoVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.down_veto_votes += &voting_power.clone(); proposal_votes.quorum += &voting_power.clone(); }); - self.down_veto_vote_cast_event(&voter, proposal_id, &voting_power, &user_energy); + self.down_veto_vote_cast_event(&voter, proposal_id, &voting_power, &user_balance); } VoteType::AbstainVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.abstain_votes += &voting_power.clone(); proposal_votes.quorum += &voting_power.clone(); }); - self.abstain_vote_cast_event(&voter, proposal_id, &voting_power, &user_energy); + self.abstain_vote_cast_event(&voter, proposal_id, &voting_power, &user_balance); } } self.user_voted_proposals(&voter).insert(proposal_id); @@ -224,10 +231,7 @@ pub trait GovernanceV2: let proposal = self.proposals().get(proposal_id); let caller = self.blockchain().get_caller(); - require!( - caller == proposal.proposer, - ONLY_PROPOSER_CANCEL - ); + require!(caller == proposal.proposer, ONLY_PROPOSER_CANCEL); self.refund_proposal_fee(proposal_id, &proposal.fee_payment.amount); self.clear_proposal(proposal_id); self.proposal_canceled_event(proposal_id); @@ -252,10 +256,7 @@ pub trait GovernanceV2: GovernanceProposalStatus::Succeeded | GovernanceProposalStatus::Defeated => { let proposal = self.proposals().get(proposal_id); - require!( - caller == proposal.proposer, - ONLY_PROPOSER_WITHDRAW - ); + require!(caller == proposal.proposer, ONLY_PROPOSER_WITHDRAW); self.refund_proposal_fee(proposal_id, &proposal.fee_payment.amount); } @@ -265,10 +266,7 @@ pub trait GovernanceV2: let refund_amount = refund_percentage * proposal.fee_payment.amount.clone() / FULL_PERCENTAGE; - require!( - caller == proposal.proposer, - ONLY_PROPOSER_WITHDRAW - ); + require!(caller == proposal.proposer, ONLY_PROPOSER_WITHDRAW); self.refund_proposal_fee(proposal_id, &refund_amount); let remaining_fee = proposal.fee_payment.amount - refund_amount; @@ -312,7 +310,12 @@ pub trait GovernanceV2: ); } - fn verify_merkle_proof(&self, power: BigUint, proof: ArrayVec, PROOF_LENGTH>, root_hash: ManagedByteArray) -> bool { + fn verify_merkle_proof( + &self, + power: BigUint, + proof: ArrayVec, PROOF_LENGTH>, + root_hash: ManagedByteArray, + ) -> bool { let caller = self.blockchain().get_caller(); let mut leaf_bytes = caller.as_managed_buffer().clone(); @@ -321,7 +324,9 @@ pub trait GovernanceV2: let mut hash = self.crypto().sha256(&leaf_bytes); for proof_item in proof { - if BigUint::from(hash.as_managed_buffer()) < BigUint::from(proof_item.as_managed_buffer()) { + if BigUint::from(hash.as_managed_buffer()) + < BigUint::from(proof_item.as_managed_buffer()) + { let mut tst = hash.as_managed_buffer().clone(); tst.append(proof_item.as_managed_buffer()); diff --git a/energy-integration/governance-v2/src/proposal.rs b/energy-integration/governance-v2/src/proposal.rs index ba12bfb4d..57ac96c17 100644 --- a/energy-integration/governance-v2/src/proposal.rs +++ b/energy-integration/governance-v2/src/proposal.rs @@ -64,6 +64,6 @@ pub struct GovernanceProposal { pub voting_delay_in_blocks: u64, pub voting_period_in_blocks: u64, pub withdraw_percentage_defeated: u64, - pub total_voting_power: BigUint, + pub total_balance: BigUint, pub proposal_start_block: u64, } diff --git a/energy-integration/governance-v2/src/views.rs b/energy-integration/governance-v2/src/views.rs index 0bca00939..f448c887c 100644 --- a/energy-integration/governance-v2/src/views.rs +++ b/energy-integration/governance-v2/src/views.rs @@ -46,7 +46,10 @@ pub trait ViewsModule: } #[view(getProposalRootHash)] - fn get_root_hash(&self, proposal_id: ProposalId) -> OptionalValue> { + fn get_root_hash( + &self, + proposal_id: ProposalId, + ) -> OptionalValue> { if !self.proposal_exists(proposal_id) { return OptionalValue::None; } @@ -90,17 +93,16 @@ pub trait ViewsModule: fn quorum_reached(&self, proposal_id: ProposalId) -> bool { let proposal = self.proposals().get(proposal_id); - let total_voting_power_for_proposal = proposal.total_voting_power; + let total_balance = proposal.total_balance; - if total_energy_for_proposal == 0u64 { - return false + if total_balance == 0u64 { + return false; } let required_minimum_percentage = proposal.minimum_quorum; let current_quorum = self.proposal_votes(proposal_id).get().quorum; - let current_quorum_percentage = - current_quorum * FULL_PERCENTAGE / total_voting_power_for_proposal; + let current_quorum_percentage = current_quorum * FULL_PERCENTAGE / total_balance; current_quorum_percentage >= required_minimum_percentage } diff --git a/energy-integration/governance-v2/tests/gov_rust_test.rs b/energy-integration/governance-v2/tests/gov_rust_test.rs index f90b9e1b2..4e99595cd 100644 --- a/energy-integration/governance-v2/tests/gov_rust_test.rs +++ b/energy-integration/governance-v2/tests/gov_rust_test.rs @@ -123,6 +123,7 @@ fn gov_propose_total_energy_0_test() { .set_nft_balance(&first_user_addr, WXMEX_TOKEN_ID, 1, &min_fee, &Empty); let (result, proposal_id) = gov_setup.propose( + gov_setup.get_merkle_root_hash(), &first_user_addr, &min_fee, &sc_addr, @@ -137,7 +138,7 @@ fn gov_propose_total_energy_0_test() { .b_mock .execute_query(&gov_setup.gov_wrapper, |sc| { let mut proposal = sc.proposals().get(1); - proposal.total_energy = managed_biguint!(0); + proposal.total_balance = managed_biguint!(0); sc.proposals().set(1, &proposal); assert!( sc.get_proposal_status(1) == GovernanceProposalStatus::Defeated, @@ -147,7 +148,6 @@ fn gov_propose_total_energy_0_test() { .assert_ok(); } - #[test] fn gov_no_veto_vote_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); @@ -211,7 +211,12 @@ fn gov_no_veto_vote_test() { // Third User DownWithVetoVote = 1_100 gov_setup - .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) + .up_vote( + &third_user_addr, + &third_user_power, + &third_user_proof, + proposal_id, + ) .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -257,9 +262,21 @@ fn gov_abstain_vote_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.abstain_vote(&first_user_addr, &first_user_power, &first_user_proof, proposal_id).assert_ok(); gov_setup - .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) + .abstain_vote( + &first_user_addr, + &first_user_power, + &first_user_proof, + proposal_id, + ) + .assert_ok(); + gov_setup + .up_vote( + &third_user_addr, + &third_user_power, + &third_user_proof, + proposal_id, + ) .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -303,7 +320,14 @@ fn gov_no_quorum_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id).assert_ok(); + gov_setup + .up_vote( + &third_user_addr, + &third_user_power, + &third_user_proof, + proposal_id, + ) + .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -346,7 +370,14 @@ fn gov_modify_quorum_after_end_vote_test() { gov_setup.increment_block_nonce(VOTING_DELAY_BLOCKS); - gov_setup.up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id).assert_ok(); + gov_setup + .up_vote( + &third_user_addr, + &third_user_power, + &third_user_proof, + proposal_id, + ) + .assert_ok(); gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); @@ -407,9 +438,21 @@ fn gov_withdraw_defeated_proposal_test() { gov_setup.increment_block_nonce(VOTING_DELAY_BLOCKS); - gov_setup.down_vote(&first_user_addr, &first_user_power, &first_user_proof, proposal_id).assert_ok(); gov_setup - .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) + .down_vote( + &first_user_addr, + &first_user_power, + &first_user_proof, + proposal_id, + ) + .assert_ok(); + gov_setup + .up_vote( + &third_user_addr, + &third_user_power, + &third_user_proof, + proposal_id, + ) .assert_ok(); gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); @@ -483,9 +526,21 @@ fn gov_modify_withdraw_defeated_proposal_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.down_vote(&first_user_addr, &first_user_power, &first_user_proof, proposal_id).assert_ok(); gov_setup - .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) + .down_vote( + &first_user_addr, + &first_user_power, + &first_user_proof, + proposal_id, + ) + .assert_ok(); + gov_setup + .up_vote( + &third_user_addr, + &third_user_power, + &third_user_proof, + proposal_id, + ) .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); @@ -563,9 +618,21 @@ fn gov_withdraw_no_with_veto_defeated_proposal_test() { gov_setup.increment_block_nonce(VOTING_PERIOD_BLOCKS); - gov_setup.down_veto_vote(&first_user_addr, &first_user_power, &first_user_proof, proposal_id).assert_ok(); gov_setup - .up_vote(&third_user_addr, &third_user_power, &third_user_proof, proposal_id) + .down_veto_vote( + &first_user_addr, + &first_user_power, + &first_user_proof, + proposal_id, + ) + .assert_ok(); + gov_setup + .up_vote( + &third_user_addr, + &third_user_power, + &third_user_proof, + proposal_id, + ) .assert_ok(); gov_setup.increment_block_nonce(LOCKING_PERIOD_BLOCKS); diff --git a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs index 171888ec7..5e74a9f54 100644 --- a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs +++ b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs @@ -1,12 +1,11 @@ -use energy_factory_mock::EnergyFactoryMock; -use energy_query::Energy; use governance_v2::{ proposal_storage::{ProposalStorageModule, VoteType}, GovernanceV2, }; use multiversx_sc::{ + arrayvec::ArrayVec, hex_literal::hex, - types::{Address, BigInt, ManagedByteArray, ManagedVec, MultiValueEncoded}, arrayvec::ArrayVec, + types::{Address, ManagedByteArray, ManagedVec, MultiValueEncoded}, }; use multiversx_sc_scenario::{ managed_address, managed_biguint, managed_buffer, managed_token_id, rust_biguint, @@ -25,8 +24,6 @@ pub const WITHDRAW_PERCENTAGE: u64 = 5_000; // 50% pub const WXMEX_TOKEN_ID: &[u8] = b"WXMEX-123456"; pub const DECIMALS_CONST: u64 = 1_000_000_000_000_000_000; pub const QUORUM: u64 = 217_433_990_694; - -pub const VOTING_POWER: u64 = 1_000_000; pub const GAS_LIMIT: u64 = 1_000_000; #[derive(Clone)] @@ -75,38 +72,6 @@ where )); b_mock.create_user_account_fixed_address(&first_merkle_user, &rust_zero); - // init energy factory - let energy_factory_wrapper = b_mock.create_sc_account( - &rust_zero, - Some(&owner), - energy_factory_mock::contract_obj, - "energy factory path", - ); - - b_mock - .execute_tx(&owner, &energy_factory_wrapper, &rust_zero, |sc| { - sc.init(); - sc.user_energy(&managed_address!(&first_user)) - .set(&Energy::new( - BigInt::from(managed_biguint!(VOTING_POWER)), - 0, - managed_biguint!(0), - )); - sc.user_energy(&managed_address!(&second_user)) - .set(&Energy::new( - BigInt::from(managed_biguint!(VOTING_POWER)), - 0, - managed_biguint!(0), - )); - sc.user_energy(&managed_address!(&third_user)) - .set(&Energy::new( - BigInt::from(managed_biguint!(VOTING_POWER + 210_000)), - 0, - managed_biguint!(0), - )); - }) - .assert_ok(); - // init governance sc let gov_wrapper = b_mock.create_sc_account(&rust_zero, Some(&owner), gov_builder, "gov path"); @@ -120,7 +85,6 @@ where VOTING_DELAY_BLOCKS, VOTING_PERIOD_BLOCKS, WITHDRAW_PERCENTAGE, - managed_address!(energy_factory_wrapper.address_ref()), managed_token_id!(WXMEX_TOKEN_ID), ); }) @@ -185,31 +149,65 @@ where (result, proposal_id) } - pub fn up_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { + pub fn up_vote( + &mut self, + voter: &Address, + power: &BigUint, + proof: &ArrayVec, 18>, + proposal_id: usize, + ) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { sc.vote(proposal_id, VoteType::UpVote, power.into(), proof.clone()); }) } - pub fn down_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { + pub fn down_vote( + &mut self, + voter: &Address, + power: &BigUint, + proof: &ArrayVec, 18>, + proposal_id: usize, + ) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { sc.vote(proposal_id, VoteType::DownVote, power.into(), proof.clone()); }) } - pub fn down_veto_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { + pub fn down_veto_vote( + &mut self, + voter: &Address, + power: &BigUint, + proof: &ArrayVec, 18>, + proposal_id: usize, + ) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::DownVetoVote, power.into(), proof.clone()); + sc.vote( + proposal_id, + VoteType::DownVetoVote, + power.into(), + proof.clone(), + ); }) } - pub fn abstain_vote(&mut self, voter: &Address, power: &BigUint, proof: &ArrayVec, 18>, proposal_id: usize) -> TxResult { + pub fn abstain_vote( + &mut self, + voter: &Address, + power: &BigUint, + proof: &ArrayVec, 18>, + proposal_id: usize, + ) -> TxResult { self.b_mock .execute_tx(voter, &self.gov_wrapper, &rust_biguint!(0), |sc| { - sc.vote(proposal_id, VoteType::AbstainVote, power.into(), proof.clone()); + sc.vote( + proposal_id, + VoteType::AbstainVote, + power.into(), + proof.clone(), + ); }) } @@ -247,89 +245,196 @@ where } pub fn first_merkle_proof(&self) -> ArrayVec, 18> { ArrayVec::from([ - ManagedByteArray::from(&hex!("5e9e904152b2a06dafc26aa02b8c55b2ec3370cdf55b06b15fe8c94bc56e43fc")), - ManagedByteArray::from(&hex!("47aa547fa524519bc946d0883591e9d273a65b4a8f06a37baf170c707c4fb782")), - ManagedByteArray::from(&hex!("da05a587448779b9368680f0ee745b3ff2df1132e309a2de518aa9814cc25de8")), - ManagedByteArray::from(&hex!("14ae69620e727d8e899119ef7a1f04191f15f7c704c2673445510a1bbce7edb2")), - ManagedByteArray::from(&hex!("449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533")), - ManagedByteArray::from(&hex!("fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66")), - ManagedByteArray::from(&hex!("889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc")), - ManagedByteArray::from(&hex!("5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f")), - ManagedByteArray::from(&hex!("ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c")), - ManagedByteArray::from(&hex!("781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82")), - ManagedByteArray::from(&hex!("5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0")), - ManagedByteArray::from(&hex!("2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059")), - ManagedByteArray::from(&hex!("9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c")), - ManagedByteArray::from(&hex!("b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4")), - ManagedByteArray::from(&hex!("95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2")), - ManagedByteArray::from(&hex!("39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838")), - ManagedByteArray::from(&hex!("b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad")), - ManagedByteArray::from(&hex!("bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1")), + ManagedByteArray::from(&hex!( + "5e9e904152b2a06dafc26aa02b8c55b2ec3370cdf55b06b15fe8c94bc56e43fc" + )), + ManagedByteArray::from(&hex!( + "47aa547fa524519bc946d0883591e9d273a65b4a8f06a37baf170c707c4fb782" + )), + ManagedByteArray::from(&hex!( + "da05a587448779b9368680f0ee745b3ff2df1132e309a2de518aa9814cc25de8" + )), + ManagedByteArray::from(&hex!( + "14ae69620e727d8e899119ef7a1f04191f15f7c704c2673445510a1bbce7edb2" + )), + ManagedByteArray::from(&hex!( + "449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533" + )), + ManagedByteArray::from(&hex!( + "fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66" + )), + ManagedByteArray::from(&hex!( + "889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc" + )), + ManagedByteArray::from(&hex!( + "5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f" + )), + ManagedByteArray::from(&hex!( + "ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c" + )), + ManagedByteArray::from(&hex!( + "781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82" + )), + ManagedByteArray::from(&hex!( + "5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0" + )), + ManagedByteArray::from(&hex!( + "2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059" + )), + ManagedByteArray::from(&hex!( + "9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c" + )), + ManagedByteArray::from(&hex!( + "b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4" + )), + ManagedByteArray::from(&hex!( + "95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2" + )), + ManagedByteArray::from(&hex!( + "39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838" + )), + ManagedByteArray::from(&hex!( + "b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad" + )), + ManagedByteArray::from(&hex!( + "bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1" + )), ]) } pub fn second_merkle_proof(&self) -> ArrayVec, 18> { ArrayVec::from([ - ManagedByteArray::from(&hex!("b1d7a256ae6b35cce14497b3735d71dd205f099f1a035a7a5cb96e8bf5c32f31")), - ManagedByteArray::from(&hex!("81dc00d137001723d5654e3120d63601b08ca2b4b8dc41802476529e6d6ada9e")), - ManagedByteArray::from(&hex!("985e3554adfefea5d2c3f7c93d404fd547cfead9054ce313845656507037df40")), - ManagedByteArray::from(&hex!("14ae69620e727d8e899119ef7a1f04191f15f7c704c2673445510a1bbce7edb2")), - ManagedByteArray::from(&hex!("449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533")), - ManagedByteArray::from(&hex!("fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66")), - ManagedByteArray::from(&hex!("889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc")), - ManagedByteArray::from(&hex!("5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f")), - ManagedByteArray::from(&hex!("ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c")), - ManagedByteArray::from(&hex!("781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82")), - ManagedByteArray::from(&hex!("5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0")), - ManagedByteArray::from(&hex!("2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059")), - ManagedByteArray::from(&hex!("9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c")), - ManagedByteArray::from(&hex!("b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4")), - ManagedByteArray::from(&hex!("95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2")), - ManagedByteArray::from(&hex!("39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838")), - ManagedByteArray::from(&hex!("b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad")), - ManagedByteArray::from(&hex!("bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1")), + ManagedByteArray::from(&hex!( + "b1d7a256ae6b35cce14497b3735d71dd205f099f1a035a7a5cb96e8bf5c32f31" + )), + ManagedByteArray::from(&hex!( + "81dc00d137001723d5654e3120d63601b08ca2b4b8dc41802476529e6d6ada9e" + )), + ManagedByteArray::from(&hex!( + "985e3554adfefea5d2c3f7c93d404fd547cfead9054ce313845656507037df40" + )), + ManagedByteArray::from(&hex!( + "14ae69620e727d8e899119ef7a1f04191f15f7c704c2673445510a1bbce7edb2" + )), + ManagedByteArray::from(&hex!( + "449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533" + )), + ManagedByteArray::from(&hex!( + "fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66" + )), + ManagedByteArray::from(&hex!( + "889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc" + )), + ManagedByteArray::from(&hex!( + "5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f" + )), + ManagedByteArray::from(&hex!( + "ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c" + )), + ManagedByteArray::from(&hex!( + "781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82" + )), + ManagedByteArray::from(&hex!( + "5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0" + )), + ManagedByteArray::from(&hex!( + "2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059" + )), + ManagedByteArray::from(&hex!( + "9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c" + )), + ManagedByteArray::from(&hex!( + "b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4" + )), + ManagedByteArray::from(&hex!( + "95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2" + )), + ManagedByteArray::from(&hex!( + "39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838" + )), + ManagedByteArray::from(&hex!( + "b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad" + )), + ManagedByteArray::from(&hex!( + "bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1" + )), ]) } pub fn third_merkle_proof(&self) -> ArrayVec, 18> { ArrayVec::from([ - ManagedByteArray::from(&hex!("aa68ae7eac4de3cc643717d33ab7d2e1b098788b127f298f23a34e8720ec609d")), - ManagedByteArray::from(&hex!("e3db2cf9f85b49279eba44b0f62ac2c6bcdf870f198b9484344634a58860ba2d")), - ManagedByteArray::from(&hex!("64468b8481d2c1737977e7382eaaa12c8072ee76fda33c3b6aaa193b38d4f1f2")), - ManagedByteArray::from(&hex!("6159dc0c80183e89221a36db3fedfabe38933d0db73c1156ad32d8caf0537085")), - ManagedByteArray::from(&hex!("449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533")), - ManagedByteArray::from(&hex!("fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66")), - ManagedByteArray::from(&hex!("889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc")), - ManagedByteArray::from(&hex!("5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f")), - ManagedByteArray::from(&hex!("ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c")), - ManagedByteArray::from(&hex!("781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82")), - ManagedByteArray::from(&hex!("5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0")), - ManagedByteArray::from(&hex!("2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059")), - ManagedByteArray::from(&hex!("9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c")), - ManagedByteArray::from(&hex!("b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4")), - ManagedByteArray::from(&hex!("95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2")), - ManagedByteArray::from(&hex!("39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838")), - ManagedByteArray::from(&hex!("b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad")), - ManagedByteArray::from(&hex!("bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1")), - + ManagedByteArray::from(&hex!( + "aa68ae7eac4de3cc643717d33ab7d2e1b098788b127f298f23a34e8720ec609d" + )), + ManagedByteArray::from(&hex!( + "e3db2cf9f85b49279eba44b0f62ac2c6bcdf870f198b9484344634a58860ba2d" + )), + ManagedByteArray::from(&hex!( + "64468b8481d2c1737977e7382eaaa12c8072ee76fda33c3b6aaa193b38d4f1f2" + )), + ManagedByteArray::from(&hex!( + "6159dc0c80183e89221a36db3fedfabe38933d0db73c1156ad32d8caf0537085" + )), + ManagedByteArray::from(&hex!( + "449e8beb9a901efc2815253a2ce416e3b98ff771fdfc9e35f4ce31004003e533" + )), + ManagedByteArray::from(&hex!( + "fdf33783f8de396173fd37b558213117bb2be3430d50b18eeb5da1af0b98fd66" + )), + ManagedByteArray::from(&hex!( + "889a7d403faae66ec51db6b0708d889ca277e2fd64f78e47612c07077df6eccc" + )), + ManagedByteArray::from(&hex!( + "5cc55493d05c9bf63431384f184e0cc6ab13c14509c3e9a64dc49b47e3821c6f" + )), + ManagedByteArray::from(&hex!( + "ca559e91dee09fccf8d3dbf9bda81f57d4094faecf2f9ac3a98e84b3f376c81c" + )), + ManagedByteArray::from(&hex!( + "781cf1316f87a336a7219095aa8b523a821d260ca0b7a7f94af5c769e17c8f82" + )), + ManagedByteArray::from(&hex!( + "5e97339ee010d2ae3ac54c38c7158e7a7ef4311f89b28b4634d0d35fd4097dc0" + )), + ManagedByteArray::from(&hex!( + "2c7b2103c3e48386a7eda174cec726c28ec6ce80466deaac49dbaf469f35d059" + )), + ManagedByteArray::from(&hex!( + "9b2ceb7809f078724efb71ea3542885c990985d41746d4cab7948928384c3a4c" + )), + ManagedByteArray::from(&hex!( + "b1f37e46c3f84a3c68804d62b26b7f035c90f344252d77fdeff2393793ae34d4" + )), + ManagedByteArray::from(&hex!( + "95ead464db14a9a65c3b9c5378cf927b76ff530ae0762dbb6456bfeb467f97b2" + )), + ManagedByteArray::from(&hex!( + "39e10ed734ddaa3098edc6300edeed2fce75780fc718140359b13c58045a1838" + )), + ManagedByteArray::from(&hex!( + "b36fbf7a645b24bab3eaca5c351985f6bbb95723b47db78171dd7d7f8883ecad" + )), + ManagedByteArray::from(&hex!( + "bffe20aa722c488465e18d10ac3abe3002603bbd4c535211d9bd9b34ce7259a1" + )), ]) } - pub fn get_first_user_voting_power(&self) -> BigUint { - BigUint::from(217_433_990_694u64) + BigUint::from(217_433_990_694u64).pow(2) } pub fn get_second_user_voting_power(&self) -> BigUint { - BigUint::from(59_024_824_840u64) + BigUint::from(59_024_824_840u64).pow(2) } pub fn get_third_user_voting_power(&self) -> BigUint { - BigUint::from(40_000_000_000u64) + BigUint::from(40_000_000_000u64).pow(2) } pub fn get_merkle_root_hash(&self) -> ManagedByteArray { - ManagedByteArray::from(&hex!("0fdb09afb35351d5becc3a79dd9bf03bae7c2366d186a6c8e8276f545d024ef5")) + ManagedByteArray::from(&hex!( + "0fdb09afb35351d5becc3a79dd9bf03bae7c2366d186a6c8e8276f545d024ef5" + )) } - } From 55c2653b76872ae16a12899f701bbf4ec19b5a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 27 Jul 2023 12:42:33 +0300 Subject: [PATCH 04/27] Governance-v2: Remove unnecesarry modules --- energy-integration/governance-v2/Cargo.toml | 14 -------------- .../governance-v2/src/configurable.rs | 4 +--- energy-integration/governance-v2/src/lib.rs | 2 -- energy-integration/governance-v2/src/views.rs | 9 --------- 4 files changed, 1 insertion(+), 28 deletions(-) diff --git a/energy-integration/governance-v2/Cargo.toml b/energy-integration/governance-v2/Cargo.toml index e1993198d..5e368a734 100644 --- a/energy-integration/governance-v2/Cargo.toml +++ b/energy-integration/governance-v2/Cargo.toml @@ -7,8 +7,6 @@ publish = false [lib] path = "src/lib.rs" -[dependencies.energy-query] -path = "../common-modules/energy-query" [dependencies.multiversx-sc] version = "=0.39.4" @@ -19,15 +17,3 @@ num-bigint = "0.4.2" [dev-dependencies.multiversx-sc-scenario] version = "=0.39.4" - -[dev-dependencies.energy-factory-mock] -path = "../energy-factory-mock" - -[dependencies.permissions_module] -path = "../../common/modules/permissions_module" - -[dependencies.fees-collector] -path = "../fees-collector" - -[dependencies.weekly-rewards-splitting] -path = "../common-modules/weekly-rewards-splitting" diff --git a/energy-integration/governance-v2/src/configurable.rs b/energy-integration/governance-v2/src/configurable.rs index c7982e68a..81a56e398 100644 --- a/energy-integration/governance-v2/src/configurable.rs +++ b/energy-integration/governance-v2/src/configurable.rs @@ -41,9 +41,7 @@ const MAX_MIN_FEE_FOR_PROPOSE: u64 = 200_000_000_000; const DECIMALS_CONST: u64 = 1_000_000_000_000_000_000; #[multiversx_sc::module] -pub trait ConfigurablePropertiesModule: - energy_query::EnergyQueryModule + permissions_module::PermissionsModule -{ +pub trait ConfigurablePropertiesModule { // endpoints - these can only be called by the SC itself. // i.e. only by proposing and executing an action with the SC as dest and the respective func name diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index b0c924800..b28ef1335 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -27,8 +27,6 @@ pub trait GovernanceV2: + proposal_storage::ProposalStorageModule + caller_check::CallerCheckModule + views::ViewsModule - + energy_query::EnergyQueryModule - + permissions_module::PermissionsModule { /// - `min_energy_for_propose` - the minimum energy required for submitting a proposal; /// - `min_fee_for_propose` - the minimum fee required for submitting a proposal; diff --git a/energy-integration/governance-v2/src/views.rs b/energy-integration/governance-v2/src/views.rs index f448c887c..e59efc5da 100644 --- a/energy-integration/governance-v2/src/views.rs +++ b/energy-integration/governance-v2/src/views.rs @@ -10,8 +10,6 @@ pub trait ViewsModule: crate::proposal_storage::ProposalStorageModule + crate::configurable::ConfigurablePropertiesModule + crate::caller_check::CallerCheckModule - + permissions_module::PermissionsModule - + energy_query::EnergyQueryModule { #[view(getProposalStatus)] fn get_proposal_status(&self, proposal_id: ProposalId) -> GovernanceProposalStatus { @@ -121,11 +119,4 @@ pub trait ViewsModule: fn proposal_exists(&self, proposal_id: ProposalId) -> bool { self.is_valid_proposal_id(proposal_id) && !self.proposals().item_is_empty(proposal_id) } - - #[proxy] - fn fees_collector_proxy(&self, sc_address: ManagedAddress) -> fees_collector::Proxy; - - #[view(getFeesCollectorAddress)] - #[storage_mapper("feesCollectorAddress")] - fn fees_collector_address(&self) -> SingleValueMapper; } From cee59c3bb9518a78b9631509e7b1c5f453263f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 27 Jul 2023 13:06:28 +0300 Subject: [PATCH 05/27] Governance-v2: Refactor balance -> quorum --- energy-integration/governance-v2/src/lib.rs | 18 +++++++++--------- .../governance-v2/src/proposal.rs | 2 +- energy-integration/governance-v2/src/views.rs | 2 +- .../governance-v2/tests/gov_rust_test.rs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index b28ef1335..25acab967 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -73,7 +73,7 @@ pub trait GovernanceV2: fn propose( &self, root_hash: ManagedByteArray, - total_balance: BigUint, + total_quorum: BigUint, description: ManagedBuffer, actions: MultiValueEncoded>, ) -> ProposalId { @@ -135,7 +135,7 @@ pub trait GovernanceV2: voting_delay_in_blocks, voting_period_in_blocks, withdraw_percentage_defeated, - total_balance, + total_quorum, proposal_start_block: current_block, }; let proposal_id = self.proposals().push(&proposal); @@ -147,13 +147,13 @@ pub trait GovernanceV2: proposal_id } - /// Vote on a proposal. The voting balance depends on the user's energy. + /// Vote on a proposal. The voting power depends on the user's quorum (number of tokens). #[endpoint] fn vote( &self, proposal_id: ProposalId, vote: VoteType, - user_balance: BigUint, + user_quorum: BigUint, proof: ArrayVec, PROOF_LENGTH>, ) { self.require_caller_not_self(); @@ -167,7 +167,7 @@ pub trait GovernanceV2: let new_user = self.user_voted_proposals(&voter).insert(proposal_id); require!(new_user, ALREADY_VOTED_ERR_MSG); - let voting_power = user_balance.sqrt(); + let voting_power = user_quorum.sqrt(); match self.get_root_hash(proposal_id) { OptionalValue::None => { @@ -187,28 +187,28 @@ pub trait GovernanceV2: proposal_votes.up_votes += &voting_power.clone(); proposal_votes.quorum += &voting_power.clone(); }); - self.up_vote_cast_event(&voter, proposal_id, &voting_power, &user_balance); + self.up_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); } VoteType::DownVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.down_votes += &voting_power.clone(); proposal_votes.quorum += &voting_power.clone(); }); - self.down_vote_cast_event(&voter, proposal_id, &voting_power, &user_balance); + self.down_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); } VoteType::DownVetoVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.down_veto_votes += &voting_power.clone(); proposal_votes.quorum += &voting_power.clone(); }); - self.down_veto_vote_cast_event(&voter, proposal_id, &voting_power, &user_balance); + self.down_veto_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); } VoteType::AbstainVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { proposal_votes.abstain_votes += &voting_power.clone(); proposal_votes.quorum += &voting_power.clone(); }); - self.abstain_vote_cast_event(&voter, proposal_id, &voting_power, &user_balance); + self.abstain_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); } } self.user_voted_proposals(&voter).insert(proposal_id); diff --git a/energy-integration/governance-v2/src/proposal.rs b/energy-integration/governance-v2/src/proposal.rs index 57ac96c17..b91f57969 100644 --- a/energy-integration/governance-v2/src/proposal.rs +++ b/energy-integration/governance-v2/src/proposal.rs @@ -64,6 +64,6 @@ pub struct GovernanceProposal { pub voting_delay_in_blocks: u64, pub voting_period_in_blocks: u64, pub withdraw_percentage_defeated: u64, - pub total_balance: BigUint, + pub total_quorum: BigUint, pub proposal_start_block: u64, } diff --git a/energy-integration/governance-v2/src/views.rs b/energy-integration/governance-v2/src/views.rs index e59efc5da..23c7f20ad 100644 --- a/energy-integration/governance-v2/src/views.rs +++ b/energy-integration/governance-v2/src/views.rs @@ -91,7 +91,7 @@ pub trait ViewsModule: fn quorum_reached(&self, proposal_id: ProposalId) -> bool { let proposal = self.proposals().get(proposal_id); - let total_balance = proposal.total_balance; + let total_balance = proposal.total_quorum; if total_balance == 0u64 { return false; diff --git a/energy-integration/governance-v2/tests/gov_rust_test.rs b/energy-integration/governance-v2/tests/gov_rust_test.rs index 4e99595cd..c35c72b50 100644 --- a/energy-integration/governance-v2/tests/gov_rust_test.rs +++ b/energy-integration/governance-v2/tests/gov_rust_test.rs @@ -138,7 +138,7 @@ fn gov_propose_total_energy_0_test() { .b_mock .execute_query(&gov_setup.gov_wrapper, |sc| { let mut proposal = sc.proposals().get(1); - proposal.total_balance = managed_biguint!(0); + proposal.total_quorum = managed_biguint!(0); sc.proposals().set(1, &proposal); assert!( sc.get_proposal_status(1) == GovernanceProposalStatus::Defeated, From 96f670f12b5083e587a104690fe85ce6cddc22b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 27 Jul 2023 13:25:08 +0300 Subject: [PATCH 06/27] Governance-v2: Rebuild contracts + refactor events --- .../governance-v2/src/configurable.rs | 19 +- .../governance-v2/src/events.rs | 16 +- energy-integration/governance-v2/src/lib.rs | 9 +- .../governance-v2/tests/gov_rust_test.rs | 2 +- .../governance-v2/wasm/Cargo.lock | 182 ------------------ .../governance-v2/wasm/src/lib.rs | 16 +- 6 files changed, 15 insertions(+), 229 deletions(-) diff --git a/energy-integration/governance-v2/src/configurable.rs b/energy-integration/governance-v2/src/configurable.rs index 81a56e398..11235c71b 100644 --- a/energy-integration/governance-v2/src/configurable.rs +++ b/energy-integration/governance-v2/src/configurable.rs @@ -9,10 +9,9 @@ multiversx_sc::imports!(); /// - voting/downvoting a certain proposal /// - after a voting period, either putting the action in a queue (if it reached quorum), or canceling /// -/// Voting is done through energy. +/// Voting is done through tokens ownership. /// /// The module provides the following configurable parameters: -/// - `minEnergyForPropose` - the minimum energy required for submitting a proposal /// - `quorum` - the minimum number of (`votes` minus `downvotes`) at the end of voting period /// - `maxActionsPerProposal` - Maximum number of actions (transfers and/or smart contract calls) that a proposal may have /// - `votingDelayInBlocks` - Number of blocks to wait after a block is proposed before being able to vote/downvote that proposal @@ -45,12 +44,6 @@ pub trait ConfigurablePropertiesModule { // endpoints - these can only be called by the SC itself. // i.e. only by proposing and executing an action with the SC as dest and the respective func name - #[only_owner] - #[endpoint(changeMinEnergyForProposal)] - fn change_min_energy_for_propose(&self, new_value: BigUint) { - self.try_change_min_energy_for_propose(new_value); - } - #[only_owner] #[endpoint(changeMinFeeForProposal)] fn change_min_fee_for_propose(&self, new_value: BigUint) { @@ -75,12 +68,6 @@ pub trait ConfigurablePropertiesModule { self.try_change_voting_period_in_blocks(new_value); } - fn try_change_min_energy_for_propose(&self, new_value: BigUint) { - require!(new_value != 0, "Min energy for proposal can't be set to 0"); - - self.min_energy_for_propose().set(&new_value); - } - fn try_change_min_fee_for_propose(&self, new_value: BigUint) { let minimum_min_fee = BigUint::from(MIN_MIN_FEE_FOR_PROPOSE) * BigUint::from(DECIMALS_CONST); @@ -135,10 +122,6 @@ pub trait ConfigurablePropertiesModule { self.fee_token_id().set_if_empty(&fee_token_id); } - #[view(getMinEnergyForPropose)] - #[storage_mapper("minEnergyForPropose")] - fn min_energy_for_propose(&self) -> SingleValueMapper; - #[view(getMinFeeForPropose)] #[storage_mapper("minFeeForPropose")] fn min_fee_for_propose(&self) -> SingleValueMapper; diff --git a/energy-integration/governance-v2/src/events.rs b/energy-integration/governance-v2/src/events.rs index 763f7a1c4..eb736bcc9 100644 --- a/energy-integration/governance-v2/src/events.rs +++ b/energy-integration/governance-v2/src/events.rs @@ -19,8 +19,8 @@ pub trait EventsModule { &self, #[indexed] up_voter: &ManagedAddress, #[indexed] proposal_id: ProposalId, - #[indexed] nr_votes: &BigUint, - #[indexed] energy: &BigUint, + #[indexed] voting_power: &BigUint, + #[indexed] user_quorum: &BigUint, ); #[event("downVoteCast")] @@ -28,8 +28,8 @@ pub trait EventsModule { &self, #[indexed] down_voter: &ManagedAddress, #[indexed] proposal_id: ProposalId, - #[indexed] nr_votes: &BigUint, - #[indexed] energy: &BigUint, + #[indexed] voting_power: &BigUint, + #[indexed] user_quorum: &BigUint, ); #[event("downVetoVoteCast")] @@ -37,8 +37,8 @@ pub trait EventsModule { &self, #[indexed] down_veto_voter: &ManagedAddress, #[indexed] proposal_id: ProposalId, - #[indexed] nr_votes: &BigUint, - #[indexed] energy: &BigUint, + #[indexed] voting_power: &BigUint, + #[indexed] user_quorum: &BigUint, ); #[event("abstainVoteCast")] @@ -46,8 +46,8 @@ pub trait EventsModule { &self, #[indexed] abstain_voter: &ManagedAddress, #[indexed] proposal_id: ProposalId, - #[indexed] nr_votes: &BigUint, - #[indexed] energy: &BigUint, + #[indexed] voting_power: &BigUint, + #[indexed] user_quorum: &BigUint, ); #[event("proposalCanceled")] diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index 25acab967..359652149 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -28,7 +28,6 @@ pub trait GovernanceV2: + caller_check::CallerCheckModule + views::ViewsModule { - /// - `min_energy_for_propose` - the minimum energy required for submitting a proposal; /// - `min_fee_for_propose` - the minimum fee required for submitting a proposal; /// - `quorum` - the minimum number of (`votes` minus `downvotes`) at the end of voting period; /// - `votingDelayInBlocks` - Number of blocks to wait after a block is proposed before being able to vote/downvote that proposal; @@ -38,7 +37,6 @@ pub trait GovernanceV2: #[init] fn init( &self, - // min_energy_for_propose: BigUint, min_fee_for_propose: BigUint, quorum_percentage: BigUint, voting_delay_in_blocks: u64, @@ -46,7 +44,6 @@ pub trait GovernanceV2: withdraw_percentage_defeated: u64, fee_token: TokenIdentifier, ) { - // self.try_change_min_energy_for_propose(min_energy_for_propose); self.try_change_min_fee_for_propose(min_fee_for_propose); self.try_change_quorum_percentage(quorum_percentage); self.try_change_voting_delay_in_blocks(voting_delay_in_blocks); @@ -65,7 +62,7 @@ pub trait GovernanceV2: /// - endpoint to be called on the destination /// - a vector of arguments for the endpoint, in the form of ManagedVec /// - /// The proposer's energy is NOT automatically used for voting. A separate vote is needed. + /// The proposer's quorum is NOT automatically used for voting. A separate vote is needed. /// /// Returns the ID of the newly created proposal. #[payable("*")] @@ -86,10 +83,6 @@ pub trait GovernanceV2: ); let proposer = self.blockchain().get_caller(); - // let user_energy = self.get_energy_amount_non_zero(&proposer); - // let min_energy_for_propose = self.min_energy_for_propose().get(); - // require!(user_energy >= min_energy_for_propose, NOT_ENOUGH_ENERGY); - let user_fee = self.call_value().single_esdt(); require!( self.fee_token_id().get() == user_fee.token_identifier, diff --git a/energy-integration/governance-v2/tests/gov_rust_test.rs b/energy-integration/governance-v2/tests/gov_rust_test.rs index c35c72b50..f8b443b41 100644 --- a/energy-integration/governance-v2/tests/gov_rust_test.rs +++ b/energy-integration/governance-v2/tests/gov_rust_test.rs @@ -111,7 +111,7 @@ fn gov_propose_test() { } #[test] -fn gov_propose_total_energy_0_test() { +fn gov_propose_total_quorum_0_test() { let mut gov_setup = GovSetup::new(governance_v2::contract_obj); let first_user_addr = gov_setup.first_user.clone(); diff --git a/energy-integration/governance-v2/wasm/Cargo.lock b/energy-integration/governance-v2/wasm/Cargo.lock index 40bcf7baa..7dc6f8db8 100644 --- a/energy-integration/governance-v2/wasm/Cargo.lock +++ b/energy-integration/governance-v2/wasm/Cargo.lock @@ -43,95 +43,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "common-types" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "common_errors" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "common_structs" -version = "0.0.0" -dependencies = [ - "fixed-supply-token", - "math", - "mergeable", - "multiversx-sc", - "unwrappable", -] - [[package]] name = "endian-type" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" -[[package]] -name = "energy-factory" -version = "0.0.0" -dependencies = [ - "common_structs", - "legacy_token_decode_module", - "math", - "mergeable", - "multiversx-sc", - "multiversx-sc-modules", - "sc_whitelist_module", - "simple-lock", - "unwrappable", - "utils", -] - -[[package]] -name = "energy-query" -version = "0.0.0" -dependencies = [ - "energy-factory", - "multiversx-sc", -] - -[[package]] -name = "fees-collector" -version = "0.0.0" -dependencies = [ - "common-types", - "common_errors", - "energy-factory", - "energy-query", - "locking_module", - "multiversx-sc", - "multiversx-sc-modules", - "sc_whitelist_module", - "simple-lock", - "utils", - "week-timekeeping", - "weekly-rewards-splitting", -] - -[[package]] -name = "fixed-supply-token" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "governance-v2" version = "0.0.0" dependencies = [ - "energy-query", - "fees-collector", "multiversx-sc", - "permissions_module", - "weekly-rewards-splitting", ] [[package]] @@ -163,50 +85,18 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "legacy_token_decode_module" -version = "0.0.0" -dependencies = [ - "common_structs", - "multiversx-sc", - "utils", -] - [[package]] name = "libc" version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" -[[package]] -name = "locking_module" -version = "0.0.0" -dependencies = [ - "energy-factory", - "multiversx-sc", - "simple-lock", -] - -[[package]] -name = "math" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "memory_units" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" -[[package]] -name = "mergeable" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "multiversx-sc" version = "0.39.4" @@ -257,15 +147,6 @@ dependencies = [ "syn", ] -[[package]] -name = "multiversx-sc-modules" -version = "0.39.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12284a3e31c0852b6ca0ce8306d3f404c3712b996a05ed78e97e765c98461f3" -dependencies = [ - "multiversx-sc", -] - [[package]] name = "multiversx-sc-wasm-adapter" version = "0.39.4" @@ -300,15 +181,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" -[[package]] -name = "permissions_module" -version = "0.0.0" -dependencies = [ - "bitflags", - "common_errors", - "multiversx-sc", -] - [[package]] name = "proc-macro2" version = "1.0.50" @@ -337,23 +209,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "sc_whitelist_module" -version = "0.0.0" -dependencies = [ - "common_errors", - "multiversx-sc", -] - -[[package]] -name = "simple-lock" -version = "0.0.0" -dependencies = [ - "common_structs", - "multiversx-sc", - "multiversx-sc-modules", -] - [[package]] name = "smallvec" version = "1.10.0" @@ -377,23 +232,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" -[[package]] -name = "unwrappable" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "utils" -version = "0.0.0" -dependencies = [ - "common_structs", - "fixed-supply-token", - "mergeable", - "multiversx-sc", -] - [[package]] name = "version_check" version = "0.9.4" @@ -412,26 +250,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "week-timekeeping" -version = "0.0.0" -dependencies = [ - "common-types", - "multiversx-sc", -] - -[[package]] -name = "weekly-rewards-splitting" -version = "0.0.0" -dependencies = [ - "common-types", - "energy-query", - "math", - "multiversx-sc", - "unwrappable", - "week-timekeeping", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/energy-integration/governance-v2/wasm/src/lib.rs b/energy-integration/governance-v2/wasm/src/lib.rs index e70fd2cb9..98ea5cb27 100644 --- a/energy-integration/governance-v2/wasm/src/lib.rs +++ b/energy-integration/governance-v2/wasm/src/lib.rs @@ -5,9 +5,9 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 27 +// Endpoints: 19 // Async Callback (empty): 1 -// Total number of exported functions: 29 +// Total number of exported functions: 21 #![no_std] #![feature(alloc_error_handler, lang_items)] @@ -22,12 +22,10 @@ multiversx_sc_wasm_adapter::endpoints! { vote cancel withdrawDeposit - changeMinEnergyForProposal changeMinFeeForProposal - changeQuorum + changeQuorumPercentage changeVotingDelayInBlocks changeVotingPeriodInBlocks - getMinEnergyForPropose getMinFeeForPropose getQuorum getVotingDelayInBlocks @@ -38,13 +36,7 @@ multiversx_sc_wasm_adapter::endpoints! { getUserVotedProposals getProposalVotes getProposalStatus - getFeesCollectorAddress - setEnergyFactoryAddress - getEnergyFactoryAddress - addAdmin - removeAdmin - updateOwnerOrAdmin - getPermissions + getProposalRootHash ) } From c26fa5ad97b4e33b0a3f986c579e722cb65bd421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 28 Jul 2023 10:29:17 +0300 Subject: [PATCH 07/27] Governance-v2: only_owner to propose + tests fix --- energy-integration/governance-v2/src/lib.rs | 2 +- energy-integration/governance-v2/src/views.rs | 7 +++---- .../governance-v2/tests/gov_test_setup/mod.rs | 12 ++++++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index b40cd102b..41ebd8fa8 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -65,6 +65,7 @@ pub trait GovernanceV2: /// The proposer's quorum is NOT automatically used for voting. A separate vote is needed. /// /// Returns the ID of the newly created proposal. + #[only_owner] #[payable("*")] #[endpoint] fn propose( @@ -204,7 +205,6 @@ pub trait GovernanceV2: self.abstain_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); } } - self.user_voted_proposals(&voter).insert(proposal_id); } /// Cancel a proposed action. This can be done: diff --git a/energy-integration/governance-v2/src/views.rs b/energy-integration/governance-v2/src/views.rs index e027f2365..700d97ffc 100644 --- a/energy-integration/governance-v2/src/views.rs +++ b/energy-integration/governance-v2/src/views.rs @@ -91,17 +91,16 @@ pub trait ViewsModule: fn quorum_reached(&self, proposal_id: ProposalId) -> bool { let proposal = self.proposals().get(proposal_id); - let total_quorum_for_proposal = proposal.total_quorum; + let total_quorum = proposal.total_quorum; - if total_quorum_for_proposal == 0u64 { + if total_quorum == 0u64 { return false; } let required_minimum_percentage = proposal.minimum_quorum; let current_quorum = self.proposal_votes(proposal_id).get().quorum; - let current_quorum_percentage = - current_quorum * FULL_PERCENTAGE / total_quorum_for_proposal; + let current_quorum_percentage = current_quorum * FULL_PERCENTAGE / total_quorum; current_quorum_percentage >= required_minimum_percentage } diff --git a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs index 5e74a9f54..19553910e 100644 --- a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs +++ b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs @@ -23,8 +23,10 @@ pub const LOCKING_PERIOD_BLOCKS: u64 = 30; pub const WITHDRAW_PERCENTAGE: u64 = 5_000; // 50% pub const WXMEX_TOKEN_ID: &[u8] = b"WXMEX-123456"; pub const DECIMALS_CONST: u64 = 1_000_000_000_000_000_000; -pub const QUORUM: u64 = 217_433_990_694; -pub const GAS_LIMIT: u64 = 1_000_000; +pub const GAS_LIMIT: u64 = 1_000_000u64; +pub const FIRST_USER_QUORUM: u64 = 217_433_990_694u64; +pub const SECOND_USER_QUORUM: u64 = 59_024_824_840u64; +pub const THIRD_USER_QUORUM: u64 = 40_000_000_000u64; #[derive(Clone)] pub struct Payment { @@ -136,10 +138,12 @@ where ) .into(), ); - + let total_quorum = managed_biguint!(FIRST_USER_QUORUM).pow(2) + + managed_biguint!(SECOND_USER_QUORUM).pow(2) + + managed_biguint!(THIRD_USER_QUORUM).pow(2); proposal_id = sc.propose( root_hash, - managed_biguint!(QUORUM), + total_quorum, managed_buffer!(b"changeTODO"), actions, ); From 68a6f4614964129835c8d6dcca54e3f63a58252a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 28 Jul 2023 17:44:36 +0300 Subject: [PATCH 08/27] Governanace-v2: Minor fix Fix verify_merkle_proof() in vote endpoint. --- energy-integration/governance-v2/src/lib.rs | 2 +- .../governance-v2/tests/gov_test_setup/mod.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index 41ebd8fa8..b0d45a3b3 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -169,7 +169,7 @@ pub trait GovernanceV2: } OptionalValue::Some(root_hash) => { require!( - self.verify_merkle_proof(voting_power.clone(), proof, root_hash), + self.verify_merkle_proof(user_quorum.clone(), proof, root_hash), INVALID_MERKLE_PROOF ); } diff --git a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs index 19553910e..cc2edc2dd 100644 --- a/energy-integration/governance-v2/tests/gov_test_setup/mod.rs +++ b/energy-integration/governance-v2/tests/gov_test_setup/mod.rs @@ -138,9 +138,9 @@ where ) .into(), ); - let total_quorum = managed_biguint!(FIRST_USER_QUORUM).pow(2) - + managed_biguint!(SECOND_USER_QUORUM).pow(2) - + managed_biguint!(THIRD_USER_QUORUM).pow(2); + let total_quorum = managed_biguint!(FIRST_USER_QUORUM) + + managed_biguint!(SECOND_USER_QUORUM) + + managed_biguint!(THIRD_USER_QUORUM); proposal_id = sc.propose( root_hash, total_quorum, @@ -425,15 +425,15 @@ where } pub fn get_first_user_voting_power(&self) -> BigUint { - BigUint::from(217_433_990_694u64).pow(2) + BigUint::from(217_433_990_694u64) } pub fn get_second_user_voting_power(&self) -> BigUint { - BigUint::from(59_024_824_840u64).pow(2) + BigUint::from(59_024_824_840u64) } pub fn get_third_user_voting_power(&self) -> BigUint { - BigUint::from(40_000_000_000u64).pow(2) + BigUint::from(40_000_000_000u64) } pub fn get_merkle_root_hash(&self) -> ManagedByteArray { From 1183f45401326c6576a10d2436e221d13373553e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 7 Aug 2023 15:13:45 +0300 Subject: [PATCH 09/27] Governance-v2: voting_power = user_quorum --- energy-integration/governance-v2/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index b0d45a3b3..efaf6cdd1 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -161,7 +161,7 @@ pub trait GovernanceV2: let new_user = self.user_voted_proposals(&voter).insert(proposal_id); require!(new_user, ALREADY_VOTED_ERR_MSG); - let voting_power = user_quorum.sqrt(); + let voting_power = user_quorum; match self.get_root_hash(proposal_id) { OptionalValue::None => { From 8cc77d61ce431455fd616716909b1a4ae6f32d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 7 Aug 2023 15:23:12 +0300 Subject: [PATCH 10/27] Governance-v2: Fix clippy issues --- energy-integration/governance-v2/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index efaf6cdd1..c914e3a95 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -161,7 +161,7 @@ pub trait GovernanceV2: let new_user = self.user_voted_proposals(&voter).insert(proposal_id); require!(new_user, ALREADY_VOTED_ERR_MSG); - let voting_power = user_quorum; + let voting_power = &user_quorum; match self.get_root_hash(proposal_id) { OptionalValue::None => { @@ -178,31 +178,31 @@ pub trait GovernanceV2: match vote { VoteType::UpVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { - proposal_votes.up_votes += &voting_power.clone(); + proposal_votes.up_votes += voting_power.clone(); proposal_votes.quorum += &user_quorum.clone(); }); - self.up_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); + self.up_vote_cast_event(&voter, proposal_id, voting_power, &user_quorum); } VoteType::DownVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { - proposal_votes.down_votes += &voting_power.clone(); + proposal_votes.down_votes += voting_power.clone(); proposal_votes.quorum += &user_quorum.clone(); }); - self.down_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); + self.down_vote_cast_event(&voter, proposal_id, voting_power, &user_quorum); } VoteType::DownVetoVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { - proposal_votes.down_veto_votes += &voting_power.clone(); + proposal_votes.down_veto_votes += voting_power.clone(); proposal_votes.quorum += &user_quorum.clone(); }); - self.down_veto_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); + self.down_veto_vote_cast_event(&voter, proposal_id, voting_power, &user_quorum); } VoteType::AbstainVote => { self.proposal_votes(proposal_id).update(|proposal_votes| { - proposal_votes.abstain_votes += &voting_power.clone(); + proposal_votes.abstain_votes += voting_power.clone(); proposal_votes.quorum += &user_quorum.clone(); }); - self.abstain_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum); + self.abstain_vote_cast_event(&voter, proposal_id, voting_power, &user_quorum); } } } From 78c8db5baa26cb562d43ba182f83abb0f25f79e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 7 Aug 2023 16:16:54 +0300 Subject: [PATCH 11/27] Governance-v2: Fix typos --- energy-integration/governance-v2/src/errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/energy-integration/governance-v2/src/errors.rs b/energy-integration/governance-v2/src/errors.rs index f1676ff79..2a8f3bf1f 100644 --- a/energy-integration/governance-v2/src/errors.rs +++ b/energy-integration/governance-v2/src/errors.rs @@ -8,7 +8,7 @@ pub const INVALID_ROOT_HASH: &[u8] = b"Invalid root hash provided"; pub const PROPOSAL_NO_ACTION: &[u8] = b"Proposal has no actions"; pub const EXEEDED_MAX_ACTIONS: &[u8] = b"Exceeded max actions per proposal"; pub const ONLY_PROPOSER_CANCEL: &[u8] = b"Only original proposer may cancel a pending proposal"; -pub const ONLY_PROPOSER_WITHDRAW: &[u8] = b"Only original proposer may cancel a pending proposal"; +pub const ONLY_PROPOSER_WITHDRAW: &[u8] = b"Only original proposer may withdraw a pending proposal"; pub const NO_PROPOSAL: &[u8] = b"Proposal does not exist"; pub const WITHDRAW_NOT_ALLOWED: &[u8] = b"You may not withdraw funds from this proposal!"; pub const INVALID_MERKLE_PROOF: &[u8] = b"Invalid merkle proof provided"; From 1a9a40ad1e33e6f42069717e0b5a28b0c323a2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 7 Aug 2023 16:22:38 +0300 Subject: [PATCH 12/27] Governance-v2: Fix tests; MIN_FEE = 1 --- energy-integration/governance-v2/src/configurable.rs | 2 +- energy-integration/governance-v2/tests/gov_rust_test.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/energy-integration/governance-v2/src/configurable.rs b/energy-integration/governance-v2/src/configurable.rs index 11235c71b..3df438fef 100644 --- a/energy-integration/governance-v2/src/configurable.rs +++ b/energy-integration/governance-v2/src/configurable.rs @@ -35,7 +35,7 @@ const MIN_VOTING_PERIOD: u64 = 14_400; // 24 Hours const MAX_VOTING_PERIOD: u64 = 201_600; // 2 Weeks const MIN_QUORUM: u64 = 1_000; // 10% const MAX_QUORUM: u64 = 6_000; // 60% -const MIN_MIN_FEE_FOR_PROPOSE: u64 = 2_000_000; +const MIN_MIN_FEE_FOR_PROPOSE: u64 = 1; const MAX_MIN_FEE_FOR_PROPOSE: u64 = 200_000_000_000; const DECIMALS_CONST: u64 = 1_000_000_000_000_000_000; diff --git a/energy-integration/governance-v2/tests/gov_rust_test.rs b/energy-integration/governance-v2/tests/gov_rust_test.rs index f8b443b41..f2cc5bf9e 100644 --- a/energy-integration/governance-v2/tests/gov_rust_test.rs +++ b/energy-integration/governance-v2/tests/gov_rust_test.rs @@ -470,7 +470,7 @@ fn gov_withdraw_defeated_proposal_test() { // Other user (not proposer) try to withdraw the fee -> Fail gov_setup .withdraw_after_defeated(&third_user_addr, proposal_id) - .assert_error(4, "Only original proposer may cancel a pending proposal"); + .assert_error(4, "Only original proposer may withdraw a pending proposal"); // Proposer withdraw gov_setup @@ -562,7 +562,7 @@ fn gov_modify_withdraw_defeated_proposal_test() { // Other user (not proposer) try to withdraw the fee -> Fail gov_setup .withdraw_after_defeated(&third_user_addr, proposal_id) - .assert_error(4, "Only original proposer may cancel a pending proposal"); + .assert_error(4, "Only original proposer may withdraw a pending proposal"); // Proposer withdraw gov_setup @@ -650,7 +650,7 @@ fn gov_withdraw_no_with_veto_defeated_proposal_test() { // Other user (not proposer) try to withdraw the fee -> Fail gov_setup .withdraw_after_defeated(&third_user_addr, proposal_id) - .assert_error(4, "Only original proposer may cancel a pending proposal"); + .assert_error(4, "Only original proposer may withdraw a pending proposal"); // Proposer withdraw gov_setup From 6e2d74546c899f219a053b361aa0785e1b32c2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 7 Aug 2023 17:51:55 +0300 Subject: [PATCH 13/27] Adjust workflow for reproducible builds. (#758) --- .../workflows/on_pull_request_build_contracts.yml | 13 +++++++++++++ .github/workflows/release.yml | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/on_pull_request_build_contracts.yml diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml new file mode 100644 index 000000000..ebf22f61c --- /dev/null +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -0,0 +1,13 @@ +name: On pull request, build contracts + +on: + pull_request: + +permissions: + contents: write + +jobs: + build: + uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.1 + with: + image_tag: v4.1.4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f4d16ca6d..e43f3cb47 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,5 +11,5 @@ jobs: build: uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.1 with: - image_tag: v5.1.0 + image_tag: v4.1.4 attach_to_existing_release: true From 05ab6ae0842754760e0245815a27d6ac239310a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 27 Dec 2023 17:36:43 +0200 Subject: [PATCH 14/27] Add Cargo.lock of workspace. Use fixed references. --- .../on_pull_request_build_contracts.yml | 2 +- .github/workflows/release.yml | 2 +- .gitignore | 4 - Cargo.lock | 2295 +++++++++++++++++ dex/farm-with-locked-rewards/meta/Cargo.toml | 2 +- dex/farm/meta/Cargo.toml | 2 +- dex/governance/meta/Cargo.toml | 2 +- dex/pair-mock/meta/Cargo.toml | 2 +- dex/pair-mock/wasm/src/lib.rs | 2 +- dex/pair/meta/Cargo.toml | 2 +- dex/price-discovery/meta/Cargo.toml | 2 +- dex/proxy-deployer/meta/Cargo.toml | 2 +- dex/router/meta/Cargo.toml | 2 +- .../energy-factory-mock/meta/Cargo.toml | 2 +- .../energy-update/meta/Cargo.toml | 2 +- .../fees-collector/meta/Cargo.toml | 2 +- .../governance-v2/meta/Cargo.toml | 2 +- .../farm-staking-proxy/meta/Cargo.toml | 2 +- farm-staking/farm-staking/meta/Cargo.toml | 2 +- .../metabonding-staking/meta/Cargo.toml | 2 +- locked-asset/distribution/meta/Cargo.toml | 2 +- locked-asset/energy-factory/meta/Cargo.toml | 2 +- locked-asset/factory/meta/Cargo.toml | 2 +- locked-asset/lkmex-transfer/meta/Cargo.toml | 2 +- .../locked-token-wrapper/meta/Cargo.toml | 2 +- locked-asset/proxy_dex/meta/Cargo.toml | 2 +- .../simple-lock-whitelist/meta/Cargo.toml | 2 +- locked-asset/simple-lock/meta/Cargo.toml | 2 +- locked-asset/token-unstake/meta/Cargo.toml | 2 +- pause-all/meta/Cargo.toml | 2 +- 30 files changed, 2323 insertions(+), 32 deletions(-) create mode 100644 Cargo.lock diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index ebf22f61c..a7d7f8641 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -10,4 +10,4 @@ jobs: build: uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.1 with: - image_tag: v4.1.4 + image_tag: v4.2.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e43f3cb47..261ffd637 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,5 +11,5 @@ jobs: build: uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.1 with: - image_tag: v4.1.4 + image_tag: v4.2.0 attach_to_existing_release: true diff --git a/.gitignore b/.gitignore index e38735f03..66e657fad 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,6 @@ # will have compiled files and executables **/target/ **/output/ -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock -!**/wasm*/Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..5a2898f4e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2295 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "ahash" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + +[[package]] +name = "anyhow" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d19de80eff169429ac1e9f48fffb163916b448a44e8e046186232046d9e1f9" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding", + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "bstr" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" +dependencies = [ + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "once_cell", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.43", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "colored" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" +dependencies = [ + "is-terminal", + "lazy_static", + "windows-sys 0.48.0", +] + +[[package]] +name = "common-types" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "common_errors" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "common_structs" +version = "0.0.0" +dependencies = [ + "fixed-supply-token", + "math", + "mergeable", + "multiversx-sc", + "unwrappable", +] + +[[package]] +name = "config" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "multiversx-sc", + "pausable", + "permissions_module", + "token_send", +] + +[[package]] +name = "contexts" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "farm_token", + "multiversx-sc", + "multiversx-sc-modules", + "pausable", + "permissions_module", + "rewards", + "token_merge_helper", + "token_send", +] + +[[package]] +name = "cpufeatures" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "dex-tests" +version = "0.0.0" +dependencies = [ + "common_structs", + "config", + "factory", + "farm", + "farm-boosted-yields", + "farm-staking", + "farm-staking-proxy", + "farm_token", + "fees-collector", + "governance", + "locking_module", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "pair", + "pausable", + "rewards", + "router", + "simple-lock", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", +] + +[[package]] +name = "distribution" +version = "0.0.0" +dependencies = [ + "common_structs", + "factory", + "multiversx-sc", + "multiversx-sc-scenario", +] + +[[package]] +name = "distribution-abi" +version = "0.0.0" +dependencies = [ + "distribution", + "multiversx-sc-meta", +] + +[[package]] +name = "distribution-tests" +version = "0.0.0" +dependencies = [ + "common_structs", + "distribution", + "energy-factory", + "factory", + "farm", + "fees-collector", + "hex", + "lkmex-transfer", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "pair", + "proxy_dex", + "router", + "simple-lock", + "token-unstake", +] + +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "energy-factory" +version = "0.0.0" +dependencies = [ + "common_structs", + "hex", + "legacy_token_decode_module", + "math", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "sc_whitelist_module", + "simple-lock", + "unwrappable", + "utils", +] + +[[package]] +name = "energy-factory-meta" +version = "0.0.0" +dependencies = [ + "energy-factory", + "multiversx-sc-meta", +] + +[[package]] +name = "energy-factory-mock" +version = "0.0.0" +dependencies = [ + "energy-query", + "multiversx-sc", + "multiversx-sc-scenario", +] + +[[package]] +name = "energy-factory-mock-meta" +version = "0.0.0" +dependencies = [ + "energy-factory-mock", + "multiversx-sc-meta", +] + +[[package]] +name = "energy-query" +version = "0.0.0" +dependencies = [ + "energy-factory", + "multiversx-sc", +] + +[[package]] +name = "energy-update" +version = "0.0.0" +dependencies = [ + "farm", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "weekly-rewards-splitting", +] + +[[package]] +name = "energy-update-meta" +version = "0.0.0" +dependencies = [ + "energy-update", + "multiversx-sc-meta", +] + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "events" +version = "0.0.0" +dependencies = [ + "common_structs", + "contexts", + "multiversx-sc", +] + +[[package]] +name = "factory" +version = "0.0.0" +dependencies = [ + "arrayvec", + "common_errors", + "common_structs", + "energy-factory", + "hex", + "itertools", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "simple-lock", + "token_merge_helper", + "token_send", + "wee_alloc", +] + +[[package]] +name = "factory-abi" +version = "0.0.0" +dependencies = [ + "factory", + "multiversx-sc-meta", +] + +[[package]] +name = "farm" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "contexts", + "energy-factory-mock", + "energy-query", + "energy-update", + "events", + "farm-boosted-yields", + "farm_base_impl", + "farm_token", + "fixed-supply-token", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "pair", + "pausable", + "permissions_module", + "rewards", + "sc_whitelist_module", + "simple-lock", + "token_send", + "utils", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "farm-abi" +version = "0.0.0" +dependencies = [ + "farm", + "multiversx-sc-meta", +] + +[[package]] +name = "farm-boosted-yields" +version = "0.0.0" +dependencies = [ + "common-types", + "config", + "energy-query", + "multiversx-sc", + "pausable", + "permissions_module", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "farm-staking" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "contexts", + "energy-factory", + "energy-query", + "events", + "farm", + "farm-boosted-yields", + "farm_base_impl", + "farm_token", + "fixed-supply-token", + "math", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "pair", + "pausable", + "permissions_module", + "rewards", + "sc_whitelist_module", + "token_send", + "utils", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "farm-staking-abi" +version = "0.0.0" +dependencies = [ + "farm-staking", + "multiversx-sc-meta", +] + +[[package]] +name = "farm-staking-proxy" +version = "0.0.0" +dependencies = [ + "common_structs", + "config", + "farm", + "farm-boosted-yields", + "farm-staking", + "farm_token", + "fixed-supply-token", + "hex-literal", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "pair", + "pausable", + "rewards", + "sc_whitelist_module", + "token_send", + "unwrappable", + "utils", +] + +[[package]] +name = "farm-staking-proxy-meta" +version = "0.0.0" +dependencies = [ + "farm-staking-proxy", + "multiversx-sc-meta", +] + +[[package]] +name = "farm-with-locked-rewards" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "contexts", + "energy-factory", + "energy-query", + "events", + "farm", + "farm-boosted-yields", + "farm_base_impl", + "farm_token", + "fixed-supply-token", + "locking_module", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "pausable", + "permissions_module", + "rewards", + "sc_whitelist_module", + "simple-lock", + "token_send", + "utils", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "farm-with-locked-rewards-meta" +version = "0.0.0" +dependencies = [ + "farm-with-locked-rewards", + "multiversx-sc-meta", +] + +[[package]] +name = "farm_base_impl" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "contexts", + "events", + "farm_token", + "fixed-supply-token", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "pausable", + "permissions_module", + "rewards", + "token_merge_helper", + "token_send", + "utils", +] + +[[package]] +name = "farm_token" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "multiversx-sc", + "multiversx-sc-modules", + "pausable", + "permissions_module", + "token_send", +] + +[[package]] +name = "fees-collector" +version = "0.0.0" +dependencies = [ + "common-types", + "common_errors", + "energy-factory", + "energy-query", + "locking_module", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "sc_whitelist_module", + "simple-lock", + "utils", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "fees-collector-meta" +version = "0.0.0" +dependencies = [ + "fees-collector", + "multiversx-sc-meta", +] + +[[package]] +name = "fixed-supply-token" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "fuzz" +version = "0.0.0" +dependencies = [ + "common_structs", + "config", + "factory", + "farm", + "farm-staking", + "farm_token", + "multiversx-sc", + "multiversx-sc-scenario", + "num-bigint", + "pair", + "pair-mock", + "pausable", + "price-discovery", + "rand 0.8.5", + "rewards", + "router", + "simple-lock", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "globset" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "governance" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "multiversx-sc-scenario", + "num-bigint", + "pair-mock", +] + +[[package]] +name = "governance-meta" +version = "0.0.0" +dependencies = [ + "governance", + "multiversx-sc-meta", +] + +[[package]] +name = "governance-v2" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "multiversx-sc-scenario", + "num-bigint", +] + +[[package]] +name = "governance-v2-meta" +version = "0.0.0" +dependencies = [ + "governance-v2", + "multiversx-sc-meta", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "ignore" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +dependencies = [ + "globset", + "lazy_static", + "log", + "memchr", + "regex", + "same-file", + "thread_local", + "walkdir", + "winapi-util", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi 0.3.3", + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "keccak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "legacy_token_decode_module" +version = "0.0.0" +dependencies = [ + "common_structs", + "multiversx-sc", + "utils", +] + +[[package]] +name = "libc" +version = "0.2.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + +[[package]] +name = "lkmex-transfer" +version = "0.0.0" +dependencies = [ + "common_structs", + "energy-factory", + "energy-query", + "legacy_token_decode_module", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "permissions_module", + "simple-lock", + "utils", +] + +[[package]] +name = "lkmex-transfer-abi" +version = "0.0.0" +dependencies = [ + "lkmex-transfer", + "multiversx-sc-meta", +] + +[[package]] +name = "locked-token-wrapper" +version = "0.0.0" +dependencies = [ + "common_structs", + "energy-factory", + "energy-factory-mock", + "energy-query", + "hex", + "legacy_token_decode_module", + "lkmex-transfer", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "simple-lock", + "utils", +] + +[[package]] +name = "locked-token-wrapper-meta" +version = "0.0.0" +dependencies = [ + "locked-token-wrapper", + "multiversx-sc-meta", +] + +[[package]] +name = "locking_module" +version = "0.0.0" +dependencies = [ + "energy-factory", + "multiversx-sc", + "simple-lock", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "math" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + +[[package]] +name = "mergeable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "metabonding-staking" +version = "0.0.0" +dependencies = [ + "common_structs", + "factory", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", +] + +[[package]] +name = "metabonding-staking-meta" +version = "0.0.0" +dependencies = [ + "metabonding-staking", + "multiversx-sc-meta", +] + +[[package]] +name = "multiversx-chain-scenario-format" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d2592a441608937c5aebec6732c38e6097f58de1dc9a64d7dbe98e0ab97a3c0" +dependencies = [ + "bech32", + "hex", + "num-bigint", + "num-traits", + "serde", + "serde_json", + "sha3 0.9.1", +] + +[[package]] +name = "multiversx-chain-vm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccfe504d59cbdce3136fd1e8549ff174c204cd600e2c0ca3482fb172c211c921" +dependencies = [ + "bech32", + "ed25519-dalek", + "hex", + "itertools", + "multiversx-chain-scenario-format", + "multiversx-sc", + "multiversx-sc-meta", + "num-bigint", + "num-traits", + "rand 0.8.5", + "rand_seeder", + "serde", + "serde_json", + "sha2 0.10.8", + "sha3 0.10.8", +] + +[[package]] +name = "multiversx-sc" +version = "0.39.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecfb3e03ac6e08114963a54e15a3c78c28e57cc0e31836e870450b35085bdf8d" +dependencies = [ + "bitflags 1.3.2", + "hashbrown 0.13.2", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7638cb46a0e99c636fd55443ac534ff0a5fad0bd772e1037fbac9a75e04c3c9" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "num-bigint", + "wee_alloc", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e976002d51367f16140929c10ee695f95dd8d34c150a45db60d3fcd1328a267a" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.39.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6eb54a7d452eb09f5de159ee9b4d1fb9ec79cf49f1602ebd3efc8532015a4ea" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn 1.0.109", +] + +[[package]] +name = "multiversx-sc-meta" +version = "0.39.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40a73abbabf2408616624b421f8ac2a6dda10beaa076dc4bdb0ce2e1b635a367" +dependencies = [ + "clap", + "colored", + "multiversx-sc", + "ruplacer", + "rustc_version", + "serde", + "serde_json", + "toml", +] + +[[package]] +name = "multiversx-sc-modules" +version = "0.39.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f12284a3e31c0852b6ca0ce8306d3f404c3712b996a05ed78e97e765c98461f3" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc-scenario" +version = "0.39.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b9e4d968f161ce956a2d4a235631c3b1df89d3ea75445f6dc654c2bab3a0caf" +dependencies = [ + "colored", + "hex", + "itertools", + "multiversx-chain-vm", + "num-traits", + "pathdiff", + "serde", + "serde_json", + "sha2 0.10.8", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "pair" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "fees-collector", + "itertools", + "multiversx-sc", + "multiversx-sc-scenario", + "num-bigint", + "pausable", + "permissions_module", + "simple-lock", + "token_send", +] + +[[package]] +name = "pair-abi" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "pair", +] + +[[package]] +name = "pair-mock" +version = "0.0.0" +dependencies = [ + "common_errors", + "itertools", + "multiversx-sc", + "multiversx-sc-scenario", +] + +[[package]] +name = "pair-mock-meta" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "pair-mock", +] + +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + +[[package]] +name = "pausable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "permissions_module", +] + +[[package]] +name = "pause-all" +version = "0.0.0" +dependencies = [ + "farm", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "pair", + "pausable", +] + +[[package]] +name = "pause-all-meta" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "pause-all", +] + +[[package]] +name = "permissions_module" +version = "0.0.0" +dependencies = [ + "bitflags 1.3.2", + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "price-discovery" +version = "0.0.0" +dependencies = [ + "hex", + "hex-literal", + "locking_module", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "simple-lock", +] + +[[package]] +name = "price-discovery-meta" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "price-discovery", +] + +[[package]] +name = "proc-macro2" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proxy-deployer" +version = "0.0.0" +dependencies = [ + "config", + "farm", + "farm_token", + "multiversx-sc", + "multiversx-sc-scenario", + "num-bigint", + "pausable", +] + +[[package]] +name = "proxy-deployer-meta" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "proxy-deployer", +] + +[[package]] +name = "proxy_dex" +version = "0.0.0" +dependencies = [ + "common_structs", + "config", + "energy-factory", + "energy-query", + "farm", + "farm-boosted-yields", + "farm-with-locked-rewards", + "farm_base_impl", + "farm_token", + "fixed-supply-token", + "hex", + "itertools", + "legacy_token_decode_module", + "locking_module", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "pair", + "pausable", + "rewards", + "sc_whitelist_module", + "simple-lock", + "token_merge_helper", + "token_send", + "utils", +] + +[[package]] +name = "proxy_dex-meta" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "proxy_dex", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.11", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_seeder" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf2890aaef0aa82719a50e808de264f9484b74b442e1a3a0e5ee38243ac40bdb" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rewards" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "farm_token", + "multiversx-sc", + "multiversx-sc-modules", + "pausable", + "permissions_module", + "token_send", +] + +[[package]] +name = "router" +version = "0.0.0" +dependencies = [ + "locking_module", + "multiversx-sc", + "multiversx-sc-scenario", + "pair", + "pausable", + "simple-lock", + "token_send", +] + +[[package]] +name = "router-abi" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "router", +] + +[[package]] +name = "ruplacer" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1001b63b19333d7a462006c7d281a43ce5c1b3c44cd2a9696ab54b8e9aa7e388" +dependencies = [ + "Inflector", + "anyhow", + "atty", + "clap", + "colored", + "ignore", + "regex", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "sc_whitelist_module" +version = "0.0.0" +dependencies = [ + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.43", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "keccak", + "opaque-debug", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + +[[package]] +name = "simple-lock" +version = "0.0.0" +dependencies = [ + "common_structs", + "hex", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", +] + +[[package]] +name = "simple-lock-meta" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "simple-lock", +] + +[[package]] +name = "simple-lock-whitelist" +version = "0.0.0" +dependencies = [ + "hex", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "simple-lock", + "utils", +] + +[[package]] +name = "simple-lock-whitelist-meta" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "simple-lock-whitelist", +] + +[[package]] +name = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", +] + +[[package]] +name = "token-unstake" +version = "0.0.0" +dependencies = [ + "common_structs", + "energy-factory", + "energy-query", + "hex", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "simple-lock", + "utils", + "week-timekeeping", +] + +[[package]] +name = "token-unstake-abi" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta", + "token-unstake", +] + +[[package]] +name = "token_merge_helper" +version = "0.0.0" +dependencies = [ + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "token_send" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "multiversx-sc", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "indexmap", + "serde", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unwrappable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "utils" +version = "0.0.0" +dependencies = [ + "common_structs", + "fixed-supply-token", + "mergeable", + "multiversx-sc", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wee_alloc" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "memory_units", + "winapi", +] + +[[package]] +name = "week-timekeeping" +version = "0.0.0" +dependencies = [ + "common-types", + "multiversx-sc", +] + +[[package]] +name = "weekly-rewards-splitting" +version = "0.0.0" +dependencies = [ + "common-types", + "energy-query", + "math", + "multiversx-sc", + "unwrappable", + "week-timekeeping", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.43", +] + +[[package]] +name = "zeroize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.43", +] diff --git a/dex/farm-with-locked-rewards/meta/Cargo.toml b/dex/farm-with-locked-rewards/meta/Cargo.toml index 5189d15c6..b35c1982d 100644 --- a/dex/farm-with-locked-rewards/meta/Cargo.toml +++ b/dex/farm-with-locked-rewards/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/dex/farm/meta/Cargo.toml b/dex/farm/meta/Cargo.toml index 0829c6199..ba2cff5c0 100644 --- a/dex/farm/meta/Cargo.toml +++ b/dex/farm/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/dex/governance/meta/Cargo.toml b/dex/governance/meta/Cargo.toml index 0714371a8..cc998004f 100644 --- a/dex/governance/meta/Cargo.toml +++ b/dex/governance/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/dex/pair-mock/meta/Cargo.toml b/dex/pair-mock/meta/Cargo.toml index ffee1543e..914c418db 100644 --- a/dex/pair-mock/meta/Cargo.toml +++ b/dex/pair-mock/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/dex/pair-mock/wasm/src/lib.rs b/dex/pair-mock/wasm/src/lib.rs index 0634dae52..54b9b427e 100644 --- a/dex/pair-mock/wasm/src/lib.rs +++ b/dex/pair-mock/wasm/src/lib.rs @@ -19,7 +19,7 @@ multiversx_sc_wasm_adapter::endpoints! { pair_mock ( addInitialLiquidity - updateAndGetTokensForGivenPositionWithSafePrice + getTokensForGivenPositionWithSafePrice ) } diff --git a/dex/pair/meta/Cargo.toml b/dex/pair/meta/Cargo.toml index 2c4f80564..e897f3fe5 100644 --- a/dex/pair/meta/Cargo.toml +++ b/dex/pair/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/dex/price-discovery/meta/Cargo.toml b/dex/price-discovery/meta/Cargo.toml index 7ffb188bc..1763b6369 100644 --- a/dex/price-discovery/meta/Cargo.toml +++ b/dex/price-discovery/meta/Cargo.toml @@ -8,4 +8,4 @@ authors = ["Dorin Iancu "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/dex/proxy-deployer/meta/Cargo.toml b/dex/proxy-deployer/meta/Cargo.toml index 43004528f..3f407684a 100644 --- a/dex/proxy-deployer/meta/Cargo.toml +++ b/dex/proxy-deployer/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/dex/router/meta/Cargo.toml b/dex/router/meta/Cargo.toml index 4901db35c..fa3655c94 100644 --- a/dex/router/meta/Cargo.toml +++ b/dex/router/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/energy-integration/energy-factory-mock/meta/Cargo.toml b/energy-integration/energy-factory-mock/meta/Cargo.toml index 194f75d4c..3c5417057 100644 --- a/energy-integration/energy-factory-mock/meta/Cargo.toml +++ b/energy-integration/energy-factory-mock/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/energy-integration/energy-update/meta/Cargo.toml b/energy-integration/energy-update/meta/Cargo.toml index 0a84ae847..52ca52bdd 100644 --- a/energy-integration/energy-update/meta/Cargo.toml +++ b/energy-integration/energy-update/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/energy-integration/fees-collector/meta/Cargo.toml b/energy-integration/fees-collector/meta/Cargo.toml index 2896d634f..a619bb638 100644 --- a/energy-integration/fees-collector/meta/Cargo.toml +++ b/energy-integration/fees-collector/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/energy-integration/governance-v2/meta/Cargo.toml b/energy-integration/governance-v2/meta/Cargo.toml index 2d5c3e77d..d53044ef9 100644 --- a/energy-integration/governance-v2/meta/Cargo.toml +++ b/energy-integration/governance-v2/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/farm-staking/farm-staking-proxy/meta/Cargo.toml b/farm-staking/farm-staking-proxy/meta/Cargo.toml index 093f5cefc..c7862ed85 100644 --- a/farm-staking/farm-staking-proxy/meta/Cargo.toml +++ b/farm-staking/farm-staking-proxy/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/farm-staking/farm-staking/meta/Cargo.toml b/farm-staking/farm-staking/meta/Cargo.toml index 5b9131e0c..24ebe7bfb 100644 --- a/farm-staking/farm-staking/meta/Cargo.toml +++ b/farm-staking/farm-staking/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/farm-staking/metabonding-staking/meta/Cargo.toml b/farm-staking/metabonding-staking/meta/Cargo.toml index 06c584a9d..d04874c6d 100644 --- a/farm-staking/metabonding-staking/meta/Cargo.toml +++ b/farm-staking/metabonding-staking/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/distribution/meta/Cargo.toml b/locked-asset/distribution/meta/Cargo.toml index e43a9e44c..312beb6bf 100644 --- a/locked-asset/distribution/meta/Cargo.toml +++ b/locked-asset/distribution/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/energy-factory/meta/Cargo.toml b/locked-asset/energy-factory/meta/Cargo.toml index 736f335ed..3ad6bc83d 100644 --- a/locked-asset/energy-factory/meta/Cargo.toml +++ b/locked-asset/energy-factory/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/factory/meta/Cargo.toml b/locked-asset/factory/meta/Cargo.toml index 56dcbd950..899310222 100644 --- a/locked-asset/factory/meta/Cargo.toml +++ b/locked-asset/factory/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/lkmex-transfer/meta/Cargo.toml b/locked-asset/lkmex-transfer/meta/Cargo.toml index 6572c05da..53ac63600 100644 --- a/locked-asset/lkmex-transfer/meta/Cargo.toml +++ b/locked-asset/lkmex-transfer/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/locked-token-wrapper/meta/Cargo.toml b/locked-asset/locked-token-wrapper/meta/Cargo.toml index 669290a57..438ccf937 100644 --- a/locked-asset/locked-token-wrapper/meta/Cargo.toml +++ b/locked-asset/locked-token-wrapper/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/proxy_dex/meta/Cargo.toml b/locked-asset/proxy_dex/meta/Cargo.toml index bac44200f..2bfb26ea7 100644 --- a/locked-asset/proxy_dex/meta/Cargo.toml +++ b/locked-asset/proxy_dex/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/simple-lock-whitelist/meta/Cargo.toml b/locked-asset/simple-lock-whitelist/meta/Cargo.toml index a55865268..74669e73e 100644 --- a/locked-asset/simple-lock-whitelist/meta/Cargo.toml +++ b/locked-asset/simple-lock-whitelist/meta/Cargo.toml @@ -8,4 +8,4 @@ authors = ["Dorin Iancu "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/simple-lock/meta/Cargo.toml b/locked-asset/simple-lock/meta/Cargo.toml index 72ac58b6f..8c31cffd9 100644 --- a/locked-asset/simple-lock/meta/Cargo.toml +++ b/locked-asset/simple-lock/meta/Cargo.toml @@ -8,4 +8,4 @@ authors = ["Dorin Iancu "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/locked-asset/token-unstake/meta/Cargo.toml b/locked-asset/token-unstake/meta/Cargo.toml index f82b14477..6292163a3 100644 --- a/locked-asset/token-unstake/meta/Cargo.toml +++ b/locked-asset/token-unstake/meta/Cargo.toml @@ -8,4 +8,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" diff --git a/pause-all/meta/Cargo.toml b/pause-all/meta/Cargo.toml index 0dafab7fb..61c94047d 100644 --- a/pause-all/meta/Cargo.toml +++ b/pause-all/meta/Cargo.toml @@ -10,4 +10,4 @@ authors = ["MultiversX "] path = ".." [dependencies.multiversx-sc-meta] -version = "0.39.4" +version = "=0.39.4" From b86502e152e8ee8513d5a9ea054714744ed44c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 27 Dec 2023 17:56:39 +0200 Subject: [PATCH 15/27] package_whole_project_src: true. --- .github/workflows/on_pull_request_build_contracts.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index a7d7f8641..46ba29af0 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -8,6 +8,7 @@ permissions: jobs: build: - uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.1 + uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@6091788cbc207453f45e98f785f6187935a8c443 with: image_tag: v4.2.0 + package_whole_project_src: true From a473d9896a63e4693fd56d355d92008cc8d8b1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 27 Dec 2023 17:59:52 +0200 Subject: [PATCH 16/27] Fix workflow. --- .github/workflows/on_pull_request_build_contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 46ba29af0..615d86c44 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -8,7 +8,7 @@ permissions: jobs: build: - uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@6091788cbc207453f45e98f785f6187935a8c443 + uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@8fe5fca0e7e1d0a56418f1ef559bdf9b12a310c1 with: image_tag: v4.2.0 package_whole_project_src: true From 4757784d62c68770ca5862971897308c56747146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 27 Dec 2023 18:02:17 +0200 Subject: [PATCH 17/27] Fix workflow. --- .github/workflows/on_pull_request_build_contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 615d86c44..53d52216e 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -8,7 +8,7 @@ permissions: jobs: build: - uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@8fe5fca0e7e1d0a56418f1ef559bdf9b12a310c1 + uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@67554b32f2e7378835cb97ee7a6530f43e2eb627 with: image_tag: v4.2.0 package_whole_project_src: true From ff9900d88333531523c407efe507b35c0f63f462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 27 Dec 2023 18:10:41 +0200 Subject: [PATCH 18/27] Test with package_whole_project_src = false. --- .github/workflows/on_pull_request_build_contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 53d52216e..35c3e64a3 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -11,4 +11,4 @@ jobs: uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@67554b32f2e7378835cb97ee7a6530f43e2eb627 with: image_tag: v4.2.0 - package_whole_project_src: true + package_whole_project_src: false From 9461af34d5307c53f5ed9f059c68b33b4eeeb4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 27 Dec 2023 18:43:52 +0200 Subject: [PATCH 19/27] Reference new workflow. --- .github/workflows/on_pull_request_build_contracts.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 35c3e64a3..02329fc99 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -8,7 +8,6 @@ permissions: jobs: build: - uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@67554b32f2e7378835cb97ee7a6530f43e2eb627 + uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@870f585842c20dc34be545d089303e37879b6836 with: image_tag: v4.2.0 - package_whole_project_src: false From d6e2799da1d75fde9dabb6a6b0b3e79960625945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 27 Dec 2023 18:49:25 +0200 Subject: [PATCH 20/27] package_whole_project_src = true. --- .github/workflows/on_pull_request_build_contracts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 02329fc99..0b3fd35df 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -11,3 +11,4 @@ jobs: uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@870f585842c20dc34be545d089303e37879b6836 with: image_tag: v4.2.0 + package_whole_project_src: true From e3e66523e3992d7529c1515d96dbd3e21e5d5a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Wed, 27 Dec 2023 18:49:47 +0200 Subject: [PATCH 21/27] Use latest workflow. --- .github/workflows/on_pull_request_build_contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 0b3fd35df..3fb485102 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -8,7 +8,7 @@ permissions: jobs: build: - uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@870f585842c20dc34be545d089303e37879b6836 + uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@c1e07711ffeda699c5e4ea205adb624d0ab7184c with: image_tag: v4.2.0 package_whole_project_src: true From 93b036c7b8fe0d731042f4280ae2f2a87d53889d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Thu, 28 Dec 2023 09:55:08 +0200 Subject: [PATCH 22/27] Newer workflow. --- .github/workflows/on_pull_request_build_contracts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 3fb485102..0fc2e4f99 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -8,7 +8,7 @@ permissions: jobs: build: - uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@c1e07711ffeda699c5e4ea205adb624d0ab7184c + uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.4 with: - image_tag: v4.2.0 + image_tag: v4.2.1 package_whole_project_src: true From 4c702f61c47c30a0d64388f48d96de63c6c812ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Thu, 28 Dec 2023 10:06:17 +0200 Subject: [PATCH 23/27] Retest. --- .github/workflows/on_pull_request_build_contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 0fc2e4f99..b87f3f67b 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -11,4 +11,4 @@ jobs: uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.4 with: image_tag: v4.2.1 - package_whole_project_src: true + package_whole_project_src: false From 3cd5b8635c9f65bbada0f4cf35bfa01ef58dbfed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Thu, 28 Dec 2023 10:10:26 +0200 Subject: [PATCH 24/27] Retest. --- .github/workflows/on_pull_request_build_contracts.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index b87f3f67b..165d377ad 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -11,4 +11,3 @@ jobs: uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.4 with: image_tag: v4.2.1 - package_whole_project_src: false From df9bc9e3a0be928a73b229786f6c22c445729c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Thu, 28 Dec 2023 10:15:24 +0200 Subject: [PATCH 25/27] Retest. --- .github/workflows/on_pull_request_build_contracts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/on_pull_request_build_contracts.yml b/.github/workflows/on_pull_request_build_contracts.yml index 165d377ad..0fc2e4f99 100644 --- a/.github/workflows/on_pull_request_build_contracts.yml +++ b/.github/workflows/on_pull_request_build_contracts.yml @@ -11,3 +11,4 @@ jobs: uses: multiversx/mx-sc-actions/.github/workflows/reproducible-build.yml@v2.3.4 with: image_tag: v4.2.1 + package_whole_project_src: true From de594b3b5390039a45c7e3a946907ce1569809d1 Mon Sep 17 00:00:00 2001 From: dragosrebegea Date: Tue, 9 Apr 2024 16:27:36 +0200 Subject: [PATCH 26/27] total quorum check --- energy-integration/governance-v2/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index c914e3a95..0165979cd 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -52,6 +52,17 @@ pub trait GovernanceV2: self.try_change_fee_token_id(fee_token); } + #[endpoint] + fn upgrade(&self) { + &self, + proposal_id: ProposalId, + total_percentage: BigUint, + ) { + let mut proposal = self.proposals().get(proposal_id); + proposal.total_quorum = total_percentage; + self.proposals().set(proposal_id, &proposal); + } + /// Propose a list of actions. /// A maximum of MAX_GOVERNANCE_PROPOSAL_ACTIONS can be proposed at a time. /// From 5c3900ffa92fa9194c04eff69a836161614930e0 Mon Sep 17 00:00:00 2001 From: dragosrebegea Date: Tue, 16 Apr 2024 10:58:50 +0300 Subject: [PATCH 27/27] fix compile issue --- energy-integration/governance-v2/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/energy-integration/governance-v2/src/lib.rs b/energy-integration/governance-v2/src/lib.rs index 0165979cd..ac502e0fa 100644 --- a/energy-integration/governance-v2/src/lib.rs +++ b/energy-integration/governance-v2/src/lib.rs @@ -53,7 +53,7 @@ pub trait GovernanceV2: } #[endpoint] - fn upgrade(&self) { + fn upgrade( &self, proposal_id: ProposalId, total_percentage: BigUint,