From 9b01b5e7fc2bca87e3b97d4eb68614e53ad32f33 Mon Sep 17 00:00:00 2001 From: lpgeiger <1364012+lpgeiger@users.noreply.github.com> Date: Mon, 31 May 2021 14:47:00 -0400 Subject: [PATCH] Fixes #522 val join issue (#523) * patch pilot text. Was showing incorrect print on account creation. * formatting on health print * ol start doesn't always attempt db restore seems to have false negative * change move error codes * entrypoint * validator universe add_self tx script. build stdlib. add mining make file test. * exists_jailbit is incorrectly checking for testnet * closes #522 * if user is onboarding can add self to validator universe. * add script for adding self to set * release.yaml to use tar gzip instead of zip * remove zip dependency from install.sh * patch onboarding move tests --- .github/workflows/release.yaml | 4 +- client/transaction-builder/src/stdlib.rs | 40 +++++++++-- .../libra_account/onboarding_flow_happy.move | 7 +- .../0L/libra_account/onboarding_reconfig.move | 28 ++++---- .../tests/0L/libra_account/onboarding_tx.move | 22 +++---- ...24_FixedPoint32.mv => 021_FixedPoint32.mv} | Bin .../stdlib/{030_Stats.mv => 022_Stats.mv} | Bin .../{031_StagingNet.mv => 023_StagingNet.mv} | Bin ...rencies.mv => 024_RegisteredCurrencies.mv} | Bin language/stdlib/compiled/stdlib/025_Libra.mv | Bin 4371 -> 4371 bytes .../stdlib/{027_GAS.mv => 026_GAS.mv} | Bin .../stdlib/{032_Globals.mv => 027_Globals.mv} | Bin 1049 -> 1049 bytes ..._FullnodeState.mv => 028_FullnodeState.mv} | Bin .../{034_MinerState.mv => 029_MinerState.mv} | Bin .../compiled/stdlib/030_ValidatorUniverse.mv | Bin 0 -> 1384 bytes .../stdlib/{021_VASP.mv => 031_VASP.mv} | Bin ...stedAccounts.mv => 032_TrustedAccounts.mv} | Bin .../stdlib/{026_LBR.mv => 033_LBR.mv} | Bin ...ransactionFee.mv => 034_TransactionFee.mv} | Bin ...29_SlidingNonce.mv => 035_SlidingNonce.mv} | Bin ...> 036_LibraTransactionPublishingOption.mv} | Bin .../stdlib/{036_FIFO.mv => 037_FIFO.mv} | Bin ...lAttestation.mv => 038_DualAttestation.mv} | Bin 2456 -> 2456 bytes ...natedDealer.mv => 039_DesignatedDealer.mv} | Bin .../stdlib/{039_Coin1.mv => 040_Coin1.mv} | Bin .../stdlib/{040_ChainId.mv => 041_ChainId.mv} | Bin ...41_LibraAccount.mv => 042_LibraAccount.mv} | Bin 10862 -> 10904 bytes .../{042_AutoPay2.mv => 043_AutoPay2.mv} | Bin .../stdlib/{043_Cases.mv => 044_Cases.mv} | Bin .../stdlib/{044_Epoch.mv => 045_Epoch.mv} | Bin .../compiled/stdlib/045_ValidatorUniverse.mv | Bin 1354 -> 0 bytes .../stdlib/compiled/stdlib/048_Subsidy.mv | Bin 3568 -> 3568 bytes .../stdlib/compiled/stdlib/050_Reconfigure.mv | Bin 1911 -> 1911 bytes .../stdlib/compiled/stdlib/055_Genesis.mv | Bin 1002 -> 1002 bytes .../abi/ol_validator_universe_add_self.abi | Bin 0 -> 287 bytes .../abi/ol_validator_universe_join.abi | Bin 375 -> 375 bytes .../ol_validator_universe_add_self.mv | Bin 0 -> 269 bytes .../ol_validator_universe_join.mv | Bin 365 -> 365 bytes language/stdlib/modules/0L/LibraAccount.move | 8 ++- .../stdlib/modules/0L/ValidatorUniverse.move | 22 ++++--- language/stdlib/modules/doc/LibraAccount.md | 5 +- .../stdlib/modules/doc/ValidatorUniverse.md | 54 +++++++-------- .../doc/ol_validator_universe_add_self.md | 62 ++++++++++++++++++ .../doc/ol_validator_universe_join.md | 2 +- .../doc/transaction_script_documentation.md | 1 + .../ol_validator_universe_add_self.move | 17 +++++ .../ol_validator_universe_join.move | 2 +- language/tools/vm-genesis/src/lib.rs | 1 + ol/miner/src/entrypoint.rs | 4 +- ol/txs/src/commands/valset_cmd.rs | 8 ++- ol/txs/src/entrypoint.rs | 2 +- ol/util/install.sh | 5 +- ol/util/test-mining.mk | 13 ++++ 53 files changed, 221 insertions(+), 86 deletions(-) rename language/stdlib/compiled/stdlib/{024_FixedPoint32.mv => 021_FixedPoint32.mv} (100%) rename language/stdlib/compiled/stdlib/{030_Stats.mv => 022_Stats.mv} (100%) rename language/stdlib/compiled/stdlib/{031_StagingNet.mv => 023_StagingNet.mv} (100%) rename language/stdlib/compiled/stdlib/{023_RegisteredCurrencies.mv => 024_RegisteredCurrencies.mv} (100%) rename language/stdlib/compiled/stdlib/{027_GAS.mv => 026_GAS.mv} (100%) rename language/stdlib/compiled/stdlib/{032_Globals.mv => 027_Globals.mv} (81%) rename language/stdlib/compiled/stdlib/{033_FullnodeState.mv => 028_FullnodeState.mv} (100%) rename language/stdlib/compiled/stdlib/{034_MinerState.mv => 029_MinerState.mv} (100%) create mode 100644 language/stdlib/compiled/stdlib/030_ValidatorUniverse.mv rename language/stdlib/compiled/stdlib/{021_VASP.mv => 031_VASP.mv} (100%) rename language/stdlib/compiled/stdlib/{022_TrustedAccounts.mv => 032_TrustedAccounts.mv} (100%) rename language/stdlib/compiled/stdlib/{026_LBR.mv => 033_LBR.mv} (100%) rename language/stdlib/compiled/stdlib/{028_TransactionFee.mv => 034_TransactionFee.mv} (100%) rename language/stdlib/compiled/stdlib/{029_SlidingNonce.mv => 035_SlidingNonce.mv} (100%) rename language/stdlib/compiled/stdlib/{035_LibraTransactionPublishingOption.mv => 036_LibraTransactionPublishingOption.mv} (100%) rename language/stdlib/compiled/stdlib/{036_FIFO.mv => 037_FIFO.mv} (100%) rename language/stdlib/compiled/stdlib/{037_DualAttestation.mv => 038_DualAttestation.mv} (88%) rename language/stdlib/compiled/stdlib/{038_DesignatedDealer.mv => 039_DesignatedDealer.mv} (100%) rename language/stdlib/compiled/stdlib/{039_Coin1.mv => 040_Coin1.mv} (100%) rename language/stdlib/compiled/stdlib/{040_ChainId.mv => 041_ChainId.mv} (100%) rename language/stdlib/compiled/stdlib/{041_LibraAccount.mv => 042_LibraAccount.mv} (51%) rename language/stdlib/compiled/stdlib/{042_AutoPay2.mv => 043_AutoPay2.mv} (100%) rename language/stdlib/compiled/stdlib/{043_Cases.mv => 044_Cases.mv} (100%) rename language/stdlib/compiled/stdlib/{044_Epoch.mv => 045_Epoch.mv} (100%) delete mode 100644 language/stdlib/compiled/stdlib/045_ValidatorUniverse.mv create mode 100644 language/stdlib/compiled/transaction_scripts/abi/ol_validator_universe_add_self.abi create mode 100644 language/stdlib/compiled/transaction_scripts/ol_validator_universe_add_self.mv create mode 100644 language/stdlib/transaction_scripts/doc/ol_validator_universe_add_self.md create mode 100644 language/stdlib/transaction_scripts/ol_validator_universe_add_self.move create mode 100644 ol/util/test-mining.mk diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 65b0b5c607..de0fe0ecea 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,12 +32,12 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Web - run: cd ol/cli/web-monitor/public/; zip -r web-monitor.zip * + run: cd ol/cli/web-monitor/public/; tar -czvf web-monitor.tar.gz * - name: Upload Web Files uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ol/cli/web-monitor/public/web-monitor.zip + file: ol/cli/web-monitor/public/web-monitor.tar.gz file_glob: true tag: ${{ github.ref }} overwrite: true diff --git a/client/transaction-builder/src/stdlib.rs b/client/transaction-builder/src/stdlib.rs index 890bf1fcac..f5a2b2181d 100644 --- a/client/transaction-builder/src/stdlib.rs +++ b/client/transaction-builder/src/stdlib.rs @@ -1549,6 +1549,8 @@ pub enum ScriptCall { currency: TypeTag, allow_minting: bool, }, + + ValAddSelf {}, } impl ScriptCall { @@ -1833,6 +1835,7 @@ impl ScriptCall { currency, allow_minting, } => encode_update_minting_ability_script(currency, allow_minting), + ValAddSelf {} => encode_val_add_self_script(), } } @@ -3709,6 +3712,10 @@ pub fn encode_update_minting_ability_script(currency: TypeTag, allow_minting: bo ) } +pub fn encode_val_add_self_script() -> Script { + Script::new(VAL_ADD_SELF_CODE.to_vec(), vec![], vec![]) +} + fn decode_add_currency_to_account_script(script: &Script) -> Option { Some(ScriptCall::AddCurrencyToAccount { currency: script.ty_args().get(0)?.clone(), @@ -4061,6 +4068,10 @@ fn decode_update_minting_ability_script(script: &Script) -> Option { }) } +fn decode_val_add_self_script(_script: &Script) -> Option { + Some(ScriptCall::ValAddSelf {}) +} + type DecoderMap = std::collections::HashMap< Vec, Box Option + std::marker::Sync + std::marker::Send>, @@ -4241,6 +4252,10 @@ static SCRIPT_DECODER_MAP: once_cell::sync::Lazy = once_cell::sync:: UPDATE_MINTING_ABILITY_CODE.to_vec(), Box::new(decode_update_minting_ability_script), ); + map.insert( + VAL_ADD_SELF_CODE.to_vec(), + Box::new(decode_val_add_self_script), + ); map }); @@ -4509,11 +4524,11 @@ const JOIN_CODE: &[u8] = &[ 108, 102, 16, 101, 120, 105, 115, 116, 115, 95, 106, 97, 105, 108, 101, 100, 98, 105, 116, 10, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 14, 105, 115, 95, 105, 110, 95, 117, 110, 105, 118, 101, 114, 115, 101, 9, 105, 115, 95, 106, 97, 105, 108, 101, 100, 11, 117, 110, 106, 97, - 105, 108, 95, 115, 101, 108, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 8, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 3, 6, 40, 10, 0, 17, 2, 12, 1, 10, 0, 10, 1, 17, 1, 7, 0, 17, 0, 12, 3, - 12, 2, 11, 2, 3, 16, 11, 0, 1, 11, 3, 39, 10, 1, 17, 6, 32, 3, 21, 5, 23, 10, 0, 17, 3, 10, 1, - 17, 4, 32, 3, 28, 5, 30, 10, 0, 17, 5, 10, 1, 17, 7, 3, 34, 5, 37, 11, 0, 17, 8, 5, 39, 11, 0, - 1, 2, + 105, 108, 95, 115, 101, 108, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 8, 197, + 91, 3, 0, 0, 0, 0, 0, 0, 3, 6, 40, 10, 0, 17, 2, 12, 1, 10, 0, 10, 1, 17, 1, 7, 0, 17, 0, 12, + 3, 12, 2, 11, 2, 3, 16, 11, 0, 1, 11, 3, 39, 10, 1, 17, 6, 32, 3, 21, 5, 23, 10, 0, 17, 3, 10, + 1, 17, 4, 32, 3, 28, 5, 30, 10, 0, 17, 5, 10, 1, 17, 7, 3, 34, 5, 37, 11, 0, 17, 8, 5, 39, 11, + 0, 1, 2, ]; const LEAVE_CODE: &[u8] = &[ @@ -4800,3 +4815,18 @@ const UPDATE_MINTING_ABILITY_CODE: &[u8] = &[ 97, 116, 101, 95, 109, 105, 110, 116, 105, 110, 103, 95, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 4, 11, 0, 10, 1, 56, 0, 2, ]; + +const VAL_ADD_SELF_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 8, 3, 8, 25, 5, 33, 18, 7, 51, 110, 8, 161, 1, 16, 6, + 177, 1, 10, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 0, 1, 5, 1, 2, 0, 2, 6, 3, 4, 0, 3, 7, 3, 5, 0, + 3, 8, 4, 2, 0, 1, 3, 2, 6, 12, 5, 1, 1, 1, 6, 12, 1, 5, 0, 3, 5, 1, 3, 6, 69, 114, 114, 111, + 114, 115, 10, 77, 105, 110, 101, 114, 83, 116, 97, 116, 101, 6, 83, 105, 103, 110, 101, 114, + 17, 86, 97, 108, 105, 100, 97, 116, 111, 114, 85, 110, 105, 118, 101, 114, 115, 101, 13, 105, + 110, 118, 97, 108, 105, 100, 95, 115, 116, 97, 116, 101, 17, 110, 111, 100, 101, 95, 97, 98, + 111, 118, 101, 95, 116, 104, 114, 101, 115, 104, 10, 97, 100, 100, 114, 101, 115, 115, 95, 111, + 102, 8, 97, 100, 100, 95, 115, 101, 108, 102, 14, 105, 115, 95, 105, 110, 95, 117, 110, 105, + 118, 101, 114, 115, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 8, 198, 91, 3, 0, + 0, 0, 0, 0, 0, 3, 6, 27, 10, 0, 17, 2, 12, 1, 10, 0, 10, 1, 17, 1, 7, 0, 17, 0, 12, 3, 12, 2, + 11, 2, 3, 16, 11, 0, 1, 11, 3, 39, 10, 1, 17, 4, 32, 3, 21, 5, 24, 11, 0, 17, 3, 5, 26, 11, 0, + 1, 2, +]; diff --git a/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_flow_happy.move b/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_flow_happy.move index 51febaebba..559b1177de 100644 --- a/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_flow_happy.move +++ b/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_flow_happy.move @@ -64,8 +64,11 @@ fun main(vm: &signer) { let expected = 1000000 + 576000; assert(bal == expected, 7357401003); - assert(!ValidatorUniverse::exists_jailedbit(eve_addr), 7357401004); - assert(!ValidatorUniverse::is_in_universe(eve_addr), 7357401005); + // validator should have jailedbit + assert(ValidatorUniverse::exists_jailedbit(eve_addr), 7357401004); + // validator should be in universe if just joined. + assert(ValidatorUniverse::is_in_universe(eve_addr), 7357401005); + // should not be jailed assert(!ValidatorUniverse::is_jailed(eve_addr), 7357401006); } } diff --git a/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_reconfig.move b/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_reconfig.move index b04e7a1dca..d3ab13bce1 100644 --- a/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_reconfig.move +++ b/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_reconfig.move @@ -96,11 +96,13 @@ script { use 0x1::Vector; fun main(vm: &signer) { // Tests on initial size of validators + // New validator is not in this set. assert(LibraSystem::validator_set_size() == 4, 7357000180101); assert(LibraSystem::is_validator({{alice}}) == true, 7357000180102); assert(!LibraSystem::is_validator(0x3DC18D1CF61FAAC6AC70E3A63F062E4B), 7357000180103); let len = Vector::length
(&ValidatorUniverse::get_eligible_validators(vm)); - assert(len == 4 , 7357000180104); + // Is in validator universe + assert(len == 5 , 7357000180104); } } // check: EXECUTED @@ -119,10 +121,10 @@ script { fun main(vm: &signer) { // Tests on initial size of validators - assert(LibraSystem::validator_set_size() == 4, 7357000180101); - assert(LibraSystem::is_validator({{alice}}) == true, 7357000180102); - assert(LibraSystem::is_validator({{bob}}) == true, 7357000180103); - assert(LibraSystem::is_validator(0x3DC18D1CF61FAAC6AC70E3A63F062E4B) == false, 7357000180103); + assert(LibraSystem::validator_set_size() == 4, 7357000180201); + assert(LibraSystem::is_validator({{alice}}) == true, 7357000180202); + assert(LibraSystem::is_validator({{bob}}) == true, 7357000180203); + assert(LibraSystem::is_validator(0x3DC18D1CF61FAAC6AC70E3A63F062E4B) == false, 7357000180204); // Mock everyone being a CASE 1 let voters = Vector::empty
(); @@ -137,14 +139,12 @@ script { MinerState::test_helper_mock_mining_vm(vm, {{dave}}, 20); MinerState::test_helper_mock_mining_vm(vm, 0x3DC18D1CF61FAAC6AC70E3A63F062E4B, 20); + // check the new account is in the list of eligible let len = Vector::length
(&ValidatorUniverse::get_eligible_validators(vm)); - assert(len == 4 , 7357000180104); - - // Adding eve to validator universe - would be done by self - ValidatorUniverse::test_helper_add_self_onboard(vm, 0x3DC18D1CF61FAAC6AC70E3A63F062E4B); + assert(len == 5 , 7357000180205); let len = Vector::length
(&ValidatorUniverse::get_eligible_validators(vm)); - assert(len == 5 , 7357000180104); + assert(len == 5 , 7357000180206); let i = 1; while (i < 16) { @@ -169,11 +169,11 @@ script { use 0x1::Vector; fun main(vm: &signer) { // Tests on initial size of validators - assert(LibraSystem::validator_set_size() == 5, 7357000200101); - assert(LibraSystem::is_validator({{alice}}) == true, 7357000200102); - assert(LibraSystem::is_validator(0x3DC18D1CF61FAAC6AC70E3A63F062E4B), 7357000200103); + assert(LibraSystem::validator_set_size() == 5, 7357000200301); + assert(LibraSystem::is_validator({{alice}}) == true, 7357000200302); + assert(LibraSystem::is_validator(0x3DC18D1CF61FAAC6AC70E3A63F062E4B), 7357000200303); let len = Vector::length
(&ValidatorUniverse::get_eligible_validators(vm)); - assert(LibraSystem::validator_set_size() == len, 7357000200104); + assert(LibraSystem::validator_set_size() == len, 7357000200304); } } // check: EXECUTED diff --git a/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_tx.move b/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_tx.move index f010fd0037..fefc5d0549 100644 --- a/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_tx.move +++ b/language/move-lang/functional-tests/tests/0L/libra_account/onboarding_tx.move @@ -12,15 +12,14 @@ use 0x1::TestFixtures; use 0x1::ValidatorConfig; use 0x1::Roles; use 0x1::Signer; -use 0x1::Debug::print; use 0x1::ValidatorUniverse; // Test Prefix: 1301 fun main(sender: &signer) { - // // Scenario: Bob, an existing validator, is sending a transaction for Eve, with a challenge and proof not yet submitted to the chain. + // Scenario: Bob, an existing validator, is sending a transaction for Eve, with a challenge and proof not yet submitted to the chain. let challenge = TestFixtures::eve_0_easy_chal(); let solution = TestFixtures::eve_0_easy_sol(); - // // Parse key and check + // Parse key and check let (eve_addr, _auth_key) = VDF::extract_address_from_challenge(&challenge); assert(eve_addr == 0x3DC18D1CF61FAAC6AC70E3A63F062E4B, 401); @@ -56,16 +55,13 @@ fun main(sender: &signer) { //Check the validator has 0 proof of weight. assert(NodeWeight::proof_of_weight(eve_addr) == 0, 7357130101071000); - // Check the account exists and the balance is 0 - // TODO: Needs some balance - print(&LibraAccount::balance(eve_addr)); + // Check the account exists and the balance has the onboarding amount. assert(LibraAccount::balance(eve_addr) == 1000000, 7357130101081000); - // Should not automatically be in validator universe - // Needs to mine and submit the join transaction. - assert(!ValidatorUniverse::is_in_universe(eve_addr), 7357130101091000); - // Does not have a jailedbit since was not added to validator universe yet. - assert(!ValidatorUniverse::exists_jailedbit(eve_addr), 7357130101101000); + // Automatically is a candidate for validator set. + assert(ValidatorUniverse::is_in_universe(eve_addr), 7357130101091000); + // Should have a jailed bit. + assert(ValidatorUniverse::exists_jailedbit(eve_addr), 7357130101101000); } } // check: EXECUTED @@ -75,14 +71,12 @@ fun main(sender: &signer) { script { use 0x1::MinerState; use 0x1::Testnet; -// use 0x1::ValidatorUniverse; + fun main(vm: &signer) { Testnet::remove_testnet(vm); // need to remove testnet for this test, since testnet does not ratelimit account creation. // check is rate-limited assert(MinerState::can_create_val_account({{bob}}) == false, 7357130101091000); - // let universe = ValidatorUniverse::get_eligible_validators(vm); - // print(&universe); } } \ No newline at end of file diff --git a/language/stdlib/compiled/stdlib/024_FixedPoint32.mv b/language/stdlib/compiled/stdlib/021_FixedPoint32.mv similarity index 100% rename from language/stdlib/compiled/stdlib/024_FixedPoint32.mv rename to language/stdlib/compiled/stdlib/021_FixedPoint32.mv diff --git a/language/stdlib/compiled/stdlib/030_Stats.mv b/language/stdlib/compiled/stdlib/022_Stats.mv similarity index 100% rename from language/stdlib/compiled/stdlib/030_Stats.mv rename to language/stdlib/compiled/stdlib/022_Stats.mv diff --git a/language/stdlib/compiled/stdlib/031_StagingNet.mv b/language/stdlib/compiled/stdlib/023_StagingNet.mv similarity index 100% rename from language/stdlib/compiled/stdlib/031_StagingNet.mv rename to language/stdlib/compiled/stdlib/023_StagingNet.mv diff --git a/language/stdlib/compiled/stdlib/023_RegisteredCurrencies.mv b/language/stdlib/compiled/stdlib/024_RegisteredCurrencies.mv similarity index 100% rename from language/stdlib/compiled/stdlib/023_RegisteredCurrencies.mv rename to language/stdlib/compiled/stdlib/024_RegisteredCurrencies.mv diff --git a/language/stdlib/compiled/stdlib/025_Libra.mv b/language/stdlib/compiled/stdlib/025_Libra.mv index b56c7a97745522b3c24b7aa595e83b3bc9a96cea..e14f033d41e18a99828ff934352cc22d88dec441 100644 GIT binary patch delta 158 zcmbQNG+AlF6=4=dHYNrZC3YqTHf0WG1~wH2=84Z^6o3>1g9)<`BO`+;m^1^E=E8hH z5esIv$;phzc^EmknV5l?jfabAvl){ivovpdYDs)iVtIU7Voqr)Pi|>WNoGM#Wqhfb z$>ela+0FA=D_MBh*esZM7`Yg@83hG4t8i^#ViekZm4}m=QE>8o{!&K%$)N)K08OwT AUjP6A delta 183 zcmW;A%?*Mu7y!_IEf$2T{4Aiz0w#(q;?1NX(3mEOhENSoq3HmwV8Y$23+UOSYp7h_ z;ptF^=Vw4Clpq=+f{dw&kr7$=@>!4nf#$>qK#R_}a~TYOlMqv9@L-rS8-wLwVmWP$ zXC(2`Jm;CJDp6()&vv=6WhrZ!7V;zp8&UHrJ@P|ZD8aU>sO7$BxQgfPwbvNTqzPtV ZBL_UcjqDo+w|%ibfsuZX6nJ{&-oLK%DVhKP diff --git a/language/stdlib/compiled/stdlib/027_GAS.mv b/language/stdlib/compiled/stdlib/026_GAS.mv similarity index 100% rename from language/stdlib/compiled/stdlib/027_GAS.mv rename to language/stdlib/compiled/stdlib/026_GAS.mv diff --git a/language/stdlib/compiled/stdlib/032_Globals.mv b/language/stdlib/compiled/stdlib/027_Globals.mv similarity index 81% rename from language/stdlib/compiled/stdlib/032_Globals.mv rename to language/stdlib/compiled/stdlib/027_Globals.mv index fad70ccd710eceb4de1226d062b080acef364450..dcf78e1f80de9ae3680fb5601ef5efc7044844c0 100644 GIT binary patch delta 67 zcmbQqF_U9LI5!J7GYbPV4>JQJ*H>6v-y@p-8we8tI$IUsgg VVsc4-(Pjh2myC?elckvd0{~mu6kGrR delta 67 zcmbQqF_U9LI5#slGXoG5fa$tC$ke3`}Z#U+X9 UAd$S(lFbH;FM%2+OELck09vXPTmS$7 diff --git a/language/stdlib/compiled/stdlib/033_FullnodeState.mv b/language/stdlib/compiled/stdlib/028_FullnodeState.mv similarity index 100% rename from language/stdlib/compiled/stdlib/033_FullnodeState.mv rename to language/stdlib/compiled/stdlib/028_FullnodeState.mv diff --git a/language/stdlib/compiled/stdlib/034_MinerState.mv b/language/stdlib/compiled/stdlib/029_MinerState.mv similarity index 100% rename from language/stdlib/compiled/stdlib/034_MinerState.mv rename to language/stdlib/compiled/stdlib/029_MinerState.mv diff --git a/language/stdlib/compiled/stdlib/030_ValidatorUniverse.mv b/language/stdlib/compiled/stdlib/030_ValidatorUniverse.mv new file mode 100644 index 0000000000000000000000000000000000000000..aa2bf064131aae2dcbd2c3b9c81121bfcb6169b5 GIT binary patch literal 1384 zcmZ8hJ&znk5UuK-o{#R?-I@KkJ$z^Tj>NJpM-Z$?&>0&E1hRBzoDht5Z`*r=_hycn z*^?n8;x~{Xkq|;kM1V-h_y+_e1c-oyh}W}w>w}S|y1KgR)$6L7`Fj5k!$hQ+5|M;* z_Y3yEVy(X6dGMw9R)*iHME|Hv{EPbC>wK?0_%aESO3qfooQxJQK zIp|0qvg-wqy--3Xk!JQ&sYv!&kvA}kXb3zSIk5v9jbmuL)FFD!*={)7o)h~9+ndgI z%W1crIB?rT2*o~oEE&1{m=#MBzK+NTF=i-&r3kP>bBkmseys4qT`Q?L2pLjJKV;xQ z0uD9>8y1|k5)M$)XVYaqpEhOnQITKTs0HcRsSSkKo6eUx+!eqKeMO6ir$~*OFMs`J`3|=ZeJoWx>(g`*=&0H!msRkd1-ZC zXU#fc2WnZ&%4s#vi$&@vX44sbvgQn_&Lr}Oc(d9rpC|TZUN?32Ny~1QH{FFTYz>Gr zyS%W~cww8&F7rh`TiWdMsxr0Ci@eFP{oHopoEO<@Q>+NvHJaxZv*y<(8*KC~Om=y` z?^th=Wml}O`1`A(#aJ&bhTaC(n9l1DhLrc11;4J9!60*YUsFmkr{W&RQp<$8JRy!T z%Lg)1VWEK?_+Z@Q)#x(gmv&!V_ z%nF;OSv;9J#hF=HIk*@EB`4>yN6SetOR>svF$zlXu(B#}^00EVGApxcfuw+#JZ*#x(giv%=)- z%qp9uSv;9JMVVPxIk*@E#V6;oN6U#ZOR>svF$#+Du(B#}^00EVGApxcfuwb(B74FwPGrKcAn%x$X2BF>6uC%KIkPrgFfWS!H;t-c4#3_VW34tsL31JYR z1qU#PG2jM_!GLjM$FYqahr~{t*tz34PU0kvkHm4}s{BZ$oTO6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ds!dmz$8 zBkl{4I-2Kx5SgML=4{wCql+P27roRlQdpl_AHNUYT`?g$H2Go5fp6K!I2TL+*-- zL&_q%&3&ihU#ZjiV0$j)ZOo|MZRiQlcv~@rX$S+oiE&>+PLl8mu$5jDfAJ-;(P23?)7A4 zZcJKrSm>+}i_4)YSb>zm>U{P&;^#15d5??qAa_CUonmlB(aJI5nTkhF+HN%!&5wJ5 zqbt%79b=vwH&t!C&s2qKdbDQT`k6{htAwW2)U>28e~vZUvea~9` z$jjhc@k)l@sYL&zO#F-b)9d}9J(w~HlH`#hp8|(v@$$*BvYe^h9IJm6Jy495<{C(k7&o8-EwEQow#GL-F0VsPP^;GzT3V5q1b1S zB|A4UE0!dD9g!aqGeZ$9MSvBWTO>pAV}&2)T1mx0$dFR{A%h1JbU0Hu!-Bh3!T@Ue ze7?$;^QNpmDe@~@)wcIuS=poIva)q;YyU}Al~t`j&I?)!8~8t<)ggO^A4MpFM5^zVx5C1tICxfe)RsMC*XP+{e)_pz*^BbZ>b%aH&S6@VOPkFXIL(@Kke^F<4Dn~R zUA;)`%e-#t?6WqWMc(w!Y+-BQ&+Y2cRy$|5$?PgW%NHw~U0r8i>%7RD9NVvKAI5o+ ztv3aUu!Ri8mX<@`fNKoj_JPctb}W|FZB^FS&UL_*U8N_Y$iavE&M9K8-W)O?=?JP{*s4sSWD z*xM?uH=`Iu(JTjQ(iT_DJa%-nJ?i!E9 z1RUetw&2o8sa;2IYQ9Z9@_+w(Q{+xF$NN2;JW<3F_;SX2-3fI`N~%S diff --git a/language/stdlib/compiled/stdlib/048_Subsidy.mv b/language/stdlib/compiled/stdlib/048_Subsidy.mv index 50092245ab885dbabc287b69897e4d5a3f1247d3..6458a61a8082237a3b853a4e6e92903deb37fbcd 100644 GIT binary patch delta 320 zcmWm5y-vbV7{>AUJ#S0fbB?s9$cLqI5bzrjCKD3}HF1MWAQ&3bh!CLhV=@lzniH?W zv5A|DlNaC(cn4g7gLU~O|Kxd=)n)a0hWjt`UN2u046M3bLCiIXL2fg{*g^xuHZt&c zAP?RyF!1*NH+B`@WN`y(ZNbs z4nuv1b)RyQh-IK)=m2t4zhRJmVT%>rNtE19=U4qT5+5`AHGE9Fs?^rLY+ ziZ91e|7I|bhl6A~U+7;t*007>+A(KTC`qY&X$j!SnR2D6RQhfU#De~G9V$$NEN|HEnt48Z)LjYz6VW>cVi!KJbCO>dB{gE#I0fAUote^hW}q{m7E0qnz;8rYnV7gx*Kh=ap&^Y3p)`K1j0^XgIfrhV zxO3ym19$;%z!9vQU;fYHS=CqdmjxcYCWC?95E4-}fq-iLXKA}gps+)8c5~PsG7$Sn zz&S*M=(M2(&QXbi)A4A&k5z8D3mV)W)ka~6MbpM^ASl2^nE+h+6udA9IlAbFI;@*} zY4TB1Z{FB*)t^M^ zFq+1b_-YyrZ%5O3JWA)uGV56jT2WH!HE9dr$cZjXOINZFMW>36} pTUE(8o)Bqs&`MHHx!s_fR!acp2f=jB{D?l*OhbO+M)oT``~yyWHYorA diff --git a/language/stdlib/compiled/stdlib/050_Reconfigure.mv b/language/stdlib/compiled/stdlib/050_Reconfigure.mv index 931732c48d3f65f2c7684fdd246b9a113ff03882..f27ad4812d8c05168c670d4d2733afb6300a159c 100644 GIT binary patch delta 110 zcmey)_nmLTC1F7g20jKRO$KHL7A*!Q1{Q4r=8aF^GD(Q1r~&0nvTbwYgT8CvR#DKOJ;(ZYk?mT QcR7?`&_NFjq-0l52mAR9!~g&Q delta 148 zcmWm6!4ZN$429wB0vk*a2;jodfF5nZimZVvCmmX_0WTCq6}&xse=cuw@WG#VEGKdl zQf?`Iip}5k>EeI?`TJE!f~k;s$e{oS0eTogwk3PKs)}n?XN|JeLh2>63vR9jeoWXg ObkM>85lSE>GfyYvpA4)3 diff --git a/language/stdlib/compiled/transaction_scripts/abi/ol_validator_universe_add_self.abi b/language/stdlib/compiled/transaction_scripts/abi/ol_validator_universe_add_self.abi new file mode 100644 index 0000000000000000000000000000000000000000..21dc4d9a868ef75349a21529aa8470719e71e3fc GIT binary patch literal 287 zcmYk1O-ckY5Jsy~opk6#nFs^p&q7xoz%#gXHR#4gh;+sYGzlba-@-%85xj(#@edPPiCc}HobCoPhm=9m`i=kX^FMPlayH|vC8qx zeA($gnkJKZMlf08UtLF`&a999Xi# X2wE9HL$^%3Yg)^V0Y~zJp#b;>NRl@R literal 0 HcmV?d00001 diff --git a/language/stdlib/compiled/transaction_scripts/abi/ol_validator_universe_join.abi b/language/stdlib/compiled/transaction_scripts/abi/ol_validator_universe_join.abi index 546e8b31f6a3de7172bfa83b078a418f7d1f3753..091d315a3d35bb41b0b35eff06f63cb3c8d12a03 100644 GIT binary patch delta 15 Wcmey)^qpygJR|ebXy(aEjG+K7%LMcQ delta 15 Wcmey)^qpygJR>tB1H)t`#!vt!J_FJK diff --git a/language/stdlib/compiled/transaction_scripts/ol_validator_universe_add_self.mv b/language/stdlib/compiled/transaction_scripts/ol_validator_universe_add_self.mv new file mode 100644 index 0000000000000000000000000000000000000000..f6e73dc7dad23e2832ea54e6fd7012855a7aae07 GIT binary patch literal 269 zcmYk%OG*SW5C-6SbkZS-G7$t{3tf2t&*0M4pc@w<(itZ(B#^XypE-h;@G@S)G`g@h z_482_RmYoeg8(2A6st>dcQ!s`b;OPQMBN>MfMHmZKmw9H0FNwy)j)tu(h5YB7CQ-K z`B-bIO+Td^>vj%vl-u;)vwI1LG=;g;=bV;UTRcg5S, @@ -451,7 +452,7 @@ module LibraAccount { &Globals::get_difficulty(), solution ); - assert(valid, Errors::invalid_argument(120102)); + assert(valid, Errors::invalid_argument(120103)); // check there's enough balance for bootstrapping both operator and validator account assert(balance(sender_addr) >= 2 * BOOTSTRAP_COIN_VALUE, Errors::limit_exceeded(EINSUFFICIENT_BALANCE)); @@ -486,6 +487,9 @@ module LibraAccount { op_fullnode_network_addresses ); + // user can join validator universe list, but will only join if the mining is above the threshold in the preceeding period. + ValidatorUniverse::add_self(&new_signer); + make_account(new_signer, auth_key_prefix); make_account(new_op_account, op_auth_key_prefix); diff --git a/language/stdlib/modules/0L/ValidatorUniverse.move b/language/stdlib/modules/0L/ValidatorUniverse.move index 5bc5038e56..5df40a45a1 100644 --- a/language/stdlib/modules/0L/ValidatorUniverse.move +++ b/language/stdlib/modules/0L/ValidatorUniverse.move @@ -14,7 +14,7 @@ address 0x1 { use 0x1::Signer; use 0x1::Testnet; use 0x1::Vector; - + use 0x1::FullnodeState; // resource for tracking the universe of accounts that have submitted a mined proof correctly, with the epoch number. resource struct ValidatorUniverse { validators: vector

@@ -42,8 +42,12 @@ address 0x1 { public fun add_self(sender: &signer) acquires ValidatorUniverse, JailedBit { let addr = Signer::address_of(sender); // Miner can only add self to set if the mining is above a threshold. - assert(MinerState::node_above_thresh(sender, addr), 220102014010); - add(sender); + if (FullnodeState::is_onboarding(addr)) { + add(sender); + } else { + assert(MinerState::node_above_thresh(sender, addr), 220102014010); + add(sender); + } } fun add(sender: &signer) acquires ValidatorUniverse, JailedBit { @@ -117,6 +121,10 @@ address 0x1 { borrow_global_mut(addr).is_jailed = false; } + public fun exists_jailedbit(addr: address): bool { + exists(addr) + } + public fun is_jailed(validator: address): bool acquires JailedBit { if (!exists(validator)) { return false @@ -126,19 +134,13 @@ address 0x1 { public fun genesis_helper(vm: &signer, validator: &signer) acquires ValidatorUniverse, JailedBit { assert(Signer::address_of(vm) == CoreAddresses::LIBRA_ROOT_ADDRESS(), 220101014010); - // let addr = Signer::address_of(sender); - // MinerState::node_above_thresh(sender, addr); add(validator); } //////// TEST //////// - public fun exists_jailedbit(addr: address): bool { - assert(Testnet::is_testnet()== true, 130115014011); - exists(addr) - } public fun test_helper_add_self_onboard(vm: &signer, addr:address) acquires ValidatorUniverse { - assert(Testnet::is_testnet()== true, 130115014011); + assert(Testnet::is_testnet()== true, 220116014011); assert(Signer::address_of(vm) == CoreAddresses::LIBRA_ROOT_ADDRESS(), 220101015010); let state = borrow_global_mut(CoreAddresses::LIBRA_ROOT_ADDRESS()); Vector::push_back
(&mut state.validators, addr); diff --git a/language/stdlib/modules/doc/LibraAccount.md b/language/stdlib/modules/doc/LibraAccount.md index 6a7baaa7a6..2a7c21f0f8 100644 --- a/language/stdlib/modules/doc/LibraAccount.md +++ b/language/stdlib/modules/doc/LibraAccount.md @@ -129,6 +129,7 @@ before and after every transaction. use 0x1::VDF; use 0x1::ValidatorConfig; use 0x1::ValidatorOperatorConfig; +use 0x1::ValidatorUniverse; use 0x1::Vector; @@ -1322,7 +1323,7 @@ Initialize this module. This is only callable from genesis. &Globals::get_difficulty(), solution ); - assert(valid, Errors::invalid_argument(120102)); + assert(valid, Errors::invalid_argument(120103)); // check there's enough balance for bootstrapping both operator and validator account assert(balance<GAS>(sender_addr) >= 2 * BOOTSTRAP_COIN_VALUE, Errors::limit_exceeded(EINSUFFICIENT_BALANCE)); @@ -1357,6 +1358,8 @@ Initialize this module. This is only callable from genesis. op_fullnode_network_addresses ); + ValidatorUniverse::add_self(&new_signer); + make_account(new_signer, auth_key_prefix); make_account(new_op_account, op_auth_key_prefix); diff --git a/language/stdlib/modules/doc/ValidatorUniverse.md b/language/stdlib/modules/doc/ValidatorUniverse.md index 849c9dd54c..f48ee58b00 100644 --- a/language/stdlib/modules/doc/ValidatorUniverse.md +++ b/language/stdlib/modules/doc/ValidatorUniverse.md @@ -17,14 +17,15 @@ - [Function `jail`](#0x1_ValidatorUniverse_jail) - [Function `unjail_self`](#0x1_ValidatorUniverse_unjail_self) - [Function `unjail`](#0x1_ValidatorUniverse_unjail) +- [Function `exists_jailedbit`](#0x1_ValidatorUniverse_exists_jailedbit) - [Function `is_jailed`](#0x1_ValidatorUniverse_is_jailed) - [Function `genesis_helper`](#0x1_ValidatorUniverse_genesis_helper) -- [Function `exists_jailedbit`](#0x1_ValidatorUniverse_exists_jailedbit) - [Function `test_helper_add_self_onboard`](#0x1_ValidatorUniverse_test_helper_add_self_onboard)
use 0x1::CoreAddresses;
 use 0x1::Errors;
+use 0x1::FullnodeState;
 use 0x1::MinerState;
 use 0x1::Signer;
 use 0x1::Testnet;
@@ -134,8 +135,12 @@
 
public fun add_self(sender: &signer) acquires ValidatorUniverse, JailedBit {
   let addr = Signer::address_of(sender);
   // Miner can only add self to set if the mining is above a threshold.
-  assert(MinerState::node_above_thresh(sender, addr), 220102014010);
-  add(sender);
+  if (FullnodeState::is_onboarding(addr)) {
+    add(sender);
+  } else {
+    assert(MinerState::node_above_thresh(sender, addr), 220102014010);
+    add(sender);
+  }
 }
 
@@ -368,13 +373,13 @@ - + -## Function `is_jailed` +## Function `exists_jailedbit` -
public fun is_jailed(validator: address): bool
+
public fun exists_jailedbit(addr: address): bool
 
@@ -383,11 +388,8 @@ Implementation -
public fun is_jailed(validator: address): bool acquires JailedBit {
-  if (!exists<JailedBit>(validator)) {
-    return false
-  };
-  borrow_global<JailedBit>(validator).is_jailed
+
public fun exists_jailedbit(addr: address): bool {
+  exists<JailedBit>(addr)
 }
 
@@ -395,13 +397,13 @@ - + -## Function `genesis_helper` +## Function `is_jailed` -
public fun genesis_helper(vm: &signer, validator: &signer)
+
public fun is_jailed(validator: address): bool
 
@@ -410,11 +412,11 @@ Implementation -
public fun genesis_helper(vm: &signer, validator: &signer) acquires ValidatorUniverse, JailedBit {
-  assert(Signer::address_of(vm) == CoreAddresses::LIBRA_ROOT_ADDRESS(), 220101014010);
-  // let addr = Signer::address_of(sender);
-  // MinerState::node_above_thresh(sender, addr);
-  add(validator);
+
public fun is_jailed(validator: address): bool acquires JailedBit {
+  if (!exists<JailedBit>(validator)) {
+    return false
+  };
+  borrow_global<JailedBit>(validator).is_jailed
 }
 
@@ -422,13 +424,13 @@ - + -## Function `exists_jailedbit` +## Function `genesis_helper` -
public fun exists_jailedbit(addr: address): bool
+
public fun genesis_helper(vm: &signer, validator: &signer)
 
@@ -437,9 +439,9 @@ Implementation -
public fun exists_jailedbit(addr: address): bool {
-  assert(Testnet::is_testnet()== true, 130115014011);
-  exists<JailedBit>(addr)
+
public fun genesis_helper(vm: &signer, validator: &signer) acquires ValidatorUniverse, JailedBit {
+  assert(Signer::address_of(vm) == CoreAddresses::LIBRA_ROOT_ADDRESS(), 220101014010);
+  add(validator);
 }
 
@@ -463,7 +465,7 @@
public fun test_helper_add_self_onboard(vm: &signer, addr:address) acquires ValidatorUniverse {
-  assert(Testnet::is_testnet()== true, 130115014011);
+  assert(Testnet::is_testnet()== true, 220116014011);
   assert(Signer::address_of(vm) == CoreAddresses::LIBRA_ROOT_ADDRESS(), 220101015010);
   let state = borrow_global_mut<ValidatorUniverse>(CoreAddresses::LIBRA_ROOT_ADDRESS());
   Vector::push_back<address>(&mut state.validators, addr);
diff --git a/language/stdlib/transaction_scripts/doc/ol_validator_universe_add_self.md b/language/stdlib/transaction_scripts/doc/ol_validator_universe_add_self.md
new file mode 100644
index 0000000000..2fc87cce67
--- /dev/null
+++ b/language/stdlib/transaction_scripts/doc/ol_validator_universe_add_self.md
@@ -0,0 +1,62 @@
+
+
+
+# Script `val_add_self`
+
+
+
+-  [Constants](#@Constants_0)
+
+
+
use 0x1::Errors;
+use 0x1::MinerState;
+use 0x1::Signer;
+use 0x1::ValidatorUniverse;
+
+ + + + + +## Constants + + + + + + +
const NOT_ABOVE_THRESH: u64 = 220102;
+
+ + + + +
public fun val_add_self(validator: &signer)
+
+ + + +
+Implementation + + +
fun val_add_self(validator: &signer) {
+    let addr = Signer::address_of(validator);
+    // if is above threshold continue, or raise error.
+    assert(MinerState::node_above_thresh(validator, addr), Errors::invalid_state(NOT_ABOVE_THRESH));
+    // if is not in universe, add back
+    if (!ValidatorUniverse::is_in_universe(addr)) {
+        ValidatorUniverse::add_self(validator);
+    };
+}
+
+ + + +
+ + +[//]: # ("File containing references which can be used from documentation") +[ACCESS_CONTROL]: https://github.com/libra/lip/blob/master/lips/lip-2.md +[ROLE]: https://github.com/libra/lip/blob/master/lips/lip-2.md#roles +[PERMISSION]: https://github.com/libra/lip/blob/master/lips/lip-2.md#permissions diff --git a/language/stdlib/transaction_scripts/doc/ol_validator_universe_join.md b/language/stdlib/transaction_scripts/doc/ol_validator_universe_join.md index 2cbd1c3c95..cbc6310ac5 100644 --- a/language/stdlib/transaction_scripts/doc/ol_validator_universe_join.md +++ b/language/stdlib/transaction_scripts/doc/ol_validator_universe_join.md @@ -25,7 +25,7 @@ -
const NOT_ABOVE_THRESH: u64 = 1;
+
const NOT_ABOVE_THRESH: u64 = 220101;
 
diff --git a/language/stdlib/transaction_scripts/doc/transaction_script_documentation.md b/language/stdlib/transaction_scripts/doc/transaction_script_documentation.md index 0c0b3cea57..57bce6b987 100644 --- a/language/stdlib/transaction_scripts/doc/transaction_script_documentation.md +++ b/language/stdlib/transaction_scripts/doc/transaction_script_documentation.md @@ -5157,6 +5157,7 @@ with this hash can be successfully sent to the network. - [`update_exchange_rate`](transaction_script_documentation.md#update_exchange_rate) - [`update_libra_version`](transaction_script_documentation.md#update_libra_version) - [`update_minting_ability`](transaction_script_documentation.md#update_minting_ability) +- [`val_add_self`](ol_validator_universe_add_self.md#val_add_self) [//]: # ("File containing references which can be used from documentation") diff --git a/language/stdlib/transaction_scripts/ol_validator_universe_add_self.move b/language/stdlib/transaction_scripts/ol_validator_universe_add_self.move new file mode 100644 index 0000000000..f0e9dda4ea --- /dev/null +++ b/language/stdlib/transaction_scripts/ol_validator_universe_add_self.move @@ -0,0 +1,17 @@ +script { + use 0x1::ValidatorUniverse; + use 0x1::Signer; + use 0x1::MinerState; + use 0x1::Errors; + const NOT_ABOVE_THRESH: u64 = 220102; + + fun val_add_self(validator: &signer) { + let addr = Signer::address_of(validator); + // if is above threshold continue, or raise error. + assert(MinerState::node_above_thresh(validator, addr), Errors::invalid_state(NOT_ABOVE_THRESH)); + // if is not in universe, add back + if (!ValidatorUniverse::is_in_universe(addr)) { + ValidatorUniverse::add_self(validator); + }; + } +} diff --git a/language/stdlib/transaction_scripts/ol_validator_universe_join.move b/language/stdlib/transaction_scripts/ol_validator_universe_join.move index e9f8be0455..d73c3fe10c 100644 --- a/language/stdlib/transaction_scripts/ol_validator_universe_join.move +++ b/language/stdlib/transaction_scripts/ol_validator_universe_join.move @@ -3,7 +3,7 @@ script { use 0x1::Signer; use 0x1::MinerState; use 0x1::Errors; - const NOT_ABOVE_THRESH: u64 = 01; + const NOT_ABOVE_THRESH: u64 = 220101; fun join(validator: &signer) { let addr = Signer::address_of(validator); diff --git a/language/tools/vm-genesis/src/lib.rs b/language/tools/vm-genesis/src/lib.rs index 67b540bb5b..f98983fb4e 100644 --- a/language/tools/vm-genesis/src/lib.rs +++ b/language/tools/vm-genesis/src/lib.rs @@ -806,6 +806,7 @@ fn initialize_testnet( if get_env() == "stage" { module_name = "StagingNet"; }; + exec_function( session, log_context, diff --git a/ol/miner/src/entrypoint.rs b/ol/miner/src/entrypoint.rs index 7426fef28b..5244a20e39 100644 --- a/ol/miner/src/entrypoint.rs +++ b/ol/miner/src/entrypoint.rs @@ -165,6 +165,8 @@ pub fn get_args() -> EntryPointTxsCmd { /// usually something like "/root/.0L" /// in case of swarm like "....../swarm_temp/0" for alice /// in case of swarm like "....../swarm_temp/1" for bob + +// TODO: This function is duplicated in other entrypoint.rs files. pub fn get_node_home() -> PathBuf { let mut config_path = dirs::home_dir().unwrap(); config_path.push(NODE_HOME); @@ -174,7 +176,7 @@ pub fn get_node_home() -> PathBuf { config_path = PathBuf::from(entry_args.swarm_path.unwrap()); if entry_args.swarm_persona.is_some() { let persona = &entry_args.swarm_persona.unwrap(); - let all_personas = vec!["alice", "bob", "carol", "dave"]; + let all_personas = vec!["alice", "bob", "carol", "dave", "eve"]; let index = all_personas.iter().position(|&r| r == persona).unwrap(); config_path.push(index.to_string()); } else { diff --git a/ol/txs/src/commands/valset_cmd.rs b/ol/txs/src/commands/valset_cmd.rs index 4d35cfb2aa..36137c8f4c 100644 --- a/ol/txs/src/commands/valset_cmd.rs +++ b/ol/txs/src/commands/valset_cmd.rs @@ -18,8 +18,8 @@ pub struct ValSetCmd { help = "remove node from validator universe, i.e. cease being a candidate for validator set" )] leave: bool, - // #[options(help = "unjail the node, add to list, and remove jailed designation")] - // unjail: bool, + #[options(help = "add to val universe")] + add: bool, } impl Runnable for ValSetCmd { @@ -31,7 +31,9 @@ impl Runnable for ValSetCmd { transaction_builder::encode_join_script() } else if *&self.leave { transaction_builder::encode_leave_script() - } else { + } else if *&self.add { + transaction_builder::encode_val_add_self_script() + }else { panic!("need to set --join or --leave flags") }; diff --git a/ol/txs/src/entrypoint.rs b/ol/txs/src/entrypoint.rs index 4aecb37cd2..c83d7ba2c4 100644 --- a/ol/txs/src/entrypoint.rs +++ b/ol/txs/src/entrypoint.rs @@ -180,7 +180,7 @@ pub fn get_node_home() -> PathBuf { config_path = PathBuf::from(entry_args.swarm_path.unwrap()); if entry_args.swarm_persona.is_some() { let persona = &entry_args.swarm_persona.unwrap(); - let all_personas = vec!["alice", "bob", "carol", "dave"]; + let all_personas = vec!["alice", "bob", "carol", "dave", "eve"]; let index = all_personas.iter().position(|&r| r == persona).unwrap(); config_path.push(index.to_string()); } else { diff --git a/ol/util/install.sh b/ol/util/install.sh index fda99549de..c26a1b1dc6 100644 --- a/ol/util/install.sh +++ b/ol/util/install.sh @@ -1,4 +1,3 @@ -apt install -y unzip zip jq DOWNLOAD_URLS=$(curl -sL https://api.github.com/repos/OLSF/libra/releases/latest | jq -r '.assets[].browser_download_url') for b in $DOWNLOAD_URLS ; do \ @@ -10,5 +9,5 @@ for b in $DOWNLOAD_URLS ; do \ done mkdir -p ~/.0L/web-monitor -mv /usr/local/bin/web-monitor.zip ~/.0L/web-monitor.zip -unzip ~/.0L/web-monitor.zip -d ~/.0L/web-monitor/ +mv /usr/local/bin/web-monitor.tar.gz ~/.0L/web-monitor.zip +tar -xf ~/.0L/web-monitor.tar.gz -d ~/.0L/web-monitor/ diff --git a/ol/util/test-mining.mk b/ol/util/test-mining.mk new file mode 100644 index 0000000000..789d54ed12 --- /dev/null +++ b/ol/util/test-mining.mk @@ -0,0 +1,13 @@ + +init: + cd ~/libra && cargo r -p ol -- --swarm-path ~/swarm_temp --swarm-persona alice init + +mine: + cd ~/libra && cargo r -p miner -- --swarm-path ~/swarm_temp --swarm-persona alice start + +create-stage: + cd ~/libra && cargo r -p txs -- --swarm-path ~/swarm_temp --swarm-persona alice create-validator -f ol/fixtures/account/stage.eve.account.json + +create: + cd ~/libra && cargo r -p txs -- --swarm-path ~/swarm_temp --swarm-persona alice create-validator -f ol/fixtures/account/eve.account.json +