Skip to content

Commit

Permalink
Release 5.2.0 (#1154)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
0o-de-lally authored Aug 12, 2022
1 parent c6d6c65 commit 7a5628b
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 78 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand Down Expand Up @@ -470,7 +470,7 @@ debug:

testnet-init: clear fix
# REQUIRES there is a genesis.blob in the fixtures/genesis/<version> 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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion config/src/config/state_sync_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ////////
}
}
}
4 changes: 2 additions & 2 deletions language/diem-framework/modules/0L/EpochBoundary.move
Original file line number Diff line number Diff line change
Expand Up @@ -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()
) {
Expand Down Expand Up @@ -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<address>(&proposed_set) <= 3) proposed_set = Stats::get_sorted_vals_by_props(vm, Vector::length<address>(&proposed_set) / 2);
if (Vector::length<address>(&proposed_set) <= 3) proposed_set = Stats::get_sorted_vals_by_props(vm, Vector::length<address>(&top_accounts) / 2);


// If still failing...in extreme case if we cannot qualify anyone. Don't change the validator set.
Expand Down
80 changes: 48 additions & 32 deletions language/diem-framework/modules/0L/TowerState.move
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ module TowerState {
});
} else {
move_to<VDFDifficulty>(vm, VDFDifficulty {
difficulty: 5000000,
difficulty: 120000000,
security: 512,
prev_diff: 5000000,
prev_diff: 120000000,
prev_sec: 512,
});
}
Expand Down Expand Up @@ -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<VDFDifficulty>(CoreAddresses::VM_RESERVED_ADDRESS());
// let diff = borrow_global<VDFDifficulty>(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)) {
Expand All @@ -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);
}
Expand All @@ -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.

Expand All @@ -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<VDFDifficulty>(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
Expand Down
4 changes: 2 additions & 2 deletions ol/devnet/set_layout_test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ owners = [
"88e74dfed34420f2ad8032148280a84b",
"e660402d586ad220ed9beff47d662d54",
"9e6bb3a75e9618fba057e86e69338c94",
"3dc18d1cf61faac6ac70e3a63f062e4b"
# "3dc18d1cf61faac6ac70e3a63f062e4b"
]
operators = [
"4c613c2f4b1e67ca8d98a542ee3f59f5-oper",
"88e74dfed34420f2ad8032148280a84b-oper",
"e660402d586ad220ed9beff47d662d54-oper",
"9e6bb3a75e9618fba057e86e69338c94-oper",
"3dc18d1cf61faac6ac70e3a63f062e4b-oper"
# "3dc18d1cf61faac6ac70e3a63f062e4b-oper"
]
2 changes: 1 addition & 1 deletion ol/fixtures/configs/alice.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion ol/fixtures/configs/bob.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion ol/fixtures/configs/carol.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion ol/fixtures/configs/dave.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion ol/fixtures/configs/eve.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions ol/fixtures/vdf_proofs/prod/dave/proof_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"height":0,"elapsed_secs":2097,"preimage":"9a6e2193488991b62dd28b47d60dd03b9e6bb3a75e9618fba057e86e69338c940000000000000000004d41494e4e4554000e2707000000000002000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074657374","proof":"0037d38818ef23d87ea047276f56db5161956c17ad896ee1620d060067e9358da8002a7390bc73b6df51e9bc2f88efe22c85b0dcfa13c506f514beabf637928dabd300302ed4899cbcacdd634fc3f74ec9968972efb56ba5363955369c8ef86a84ed7c002321f2ca9456d12f26f413f2918f0a446170634a4e219cbe41ae69b3c997536d001917d01548afc20264697641eff6a357e8fb84e2f1b69aebb4d1ace04fce989efffd366e150b4dfbd4fd2fbb478095060136276d2db7af6c2b9204dfb3573a6d55000d42efb0976d2ef8db5e14d78c8525bfbc9564b3852830665cd1d3e0a305e91afff767ab99bad1a928765230c5e83953480245b3798c532c0ee8085cc574c6822d00615d3a07392784b41b5fce8528bff4b6cad8a4bb09f78235a578098593792288ffc035119e96f4906915e8511eafee5c8a301c246d242031f49b53298e36b36d0d002cbd861a0ba877e20f0e8e1cc7d3008b677cc390657d62167eb970ec1f0507d0000d27e10a7cecfab3381aaf77fe62d475f2b53d26cc249f75c8ed4053f2d5448300540b2803a2c92be40b2ce5cb49aec74d166eefd5dd8260896ad5044faf9130ac000426454579da11ee65558e283f7625457795ae9acb05b2f780ce8aede88fbfeb0013bf5f8365252ab375e1aed1b6f487a34c061e9b7ce8ac94135194ab1eed8114000ded158c4c440adaa0d96a9ecc61f10691187f33e925cfeb8c8a268c958505f30009812a90e3af37bfc4eb2f8ba44b7524f4bb48ca013f39fae76465106a99d81afffde6cba4ea5ce93e1d3beecf9fdac3039be48b2217f548f16d7e6eedafd2f79f0025f0da391b4f459c646798f6d21569297a50611d0e57f15aafd6f1a9675ceb9cfff188b6aa0885508d5bcdcdba4fd3c9641d1c9365b913c313d84c736dc4b4568d0015924d80612cd9e09e26199e0cb42f38070945f5c72375e904b372a3377ea10e00082e2e71ee4696d99aa30cbda1fef460dd10f91d9747bb8d18ab0e98e9eb5b9b0059ebd3655c036f6f2bed6bc193a1bfcc7c9fc80cf85e47dcd0bce67b89deda34000f8dafb206dcff3db5baee2a579ce530d73bf96453f0083bd9b9552e2243cfb5003b6ef251eb7af8f37e6e33c2ca8bcb7ae95081fd005a56576ccd8e2353e1279c000c5bbb2c14f4cb952b1d00fd8816aa1f02b1db97f78cbb7d756e9c2a11dbed43006f7bfa31a055f250e3c0f2491d06778cf7b021bc1ae174ae8fea64e430267958ff9a838964515eb85e4c275b62ed9daacdaa1095698e16cec569dac37ccce2ac930017003f9886e82dbfacb0d4eb980568d5eb766eb425a988b61f7a07b7de542f40fff0f47c77df20206ab22017fb715e03aad3d47566a5b4f6d2e7afa80bbe96307d002305e9d3ce12de279fd54e0b01fa3d3b7295f6489c486602c21083d6bbd9a608ffe1277bb9cf54a8fc2ca96934f6dcc4fe12f0a897a4c196d20710449e8e0305e30009fd54af3ca1349585eef845d953e7b15d1b15b74ed13a39bbdf6662f4646e99000970dca25e9ef872aed638e438383d7151100773bb5308f3925163eed794b169004ce6483da581bd96e3bfcec0ea47d05225c4fb5d2de11481782a20fb152f7ff40005f8b57432b653b168760b252f79339dee39b30a447065f04ff05fb2cd206dcd0050709e6cb21621d1bdc83f8baadc8a628a37811e3d6fcfb5d773ea1faedadebdffecc28e2fa4fe089edfb26a6db8ced0f630036921bed33e2c0e7dbc893e1c286b0059066071730389d9f12f7bab600f6e9a048b87c5dacf5cf3e86753734f1786eaffdc8cdd9b0bea8466564151be30ae6f620951e1afc9ef4f1bfdecfaeab2f0fcb9004e128350cd00dfedc0dbd05947186701c36cb70be74fb310ff0721bf11ce2beeffbbe4796241d434034e51ff150dae2830018bcae34c48ce8d6cc0c9f5a2416ff1","difficulty":120000000,"security":512}
Loading

0 comments on commit 7a5628b

Please sign in to comment.