From 7a5628bd43cfd3a4aa3d647ecb049f7629937daf Mon Sep 17 00:00:00 2001 From: 0o-de-lally <1364012+0o-de-lally@users.noreply.github.com> Date: Thu, 11 Aug 2022 21:49:07 -0400 Subject: [PATCH] Release 5.2.0 (#1154) * tower integration test should span many blocks and across epochs * patch makefile for teestnet * implement a deserializer for namedchain * update fixtures * increase state sync tick interval to prevent timeouts * separate stdlib from genesis in makefile recipe * change set layout * testnet genesis to have 4 nodes [skip-ci] * namedchain parsing * use the correct historical/baseline proof difficulty * patch tower baseline difficulty in Move code * Move bug in checking first proof in epoch * add dave prod mode proof * ... and stages * patch TowerState bug with non-test envs for checking proof submission * refector towerstate difficulty checking so that it applies to operator sent proofs. * patch bug where the epoch boundary failover should start from longest list of validators (validator universe) * add proof zero for eve --- Makefile | 8 +- config/src/config/state_sync_config.rs | 2 +- .../modules/0L/EpochBoundary.move | 4 +- .../diem-framework/modules/0L/TowerState.move | 80 +++++++++++-------- ol/devnet/set_layout_test.toml | 4 +- ol/fixtures/configs/alice.toml | 2 +- ol/fixtures/configs/bob.toml | 2 +- ol/fixtures/configs/carol.toml | 2 +- ol/fixtures/configs/dave.toml | 2 +- ol/fixtures/configs/eve.toml | 2 +- ol/fixtures/vdf_proofs/prod/dave/proof_0.json | 1 + ol/fixtures/vdf_proofs/prod/eve/proof_0.json | 1 + .../vdf_proofs/stage/alice/proof_1.json | 8 ++ .../vdf_proofs/stage/dave/proof_0.json | 1 + ol/fixtures/vdf_proofs/stage/eve/proof_0.json | 1 + ol/integration-tests/test-mining.mk | 3 +- ol/tower/src/next_proof.rs | 40 ++++------ types/src/chain_id.rs | 18 ++++- types/src/ol_vdf_difficulty.rs | 6 +- 19 files changed, 109 insertions(+), 78 deletions(-) create mode 100644 ol/fixtures/vdf_proofs/prod/dave/proof_0.json create mode 100644 ol/fixtures/vdf_proofs/prod/eve/proof_0.json create mode 100644 ol/fixtures/vdf_proofs/stage/alice/proof_1.json create mode 100644 ol/fixtures/vdf_proofs/stage/dave/proof_0.json create mode 100644 ol/fixtures/vdf_proofs/stage/eve/proof_0.json diff --git a/Makefile b/Makefile index cd3a52311f..207d7283a7 100644 --- a/Makefile +++ b/Makefile @@ -291,7 +291,7 @@ verify-gen: --validator-backend ${LOCAL} \ --genesis-path ${DATA_PATH}/genesis.blob -genesis: stdlib +genesis: cargo run -p diem-genesis-tool ${CARGO_ARGS} -- files \ --chain-id ${CHAIN_ID} \ --validator-backend ${LOCAL} \ @@ -470,7 +470,7 @@ debug: testnet-init: clear fix # REQUIRES there is a genesis.blob in the fixtures/genesis/ you are testing - MNEM='${MNEM}' cargo run -p onboard -- val --skip-mining --chain-id 1 --genesis-ceremony + MNEM='${MNEM}' cargo run -p onboard -- val --skip-mining --chain-id ${CHAIN_ID} --genesis-ceremony # Do the genesis ceremony registration, this includes the step testnet-validator-init-wizard testnet-register: testnet-init gen-register @@ -498,8 +498,8 @@ testnet-genesis: genesis set-waypoint testnet: clear fix testnet-init testnet-genesis start # For subsequent validators joining the testnet. This will fetch the genesis information saved -testnet-onboard: clear fix - MNEM='${MNEM}' cargo run -p onboard -- val --github-org OLSF --repo dev-genesis --chain-id 1 +testnet-onboard: clear + MNEM='${MNEM}' cargo run -p onboard -- val --github-org OLSF --repo dev-genesis --chain-id ${CHAIN_ID} # start a node with fullnode.node.yaml configs cargo r -p diem-node -- -f ~/.0L/fullnode.node.yaml diff --git a/config/src/config/state_sync_config.rs b/config/src/config/state_sync_config.rs index 8026297907..643bea97a6 100644 --- a/config/src/config/state_sync_config.rs +++ b/config/src/config/state_sync_config.rs @@ -45,7 +45,7 @@ impl Default for StateSyncConfig { mempool_commit_timeout_ms: 5_000, multicast_timeout_ms: 30_000, sync_request_timeout_ms: 60_000, //////// 0L ///////// - tick_interval_ms: 500, //////// 0L //////// + tick_interval_ms: 3000, //////// 0L //////// } } } diff --git a/language/diem-framework/modules/0L/EpochBoundary.move b/language/diem-framework/modules/0L/EpochBoundary.move index dced3b6b4b..a8001011ff 100644 --- a/language/diem-framework/modules/0L/EpochBoundary.move +++ b/language/diem-framework/modules/0L/EpochBoundary.move @@ -192,7 +192,7 @@ module EpochBoundary { // can't be more than index of accounts i < Vector::length(&top_accounts) && // the new proposed set can only only expand by 15% - Vector::length(&proposed_set) < len_proven_nodes + max_unproven_nodes && + Vector::length(&proposed_set) < (len_proven_nodes + max_unproven_nodes) && // Validator set can only be as big as the maximum set size Vector::length(&proposed_set) < Globals::get_max_validators_per_set() ) { @@ -228,7 +228,7 @@ module EpochBoundary { // if we are failing to qualify anyone. Pick top 1/2 of validator set by proposals. They are probably online. - if (Vector::length
(&proposed_set) <= 3) proposed_set = Stats::get_sorted_vals_by_props(vm, Vector::length
(&proposed_set) / 2); + if (Vector::length
(&proposed_set) <= 3) proposed_set = Stats::get_sorted_vals_by_props(vm, Vector::length
(&top_accounts) / 2); // If still failing...in extreme case if we cannot qualify anyone. Don't change the validator set. diff --git a/language/diem-framework/modules/0L/TowerState.move b/language/diem-framework/modules/0L/TowerState.move index b2b2fc80fb..8a4be4b7c9 100644 --- a/language/diem-framework/modules/0L/TowerState.move +++ b/language/diem-framework/modules/0L/TowerState.move @@ -112,9 +112,9 @@ module TowerState { }); } else { move_to(vm, VDFDifficulty { - difficulty: 5000000, + difficulty: 120000000, security: 512, - prev_diff: 5000000, + prev_diff: 120000000, prev_sec: 512, }); } @@ -234,7 +234,7 @@ module TowerState { ) acquires TowerProofHistory, TowerList, TowerCounter, VDFDifficulty { // Get address, assumes the sender is the signer. let miner_addr = Signer::address_of(miner_sign); - let diff = borrow_global_mut(CoreAddresses::VM_RESERVED_ADDRESS()); + // let diff = borrow_global(CoreAddresses::VM_RESERVED_ADDRESS()); // This may be the 0th proof of an end user that hasn't had tower state initialized if (!is_init(miner_addr)) { @@ -250,27 +250,28 @@ module TowerState { return }; + check_difficulty(miner_addr, &proof); - // Skip this check on local tests, we need tests to send different difficulties. - if (!Testnet::is_testnet()){ - // Get vdf difficulty constant. Will be different in tests than in production. + // // Skip this check on local tests, we need tests to send different difficulties. + // if (!Testnet::is_testnet()){ + // // Get vdf difficulty constant. Will be different in tests than in production. - // need to also give allowance for user's first proof in epoch to be in the last proof. - if (get_count_in_epoch(miner_addr) == 0) { - // first proof in this epoch, can be either the previous difficulty or the current one - let is_diff = &proof.difficulty == &diff.difficulty || - &proof.difficulty == &diff.prev_diff; - - let is_sec = &proof.difficulty == &diff.security || - &proof.difficulty == &diff.prev_sec; - - assert(is_diff, Errors::invalid_argument(130102)); - assert(is_sec, Errors::invalid_argument(13010202)); - } else { - assert(&proof.difficulty == &diff.difficulty, Errors::invalid_argument(130102)); - assert(&proof.security == &diff.security, Errors::invalid_argument(13010202)); - }; - }; + // // need to also give allowance for user's first proof in epoch to be in the last proof. + // if (get_count_in_epoch(miner_addr) == 0) { + // // first proof in this epoch, can be either the previous difficulty or the current one + // let is_diff = &proof.difficulty == &diff.difficulty || + // &proof.difficulty == &diff.prev_diff; + + // let is_sec = &proof.security == &diff.security || + // &proof.security == &diff.prev_sec; + + // assert(is_diff, Errors::invalid_argument(130102)); + // assert(is_sec, Errors::invalid_argument(13010202)); + // } else { + // assert(&proof.difficulty == &diff.difficulty, Errors::invalid_argument(130102)); + // assert(&proof.security == &diff.security, Errors::invalid_argument(13010202)); + // }; + // }; // Process the proof verify_and_update_state(miner_addr, proof, true); } @@ -283,7 +284,7 @@ module TowerState { operator_sig: &signer, miner_addr: address, proof: Proof - ) acquires TowerProofHistory, TowerList, TowerCounter { + ) acquires TowerProofHistory, TowerList, TowerCounter, VDFDifficulty { // Check the signer is in fact an operator delegated by the owner. @@ -295,21 +296,36 @@ module TowerState { // Return early if difficulty and security are not correct. // Check vdf difficulty constant. Will be different in tests than in production. // Skip this check on local tests, we need tests to send differentdifficulties. - if (!Testnet::is_testnet()){ - assert(&proof.difficulty == &Globals::get_vdf_difficulty_baseline(), Errors::invalid_argument(130105)); - assert(&proof.security == &Globals::get_vdf_difficulty_baseline(), Errors::invalid_state(130106)); - }; + check_difficulty(miner_addr, &proof); // Process the proof verify_and_update_state(miner_addr, proof, true); - // TODO: The operator mining needs its own struct to count mining. - // For now it is implicit there is only 1 operator per validator, - // and that the fullnode state is the place to count. - // This will require a breaking change to TowerState - // FullnodeState::inc_proof_by_operator(operator_sig, miner_addr); } + fun check_difficulty(miner_addr: address, proof: &Proof) acquires TowerProofHistory, VDFDifficulty { + if (!Testnet::is_testnet()){ + // Get vdf difficulty constant. Will be different in tests than in production.ex + let diff = borrow_global(CoreAddresses::VM_RESERVED_ADDRESS()); + + // need to also give allowance for user's first proof in epoch to be in the last proof. + if (get_count_in_epoch(miner_addr) == 0) { + // first proof in this epoch, can be either the previous difficulty or the current one + let is_diff = &proof.difficulty == &diff.difficulty || + &proof.difficulty == &diff.prev_diff; + + let is_sec = &proof.security == &diff.security || + &proof.security == &diff.prev_sec; + + assert(is_diff, Errors::invalid_argument(130102)); + assert(is_sec, Errors::invalid_argument(13010202)); + } else { + assert(&proof.difficulty == &diff.difficulty, Errors::invalid_argument(130102)); + assert(&proof.security == &diff.security, Errors::invalid_argument(13010202)); + }; + }; + + } // Function to verify a proof blob and update a TowerProofHistory // Permissions: private function. // Function index: 03 diff --git a/ol/devnet/set_layout_test.toml b/ol/devnet/set_layout_test.toml index 011b7a367f..3b90906a98 100644 --- a/ol/devnet/set_layout_test.toml +++ b/ol/devnet/set_layout_test.toml @@ -3,12 +3,12 @@ owners = [ "88e74dfed34420f2ad8032148280a84b", "e660402d586ad220ed9beff47d662d54", "9e6bb3a75e9618fba057e86e69338c94", - "3dc18d1cf61faac6ac70e3a63f062e4b" + # "3dc18d1cf61faac6ac70e3a63f062e4b" ] operators = [ "4c613c2f4b1e67ca8d98a542ee3f59f5-oper", "88e74dfed34420f2ad8032148280a84b-oper", "e660402d586ad220ed9beff47d662d54-oper", "9e6bb3a75e9618fba057e86e69338c94-oper", - "3dc18d1cf61faac6ac70e3a63f062e4b-oper" + # "3dc18d1cf61faac6ac70e3a63f062e4b-oper" ] diff --git a/ol/fixtures/configs/alice.toml b/ol/fixtures/configs/alice.toml index 74cd5c2f08..1f72d7755a 100644 --- a/ol/fixtures/configs/alice.toml +++ b/ol/fixtures/configs/alice.toml @@ -15,7 +15,7 @@ default_node = "http://localhost:8080/" upstream_nodes = ["http://localhost:8080/"] [chain_info] -chain_id = "experimental" +chain_id = "TESTING" base_epoch = 0 base_waypoint = "0:683185844ef67e5c8eeaa158e635de2a4c574ce7bbb7f41f787d38db2d623ae2" [tx_configs.management_txs] diff --git a/ol/fixtures/configs/bob.toml b/ol/fixtures/configs/bob.toml index 238ae69bfd..33f200b60d 100644 --- a/ol/fixtures/configs/bob.toml +++ b/ol/fixtures/configs/bob.toml @@ -15,7 +15,7 @@ default_node = "http://localhost:8080/" upstream_nodes = ["http://localhost:8080/"] [chain_info] -chain_id = "experimental" +chain_id = "TESTING" base_epoch = 0 base_waypoint = "0:683185844ef67e5c8eeaa158e635de2a4c574ce7bbb7f41f787d38db2d623ae2" [tx_configs.management_txs] diff --git a/ol/fixtures/configs/carol.toml b/ol/fixtures/configs/carol.toml index 70aaf9d8da..42aceeaf88 100644 --- a/ol/fixtures/configs/carol.toml +++ b/ol/fixtures/configs/carol.toml @@ -14,7 +14,7 @@ default_node = "http://localhost:8080/" upstream_nodes = ["http://localhost:8080/"] [chain_info] -chain_id = "experimental" +chain_id = "TESTING" base_epoch = 0 base_waypoint = "0:683185844ef67e5c8eeaa158e635de2a4c574ce7bbb7f41f787d38db2d623ae2" [tx_configs.management_txs] diff --git a/ol/fixtures/configs/dave.toml b/ol/fixtures/configs/dave.toml index 65d925ff06..0022f64256 100644 --- a/ol/fixtures/configs/dave.toml +++ b/ol/fixtures/configs/dave.toml @@ -14,7 +14,7 @@ default_node = "http://localhost:8080/" upstream_nodes = ["http://localhost:8080/"] [chain_info] -chain_id = "experimental" +chain_id = "TESTING" base_epoch = 0 base_waypoint = "0:683185844ef67e5c8eeaa158e635de2a4c574ce7bbb7f41f787d38db2d623ae2" [tx_configs.management_txs] diff --git a/ol/fixtures/configs/eve.toml b/ol/fixtures/configs/eve.toml index 88d49232d6..b58570795e 100644 --- a/ol/fixtures/configs/eve.toml +++ b/ol/fixtures/configs/eve.toml @@ -14,7 +14,7 @@ default_node = "http://localhost:8080/" upstream_nodes = ["http://localhost:8080/"] [chain_info] -chain_id = "experimental" +chain_id = "TESTING" base_epoch = 0 base_waypoint = "0:683185844ef67e5c8eeaa158e635de2a4c574ce7bbb7f41f787d38db2d623ae2" diff --git a/ol/fixtures/vdf_proofs/prod/dave/proof_0.json b/ol/fixtures/vdf_proofs/prod/dave/proof_0.json new file mode 100644 index 0000000000..3a99af45a4 --- /dev/null +++ b/ol/fixtures/vdf_proofs/prod/dave/proof_0.json @@ -0,0 +1 @@ +{"height":0,"elapsed_secs":2097,"preimage":"9a6e2193488991b62dd28b47d60dd03b9e6bb3a75e9618fba057e86e69338c940000000000000000004d41494e4e4554000e2707000000000002000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074657374","proof":"0037d38818ef23d87ea047276f56db5161956c17ad896ee1620d060067e9358da8002a7390bc73b6df51e9bc2f88efe22c85b0dcfa13c506f514beabf637928dabd300302ed4899cbcacdd634fc3f74ec9968972efb56ba5363955369c8ef86a84ed7c002321f2ca9456d12f26f413f2918f0a446170634a4e219cbe41ae69b3c997536d001917d01548afc20264697641eff6a357e8fb84e2f1b69aebb4d1ace04fce989efffd366e150b4dfbd4fd2fbb478095060136276d2db7af6c2b9204dfb3573a6d55000d42efb0976d2ef8db5e14d78c8525bfbc9564b3852830665cd1d3e0a305e91afff767ab99bad1a928765230c5e83953480245b3798c532c0ee8085cc574c6822d00615d3a07392784b41b5fce8528bff4b6cad8a4bb09f78235a578098593792288ffc035119e96f4906915e8511eafee5c8a301c246d242031f49b53298e36b36d0d002cbd861a0ba877e20f0e8e1cc7d3008b677cc390657d62167eb970ec1f0507d0000d27e10a7cecfab3381aaf77fe62d475f2b53d26cc249f75c8ed4053f2d5448300540b2803a2c92be40b2ce5cb49aec74d166eefd5dd8260896ad5044faf9130ac000426454579da11ee65558e283f7625457795ae9acb05b2f780ce8aede88fbfeb0013bf5f8365252ab375e1aed1b6f487a34c061e9b7ce8ac94135194ab1eed8114000ded158c4c440adaa0d96a9ecc61f10691187f33e925cfeb8c8a268c958505f30009812a90e3af37bfc4eb2f8ba44b7524f4bb48ca013f39fae76465106a99d81afffde6cba4ea5ce93e1d3beecf9fdac3039be48b2217f548f16d7e6eedafd2f79f0025f0da391b4f459c646798f6d21569297a50611d0e57f15aafd6f1a9675ceb9cfff188b6aa0885508d5bcdcdba4fd3c9641d1c9365b913c313d84c736dc4b4568d0015924d80612cd9e09e26199e0cb42f38070945f5c72375e904b372a3377ea10e00082e2e71ee4696d99aa30cbda1fef460dd10f91d9747bb8d18ab0e98e9eb5b9b0059ebd3655c036f6f2bed6bc193a1bfcc7c9fc80cf85e47dcd0bce67b89deda34000f8dafb206dcff3db5baee2a579ce530d73bf96453f0083bd9b9552e2243cfb5003b6ef251eb7af8f37e6e33c2ca8bcb7ae95081fd005a56576ccd8e2353e1279c000c5bbb2c14f4cb952b1d00fd8816aa1f02b1db97f78cbb7d756e9c2a11dbed43006f7bfa31a055f250e3c0f2491d06778cf7b021bc1ae174ae8fea64e430267958ff9a838964515eb85e4c275b62ed9daacdaa1095698e16cec569dac37ccce2ac930017003f9886e82dbfacb0d4eb980568d5eb766eb425a988b61f7a07b7de542f40fff0f47c77df20206ab22017fb715e03aad3d47566a5b4f6d2e7afa80bbe96307d002305e9d3ce12de279fd54e0b01fa3d3b7295f6489c486602c21083d6bbd9a608ffe1277bb9cf54a8fc2ca96934f6dcc4fe12f0a897a4c196d20710449e8e0305e30009fd54af3ca1349585eef845d953e7b15d1b15b74ed13a39bbdf6662f4646e99000970dca25e9ef872aed638e438383d7151100773bb5308f3925163eed794b169004ce6483da581bd96e3bfcec0ea47d05225c4fb5d2de11481782a20fb152f7ff40005f8b57432b653b168760b252f79339dee39b30a447065f04ff05fb2cd206dcd0050709e6cb21621d1bdc83f8baadc8a628a37811e3d6fcfb5d773ea1faedadebdffecc28e2fa4fe089edfb26a6db8ced0f630036921bed33e2c0e7dbc893e1c286b0059066071730389d9f12f7bab600f6e9a048b87c5dacf5cf3e86753734f1786eaffdc8cdd9b0bea8466564151be30ae6f620951e1afc9ef4f1bfdecfaeab2f0fcb9004e128350cd00dfedc0dbd05947186701c36cb70be74fb310ff0721bf11ce2beeffbbe4796241d434034e51ff150dae2830018bcae34c48ce8d6cc0c9f5a2416ff1","difficulty":120000000,"security":512} \ No newline at end of file diff --git a/ol/fixtures/vdf_proofs/prod/eve/proof_0.json b/ol/fixtures/vdf_proofs/prod/eve/proof_0.json new file mode 100644 index 0000000000..e811232f7f --- /dev/null +++ b/ol/fixtures/vdf_proofs/prod/eve/proof_0.json @@ -0,0 +1 @@ +{"height":0,"elapsed_secs":7811,"preimage":"2bffcbd0e9016013cb8ca78459f69d2b3dc18d1cf61faac6ac70e3a63f062e4b0000000000000000004d41494e4e4554000e2707000000000002000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074657374","proof":"0058f6684a238a6f6e85b349a6fe9fc40477308d1795e6587424b1518a7c8abcd3ffd028eac7218ae5fda097fadc1196032fadbbeeec86395e37f906614af5443e69000769fe70ff1bb222c38cd14ac3b46e283cba02c849f06492316412565064836a0002f8890de91ac0885af67058e17dc120ed4b770f4931d83ebef11c31142ab4c1000f98f24d939082907f948a311592784df937a743b128aabe7efcf0c6e55d695c00016245a256047a35932e091be8b09d82b5f13582e756359fc6bd031ed3326675001227ed31c870c45a5a2cf9a33012a6fd843da73af60af69a1625d0792d851d9e0007f547d3ae6f7f793066b545bdb4b4420cf4760339bdc7d7d280601f8109e8b3003fea80b56a88203bbca55827f5b74adf6614d025f6eba9e288a3c78f3f72d509fff424c4783a8fe2151a2e683a9e2cb082e33739492b9d1779cbfde71fde49569100026b89637e1aa9ba2c50318b356f4f907f73d423af110c4706d04cf219eb49eafffd9aa1a5ea9367a5d5e7fe2559d94ea2a287e6b54725bcb3eaa22a4e7b255f51007117b58010271a94eeb90261a2af34eb2b4a389293e7f5292bf694cec29eef68fffda405e3d4a0f1a6e2e8cdf2a8c781579b17c9a1172452bf6a6c0141e1ac8a8b00046ce51c7e7548b44f88f6fc8b4a7ec618195d2fdac81002b0624bb691dcaad10003362a540b68c02facdc70ec044de9920634ede09cf4515bb63244b12d8ec8fb001ebc161569396fecc07c944bafdc321b1b186d7b27c9df0fbbdf7166988b12660011e60b1dac18de38d3e29b423640e9b8045538edced0b843dd90fee8612b8d93002ca69d9cdfc83e673e4caf4667e89e1d87443fccb4f0793ff3c7d10a2d57a8c90029dbbab1051f3630b82dd9688e30a06d782ec54e7ac8e9cce23aa8d922763bd7006e4c2f4577c9fb9ebfe262b7e7c3dcbcc7fc00af1c45b4b45543c2efd4bf369c00317fb10f30e73a08bff02be11bf04e3b6defb06dcd0fe1e941ea37935b1828fd006aa6d8fb7426a5cc71947fc7ec236814fea5045b82cda41736eb6474652788430060f27c658309966b0d565981b641dab27ae26cf64c3492217eab600a90b51aef007aadadfe95efad8c5ec36286751ad9f938d25773024e7f6999f99bf61ef6cc8e00775bc3c57f259e7729f66df178d4fe2d91f9104ac20ad2c38db0a3630f2402b50031a7ae6db7cfa1591e0b45964e088eb95a7aa8d81c5a5dc962748276a6c62ae0fff60e65eaf28583d6021bf4683705e8333c0367112a004bd4b724155034ec4d85001a1b3a7219e8310a667230f6ceb73ca519d6844dc7d806d5b910825f89d5aed4fff90cd27d23118d70dbc4459449acf360a66b0c4a3f544826fd5a70a094954b15002e0b984f2c1e5ccb86e7c40088b8fc74a9c7930790a4d7dc0b212b49cfcd3370ffd69330472491bcbaecfeedf2f47914d568086baf353e6010fe13028be964df7b004b0f06c11036a9e245f9c8f5a519a37dded7c52c575a804f84c93d00dcd09ccf0008432a55707fd4361c17f2e2a055d2905357dfb941b945f15d7835d1f8332543005a68669aeef540cba434b5aebf5d34b30a19bf4c104a2a469ad45a4dff144a4fffbb6bb2e429e819f376115f8b48fa6d85bbbb87e0f2d1b6e6b9b820b1765882ef0038d30f9fc0d03e1a3ced508c66362aebec4db875642374230a2d12cc6ebda5c40028610d477f1ecabad2a91652b521d9d793c3791e0195502efbf954ffa580472b000a3ebe8eb1c945a1ad8c218c45db53cbcefa29b70a4088194181922239215348fffc1cb4c96ee3621da35b58194ee44170dbb15881244ab4497c3bce32a445674b00072e713d36d938fca0e3af0712f861489730b73efe9de60bd12527e1dd54024a00025fe11a946be628bb28e89a1de04421977885f4fc851a49fcfd97ea4be17d93","difficulty":120000000,"security":512} \ No newline at end of file diff --git a/ol/fixtures/vdf_proofs/stage/alice/proof_1.json b/ol/fixtures/vdf_proofs/stage/alice/proof_1.json new file mode 100644 index 0000000000..c30b70f430 --- /dev/null +++ b/ol/fixtures/vdf_proofs/stage/alice/proof_1.json @@ -0,0 +1,8 @@ +{ + "height": 1, + "elapsed_secs": 1698, + "preimage": "45af4b12ad1ced838f50a8daeed89814dfe40734b8dd43a5ccbf0a6bbdbaeb0a", + "proof": "0064f1651821e42cc9016910088475876d3a7bb438c502b078c764c3cfd5468b71004db8bec520859572e9dd8302f94f051f6aa1fc78abe1cf0e51802876ad516f73004b559abb618185f7335d9cbd9ae620b42ab45542c0770830830ca181376f56b20014e85cd6de8a19403178110eecd94b39e95f95a18e90022a42437cb96b8fffa5006bf92da9408b14792d8696e30aabe1d21e8281a1303e60f94e0e3cd4ef5937bd001eef958824bca650fc600334c6e9613854081d487c1193d2a03167bc22341ac5006014057af54074112a73e09125f28d343a041c9e8e90dc39bd9eedaba11a5838ffceca9c45c7b9295967493c0a620e34ef77cd1914bb74419d5846be5608d47f6b0051dad92055cd740407b4677be9ca25c72a104a79aa22d286f21557355ead4844fff8d85b9ff5fbf6151ddaabcc6512807112e2e064b8a2d79fbe2a2fe021dab725006290c10d70a17a2074b62da4a634c3d307925e0adc91a793744a75bfc6743c8c005ec47dee65522e2fe9865b4af12ec24e5fc774fea31bfc396943586e9c60b505004b29e040e9ad216f3e5069ed04954fae187489c9a01afdf14d04b5a0e0911236001a8353fc4dca8447257ffb84e5e22644f8de119000dc9e0c342cc423a7b371c70007e5a65bee9bfc830eddd1ca14e70623c778e9468de8a0aaafc511a142a374bafff999fa3ed761eae910a646081361dc06a43b30916fe88126b896f4e4cbd73e0900497c2e37362345a72c8f705739f148e638bede9d907e30f05cda18fc746e93a4002083519c6750698fd9f1afc38448153e1b50b68866ac436a41003a7f32b2a78b005b408b1965f08b6161f2ed0ddb8e275fc76689c52d68c7d5275b4878a877ab20ffbabee64a403ede293cf341888cd71799deac84a76dcffbdf38ae8dadd05dea5b000db441b59434924f90167344b6aeae72886d59280d82e6f3dcd6402a20321c1afff8e6fac6fd3f631bea533fa1f10ad15d745f3562a0f24c7c2a85e866c7e4c613001b98f9be8724e2e688f453f05d06ff52d16cd5ed3070b8357a53c8655ef872feffea8a22cc41fdb3b3b50ca90db5aae83c6e51ae5bc2fb11191166850c9a9033e5002afc6b3c463933760d0948d50fefbb6cdc2879a42fcbbb3215bd2bd3483f8fc3ffe11f1c553d184a9edced108175b7cdb9de537ea2d48a1e790919bc58ba3b460d0046049c0330ae303c5b19049526ee4d31d3927276a4a70d1d8be1262b474875d6003a904ea8fe06fef5b5488d30c67d555142065ad137a2153d34e43d09755f11970008ce9d53b48ae85793b8491af009c7418c9b1440b9d811c532aa4ac629fc8c30fff8e8d0dcc051d9359e04fd490e0079dc47ba23932e5314373db7631ce31a262500302adb43191b6ab1c8316a352eea689826ee30ad4ebe81b575fe69439a810e5afff45fb30a24a68267e3c78b7f9ceec6f271c4fb214f6e72a2dddd7812a63b3829006cd1ad5be7d78f6da90a0aa1bb4fe1a066e256f65b532c04d73732a18f58a7c8ffe5559f41bb8193f6781422513e26bd1635d079eb563fcc278fa61d04335c0e15000fdbf265ade7b106924b60f25fb70f8ffd00d388c1d338aea5febb5b9cc80513fffa4ed4dcd83096a48af94caaaf85e4b5827da575c836bec49bc3fa42ab298115001cf72981bef85f608663b492a2e446dfd4aed8ef05f0fed79eeb476945ef56aafff912a7c12d2ec5446af91e131c17522240241f1074f0048d67e06fc47813d519000964df61c493a48a57ec35e98158e709f2e369ab45613d98944cd82b495f9837fffbb7b742a0ade6cdc450ca298c0dc38bc0ea137250ad7b49081bc3e1320ab241005d5f308fbf0507fd0479f66e760cc83d7202e4e56049af756d461e820ccd17fc003688de9babeaec6fe3ff237afe6ee2c92510efb7dc1eb91171061d6b58af6d4d", + "difficulty": 120000000, + "security": 512 +} \ No newline at end of file diff --git a/ol/fixtures/vdf_proofs/stage/dave/proof_0.json b/ol/fixtures/vdf_proofs/stage/dave/proof_0.json new file mode 100644 index 0000000000..3a99af45a4 --- /dev/null +++ b/ol/fixtures/vdf_proofs/stage/dave/proof_0.json @@ -0,0 +1 @@ +{"height":0,"elapsed_secs":2097,"preimage":"9a6e2193488991b62dd28b47d60dd03b9e6bb3a75e9618fba057e86e69338c940000000000000000004d41494e4e4554000e2707000000000002000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074657374","proof":"0037d38818ef23d87ea047276f56db5161956c17ad896ee1620d060067e9358da8002a7390bc73b6df51e9bc2f88efe22c85b0dcfa13c506f514beabf637928dabd300302ed4899cbcacdd634fc3f74ec9968972efb56ba5363955369c8ef86a84ed7c002321f2ca9456d12f26f413f2918f0a446170634a4e219cbe41ae69b3c997536d001917d01548afc20264697641eff6a357e8fb84e2f1b69aebb4d1ace04fce989efffd366e150b4dfbd4fd2fbb478095060136276d2db7af6c2b9204dfb3573a6d55000d42efb0976d2ef8db5e14d78c8525bfbc9564b3852830665cd1d3e0a305e91afff767ab99bad1a928765230c5e83953480245b3798c532c0ee8085cc574c6822d00615d3a07392784b41b5fce8528bff4b6cad8a4bb09f78235a578098593792288ffc035119e96f4906915e8511eafee5c8a301c246d242031f49b53298e36b36d0d002cbd861a0ba877e20f0e8e1cc7d3008b677cc390657d62167eb970ec1f0507d0000d27e10a7cecfab3381aaf77fe62d475f2b53d26cc249f75c8ed4053f2d5448300540b2803a2c92be40b2ce5cb49aec74d166eefd5dd8260896ad5044faf9130ac000426454579da11ee65558e283f7625457795ae9acb05b2f780ce8aede88fbfeb0013bf5f8365252ab375e1aed1b6f487a34c061e9b7ce8ac94135194ab1eed8114000ded158c4c440adaa0d96a9ecc61f10691187f33e925cfeb8c8a268c958505f30009812a90e3af37bfc4eb2f8ba44b7524f4bb48ca013f39fae76465106a99d81afffde6cba4ea5ce93e1d3beecf9fdac3039be48b2217f548f16d7e6eedafd2f79f0025f0da391b4f459c646798f6d21569297a50611d0e57f15aafd6f1a9675ceb9cfff188b6aa0885508d5bcdcdba4fd3c9641d1c9365b913c313d84c736dc4b4568d0015924d80612cd9e09e26199e0cb42f38070945f5c72375e904b372a3377ea10e00082e2e71ee4696d99aa30cbda1fef460dd10f91d9747bb8d18ab0e98e9eb5b9b0059ebd3655c036f6f2bed6bc193a1bfcc7c9fc80cf85e47dcd0bce67b89deda34000f8dafb206dcff3db5baee2a579ce530d73bf96453f0083bd9b9552e2243cfb5003b6ef251eb7af8f37e6e33c2ca8bcb7ae95081fd005a56576ccd8e2353e1279c000c5bbb2c14f4cb952b1d00fd8816aa1f02b1db97f78cbb7d756e9c2a11dbed43006f7bfa31a055f250e3c0f2491d06778cf7b021bc1ae174ae8fea64e430267958ff9a838964515eb85e4c275b62ed9daacdaa1095698e16cec569dac37ccce2ac930017003f9886e82dbfacb0d4eb980568d5eb766eb425a988b61f7a07b7de542f40fff0f47c77df20206ab22017fb715e03aad3d47566a5b4f6d2e7afa80bbe96307d002305e9d3ce12de279fd54e0b01fa3d3b7295f6489c486602c21083d6bbd9a608ffe1277bb9cf54a8fc2ca96934f6dcc4fe12f0a897a4c196d20710449e8e0305e30009fd54af3ca1349585eef845d953e7b15d1b15b74ed13a39bbdf6662f4646e99000970dca25e9ef872aed638e438383d7151100773bb5308f3925163eed794b169004ce6483da581bd96e3bfcec0ea47d05225c4fb5d2de11481782a20fb152f7ff40005f8b57432b653b168760b252f79339dee39b30a447065f04ff05fb2cd206dcd0050709e6cb21621d1bdc83f8baadc8a628a37811e3d6fcfb5d773ea1faedadebdffecc28e2fa4fe089edfb26a6db8ced0f630036921bed33e2c0e7dbc893e1c286b0059066071730389d9f12f7bab600f6e9a048b87c5dacf5cf3e86753734f1786eaffdc8cdd9b0bea8466564151be30ae6f620951e1afc9ef4f1bfdecfaeab2f0fcb9004e128350cd00dfedc0dbd05947186701c36cb70be74fb310ff0721bf11ce2beeffbbe4796241d434034e51ff150dae2830018bcae34c48ce8d6cc0c9f5a2416ff1","difficulty":120000000,"security":512} \ No newline at end of file diff --git a/ol/fixtures/vdf_proofs/stage/eve/proof_0.json b/ol/fixtures/vdf_proofs/stage/eve/proof_0.json new file mode 100644 index 0000000000..e811232f7f --- /dev/null +++ b/ol/fixtures/vdf_proofs/stage/eve/proof_0.json @@ -0,0 +1 @@ +{"height":0,"elapsed_secs":7811,"preimage":"2bffcbd0e9016013cb8ca78459f69d2b3dc18d1cf61faac6ac70e3a63f062e4b0000000000000000004d41494e4e4554000e2707000000000002000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074657374","proof":"0058f6684a238a6f6e85b349a6fe9fc40477308d1795e6587424b1518a7c8abcd3ffd028eac7218ae5fda097fadc1196032fadbbeeec86395e37f906614af5443e69000769fe70ff1bb222c38cd14ac3b46e283cba02c849f06492316412565064836a0002f8890de91ac0885af67058e17dc120ed4b770f4931d83ebef11c31142ab4c1000f98f24d939082907f948a311592784df937a743b128aabe7efcf0c6e55d695c00016245a256047a35932e091be8b09d82b5f13582e756359fc6bd031ed3326675001227ed31c870c45a5a2cf9a33012a6fd843da73af60af69a1625d0792d851d9e0007f547d3ae6f7f793066b545bdb4b4420cf4760339bdc7d7d280601f8109e8b3003fea80b56a88203bbca55827f5b74adf6614d025f6eba9e288a3c78f3f72d509fff424c4783a8fe2151a2e683a9e2cb082e33739492b9d1779cbfde71fde49569100026b89637e1aa9ba2c50318b356f4f907f73d423af110c4706d04cf219eb49eafffd9aa1a5ea9367a5d5e7fe2559d94ea2a287e6b54725bcb3eaa22a4e7b255f51007117b58010271a94eeb90261a2af34eb2b4a389293e7f5292bf694cec29eef68fffda405e3d4a0f1a6e2e8cdf2a8c781579b17c9a1172452bf6a6c0141e1ac8a8b00046ce51c7e7548b44f88f6fc8b4a7ec618195d2fdac81002b0624bb691dcaad10003362a540b68c02facdc70ec044de9920634ede09cf4515bb63244b12d8ec8fb001ebc161569396fecc07c944bafdc321b1b186d7b27c9df0fbbdf7166988b12660011e60b1dac18de38d3e29b423640e9b8045538edced0b843dd90fee8612b8d93002ca69d9cdfc83e673e4caf4667e89e1d87443fccb4f0793ff3c7d10a2d57a8c90029dbbab1051f3630b82dd9688e30a06d782ec54e7ac8e9cce23aa8d922763bd7006e4c2f4577c9fb9ebfe262b7e7c3dcbcc7fc00af1c45b4b45543c2efd4bf369c00317fb10f30e73a08bff02be11bf04e3b6defb06dcd0fe1e941ea37935b1828fd006aa6d8fb7426a5cc71947fc7ec236814fea5045b82cda41736eb6474652788430060f27c658309966b0d565981b641dab27ae26cf64c3492217eab600a90b51aef007aadadfe95efad8c5ec36286751ad9f938d25773024e7f6999f99bf61ef6cc8e00775bc3c57f259e7729f66df178d4fe2d91f9104ac20ad2c38db0a3630f2402b50031a7ae6db7cfa1591e0b45964e088eb95a7aa8d81c5a5dc962748276a6c62ae0fff60e65eaf28583d6021bf4683705e8333c0367112a004bd4b724155034ec4d85001a1b3a7219e8310a667230f6ceb73ca519d6844dc7d806d5b910825f89d5aed4fff90cd27d23118d70dbc4459449acf360a66b0c4a3f544826fd5a70a094954b15002e0b984f2c1e5ccb86e7c40088b8fc74a9c7930790a4d7dc0b212b49cfcd3370ffd69330472491bcbaecfeedf2f47914d568086baf353e6010fe13028be964df7b004b0f06c11036a9e245f9c8f5a519a37dded7c52c575a804f84c93d00dcd09ccf0008432a55707fd4361c17f2e2a055d2905357dfb941b945f15d7835d1f8332543005a68669aeef540cba434b5aebf5d34b30a19bf4c104a2a469ad45a4dff144a4fffbb6bb2e429e819f376115f8b48fa6d85bbbb87e0f2d1b6e6b9b820b1765882ef0038d30f9fc0d03e1a3ced508c66362aebec4db875642374230a2d12cc6ebda5c40028610d477f1ecabad2a91652b521d9d793c3791e0195502efbf954ffa580472b000a3ebe8eb1c945a1ad8c218c45db53cbcefa29b70a4088194181922239215348fffc1cb4c96ee3621da35b58194ee44170dbb15881244ab4497c3bce32a445674b00072e713d36d938fca0e3af0712f861489730b73efe9de60bd12527e1dd54024a00025fe11a946be628bb28e89a1de04421977885f4fc851a49fcfd97ea4be17d93","difficulty":120000000,"security":512} \ No newline at end of file diff --git a/ol/integration-tests/test-mining.mk b/ol/integration-tests/test-mining.mk index 1261838624..18fecb68ba 100644 --- a/ol/integration-tests/test-mining.mk +++ b/ol/integration-tests/test-mining.mk @@ -22,8 +22,7 @@ MNEM="talent sunset lizard pill fame nuclear spy noodle basket okay critic grow NUM_NODES = 2 START_TEXT = "To run the Diem CLI client" -SUCCESS_TEXT = "Proof committed to chain" - +SUCCESS_TEXT = "Remote tower height: 10" test: swarm check-swarm start-mine check stop diff --git a/ol/tower/src/next_proof.rs b/ol/tower/src/next_proof.rs index ae8d3cd912..fa2c6b4974 100644 --- a/ol/tower/src/next_proof.rs +++ b/ol/tower/src/next_proof.rs @@ -76,40 +76,28 @@ pub fn get_next_proof_from_chain( n.refresh_onchain_state(); // TODO: we are picking Client twice let diff = get_difficulty_from_chain(&n)?; - - // // get the user's tower state from chain. - let ts = n - .client - .get_account_state(config.profile.account)? - .get_miner_state()?; - - if let Some(t) = ts { - Ok(NextProof { - diff, - next_height: t.verified_tower_height + 1, - preimage: t.previous_proof_hash, - }) - } else { + + // get the user's tower state from chain. + let ts = n.client + .get_account_state(config.profile.account)? + .get_miner_state()?; + + if let Some(t) = ts { + Ok(NextProof { + diff, + next_height: t.verified_tower_height + 1, + preimage: t.previous_proof_hash, + }) + } else { bail!("cannot get tower resource for account") } } /// Get the VDF difficulty from chain. pub fn get_difficulty_from_chain(n: &Node) -> anyhow::Result { - // dbg!("pick_client"); - // let client = pick_client(swarm_path.clone(), config)?; - - // dbg!("get_account_state"); - - // let mut n = Node::new(client, config, swarm_path.is_some()); - - // // get the user's tower state from chain. - // let ts = client.get_account_state(config.profile.account)?.get_miner_state()?; if let Some(a) = &n.chain_state { - // let a = client.get_account_state(AccountAddress::ZERO)?; - // dbg!(&a); - // dbg!(&a.get_diem_version()); + if let Some(diff) = a.get_tower_params()? { return Ok(diff); } diff --git a/types/src/chain_id.rs b/types/src/chain_id.rs index 714cc03bd0..d8f49147c3 100644 --- a/types/src/chain_id.rs +++ b/types/src/chain_id.rs @@ -9,7 +9,7 @@ use std::{convert::TryFrom, fmt, str::FromStr}; /// When signing transactions for such chains, the numerical chain ID should still be used /// (e.g. MAINNET has numeric chain ID 1, TESTNET has chain ID 2, etc) #[repr(u8)] -#[derive(Copy, Clone, Debug, Serialize, Deserialize)] ///////// 0L //////// +#[derive(Copy, Clone, Debug, Serialize)] ///////// 0L //////// pub enum NamedChain { /// Users might accidentally initialize the ChainId field to 0, hence reserving ChainId 0 for accidental /// initialization. @@ -33,6 +33,12 @@ impl NamedChain { "TESTING" => NamedChain::TESTING, "PREMAINNET" => NamedChain::PREMAINNET, "EXPERIMENTAL" => NamedChain::EXPERIMENTAL, //////// 0L //////// + "Mainnet" => NamedChain::MAINNET, // Backwards compatibility. + "Testnet" => NamedChain::TESTNET, + "Devnet" => NamedChain::DEVNET, + "Testing" => NamedChain::TESTING, + "Premainet" => NamedChain::PREMAINNET, + "Experimental" => NamedChain::EXPERIMENTAL, //////// 0L //////// "1" => NamedChain::MAINNET, "2" => NamedChain::TESTNET, "3" => NamedChain::DEVNET, @@ -68,6 +74,16 @@ impl NamedChain { } } +impl<'de> Deserialize<'de> for NamedChain { //////// 0L //////// + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + NamedChain::from_str(&s).map_err(serde::de::Error::custom) + } +} + impl FromStr for NamedChain { //////// 0L //////// type Err = Error; diff --git a/types/src/ol_vdf_difficulty.rs b/types/src/ol_vdf_difficulty.rs index 5a460dd0f1..b82e0b5ccd 100644 --- a/types/src/ol_vdf_difficulty.rs +++ b/types/src/ol_vdf_difficulty.rs @@ -65,9 +65,9 @@ impl MoveResource for VDFDifficulty {} impl Default for VDFDifficulty { fn default() -> Self { Self { - difficulty: 5_000_000, // historical value from genesis - security: 512, // historical value from genesis - prev_diff: 5_000_000, + difficulty: 120_000_000, // baseline, the historical value from genesis + security: 512, // baseline, historical value from genesis + prev_diff: 120_000_000, prev_sec: 512, } }