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 b56c7a9774..e14f033d41 100644 Binary files a/language/stdlib/compiled/stdlib/025_Libra.mv and b/language/stdlib/compiled/stdlib/025_Libra.mv differ 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 fad70ccd71..dcf78e1f80 100644 Binary files a/language/stdlib/compiled/stdlib/032_Globals.mv and b/language/stdlib/compiled/stdlib/027_Globals.mv differ 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 0000000000..aa2bf06413 Binary files /dev/null and b/language/stdlib/compiled/stdlib/030_ValidatorUniverse.mv differ diff --git a/language/stdlib/compiled/stdlib/021_VASP.mv b/language/stdlib/compiled/stdlib/031_VASP.mv similarity index 100% rename from language/stdlib/compiled/stdlib/021_VASP.mv rename to language/stdlib/compiled/stdlib/031_VASP.mv diff --git a/language/stdlib/compiled/stdlib/022_TrustedAccounts.mv b/language/stdlib/compiled/stdlib/032_TrustedAccounts.mv similarity index 100% rename from language/stdlib/compiled/stdlib/022_TrustedAccounts.mv rename to language/stdlib/compiled/stdlib/032_TrustedAccounts.mv diff --git a/language/stdlib/compiled/stdlib/026_LBR.mv b/language/stdlib/compiled/stdlib/033_LBR.mv similarity index 100% rename from language/stdlib/compiled/stdlib/026_LBR.mv rename to language/stdlib/compiled/stdlib/033_LBR.mv diff --git a/language/stdlib/compiled/stdlib/028_TransactionFee.mv b/language/stdlib/compiled/stdlib/034_TransactionFee.mv similarity index 100% rename from language/stdlib/compiled/stdlib/028_TransactionFee.mv rename to language/stdlib/compiled/stdlib/034_TransactionFee.mv diff --git a/language/stdlib/compiled/stdlib/029_SlidingNonce.mv b/language/stdlib/compiled/stdlib/035_SlidingNonce.mv similarity index 100% rename from language/stdlib/compiled/stdlib/029_SlidingNonce.mv rename to language/stdlib/compiled/stdlib/035_SlidingNonce.mv diff --git a/language/stdlib/compiled/stdlib/035_LibraTransactionPublishingOption.mv b/language/stdlib/compiled/stdlib/036_LibraTransactionPublishingOption.mv similarity index 100% rename from language/stdlib/compiled/stdlib/035_LibraTransactionPublishingOption.mv rename to language/stdlib/compiled/stdlib/036_LibraTransactionPublishingOption.mv diff --git a/language/stdlib/compiled/stdlib/036_FIFO.mv b/language/stdlib/compiled/stdlib/037_FIFO.mv similarity index 100% rename from language/stdlib/compiled/stdlib/036_FIFO.mv rename to language/stdlib/compiled/stdlib/037_FIFO.mv diff --git a/language/stdlib/compiled/stdlib/037_DualAttestation.mv b/language/stdlib/compiled/stdlib/038_DualAttestation.mv similarity index 88% rename from language/stdlib/compiled/stdlib/037_DualAttestation.mv rename to language/stdlib/compiled/stdlib/038_DualAttestation.mv index 13ee6769f9..518171efd5 100644 Binary files a/language/stdlib/compiled/stdlib/037_DualAttestation.mv and b/language/stdlib/compiled/stdlib/038_DualAttestation.mv differ diff --git a/language/stdlib/compiled/stdlib/038_DesignatedDealer.mv b/language/stdlib/compiled/stdlib/039_DesignatedDealer.mv similarity index 100% rename from language/stdlib/compiled/stdlib/038_DesignatedDealer.mv rename to language/stdlib/compiled/stdlib/039_DesignatedDealer.mv diff --git a/language/stdlib/compiled/stdlib/039_Coin1.mv b/language/stdlib/compiled/stdlib/040_Coin1.mv similarity index 100% rename from language/stdlib/compiled/stdlib/039_Coin1.mv rename to language/stdlib/compiled/stdlib/040_Coin1.mv diff --git a/language/stdlib/compiled/stdlib/040_ChainId.mv b/language/stdlib/compiled/stdlib/041_ChainId.mv similarity index 100% rename from language/stdlib/compiled/stdlib/040_ChainId.mv rename to language/stdlib/compiled/stdlib/041_ChainId.mv diff --git a/language/stdlib/compiled/stdlib/041_LibraAccount.mv b/language/stdlib/compiled/stdlib/042_LibraAccount.mv similarity index 51% rename from language/stdlib/compiled/stdlib/041_LibraAccount.mv rename to language/stdlib/compiled/stdlib/042_LibraAccount.mv index eda938f26e..ca00c510c1 100644 Binary files a/language/stdlib/compiled/stdlib/041_LibraAccount.mv and b/language/stdlib/compiled/stdlib/042_LibraAccount.mv differ diff --git a/language/stdlib/compiled/stdlib/042_AutoPay2.mv b/language/stdlib/compiled/stdlib/043_AutoPay2.mv similarity index 100% rename from language/stdlib/compiled/stdlib/042_AutoPay2.mv rename to language/stdlib/compiled/stdlib/043_AutoPay2.mv diff --git a/language/stdlib/compiled/stdlib/043_Cases.mv b/language/stdlib/compiled/stdlib/044_Cases.mv similarity index 100% rename from language/stdlib/compiled/stdlib/043_Cases.mv rename to language/stdlib/compiled/stdlib/044_Cases.mv diff --git a/language/stdlib/compiled/stdlib/044_Epoch.mv b/language/stdlib/compiled/stdlib/045_Epoch.mv similarity index 100% rename from language/stdlib/compiled/stdlib/044_Epoch.mv rename to language/stdlib/compiled/stdlib/045_Epoch.mv diff --git a/language/stdlib/compiled/stdlib/045_ValidatorUniverse.mv b/language/stdlib/compiled/stdlib/045_ValidatorUniverse.mv deleted file mode 100644 index 19b9fce2d8..0000000000 Binary files a/language/stdlib/compiled/stdlib/045_ValidatorUniverse.mv and /dev/null differ diff --git a/language/stdlib/compiled/stdlib/048_Subsidy.mv b/language/stdlib/compiled/stdlib/048_Subsidy.mv index 50092245ab..6458a61a80 100644 Binary files a/language/stdlib/compiled/stdlib/048_Subsidy.mv and b/language/stdlib/compiled/stdlib/048_Subsidy.mv differ diff --git a/language/stdlib/compiled/stdlib/050_Reconfigure.mv b/language/stdlib/compiled/stdlib/050_Reconfigure.mv index 931732c48d..f27ad4812d 100644 Binary files a/language/stdlib/compiled/stdlib/050_Reconfigure.mv and b/language/stdlib/compiled/stdlib/050_Reconfigure.mv differ diff --git a/language/stdlib/compiled/stdlib/055_Genesis.mv b/language/stdlib/compiled/stdlib/055_Genesis.mv index 84ed73de73..5d757b1e9e 100644 Binary files a/language/stdlib/compiled/stdlib/055_Genesis.mv and b/language/stdlib/compiled/stdlib/055_Genesis.mv differ 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 0000000000..21dc4d9a86 Binary files /dev/null and b/language/stdlib/compiled/transaction_scripts/abi/ol_validator_universe_add_self.abi differ 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 546e8b31f6..091d315a3d 100644 Binary files a/language/stdlib/compiled/transaction_scripts/abi/ol_validator_universe_join.abi and b/language/stdlib/compiled/transaction_scripts/abi/ol_validator_universe_join.abi differ 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 0000000000..f6e73dc7da Binary files /dev/null and b/language/stdlib/compiled/transaction_scripts/ol_validator_universe_add_self.mv differ diff --git a/language/stdlib/compiled/transaction_scripts/ol_validator_universe_join.mv b/language/stdlib/compiled/transaction_scripts/ol_validator_universe_join.mv index 41d4fb4f09..582e756a8e 100644 Binary files a/language/stdlib/compiled/transaction_scripts/ol_validator_universe_join.mv and b/language/stdlib/compiled/transaction_scripts/ol_validator_universe_join.mv differ diff --git a/language/stdlib/modules/0L/LibraAccount.move b/language/stdlib/modules/0L/LibraAccount.move index 486da19573..c5ee2a3895 100644 --- a/language/stdlib/modules/0L/LibraAccount.move +++ b/language/stdlib/modules/0L/LibraAccount.move @@ -40,6 +40,7 @@ module LibraAccount { use 0x1::Testnet::is_testnet; use 0x1::FIFO; use 0x1::FixedPoint32; + use 0x1::ValidatorUniverse; /// An `address` is a Libra Account if it has a published LibraAccount resource. resource struct LibraAccount { @@ -400,7 +401,7 @@ module LibraAccount { // This function has no permissions, it doesn't check the signer. And it exceptionally is moving a resource to a different account than the signer. // LibraAccount is the only code in the VM which can place a resource in an account. As such the module and especially this function has an attack surface. - /////// 0L //////// + /////// 0L //////// //Function code: 01 public fun create_user_account_with_proof( challenge: &vector, @@ -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 +