Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sovereign-Forge SC #207

Merged
merged 106 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
1f12f09
Merge pull request #191 from multiversx/merge-beta-in-sovereign-forge
andreiblt1304 Nov 25, 2024
f487641
Removed bridge module
andreiblt1304 Nov 25, 2024
3aedf9e
Added `update_config` endpoint
andreiblt1304 Nov 25, 2024
03267f8
Added endpoint to finish setup_phase
andreiblt1304 Nov 25, 2024
5fe6ad8
Added endpoint to deploy esdt_safe
andreiblt1304 Nov 25, 2024
0d251bf
Added functions to deploy esdt-safe and header-verifier
andreiblt1304 Nov 25, 2024
ed0de28
Added `complete_phases` module for chain-factory SC
andreiblt1304 Nov 25, 2024
9388b08
Added empty `deploy_phase_two` endpoint
andreiblt1304 Nov 26, 2024
49ea528
Added `chain-factory` as dependency
andreiblt1304 Nov 26, 2024
219c858
Regenerated proxy and added export for sovereign forge
andreiblt1304 Nov 26, 2024
7425469
Added views + build + proxy regen
andreiblt1304 Nov 26, 2024
f41524b
Fixed endpoint bug
andreiblt1304 Nov 26, 2024
d00a00a
Fixed `complete_setup_phase` bug
andreiblt1304 Nov 26, 2024
76c00f4
Added unit tests
andreiblt1304 Nov 27, 2024
07543dd
Fix after review
andreiblt1304 Nov 27, 2024
a3af379
Set `setup_phase_complete` to true
andreiblt1304 Nov 27, 2024
289b4a6
Merge pull request #192 from multiversx/phase-one
andreiblt1304 Nov 27, 2024
7d64754
Merge branch 'feat/sovereign-forge' into forge-tdd
andreiblt1304 Nov 27, 2024
6c19855
Added more tests
andreiblt1304 Nov 27, 2024
aab02c3
Merge pull request #193 from multiversx/forge-tdd
andreiblt1304 Nov 27, 2024
ab15d7f
Completed endpoint for phase two deployment
andreiblt1304 Nov 29, 2024
6db7e27
Modified storage logic for sovereign history
andreiblt1304 Nov 29, 2024
9af6408
Merge branch 'forge-storage' into phase-two
andreiblt1304 Nov 29, 2024
ce21a4c
Added alias type to be more explicit
andreiblt1304 Nov 29, 2024
3be917a
Modified helper function to check for deployed contract with parameter
andreiblt1304 Nov 29, 2024
cf59257
Made type alias public
andreiblt1304 Nov 29, 2024
6c89084
Added getter function for chain_id
andreiblt1304 Nov 29, 2024
e26b18f
Renamed contracts in enum
andreiblt1304 Nov 29, 2024
897e6c4
Added logic for phase two of deployment
andreiblt1304 Nov 29, 2024
8731152
Updated proxy
andreiblt1304 Nov 29, 2024
166c241
Used parameter instead of hardcoded `ScArray` id
andreiblt1304 Nov 29, 2024
8092094
Added error unit test
andreiblt1304 Nov 29, 2024
2815501
Added `complete_setup_phase` for HeaderVerifier
andreiblt1304 Nov 29, 2024
af698be
Update cargo lock
andreiblt1304 Nov 29, 2024
890a559
Merge pull request #194 from multiversx/forge-storage
andreiblt1304 Nov 29, 2024
ac70b26
Build + proxy regen
andreiblt1304 Nov 29, 2024
b82e3b5
Merge branch 'feat/sovereign-forge' into phase-two
andreiblt1304 Nov 29, 2024
c888c6b
Merge pull request #196 from multiversx/beta-in-sov-forge
andreiblt1304 Nov 29, 2024
8f1f159
Modified logic for checking if SC is deployed
andreiblt1304 Dec 2, 2024
b100aa6
Removed SCDisplay trait
andreiblt1304 Dec 2, 2024
d63d628
Removed unused import
andreiblt1304 Dec 2, 2024
5aae9b0
Fix after review
andreiblt1304 Dec 2, 2024
39e5a75
Added getter for `chain_factory` address
andreiblt1304 Dec 3, 2024
18f4662
Added common `sc_deploy` module for the deploy functions
andreiblt1304 Dec 3, 2024
48bb128
Added parameter for the function that checks if the contract is deployed
andreiblt1304 Dec 3, 2024
e03a74f
Removed unnecessary variable and made deploy functions `#[inline]`
andreiblt1304 Dec 3, 2024
41ab7e0
Added function to check if the first phase is completed
andreiblt1304 Dec 3, 2024
7dee3f2
Clippy fix
andreiblt1304 Dec 3, 2024
b9eccdc
Added first check for phase three
andreiblt1304 Dec 3, 2024
6deed30
Modified function to check first phase of deployment
andreiblt1304 Dec 3, 2024
90fbe08
Added require before deployment
andreiblt1304 Dec 3, 2024
ca44ef2
Fixed failing test
andreiblt1304 Dec 3, 2024
b3622f9
Merge pull request #197 from multiversx/phase-two
andreiblt1304 Dec 4, 2024
23d7de9
Fixed bug in `is_contract_deployed` function
andreiblt1304 Dec 4, 2024
78a202f
Fixed wrong require message
andreiblt1304 Dec 4, 2024
bbb49b8
Fixed require condition
andreiblt1304 Dec 4, 2024
a98d980
Added coverage for sovereign-forge
andreiblt1304 Dec 4, 2024
bbabe4d
Fixed setup bug
andreiblt1304 Dec 4, 2024
02c06e8
Added reference
andreiblt1304 Dec 4, 2024
edbf8ef
Merge pull request #199 from multiversx/phase-two-coverage
andreiblt1304 Dec 4, 2024
90cb662
Merge branch 'feat/sovereign-forge' into phase-three
andreiblt1304 Dec 5, 2024
6690a93
Removed junk code
andreiblt1304 Dec 5, 2024
4cafca9
Added transaction to set esdt_safe_address in header-address
andreiblt1304 Dec 5, 2024
f17a5d5
Added `header_verifier_address` as endpoint parameter
andreiblt1304 Dec 5, 2024
56b81a2
Phase three TDD
andreiblt1304 Dec 6, 2024
e6ac6eb
Added interactor setup
andreiblt1304 Dec 6, 2024
bd87dec
WIP Sovereign Forge interactor setup fixes
andreiblt1304 Dec 6, 2024
af54cc1
Uncommented code
andreiblt1304 Dec 9, 2024
207d459
WIP interactor setp
andreiblt1304 Dec 9, 2024
136c33e
Merge branch 'feat/beta' into feat/sovereign-forge
andreiblt1304 Dec 9, 2024
34ad384
Fixes for CI/CD
andreiblt1304 Dec 9, 2024
ab26a6f
Merge pull request #202 from multiversx/beta-into-sovereign-forge
andreiblt1304 Dec 9, 2024
f27be3b
Merge branch 'feat/sovereign-forge' into phase-three
andreiblt1304 Dec 10, 2024
b6f777f
Phase three fixes + unit tests
andreiblt1304 Dec 10, 2024
fc75117
Added reference for `ManagedAddress`
andreiblt1304 Dec 10, 2024
60d19a3
Built + proxy regen
andreiblt1304 Dec 10, 2024
7e7ac8f
Removed unused import
andreiblt1304 Dec 10, 2024
ab60f22
Merge branch 'phase-three' into phase-three-interactor
andreiblt1304 Dec 10, 2024
1ec46e1
Added helper function to get managed address
andreiblt1304 Dec 10, 2024
7a9bf14
Fixed address bug
andreiblt1304 Dec 10, 2024
4a4da14
Modified .gitignore to ignore state file
andreiblt1304 Dec 10, 2024
3646982
Uncommented on-chain test
andreiblt1304 Dec 10, 2024
1a0ad42
Removed comments + added feature flag
andreiblt1304 Dec 10, 2024
410bb3b
Modified gitignore
andreiblt1304 Dec 10, 2024
fa66115
Merge pull request #203 from multiversx/phase-three
andreiblt1304 Dec 10, 2024
ed7d46c
Added workflow for chain-simulator tests
andreiblt1304 Dec 10, 2024
95100ab
Added Makefile
andreiblt1304 Dec 10, 2024
3968673
Added docker-compose file
andreiblt1304 Dec 10, 2024
586e475
Removed proxy and modified sc-config to not generate proxy in interactor
andreiblt1304 Dec 10, 2024
f1711bd
Updated state.toml
andreiblt1304 Dec 10, 2024
6ec9842
Removed makefile and docker-compose
andreiblt1304 Dec 10, 2024
769c41f
Added commit hash for action.yml
andreiblt1304 Dec 10, 2024
b42d94a
Fixed cs test
andreiblt1304 Dec 11, 2024
6e90a97
Reverted yml file
andreiblt1304 Dec 11, 2024
ad67803
Added `deploy_phase_four` endpoint
andreiblt1304 Dec 11, 2024
767794c
Removed comments
andreiblt1304 Dec 11, 2024
2f07c42
Added fee-market as dependency
andreiblt1304 Dec 11, 2024
9872203
Added proxy rename + regen
andreiblt1304 Dec 11, 2024
6f3e181
Modified error message
andreiblt1304 Dec 11, 2024
47fde5d
Added unit tests
andreiblt1304 Dec 11, 2024
a78f490
Merge pull request #204 from multiversx/phase-three-interactor
andreiblt1304 Dec 11, 2024
4f366ed
Added logic to also set `fee_market_address` in ESDTSafe contract
andreiblt1304 Dec 11, 2024
669a447
Merge branch 'feat/sovereign-forge' into phase-four
andreiblt1304 Dec 11, 2024
120737f
Added setup + chain-simulator test update
andreiblt1304 Dec 11, 2024
8412739
Removed `state.toml`
andreiblt1304 Dec 11, 2024
467a819
Merge pull request #205 from multiversx/phase-four
andreiblt1304 Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ permissions:
jobs:
contracts:
name: Contracts
uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v3.3.1
uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@79d7ac76e34b3208fbe07559ac276d0ea48be4da
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be modified when a stable release of the actions.yml is launched

with:
rust-toolchain: stable
coverage-args: --ignore-filename-regex='/.cargo/git' --output ./coverage.md
Expand Down
22 changes: 21 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ members = [
"testing-sc",
"testing-sc/meta",
"sovereign-forge",
"sovereign-forge/interactor",
"sovereign-forge/meta",
]
3 changes: 3 additions & 0 deletions chain-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ version = "=0.54.5"

[dependencies.transaction]
path = "../common/transaction"

[dependencies.setup-phase]
path = "../common/setup-phase"
40 changes: 0 additions & 40 deletions chain-config/src/bridge.rs

This file was deleted.

44 changes: 42 additions & 2 deletions chain-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ use validator_rules::TokenIdAmountPair;

multiversx_sc::imports!();

pub mod bridge;
pub mod validator_rules;

#[multiversx_sc::contract]
pub trait ChainConfigContract:
bridge::BridgeModule + validator_rules::ValidatorRulesModule + only_admin::OnlyAdminModule
validator_rules::ValidatorRulesModule + only_admin::OnlyAdminModule + setup_phase::SetupPhaseModule
{
#[init]
fn init(
Expand Down Expand Up @@ -42,6 +41,47 @@ pub trait ChainConfigContract:
self.additional_stake_required().set(additional_stake_vec);
}

#[only_admin]
fn update_config(
&self,
opt_min_validators: Option<u64>,
opt_max_validators: Option<u64>,
opt_min_stake: Option<BigUint>,
opt_additional_stake_required: Option<MultiValueEncoded<StakeMultiArg<Self::Api>>>,
) {
if let Some(min_validators) = opt_min_validators {
self.min_validators().set(min_validators);
}
if let Some(max_validators) = opt_max_validators {
self.max_validators().set(max_validators);
}
if let Some(min_stake) = opt_min_stake {
self.min_stake().set(min_stake);
}
if let Some(additional_stake_required) = opt_additional_stake_required {
let mut additional_stake_vec = ManagedVec::new();
for multi_value in additional_stake_required {
let (token_id, amount) = multi_value.into_tuple();
let value = TokenIdAmountPair { token_id, amount };

additional_stake_vec.push(value);
}
self.additional_stake_required().set(additional_stake_vec);
Comment on lines +62 to +69
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract in separate function

}
}

#[only_owner]
fn complete_setup_phase(&self) {
if self.is_setup_phase_complete() {
return;
}

self.require_config_set();
// validator set in header verifier
// change ownership to header-verifier
self.setup_phase_complete().set(true);
}

#[upgrade]
fn upgrade(&self) {}
}
20 changes: 20 additions & 0 deletions chain-config/src/validator_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ pub struct TokenIdAmountPair<M: ManagedTypeApi> {

#[multiversx_sc::module]
pub trait ValidatorRulesModule {
fn require_config_set(&self) {
require!(
!self.min_validators().is_empty(),
"The minimum number of validators is not set"
);
require!(
!self.max_validators().is_empty(),
"The maximum number of validators is not set"
);
require!(
!self.min_stake().is_empty(),
"The mininum number of stake is not set"
);
require!(
!self.additional_stake_required().is_empty(),
"The additional stake criteria is not set"
);
}

#[view(getMinValidators)]
#[storage_mapper("minValidators")]
fn min_validators(&self) -> SingleValueMapper<u64>;
Expand All @@ -26,6 +45,7 @@ pub trait ValidatorRulesModule {
#[storage_mapper("minStake")]
fn min_stake(&self) -> SingleValueMapper<BigUint>;

// NOTE: ManagedVec or MultiValueEncoded ?
// TODO: Read user stake and verify
#[view(getAdditionalStakeRequired)]
#[storage_mapper("additionalStakeRequired")]
Expand Down
8 changes: 8 additions & 0 deletions chain-config/wasm-chain-config-full/Cargo.lock

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

5 changes: 2 additions & 3 deletions chain-config/wasm-chain-config-full/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

// Init: 1
// Upgrade: 1
// Endpoints: 10
// Endpoints: 9
// Async Callback (empty): 1
// Total number of exported functions: 13
// Total number of exported functions: 12

#![no_std]

Expand All @@ -20,7 +20,6 @@ multiversx_sc_wasm_adapter::endpoints! {
(
init => init
upgrade => upgrade
deployBridge => deploy_bridge
getMinValidators => min_validators
getMaxValidators => max_validators
getMinStake => min_stake
Expand Down
8 changes: 8 additions & 0 deletions chain-config/wasm-chain-config-view/Cargo.lock

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

8 changes: 8 additions & 0 deletions chain-config/wasm/Cargo.lock

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

5 changes: 2 additions & 3 deletions chain-config/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

// Init: 1
// Upgrade: 1
// Endpoints: 10
// Endpoints: 9
// Async Callback (empty): 1
// Total number of exported functions: 13
// Total number of exported functions: 12

#![no_std]

Expand All @@ -20,7 +20,6 @@ multiversx_sc_wasm_adapter::endpoints! {
(
init => init
upgrade => upgrade
deployBridge => deploy_bridge
getMinValidators => min_validators
getMaxValidators => max_validators
getMinStake => min_stake
Expand Down
14 changes: 14 additions & 0 deletions chain-factory/src/complete_phases.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#[multiversx_sc::module]
pub trait CompletePhasesModule {
#[endpoint(completeChainConfigSetup)]
fn complete_chain_config_setup(&self) {}

#[endpoint(completeHeaderVerifierSetup)]
fn complete_header_verifier_setup(&self) {}

#[endpoint(completeFeeMarketSetup)]
fn complete_fee_market_setup(&self) {}

#[endpoint(completeEsdtSafeSetup)]
fn complete_esdt_safe_setup(&self) {}
}
Loading
Loading