diff --git a/CHANGELOG.md b/CHANGELOG.md index 8154a8fb6..3e65c4834 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,6 @@ - Add spec for the light client attack evidence handling ([#526]) - Return RFC6962 hash for empty merkle tree ([#498]) - The `tendermint`, `tendermint-rpc`, and `tendermint-light-client` crates now compile to WASM on the `wasm32-unknown-unknown` and `wasm32-wasi` targets ([#463]) -- Implement protobuf encoding/decoding of Tendermint Proto types ([#504]) -- Separate protobuf types from Rust domain types using the DomainType trait ([#535]) -- Changed validator sorting order to sort by voting power (descending) and address (ascending). ([#506]) - Dependency update: sled 0.34 ([#490]) ### BREAKING CHANGES: @@ -18,6 +15,11 @@ subscription. To access this struct, you now need to enable both the `client` and `transport_http` features when using the `tendermint-rpc` crate. ([#516]) +- `[tendermint]` Removed Amino types. All types are now `DomainType`s + implementing Protobuf-encoding using Prost. ([#504], [#535], [#536], + [#585]) +- `[tendermint]` Changed validator sorting order to sort by voting power + (descending) and address (ascending). ([#506]) ### IMPROVEMENTS: @@ -49,6 +51,8 @@ [#535]: https://github.com/informalsystems/tendermint-rs/issues/535 [#506]: https://github.com/informalsystems/tendermint-rs/issues/506 [#516]: https://github.com/informalsystems/tendermint-rs/pull/516 +[#536]: https://github.com/informalsystems/tendermint-rs/issues/536 +[#585]: https://github.com/informalsystems/tendermint-rs/issues/585 [#584]: https://github.com/informalsystems/tendermint-rs/pull/584 ## v0.16.0 diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index 7bc2550cf..16724047e 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -35,7 +35,6 @@ contracts = "0.4.0" crossbeam-channel = "0.4.2" derive_more = "0.99.5" futures = "0.3.4" -prost-amino = "0.6.0" serde = "1.0.106" serde_cbor = "0.11.1" serde_derive = "1.0.106" diff --git a/light-client/src/components/io.rs b/light-client/src/components/io.rs index 4c0d957f7..1170ee8f8 100644 --- a/light-client/src/components/io.rs +++ b/light-client/src/components/io.rs @@ -114,7 +114,8 @@ mod prod { /// A peer map which maps peer IDS to their network address must be supplied. pub fn new( peer_id: PeerId, - rpc_client: rpc::HttpClient, // TODO(thane): Generalize over client transport (instead of using HttpClient directly) + rpc_client: rpc::HttpClient, /* TODO(thane): Generalize over client transport + * (instead of using HttpClient directly) */ timeout: Option, ) -> Self { Self { diff --git a/light-client/src/components/scheduler.rs b/light-client/src/components/scheduler.rs index e8d722af1..1e206271a 100644 --- a/light-client/src/components/scheduler.rs +++ b/light-client/src/components/scheduler.rs @@ -4,6 +4,7 @@ use contracts::*; use crate::store::LightStore; use crate::types::Height; +use std::convert::TryInto; /// The scheduler decides what block to verify next given the current and target heights. /// @@ -122,5 +123,7 @@ pub fn valid_schedule( #[pre(low <= high)] #[post(low <= ret && ret <= high)] fn midpoint(low: Height, high: Height) -> Height { - (low.value() + (high.value() + 1 - low.value()) / 2).into() + (low.value() + (high.value() + 1 - low.value()) / 2) + .try_into() + .unwrap() // Will panic if midpoint is higher than i64::MAX } diff --git a/light-client/src/operations/voting_power.rs b/light-client/src/operations/voting_power.rs index 590dc83ba..3f5b1e895 100644 --- a/light-client/src/operations/voting_power.rs +++ b/light-client/src/operations/voting_power.rs @@ -10,9 +10,10 @@ use serde::{Deserialize, Serialize}; use std::collections::HashSet; use std::fmt; +use std::convert::{TryFrom, TryInto}; use tendermint::block::CommitSig; use tendermint::trust_threshold::TrustThreshold as _; -use tendermint::vote::{SignedVote, Vote}; +use tendermint::vote::{SignedVote, ValidatorIndex, Vote}; /// Tally for the voting power computed by the `VotingPowerCalculator` #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -115,7 +116,11 @@ impl VotingPowerCalculator for ProdVotingPowerCalculator { // Get non-absent votes from the signatures let non_absent_votes = signatures.iter().enumerate().flat_map(|(idx, signature)| { - if let Some(vote) = non_absent_vote(signature, idx as u16, &signed_header.commit) { + if let Some(vote) = non_absent_vote( + signature, + ValidatorIndex::try_from(idx).unwrap(), + &signed_header.commit, + ) { Some((signature, vote)) } else { None @@ -138,8 +143,8 @@ impl VotingPowerCalculator for ProdVotingPowerCalculator { }; let signed_vote = SignedVote::new( - (&vote).into(), - signed_header.header.chain_id.as_str(), + vote.clone(), + signed_header.header.chain_id.clone(), vote.validator_address, vote.signature, ); @@ -179,7 +184,11 @@ impl VotingPowerCalculator for ProdVotingPowerCalculator { } } -fn non_absent_vote(commit_sig: &CommitSig, validator_index: u16, commit: &Commit) -> Option { +fn non_absent_vote( + commit_sig: &CommitSig, + validator_index: ValidatorIndex, + commit: &Commit, +) -> Option { let (validator_address, timestamp, signature, block_id) = match commit_sig { CommitSig::BlockIDFlagAbsent { .. } => return None, CommitSig::BlockIDFlagCommit { @@ -190,7 +199,7 @@ fn non_absent_vote(commit_sig: &CommitSig, validator_index: u16, commit: &Commit *validator_address, *timestamp, signature, - Some(commit.block_id.clone()), + Some(commit.block_id), ), CommitSig::BlockIDFlagNil { validator_address, @@ -202,9 +211,9 @@ fn non_absent_vote(commit_sig: &CommitSig, validator_index: u16, commit: &Commit Some(Vote { vote_type: tendermint::vote::Type::Precommit, height: commit.height, - round: commit.round, + round: commit.round.try_into().unwrap(), block_id, - timestamp, + timestamp: Some(timestamp), validator_address, validator_index, signature: *signature, diff --git a/light-client/tests/integration.rs b/light-client/tests/integration.rs index 8843040d0..f96aa34b0 100644 --- a/light-client/tests/integration.rs +++ b/light-client/tests/integration.rs @@ -97,7 +97,7 @@ fn sync() { let handle = supervisor.handle(); std::thread::spawn(|| supervisor.run()); - let max_iterations: usize = 1; // FIXME: Fix no witness left error in subsequent iterations + let max_iterations: usize = 10; for i in 1..=max_iterations { println!("[info ] - iteration {}/{}", i, max_iterations); diff --git a/light-client/tests/light_client.rs b/light-client/tests/light_client.rs index b6db26a43..945e90f86 100644 --- a/light-client/tests/light_client.rs +++ b/light-client/tests/light_client.rs @@ -15,6 +15,7 @@ use tendermint_light_client::{ types::{LightBlock, Status, TrustThreshold}, }; +use std::convert::TryInto; use tendermint_testgen::Tester; // Link to JSON test files repo: @@ -169,7 +170,7 @@ fn bisection_lower_test(tc: TestBisection) { trusted_height = trusted_height.increment(); } - tc.height_to_verify = (trusted_height.value() - 1).into(); + tc.height_to_verify = (trusted_height.value() - 1).try_into().unwrap(); let test_result = run_bisection_test(tc); match test_result.new_states { diff --git a/light-client/tests/support/.gitignore b/light-client/tests/support/.gitignore index 6cd39eb71..b99c64f22 100644 --- a/light-client/tests/support/.gitignore +++ b/light-client/tests/support/.gitignore @@ -1 +1,2 @@ _*/* +*/_* \ No newline at end of file diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustFailure.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustFailure.json index e81d0dfee..87345a67b 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustFailure.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustFailure.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_Test2NotEnoughTrustFailure.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -14,7 +14,7 @@ "last_commit_hash": null, "data_hash": null, "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, @@ -25,33 +25,36 @@ "height": "1", "round": 1, "block_id": { - "hash": "FF5EF036A792C2A2D993AB8318E00C557F7CC12A356C58E6EE15448E53A9CEDD", - "parts": null + "hash": "037EDD75748E835B951090EA56AFBA5E537D6BCBFD8833450FFED37BCB947352", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "THfXPVusiq4yghPPiUCxdnNzN1VU7mfCHsK4QBKlKo1rGRagfAPdcGdJyPpWjmala7Vigi1ie7owlCtHmM/WBA==" + "signature": "dyC/98kdQ9pBcjRMngvmxm4OJ5f1Ddzw/l8mT7V+G/uKuH3Il618O7YN40/ATTHtu517DFm+tsfHcDLY8KvgCg==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "0lQIE1KNt6at5gxy8lcd/VYSQ/BlrB6Tfv7OTCL1TuGKjrCxrR9spthoenq0vsbyhHLm9tZ2qdzfK/Es7BOnBA==" + "signature": "w/035jufehur92XKIpEV/ddEaGd8zNK1IBxyOeK6c4zSKDN65KTk83IoRUZorPxm5WdG3qpouGAjYZKXNGh1Ag==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "td+NH5Z/HbkJ+FVaHQKDl3fMsdoF4mFkfN/0NgF3+cdtLpQZS+9j+Kt2fbFCr/faJC/gd2ngy9c8YRY4Jaw0BA==" + "signature": "CZGS/p05b+r0Y3py9tb2N6yQF1rxPhzdQwnm7XAldTqDBbVH9/6qSm+2N4pPrytM4RmooSX2WlDM+lKjyw7cBg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "HS8xj/i2VeZT5gnzGZkSdGaJW0FNyl0rK6c++oce+cTGWy2OFJS+0BRaQn+bkIr4uhRiaF9nuz0gEyqV2DYUAw==" + "signature": "idu2/K9v9auv81wUKZJHNUP1ke5AEFjVYwBYpdsglHJTI2WDd2O8u6c2Pg0O2ZDliiv7/ChM+snLAFKrrMs8Ag==" } ] } @@ -59,27 +62,27 @@ "next_validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null } }, "trusting_period": "1400000000000", - "now": "2020-09-25T12:05:22.094559019Z" + "now": "2020-10-07T14:19:52.1602080392Z" }, "input": [ { @@ -92,37 +95,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:05Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "next_validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", - "consensus_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", + "validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "next_validators_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", + "consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "81D85BE9567F7069A4760C663062E66660DADF34" + "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "6AD76EF8330ACD5B2A843B36E533DF64505A1095333453166359A399F9F8AAAA", - "parts": null + "hash": "0EB5049300A3BF6A48AA100639D81AC2EB79BD78FA228C0C1C11676B21E4AC35", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "Tw1wbIXq3eX8tYP++oTh7hjJLBHEFnjzpBusHvuueESgXDTDu9TijQJVXfVcnuZCwUZt2Ka9VCwaZoV5dRWeCA==" - }, - { - "block_id_flag": 2, - "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "ntk3NuonP1y/wpL+vRYTa/HMBtjy7A1QCzeh7vceTh5QUfjtq7hIFTE5+Sj8NwVtkX9W2siPcLKPK0KfLKiGAw==" + "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "timestamp": "1970-01-01T00:00:05Z", + "signature": "7YoqoViVeQmKz2btjoVI5euI7WETWM6eKX3xOFWpj04CYHvnwamVrMG8AdGKi5OFQ1iM+E33hJqn3ZTYX7H5Bw==" } ] } @@ -130,29 +130,20 @@ "validator_set": { "validators": [ { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null @@ -160,15 +151,6 @@ }, "next_validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -179,27 +161,27 @@ "proposer_priority": null }, { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:05Z", + "now": "1970-01-01T00:00:06Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -216,27 +198,30 @@ "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", - "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", - "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "next_validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" }, "commit": { "height": "3", "round": 1, "block_id": { - "hash": "8AA4F784D35E9D5B19F6321ADBDBC1FF33556BA82B939429011BC60F27188881", - "parts": null + "hash": "020BE769E526D232E320357C2302C76DE359FEEA14DA211C1647CCAD0A0AC67E", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:02Z", - "signature": "Y514CCQOA8ksQD8fPWnOhAqyq/aeaVW0o8Uj9hO4w49AzEGXQaBlhWhYJU7CUJcWrSrKWJxoANEUi9pPzjSJAw==" + "signature": "4iLlRp0sbGAhPzkCow6RRZlEEeZGq/nrtirAXDd4Utq0EOa69P1DlRk3aQpqwCjGRiauL6JT+KV6Gylb8fYHDQ==" } ] } @@ -244,20 +229,20 @@ "validator_set": { "validators": [ { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null @@ -266,124 +251,55 @@ "next_validator_set": { "validators": [ { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null - } - ], - "proposer": { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null - } - } - }, - "now": "1970-01-01T00:00:05Z", - "verdict": "NOT_ENOUGH_TRUST" - }, - { - "block": { - "signed_header": { - "header": { - "version": { - "block": "0", - "app": "0" - }, - "chain_id": "test-chain", - "height": "2", - "time": "1970-01-01T00:00:02Z", - "last_block_id": null, - "last_commit_hash": null, - "data_hash": null, - "validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "next_validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "app_hash": "", - "last_results_hash": null, - "evidence_hash": null, - "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" - }, - "commit": { - "height": "2", - "round": 1, - "block_id": { - "hash": "47A20AAC962BEC23F44A912B15B2D2FB2E3806ECB33990E400E3E4BAB13FD4E0", - "parts": null }, - "signatures": [ - { - "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "UhhxviJ8Orwcf3K2l+kZUJbXVT0n5EBHFRD0tAtOE7sxRW2osvrnnnDrn7+OR9cjs7jEjhBHA9pqPGiZjE2BAg==" - } - ] - } - }, - "validator_set": { - "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null - } - ], - "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, - "voting_power": "50", - "proposer_priority": null - } - }, - "next_validator_set": { - "validators": [ { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null }, { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:20Z", - "verdict": "SUCCESS" + "now": "1970-01-01T00:00:06Z", + "verdict": "NOT_ENOUGH_TRUST" }, { "block": { @@ -394,53 +310,47 @@ "app": "0" }, "chain_id": "test-chain", - "height": "4", - "time": "1970-01-01T00:00:04Z", + "height": "2", + "time": "1970-01-01T00:00:02Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "next_validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", - "consensus_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", + "validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "next_validators_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", + "consensus_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "81D85BE9567F7069A4760C663062E66660DADF34" + "proposer_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF" }, "commit": { - "height": "4", + "height": "2", "round": 1, "block_id": { - "hash": "6AD76EF8330ACD5B2A843B36E533DF64505A1095333453166359A399F9F8AAAA", - "parts": null + "hash": "80834C414998C26789D81B49C1F5911E0A68ECD4AB781ABBF7BD01D487F45FC3", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "Tw1wbIXq3eX8tYP++oTh7hjJLBHEFnjzpBusHvuueESgXDTDu9TijQJVXfVcnuZCwUZt2Ka9VCwaZoV5dRWeCA==" + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:02Z", + "signature": "Qoczjg85vNtL8LfkctxRSTPZC104JRgAxS5jbXcLvRgyQwj2WqSi9HfKbD8Ixt+0pS5Xma68zqPhziUU4R5oAA==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "ntk3NuonP1y/wpL+vRYTa/HMBtjy7A1QCzeh7vceTh5QUfjtq7hIFTE5+Sj8NwVtkX9W2siPcLKPK0KfLKiGAw==" + "timestamp": "1970-01-01T00:00:02Z", + "signature": "v38vgTmFRbspOjeESjVhLRKZ6U4pjwgnDV336JJ3JiLN9XVpLGkg76uCkiZZrVfTXjipix7hnYf8aLqVvT9LAA==" } ] } }, "validator_set": { "validators": [ - { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -452,10 +362,10 @@ } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null @@ -463,15 +373,6 @@ }, "next_validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -482,28 +383,28 @@ "proposer_priority": null }, { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:20Z", - "verdict": "SUCCESS" + "now": "1970-01-01T00:00:06Z", + "verdict": "INVALID" } ] } \ No newline at end of file diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustFailure.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustFailure.tla index 0c76987b6..f08f18e7e 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustFailure.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustFailure.tla @@ -9,41 +9,41 @@ TRUE (* Transition 0 to State2 *) State2 == -/\ Faulty = {"n4"} +/\ Faulty = {"n1"} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n3"}, + VS |-> { "n2", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, + lastCommit |-> {"n3"}, time |-> 3] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n3"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> { "n2", "n4" }, time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> {"n3"}, time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -52,44 +52,44 @@ State2 == :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 6, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" /\ nextHeight = 4 -/\ now = 5 +/\ now = 6 /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ prevNow = 5 +/\ prevNow = 6 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -99,114 +99,114 @@ State2 == (* Transition 1 to State3 *) State3 == -/\ Faulty = {"n4"} +/\ Faulty = {"n1"} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n3"}, + VS |-> { "n2", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, + lastCommit |-> {"n3"}, time |-> 3] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n3"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> { "n2", "n4" }, time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> {"n3"}, time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 4 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> {"n3"}, + time |-> 5]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 6, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 5, + lastCommit |-> {"n3"}, + time |-> 5]], + now |-> 6, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 4 :> "StateUnverified" /\ nextHeight = 3 -/\ now = 5 +/\ now = 6 /\ nprobes = 1 -/\ prevCurrent = [Commits |-> { "n2", "n3" }, +/\ prevCurrent = [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] -/\ prevNow = 5 + lastCommit |-> {"n3"}, + time |-> 5]] +/\ prevNow = 6 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -216,518 +216,325 @@ State3 == (* Transition 1 to State4 *) State4 == -/\ Faulty = {"n4"} +/\ Faulty = {"n1"} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n3"}, + VS |-> { "n2", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, + lastCommit |-> {"n3"}, time |-> 3] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n3"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> { "n2", "n4" }, time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> {"n3"}, time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 3 - :> [Commits |-> {"n4"}, + :> [Commits |-> {"n1"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n1"}, height |-> 3, - lastCommit |-> { "n2", "n4" }, + lastCommit |-> {}, time |-> 2]] @@ 4 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> {"n3"}, + time |-> 5]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 6, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 5, + lastCommit |-> {"n3"}, + time |-> 5]], + now |-> 6, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n4"}, + [Commits |-> {"n1"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n1"}, height |-> 3, - lastCommit |-> { "n2", "n4" }, + lastCommit |-> {}, time |-> 2]], - now |-> 5, + now |-> 6, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" /\ nextHeight = 2 -/\ now = 1400 +/\ now = 6 /\ nprobes = 2 -/\ prevCurrent = [Commits |-> {"n4"}, +/\ prevCurrent = [Commits |-> {"n1"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n1"}, height |-> 3, - lastCommit |-> { "n2", "n4" }, + lastCommit |-> {}, time |-> 2]] -/\ prevNow = 5 +/\ prevNow = 6 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ state = "working" -(* Transition 3 to State5 *) +(* Transition 5 to State5 *) State5 == -/\ Faulty = {"n4"} +/\ Faulty = {"n1"} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n3"}, + VS |-> { "n2", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, + lastCommit |-> {"n3"}, time |-> 3] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n3"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> { "n2", "n4" }, time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> {"n3"}, time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> {"n1"}, + :> [Commits |-> { "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 2]] @@ 3 - :> [Commits |-> {"n4"}, + :> [Commits |-> {"n1"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n1"}, height |-> 3, - lastCommit |-> { "n2", "n4" }, + lastCommit |-> {}, time |-> 2]] @@ 4 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> {"n3"}, + time |-> 5]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 6, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 5, + lastCommit |-> {"n3"}, + time |-> 5]], + now |-> 6, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n4"}, + [Commits |-> {"n1"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n1"}, height |-> 3, - lastCommit |-> { "n2", "n4" }, + lastCommit |-> {}, time |-> 2]], - now |-> 5, + now |-> 6, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> { "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 2]], - now |-> 1400, - verdict |-> "SUCCESS", + now |-> 6, + verdict |-> "INVALID", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] -/\ latestVerified = [Commits |-> {"n1"}, +/\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, - height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + [NextVS |-> {"n3"}, + VS |-> { "n1", "n2", "n3", "n4" }, + height |-> 1, + lastCommit |-> {}, + time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" - @@ 2 :> "StateVerified" + @@ 2 :> "StateFailed" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" -/\ nextHeight = 4 -/\ now = 1400 +/\ nextHeight = 2 +/\ now = 6 /\ nprobes = 3 -/\ prevCurrent = [Commits |-> {"n1"}, +/\ prevCurrent = [Commits |-> { "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 2]] -/\ prevNow = 1400 -/\ prevVerdict = "SUCCESS" +/\ prevNow = 6 +/\ prevVerdict = "INVALID" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ state = "working" - -(* Transition 0 to State6 *) - -State6 == -/\ Faulty = {"n4"} -/\ blockchain = 1 - :> [NextVS |-> {"n1"}, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1] - @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, - height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] - @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, - height |-> 3, - lastCommit |-> {"n1"}, - time |-> 3] - @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, - height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] - @@ 5 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, - height |-> 5, - lastCommit |-> { "n2", "n3" }, - time |-> 5] -/\ fetchedLightBlocks = 1 - :> [Commits |-> { "n1", "n2", "n3", "n4" }, - header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]] - @@ 2 - :> [Commits |-> {"n1"}, - header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, - height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] - @@ 3 - :> [Commits |-> {"n4"}, - header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, - height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]] - @@ 4 - :> [Commits |-> { "n2", "n3" }, - header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, - height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] -/\ history = 0 - :> [current |-> - [Commits |-> { "n1", "n2", "n3", "n4" }, - header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]], - now |-> 5, - verdict |-> "SUCCESS", - verified |-> - [Commits |-> { "n1", "n2", "n3", "n4" }, - header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]]] - @@ 1 - :> [current |-> - [Commits |-> { "n2", "n3" }, - header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, - height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 5, - verdict |-> "NOT_ENOUGH_TRUST", - verified |-> - [Commits |-> { "n1", "n2", "n3", "n4" }, - header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]]] - @@ 2 - :> [current |-> - [Commits |-> {"n4"}, - header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, - height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]], - now |-> 5, - verdict |-> "NOT_ENOUGH_TRUST", - verified |-> - [Commits |-> { "n1", "n2", "n3", "n4" }, - header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]]] - @@ 3 - :> [current |-> - [Commits |-> {"n1"}, - header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, - height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]], - now |-> 1400, - verdict |-> "SUCCESS", - verified |-> - [Commits |-> { "n1", "n2", "n3", "n4" }, - header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]]] - @@ 4 - :> [current |-> - [Commits |-> { "n2", "n3" }, - header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, - height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 1400, - verdict |-> "SUCCESS", - verified |-> - [Commits |-> {"n1"}, - header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, - height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]]] -/\ latestVerified = [Commits |-> { "n2", "n3" }, - header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, - height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] -/\ lightBlockStatus = 1 :> "StateVerified" - @@ 2 :> "StateVerified" - @@ 3 :> "StateUnverified" - @@ 4 :> "StateVerified" -/\ nextHeight = 4 -/\ now = 1400 -/\ nprobes = 4 -/\ prevCurrent = [Commits |-> { "n2", "n3" }, - header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, - height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] -/\ prevNow = 1400 -/\ prevVerdict = "SUCCESS" -/\ prevVerified = [Commits |-> {"n1"}, - header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, - height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] -/\ state = "finishedSuccess" +/\ state = "finishedFailure" (* The following formula holds true in the last state and violates the invariant *) InvariantViolation == - state = "finishedSuccess" + state = "finishedFailure" /\ BMC!Skolem((\E s1$2 \in DOMAIN history: BMC!Skolem((\E s2$2 \in DOMAIN history: ~(s1$2 = s2$2) @@ -735,5 +542,5 @@ InvariantViolation == /\ history[s2$2]["verdict"] = "NOT_ENOUGH_TRUST")))) ================================================================================ -\* Created by Apalache on Fri Sep 25 14:05:21 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:19:52 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustSuccess.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustSuccess.json index c57e38cc4..ad5938f62 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustSuccess.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustSuccess.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_Test2NotEnoughTrustSuccess.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -14,7 +14,7 @@ "last_commit_hash": null, "data_hash": null, "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "next_validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, @@ -25,33 +25,36 @@ "height": "1", "round": 1, "block_id": { - "hash": "FF5EF036A792C2A2D993AB8318E00C557F7CC12A356C58E6EE15448E53A9CEDD", - "parts": null + "hash": "67A2F8253E1545321561A82A23D87B984E11621D2B877EB236FE649A20442932", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "THfXPVusiq4yghPPiUCxdnNzN1VU7mfCHsK4QBKlKo1rGRagfAPdcGdJyPpWjmala7Vigi1ie7owlCtHmM/WBA==" + "signature": "yJFAxO4S7lWyeJYsQ+ZXD8qqOEJMea6qJI4emHXiz1G8toYIN31z7gcsXj3P0DUbdzIVUvCgPvvgVwoiLCKTDQ==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "0lQIE1KNt6at5gxy8lcd/VYSQ/BlrB6Tfv7OTCL1TuGKjrCxrR9spthoenq0vsbyhHLm9tZ2qdzfK/Es7BOnBA==" + "signature": "hrdfvpMuSAwpAdG/apS8astAtVzL1GE1pV+b2LoSZwxx7XG78LbjvVzy9noKSY4XT6UlNaScd24ds0Dg1KnwBQ==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "td+NH5Z/HbkJ+FVaHQKDl3fMsdoF4mFkfN/0NgF3+cdtLpQZS+9j+Kt2fbFCr/faJC/gd2ngy9c8YRY4Jaw0BA==" + "signature": "RM39gQxzEDoC6uc0x+KW2ULfNiFXhetirKHn9J/suisjslOcWaanyhB9YFeJC2XQ42amV3b6lveGE3pauA1cBg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "HS8xj/i2VeZT5gnzGZkSdGaJW0FNyl0rK6c++oce+cTGWy2OFJS+0BRaQn+bkIr4uhRiaF9nuz0gEyqV2DYUAw==" + "signature": "SB2j93BXgPL20kTmEhBFlHKmw6LtACQYCILz67xRhsUmXRAsIXQt5AQXW4bU5BHOYpHog8lz/5ZmSQ7If1rFAw==" } ] } @@ -66,6 +69,24 @@ }, "voting_power": "50", "proposer_priority": null + }, + { + "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + }, + "voting_power": "50", + "proposer_priority": null + }, + { + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + }, + "voting_power": "50", + "proposer_priority": null } ], "proposer": { @@ -79,7 +100,7 @@ } }, "trusting_period": "1400000000000", - "now": "2020-09-25T12:05:22.094559019Z" + "now": "2020-10-07T14:19:40.1602080380Z" }, "input": [ { @@ -92,37 +113,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:05Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "next_validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", - "consensus_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", + "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "next_validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", + "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "81D85BE9567F7069A4760C663062E66660DADF34" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "6AD76EF8330ACD5B2A843B36E533DF64505A1095333453166359A399F9F8AAAA", - "parts": null + "hash": "D67533E0DAFB3715FEB042160B5B92D83FFF66612396F4C21BA0E44F5E9B32B3", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "Tw1wbIXq3eX8tYP++oTh7hjJLBHEFnjzpBusHvuueESgXDTDu9TijQJVXfVcnuZCwUZt2Ka9VCwaZoV5dRWeCA==" - }, - { - "block_id_flag": 2, - "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "ntk3NuonP1y/wpL+vRYTa/HMBtjy7A1QCzeh7vceTh5QUfjtq7hIFTE5+Sj8NwVtkX9W2siPcLKPK0KfLKiGAw==" + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:05Z", + "signature": "U7LI1fPPCnzo2A+lbedXTQRFWx3NassTtt84R5xIPDtk4wF9HBou9fN3bXYI4YsLITK6PZ4YozR82Sn/Sg/nCA==" } ] } @@ -130,29 +148,20 @@ "validator_set": { "validators": [ { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null @@ -160,15 +169,6 @@ }, "next_validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -189,17 +189,17 @@ } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:05Z", + "now": "1970-01-01T00:23:18Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -212,13 +212,13 @@ }, "chain_id": "test-chain", "height": "3", - "time": "1970-01-01T00:00:02Z", + "time": "1970-01-01T00:00:04Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "validators_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", - "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "consensus_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", "app_hash": "", "last_results_hash": null, "evidence_hash": null, @@ -228,21 +228,39 @@ "height": "3", "round": 1, "block_id": { - "hash": "8AA4F784D35E9D5B19F6321ADBDBC1FF33556BA82B939429011BC60F27188881", - "parts": null + "hash": "1E8C50E56D867507E195C5BAEC661D6A2BB13A0DE7D0938AD92F00C4F95F2DE5", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "Y514CCQOA8ksQD8fPWnOhAqyq/aeaVW0o8Uj9hO4w49AzEGXQaBlhWhYJU7CUJcWrSrKWJxoANEUi9pPzjSJAw==" + "timestamp": "1970-01-01T00:00:04Z", + "signature": "VEo+CNnfMpbACDALmTmdgVljvugBj3TiH4kC1p2dT2tLS94luAOmB9psKeMVdcq3rbn2xwAUAH9x3Sn/6JDTBQ==" + }, + { + "block_id_flag": 2, + "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "timestamp": "1970-01-01T00:00:04Z", + "signature": "07NvNRtxhpFiZwpcKv0WSl/P/+fDSnTwsBQINAvzGRsWsF2kAQKhG1wEXjP+FXaFSSg6hjQWSF5GqgsD4w94Bw==" } ] } }, "validator_set": { "validators": [ + { + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { @@ -254,10 +272,10 @@ } ], "proposer": { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null @@ -286,7 +304,7 @@ } } }, - "now": "1970-01-01T00:00:05Z", + "now": "1970-01-01T00:23:20Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -299,13 +317,13 @@ }, "chain_id": "test-chain", "height": "2", - "time": "1970-01-01T00:00:02Z", + "time": "1970-01-01T00:00:03Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "next_validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", + "next_validators_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", + "consensus_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", "app_hash": "", "last_results_hash": null, "evidence_hash": null, @@ -315,15 +333,30 @@ "height": "2", "round": 1, "block_id": { - "hash": "47A20AAC962BEC23F44A912B15B2D2FB2E3806ECB33990E400E3E4BAB13FD4E0", - "parts": null + "hash": "D639D3CDB4C5919F4368A9F035ECB5211F1E5E7BC759D9CAEA86499842D2ECC4", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "UhhxviJ8Orwcf3K2l+kZUJbXVT0n5EBHFRD0tAtOE7sxRW2osvrnnnDrn7+OR9cjs7jEjhBHA9pqPGiZjE2BAg==" + "timestamp": "1970-01-01T00:00:03Z", + "signature": "21j4qzGjM4/rUVRee9mmb7iBLZJce7ga5GoyUQ8oM7ZQ5Mh/wikKHuW+QNkpUy1eiCexadbklzNtZWzzUW+XBg==" + }, + { + "block_id_flag": 2, + "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", + "timestamp": "1970-01-01T00:00:03Z", + "signature": "KmKhoCUZ9OuWjuNQVQZvua3dEANFO8mA96hlmXZjUmc0jx4zi6Z12yGqVUHv+i6qG6tmgC/mCg+SGEslN8YMBA==" + }, + { + "block_id_flag": 2, + "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "timestamp": "1970-01-01T00:00:03Z", + "signature": "zUBHDUWaXD4jjNY8rUiSz31hRnMmUrzvkj18wrws5NKpHUvYzcdyupwUyllI6T6mLy25gGXyU/mBJgjWBLxSDw==" } ] } @@ -338,6 +371,24 @@ }, "voting_power": "50", "proposer_priority": null + }, + { + "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + }, + "voting_power": "50", + "proposer_priority": null + }, + { + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + }, + "voting_power": "50", + "proposer_priority": null } ], "proposer": { @@ -353,29 +404,29 @@ "next_validator_set": { "validators": [ { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null }, { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null @@ -395,37 +446,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:05Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "next_validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", - "consensus_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", + "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "next_validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", + "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "81D85BE9567F7069A4760C663062E66660DADF34" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "6AD76EF8330ACD5B2A843B36E533DF64505A1095333453166359A399F9F8AAAA", - "parts": null + "hash": "D67533E0DAFB3715FEB042160B5B92D83FFF66612396F4C21BA0E44F5E9B32B3", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "Tw1wbIXq3eX8tYP++oTh7hjJLBHEFnjzpBusHvuueESgXDTDu9TijQJVXfVcnuZCwUZt2Ka9VCwaZoV5dRWeCA==" - }, - { - "block_id_flag": 2, - "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "ntk3NuonP1y/wpL+vRYTa/HMBtjy7A1QCzeh7vceTh5QUfjtq7hIFTE5+Sj8NwVtkX9W2siPcLKPK0KfLKiGAw==" + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:05Z", + "signature": "U7LI1fPPCnzo2A+lbedXTQRFWx3NassTtt84R5xIPDtk4wF9HBou9fN3bXYI4YsLITK6PZ4YozR82Sn/Sg/nCA==" } ] } @@ -433,29 +481,20 @@ "validator_set": { "validators": [ { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null @@ -463,15 +502,6 @@ }, "next_validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -492,17 +522,17 @@ } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:20Z", + "now": "1970-01-01T00:23:22Z", "verdict": "SUCCESS" } ] diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustSuccess.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustSuccess.tla index 0c76987b6..f3ddde223 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustSuccess.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test2NotEnoughTrustSuccess.tla @@ -9,41 +9,41 @@ TRUE (* Transition 0 to State2 *) State2 == -/\ Faulty = {"n4"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, - time |-> 3] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n3", "n4" }, + time |-> 5] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> { "n2", "n3" }, height |-> 5, - lastCommit |-> { "n2", "n3" }, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 6] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -52,44 +52,44 @@ State2 == :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" /\ nextHeight = 4 -/\ now = 5 +/\ now = 1398 /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ prevNow = 5 +/\ prevNow = 1398 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -99,114 +99,114 @@ State2 == (* Transition 1 to State3 *) State3 == -/\ Faulty = {"n4"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, - time |-> 3] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n3", "n4" }, + time |-> 5] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> { "n2", "n3" }, height |-> 5, - lastCommit |-> { "n2", "n3" }, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 6] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 4 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n3", "n4" }, + time |-> 5]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 5, + lastCommit |-> { "n3", "n4" }, + time |-> 5]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 4 :> "StateUnverified" /\ nextHeight = 3 -/\ now = 5 +/\ now = 1400 /\ nprobes = 1 -/\ prevCurrent = [Commits |-> { "n2", "n3" }, +/\ prevCurrent = [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] -/\ prevNow = 5 + lastCommit |-> { "n3", "n4" }, + time |-> 5]] +/\ prevNow = 1398 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -216,121 +216,121 @@ State3 == (* Transition 1 to State4 *) State4 == -/\ Faulty = {"n4"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, - time |-> 3] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n3", "n4" }, + time |-> 5] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> { "n2", "n3" }, height |-> 5, - lastCommit |-> { "n2", "n3" }, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 6] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 3 - :> [Commits |-> {"n4"}, + :> [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n4"}, - VS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4]] @@ 4 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n3", "n4" }, + time |-> 5]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 5, + lastCommit |-> { "n3", "n4" }, + time |-> 5]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n4"}, + [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n4"}, - VS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]], - now |-> 5, + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4]], + now |-> 1400, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -339,18 +339,18 @@ State4 == /\ nextHeight = 2 /\ now = 1400 /\ nprobes = 2 -/\ prevCurrent = [Commits |-> {"n4"}, +/\ prevCurrent = [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n4"}, - VS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]] -/\ prevNow = 5 + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4]] +/\ prevNow = 1400 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -360,171 +360,171 @@ State4 == (* Transition 3 to State5 *) State5 == -/\ Faulty = {"n4"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, - time |-> 3] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n3", "n4" }, + time |-> 5] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> { "n2", "n3" }, height |-> 5, - lastCommit |-> { "n2", "n3" }, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 6] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> {"n1"}, + :> [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]] @@ 3 - :> [Commits |-> {"n4"}, + :> [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n4"}, - VS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4]] @@ 4 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n3", "n4" }, + time |-> 5]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 5, + lastCommit |-> { "n3", "n4" }, + time |-> 5]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n4"}, + [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n4"}, - VS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]], - now |-> 5, + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4]], + now |-> 1400, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]], + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]], now |-> 1400, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] -/\ latestVerified = [Commits |-> {"n1"}, +/\ latestVerified = [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" /\ nextHeight = 4 -/\ now = 1400 +/\ now = 1402 /\ nprobes = 3 -/\ prevCurrent = [Commits |-> {"n1"}, +/\ prevCurrent = [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]] /\ prevNow = 1400 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -534,194 +534,194 @@ State5 == (* Transition 0 to State6 *) State6 == -/\ Faulty = {"n4"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3] @@ 3 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> {"n1"}, - time |-> 3] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n3", "n4" }, + time |-> 5] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3" }, + VS |-> { "n2", "n3" }, height |-> 5, - lastCommit |-> { "n2", "n3" }, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 6] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> {"n1"}, + :> [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]] @@ 3 - :> [Commits |-> {"n4"}, + :> [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n4"}, - VS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4]] @@ 4 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n3", "n4" }, + time |-> 5]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 5, + lastCommit |-> { "n3", "n4" }, + time |-> 5]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n4"}, + [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n4"}, - VS |-> {"n4"}, + VS |-> { "n3", "n4" }, height |-> 3, - lastCommit |-> { "n2", "n4" }, - time |-> 2]], - now |-> 5, + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 4]], + now |-> 1400, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]], + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]], now |-> 1400, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 4 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 1400, + lastCommit |-> { "n3", "n4" }, + time |-> 5]], + now |-> 1402, verdict |-> "SUCCESS", verified |-> - [Commits |-> {"n1"}, + [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]]] -/\ latestVerified = [Commits |-> { "n2", "n3" }, + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]]] +/\ latestVerified = [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n3", "n4" }, + time |-> 5]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateVerified" /\ nextHeight = 4 -/\ now = 1400 +/\ now = 1402 /\ nprobes = 4 -/\ prevCurrent = [Commits |-> { "n2", "n3" }, +/\ prevCurrent = [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n2", "n3" }, + [NextVS |-> { "n2", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] -/\ prevNow = 1400 + lastCommit |-> { "n3", "n4" }, + time |-> 5]] +/\ prevNow = 1402 /\ prevVerdict = "SUCCESS" -/\ prevVerified = [Commits |-> {"n1"}, +/\ prevVerified = [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]] /\ state = "finishedSuccess" (* The following formula holds true in the last state and violates the invariant *) @@ -735,5 +735,5 @@ InvariantViolation == /\ history[s2$2]["verdict"] = "NOT_ENOUGH_TRUST")))) ================================================================================ -\* Created by Apalache on Fri Sep 25 14:05:21 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:19:39 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustFailure.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustFailure.json index 8925c56ea..ce2b6ebc9 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustFailure.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustFailure.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_Test3NotEnoughTrustFailure.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -14,7 +14,7 @@ "last_commit_hash": null, "data_hash": null, "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", + "next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, @@ -25,48 +25,42 @@ "height": "1", "round": 1, "block_id": { - "hash": "F044F58B7F878646F25FDD75D120DC1E4C5F64DBDFE0C52D4A212F5C9043D994", - "parts": null + "hash": "037EDD75748E835B951090EA56AFBA5E537D6BCBFD8833450FFED37BCB947352", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "qkhVIFyVlzzwHD1NylpANRbyT6NM4Y+jqpODUNqIUGAuV3sYH5oTUIZ/FVjsIZEGyny0uBw3283haLOZl8JIBQ==" + "signature": "dyC/98kdQ9pBcjRMngvmxm4OJ5f1Ddzw/l8mT7V+G/uKuH3Il618O7YN40/ATTHtu517DFm+tsfHcDLY8KvgCg==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "LGRH8RlcOVExX8iBbRXbD2nmylLkYGYRmjp0pTBI/N/+dkGzEwCZn7g6cDUDr0b8TLIft7ltt07VDJP56HPCCA==" + "signature": "w/035jufehur92XKIpEV/ddEaGd8zNK1IBxyOeK6c4zSKDN65KTk83IoRUZorPxm5WdG3qpouGAjYZKXNGh1Ag==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "YQGHg6phuIXAR+n+TIWLSoog3DdG+BAugA4hwuJ6zFL70hpnNgZP/AoV3Vu9L8UVVBvS00mQq25WqOLdeKD3Cw==" + "signature": "CZGS/p05b+r0Y3py9tb2N6yQF1rxPhzdQwnm7XAldTqDBbVH9/6qSm+2N4pPrytM4RmooSX2WlDM+lKjyw7cBg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "APuTeabgsLEUn4QLeHfSbSTFxtmgZQ5vJmvsq0WvVu2RU8826WwQ2EPmXAz6Moy+PqiAULFdexNX37n9c3l2Dw==" + "signature": "idu2/K9v9auv81wUKZJHNUP1ke5AEFjVYwBYpdsglHJTI2WDd2O8u6c2Pg0O2ZDliiv7/ChM+snLAFKrrMs8Ag==" } ] } }, "next_validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -75,29 +69,20 @@ }, "voting_power": "50", "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null } }, "trusting_period": "1400000000000", - "now": "2020-09-25T12:59:36.770095880Z" + "now": "2020-10-07T14:20:45.1602080445Z" }, "input": [ { @@ -110,31 +95,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:05Z", + "time": "1970-01-01T00:00:04Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "next_validators_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", - "consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "next_validators_hash": "8F7563A251157673D3222D25CC728CE0C9D049A33D8776DC9A2465DEEEC4F5CD", + "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "D09C5AB58E1DADC1F90DCAABE76DA179D207FE2384CBBC2E9E6C0A3F2390A4C1", - "parts": null + "hash": "26EF377F2EFF5DAF0A8A654D23493FFBA28E5500139824A00527B5F2C0FEFCC5", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:05Z", - "signature": "Fr0vZXWjZgrcmBA2sv2hjuQQ9356UpX+ifrOnTbfu1G563CPRsUtG4Tfv9FAZlhYcfDqWnPQYvbzj7bXs9xeBw==" + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:04Z", + "signature": "a2Y4iKwhKuHCppACKu2F1LZYUKxQJ1NXPlXtk7C41zdyHDuhu5Dk7USIIJmmGLt9+iYg9XbKB//ao2/9ZV83BA==" } ] } @@ -142,20 +130,20 @@ "validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null @@ -164,36 +152,36 @@ "next_validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null }, { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:06Z", + "now": "1970-01-01T00:23:18Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -206,13 +194,13 @@ }, "chain_id": "test-chain", "height": "3", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:03Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", - "next_validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "consensus_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", + "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, "evidence_hash": null, @@ -222,27 +210,51 @@ "height": "3", "round": 1, "block_id": { - "hash": "E7022EAADFC742F16A8E571025ADE66774184D494793848FDF7B66958BE9D12E", - "parts": null + "hash": "D10E34B2FCD44BB14B6805C945903AEFA3C8A3E6895F36A7B013A69F743DC4ED", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "C+MMeR401JzRhlAN7jEotEps2/vXeCyJVJx9+34jaGBJbKMrHPSGarMZJhmuROfh4RlPsEDY9T3EKb2LRxk1CQ==" + "timestamp": "1970-01-01T00:00:03Z", + "signature": "+EdHuBQQ41ClCr4dSSJdYs8l4RafusybwdDRNki9V2U1A2xIxzheyy005Cr1N822C4EH/dQV27O0M/4iXO4xDA==" + }, + { + "block_id_flag": 2, + "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "timestamp": "1970-01-01T00:00:03Z", + "signature": "I1B5vGesLSVnYSMLTIITweGzQiN4bsZ0HxS2KThv7qnLA4j95UTnq3Hc0DygqGiH83K/9zjnrwOngyr7egdLCA==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "hxLO7Bu8XO1Get6FslewvL6+rROjbWY3YkFFWm4x7tLxBJfLdIKqv2Jc16f4Ar7FQF2sJhiTJCSiB50AhMTKBQ==" + "timestamp": "1970-01-01T00:00:03Z", + "signature": "ma5W2Jt1OcHLCqDEaIxNqAz8LLtXxo4xaIYFuxh5bcDYldiXdY4upSrO2c+4UaxTG4Yx2LEf3DbBYakCpGGLCw==" + }, + { + "block_id_flag": 1, + "validator_address": null, + "timestamp": null, + "signature": null } ] } }, "validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -252,6 +264,15 @@ "voting_power": "50", "proposer_priority": null }, + { + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { @@ -263,10 +284,10 @@ } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null @@ -275,27 +296,27 @@ "next_validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:06Z", + "now": "1970-01-01T00:23:18Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -312,54 +333,36 @@ "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", - "next_validators_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", - "consensus_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", + "validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "next_validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "consensus_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF" }, "commit": { "height": "2", "round": 1, "block_id": { - "hash": "24E2E43440884A32DD1657BA4DC17B5E6029BCAD6D63104E6C4E5AAF612B14D1", - "parts": null + "hash": "BFE673CD34975C4F9ECDC3111596018D6499A81E3C39EF512C2AB01433B40DD0", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ - { - "block_id_flag": 2, - "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "ZZFf7kxPxQ6J5Ax53vD4PRSmhr+jJoe7eLqYOkhPzESyQR/vVvfPyZ48TRE9QS3XlGQOUDgn+HN8M5wd+38LAg==" - }, - { - "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "MkULP5FYI4dptVuxHLFWYzDhd9YUycA4KqLuxEOP9f4L/NCPv/XPW9F6saNdHJsY29bRaRsePLH9n9iDbZdjAA==" - }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:02Z", - "signature": "aJAPtWKQArnlvykNaBtsgrMoiwSGiwff55fdFWZCOArvX6oMabA4MpZnO9UJuugGSvJ0/5UMgEjJSaOhA/QSCA==" + "signature": "8Yty3A8DBzcCRBIoH7JthqMBmS17X46pvMsA78DM7K19SpU9o0YyRUR3jspEdtM4EzoEyaoWjWwNnIzI5viCBQ==" } ] } }, "validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -368,22 +371,13 @@ }, "voting_power": "50", "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null @@ -391,6 +385,15 @@ }, "next_validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -400,6 +403,15 @@ "voting_power": "50", "proposer_priority": null }, + { + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { @@ -411,17 +423,17 @@ } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:20Z", + "now": "1970-01-01T00:23:18Z", "verdict": "SUCCESS" }, { @@ -434,31 +446,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:05Z", + "time": "1970-01-01T00:00:04Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "next_validators_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", - "consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "next_validators_hash": "8F7563A251157673D3222D25CC728CE0C9D049A33D8776DC9A2465DEEEC4F5CD", + "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "D09C5AB58E1DADC1F90DCAABE76DA179D207FE2384CBBC2E9E6C0A3F2390A4C1", - "parts": null + "hash": "26EF377F2EFF5DAF0A8A654D23493FFBA28E5500139824A00527B5F2C0FEFCC5", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:05Z", - "signature": "Fr0vZXWjZgrcmBA2sv2hjuQQ9356UpX+ifrOnTbfu1G563CPRsUtG4Tfv9FAZlhYcfDqWnPQYvbzj7bXs9xeBw==" + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:04Z", + "signature": "a2Y4iKwhKuHCppACKu2F1LZYUKxQJ1NXPlXtk7C41zdyHDuhu5Dk7USIIJmmGLt9+iYg9XbKB//ao2/9ZV83BA==" } ] } @@ -466,20 +481,20 @@ "validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null @@ -488,36 +503,36 @@ "next_validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null }, { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:20Z", + "now": "1970-01-01T00:23:19Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -530,13 +545,13 @@ }, "chain_id": "test-chain", "height": "3", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:03Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", - "next_validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "consensus_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", + "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, "evidence_hash": null, @@ -546,27 +561,51 @@ "height": "3", "round": 1, "block_id": { - "hash": "E7022EAADFC742F16A8E571025ADE66774184D494793848FDF7B66958BE9D12E", - "parts": null + "hash": "D10E34B2FCD44BB14B6805C945903AEFA3C8A3E6895F36A7B013A69F743DC4ED", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "C+MMeR401JzRhlAN7jEotEps2/vXeCyJVJx9+34jaGBJbKMrHPSGarMZJhmuROfh4RlPsEDY9T3EKb2LRxk1CQ==" + "timestamp": "1970-01-01T00:00:03Z", + "signature": "+EdHuBQQ41ClCr4dSSJdYs8l4RafusybwdDRNki9V2U1A2xIxzheyy005Cr1N822C4EH/dQV27O0M/4iXO4xDA==" + }, + { + "block_id_flag": 2, + "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "timestamp": "1970-01-01T00:00:03Z", + "signature": "I1B5vGesLSVnYSMLTIITweGzQiN4bsZ0HxS2KThv7qnLA4j95UTnq3Hc0DygqGiH83K/9zjnrwOngyr7egdLCA==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "hxLO7Bu8XO1Get6FslewvL6+rROjbWY3YkFFWm4x7tLxBJfLdIKqv2Jc16f4Ar7FQF2sJhiTJCSiB50AhMTKBQ==" + "timestamp": "1970-01-01T00:00:03Z", + "signature": "ma5W2Jt1OcHLCqDEaIxNqAz8LLtXxo4xaIYFuxh5bcDYldiXdY4upSrO2c+4UaxTG4Yx2LEf3DbBYakCpGGLCw==" + }, + { + "block_id_flag": 1, + "validator_address": null, + "timestamp": null, + "signature": null } ] } }, "validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -576,6 +615,15 @@ "voting_power": "50", "proposer_priority": null }, + { + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { @@ -587,10 +635,10 @@ } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null @@ -599,27 +647,27 @@ "next_validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:22Z", + "now": "1970-01-01T00:23:23Z", "verdict": "INVALID" } ] diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustFailure.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustFailure.tla index 6b3c77f25..64b02f007 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustFailure.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustFailure.tla @@ -11,39 +11,39 @@ TRUE State2 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n3", "n4" }, + VS |-> { "n1", "n3" }, height |-> 5, - lastCommit |-> {"n1"}, - time |-> 6] + lastCommit |-> {"n4"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -52,44 +52,44 @@ State2 == :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" /\ nextHeight = 4 -/\ now = 6 +/\ now = 1398 /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ prevNow = 6 +/\ prevNow = 1398 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -101,112 +101,112 @@ State2 == State3 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n3", "n4" }, + VS |-> { "n1", "n3" }, height |-> 5, - lastCommit |-> {"n1"}, - time |-> 6] + lastCommit |-> {"n4"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 4 - :> [Commits |-> {"n1"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]], - now |-> 6, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 4 :> "StateUnverified" /\ nextHeight = 3 -/\ now = 6 +/\ now = 1398 /\ nprobes = 1 -/\ prevCurrent = [Commits |-> {"n1"}, +/\ prevCurrent = [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]] -/\ prevNow = 6 + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]] +/\ prevNow = 1398 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -218,139 +218,139 @@ State3 == State4 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n3", "n4" }, + VS |-> { "n1", "n3" }, height |-> 5, - lastCommit |-> {"n1"}, - time |-> 6] + lastCommit |-> {"n4"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 3 - :> [Commits |-> { "n2", "n4" }, + :> [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]] + lastCommit |-> {"n3"}, + time |-> 3]] @@ 4 - :> [Commits |-> {"n1"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]], - now |-> 6, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> { "n2", "n4" }, + [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]], - now |-> 6, + lastCommit |-> {"n3"}, + time |-> 3]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" /\ nextHeight = 2 -/\ now = 1400 +/\ now = 1398 /\ nprobes = 2 -/\ prevCurrent = [Commits |-> { "n2", "n4" }, +/\ prevCurrent = [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]] -/\ prevNow = 6 + lastCommit |-> {"n3"}, + time |-> 3]] +/\ prevNow = 1398 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -362,169 +362,169 @@ State4 == State5 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n3", "n4" }, + VS |-> { "n1", "n3" }, height |-> 5, - lastCommit |-> {"n1"}, - time |-> 6] + lastCommit |-> {"n4"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n1", "n3", "n4" }, + :> [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] @@ 3 - :> [Commits |-> { "n2", "n4" }, + :> [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]] + lastCommit |-> {"n3"}, + time |-> 3]] @@ 4 - :> [Commits |-> {"n1"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]], - now |-> 6, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> { "n2", "n4" }, + [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]], - now |-> 6, + lastCommit |-> {"n3"}, + time |-> 3]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n1", "n3", "n4" }, + [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]], - now |-> 1400, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] -/\ latestVerified = [Commits |-> { "n1", "n3", "n4" }, +/\ latestVerified = [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" /\ nextHeight = 4 -/\ now = 1400 +/\ now = 1399 /\ nprobes = 3 -/\ prevCurrent = [Commits |-> { "n1", "n3", "n4" }, +/\ prevCurrent = [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] -/\ prevNow = 1400 +/\ prevNow = 1398 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -536,191 +536,191 @@ State5 == State6 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n3", "n4" }, + VS |-> { "n1", "n3" }, height |-> 5, - lastCommit |-> {"n1"}, - time |-> 6] + lastCommit |-> {"n4"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n1", "n3", "n4" }, + :> [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] @@ 3 - :> [Commits |-> { "n2", "n4" }, + :> [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]] + lastCommit |-> {"n3"}, + time |-> 3]] @@ 4 - :> [Commits |-> {"n1"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]], - now |-> 6, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> { "n2", "n4" }, + [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]], - now |-> 6, + lastCommit |-> {"n3"}, + time |-> 3]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n1", "n3", "n4" }, + [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]], - now |-> 1400, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 4 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]], - now |-> 1400, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]], + now |-> 1399, verdict |-> "NOT_ENOUGH_TRUST", verified |-> - [Commits |-> { "n1", "n3", "n4" }, + [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]]] -/\ latestVerified = [Commits |-> { "n1", "n3", "n4" }, +/\ latestVerified = [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" /\ nextHeight = 3 -/\ now = 1402 +/\ now = 1403 /\ nprobes = 4 -/\ prevCurrent = [Commits |-> {"n1"}, +/\ prevCurrent = [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]] -/\ prevNow = 1400 + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]] +/\ prevNow = 1399 /\ prevVerdict = "NOT_ENOUGH_TRUST" -/\ prevVerified = [Commits |-> { "n1", "n3", "n4" }, +/\ prevVerified = [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] /\ state = "working" @@ -729,210 +729,210 @@ State6 == State7 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n3", "n4" }, + VS |-> { "n1", "n3" }, height |-> 5, - lastCommit |-> {"n1"}, - time |-> 6] + lastCommit |-> {"n4"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n1", "n3", "n4" }, + :> [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] @@ 3 - :> [Commits |-> { "n2", "n4" }, + :> [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]] + lastCommit |-> {"n3"}, + time |-> 3]] @@ 4 - :> [Commits |-> {"n1"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]] + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]], - now |-> 6, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> { "n2", "n4" }, + [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]], - now |-> 6, + lastCommit |-> {"n3"}, + time |-> 3]], + now |-> 1398, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n1", "n3", "n4" }, + [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]], - now |-> 1400, + now |-> 1398, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n3", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 4 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> {"n1"}, + [NextVS |-> { "n1", "n3" }, + VS |-> {"n4"}, height |-> 4, - lastCommit |-> { "n2", "n4" }, - time |-> 5]], - now |-> 1400, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 4]], + now |-> 1399, verdict |-> "NOT_ENOUGH_TRUST", verified |-> - [Commits |-> { "n1", "n3", "n4" }, + [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]]] @@ 5 :> [current |-> - [Commits |-> { "n2", "n4" }, + [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]], - now |-> 1402, + lastCommit |-> {"n3"}, + time |-> 3]], + now |-> 1403, verdict |-> "INVALID", verified |-> - [Commits |-> { "n1", "n3", "n4" }, + [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]]] -/\ latestVerified = [Commits |-> { "n1", "n3", "n4" }, +/\ latestVerified = [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateFailed" @@ 4 :> "StateUnverified" /\ nextHeight = 3 -/\ now = 1402 +/\ now = 1403 /\ nprobes = 5 -/\ prevCurrent = [Commits |-> { "n2", "n4" }, +/\ prevCurrent = [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n2", "n4" }, + [NextVS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 4]] -/\ prevNow = 1402 + lastCommit |-> {"n3"}, + time |-> 3]] +/\ prevNow = 1403 /\ prevVerdict = "INVALID" -/\ prevVerified = [Commits |-> { "n1", "n3", "n4" }, +/\ prevVerified = [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n2", "n4" }, - VS |-> { "n1", "n3", "n4" }, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 2]] /\ state = "finishedFailure" @@ -949,5 +949,5 @@ InvariantViolation == /\ history[s3$2]["verdict"] = "NOT_ENOUGH_TRUST")))))) ================================================================================ -\* Created by Apalache on Fri Sep 25 14:59:36 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:20:45 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustSuccess.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustSuccess.json index 62562dea1..d6fb6c1fd 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustSuccess.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustSuccess.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_Test3NotEnoughTrustSuccess.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -14,7 +14,7 @@ "last_commit_hash": null, "data_hash": null, "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "next_validators_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, @@ -25,33 +25,36 @@ "height": "1", "round": 1, "block_id": { - "hash": "A1227FA5ABACADB137F59906C4A604E806190C9991D6D965C50BED0D28CA8375", - "parts": null + "hash": "54BD5EF1D284E0C21E1F1B36CC355275D7394B39F8AF10837D680EB32C7D776D", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "6pKtB84HEN/nVin25bXP3LrYtn+w1QtYC3+jWjo0bAZrDVVRjpr6u0AHmkHNIjpDCBZwPxoc3Lrpe6bkckc2Dw==" + "signature": "GgOVVVxrRwdFob0atNnPys0fJ8l/xcvknvsJxtgeiShup8aIgZJd445J976JtLBbWgoTBhCfY7Hyc9YnScwPCA==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "iYdpbTw2CanDKKHE0JUNa4a8DPkvZAwXFI2jvgUw9Wy4MKof8dnQGWUc7idLnU1AqCJRq31jokYx5uS1GJklAw==" + "signature": "u76LJKtjHSF8GPayHDDhGfowGpXLHxMLg4KS0S0QTL2eWxAAH5LgAD1Tz80W8Vr/U458ZLppU9J6QvEB5CIrAg==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "z86oIuIYg6wDVqN4u16Oxn9zybsfQmmwzGkhTU7x4y9Z9QaXBV1S7fIYVB7xIoljCc+IBufyg5c1aaCFa0ncCQ==" + "signature": "ZpOcjQDpiFdI3xYpuIw5kGUzU7kyLLs+jfXDFzgxTGHQbWT/+HmL2chLUM1Fq2p9aNdAhWcFNhnnBh6NH7/nAg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "71uebWj6TqfykfaVTew96byLAPw6X7memRyWoHNqtQQV7F3eThTZtRTsZdFwhxl5qYl+/5MbZbX1lYer8SL1Dw==" + "signature": "cTzFxyrl1j2C7P/y5qN850JFbxZmHCiva6cY9NYQXahZ4cvnQchkQLvoCnE+jMDQKddDMySQLNGoI/AKb/2sCQ==" } ] } @@ -67,15 +70,6 @@ "voting_power": "50", "proposer_priority": null }, - { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -106,7 +100,7 @@ } }, "trusting_period": "1400000000000", - "now": "2020-09-25T12:59:18.482479128Z" + "now": "2020-10-07T14:20:21.1602080421Z" }, "input": [ { @@ -119,31 +113,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:06Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", - "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", - "consensus_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "next_validators_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", + "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "5DBF7A9A5E9D6C6FC111C041E7BE0019AD09568C2406FC82BAED700C8EB99940", - "parts": null + "hash": "6B7DFF67CD01C0AD7132845B00D3BA18CC909384B80DA6DD5FA6F91B4398C1D0", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "2ttq/1XYCdzEnR8hxX4HHXQ5VLN4Mzb8vgCvbRvlfEtOSm92UmBEd3cAXAY9/9HU7XvyxeFli5eGtSo4j+d9Dg==" + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:06Z", + "signature": "OokXT2v9ItLVTfVoPuNL5ld3ZQdj4mmrlsHDpmpKnhc/uX+TlGv2QtRCiYxkyFKbbvbBPzX52gfn7+dfRj0LAw==" } ] } @@ -151,20 +148,20 @@ "validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null @@ -172,6 +169,15 @@ }, "next_validator_set": { "validators": [ + { + "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { @@ -183,17 +189,17 @@ } ], "proposer": { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:05Z", + "now": "1970-01-01T00:00:07Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -206,12 +212,12 @@ }, "chain_id": "test-chain", "height": "3", - "time": "1970-01-01T00:00:03Z", + "time": "1970-01-01T00:00:05Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, "validators_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", - "next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "consensus_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", "app_hash": "", "last_results_hash": null, @@ -222,15 +228,18 @@ "height": "3", "round": 1, "block_id": { - "hash": "704A3FD15FFD48113CC0434DAEC6E5A6AD16AC01891DCD674DE366681A1F6E03", - "parts": null + "hash": "11B82BD3F66BCAB87DAF14E2B56CDEE6E8ED044BA40534BDC97404F997776313", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:03Z", - "signature": "+wvPdExMDYIriZCSEHmhiyte4moNGxlOmFgIFckgC4jM882PCXtE5Zj7G04lgG3Y2Pp3pn70vLxm1W3MELgUCg==" + "timestamp": "1970-01-01T00:00:05Z", + "signature": "v32IyC2igxhJcG+sk8yqw9yMwuz/nxgJG/fbGkTZ1ZOMeYwrtfSRGNsJAqg82YLaAvab6KR3IC6quAd1V2jYDw==" } ] } @@ -260,27 +269,27 @@ "next_validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:06Z", + "now": "1970-01-01T00:00:07Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -293,13 +302,13 @@ }, "chain_id": "test-chain", "height": "2", - "time": "1970-01-01T00:00:02Z", + "time": "1970-01-01T00:00:03Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "validators_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", "next_validators_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", - "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "consensus_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", "app_hash": "", "last_results_hash": null, "evidence_hash": null, @@ -309,33 +318,30 @@ "height": "2", "round": 1, "block_id": { - "hash": "5BFF77E161A625A9D1AEE8B0D5F4BEA742DA2C22F796D5E23DE65D705453ED10", - "parts": null + "hash": "1302ECEB6D8AB030E1F9F30EAA22DABE2EB7ADB950ADF61DB79F6A7DB99F3B52", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "z6ymLMn3TjzaPqb3JBnNzAbdnctrrgVXQJdM7fo/WXt8ruXrUGPFI/geZ2oi02qa7WRgP0SETBWWF41oMNH+BA==" - }, - { - "block_id_flag": 1, - "validator_address": null, - "timestamp": null, - "signature": null + "timestamp": "1970-01-01T00:00:03Z", + "signature": "TpVzPdPEDnY2iRhaWQLnJRWlk4bhD7gW+9j9Kj5u58GokYKYUI1yNb7alcm/Ac5/BqbxTn9Gg1qW5q5EXrxcAQ==" }, { "block_id_flag": 2, - "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "Dfp8WG+b+zWSL0dv0BrYpzmmtRmO6/eF9mGbD4epwOj9akqS+YMSWGf7oMB4k39yf0tArDO6mSDJZy+ZimdFCw==" + "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "timestamp": "1970-01-01T00:00:03Z", + "signature": "cJ79/g3kvbq+3l+904jR8hAFn9pRsJq+i7lqMb2ZfpIRYtZYoWqJdRpvrHWjieWbPw3RWLoczRH+5dE63V1TDg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "XG8fbt/TLoBTzy8bSTCZ444rGqe2k9i400IfBrG8lIv+61w1UxS0L3IofSUqvMeYwtMkv9ZFye0UpvqQaFJ2DQ==" + "timestamp": "1970-01-01T00:00:03Z", + "signature": "B/5ihARgS/g4tvxlMJAlih6tqBav6ID9+JByAkpukKaN3lUSJpS+XM6PySS2oo6MW8gLo4ETW9b/70USX2SDBA==" } ] } @@ -351,15 +357,6 @@ "voting_power": "50", "proposer_priority": null }, - { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -412,7 +409,7 @@ } } }, - "now": "1970-01-01T00:00:07Z", + "now": "1970-01-01T00:00:08Z", "verdict": "SUCCESS" }, { @@ -425,31 +422,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:06Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", - "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", - "consensus_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "next_validators_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", + "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "5DBF7A9A5E9D6C6FC111C041E7BE0019AD09568C2406FC82BAED700C8EB99940", - "parts": null + "hash": "6B7DFF67CD01C0AD7132845B00D3BA18CC909384B80DA6DD5FA6F91B4398C1D0", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "2ttq/1XYCdzEnR8hxX4HHXQ5VLN4Mzb8vgCvbRvlfEtOSm92UmBEd3cAXAY9/9HU7XvyxeFli5eGtSo4j+d9Dg==" + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:06Z", + "signature": "OokXT2v9ItLVTfVoPuNL5ld3ZQdj4mmrlsHDpmpKnhc/uX+TlGv2QtRCiYxkyFKbbvbBPzX52gfn7+dfRj0LAw==" } ] } @@ -457,20 +457,20 @@ "validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null @@ -478,6 +478,15 @@ }, "next_validator_set": { "validators": [ + { + "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { @@ -489,17 +498,17 @@ } ], "proposer": { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:07Z", + "now": "1970-01-01T00:00:08Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -512,12 +521,12 @@ }, "chain_id": "test-chain", "height": "3", - "time": "1970-01-01T00:00:03Z", + "time": "1970-01-01T00:00:05Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, "validators_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", - "next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "consensus_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", "app_hash": "", "last_results_hash": null, @@ -528,15 +537,18 @@ "height": "3", "round": 1, "block_id": { - "hash": "704A3FD15FFD48113CC0434DAEC6E5A6AD16AC01891DCD674DE366681A1F6E03", - "parts": null + "hash": "11B82BD3F66BCAB87DAF14E2B56CDEE6E8ED044BA40534BDC97404F997776313", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:03Z", - "signature": "+wvPdExMDYIriZCSEHmhiyte4moNGxlOmFgIFckgC4jM882PCXtE5Zj7G04lgG3Y2Pp3pn70vLxm1W3MELgUCg==" + "timestamp": "1970-01-01T00:00:05Z", + "signature": "v32IyC2igxhJcG+sk8yqw9yMwuz/nxgJG/fbGkTZ1ZOMeYwrtfSRGNsJAqg82YLaAvab6KR3IC6quAd1V2jYDw==" } ] } @@ -566,27 +578,27 @@ "next_validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:08Z", + "now": "1970-01-01T00:23:22Z", "verdict": "SUCCESS" }, { @@ -599,31 +611,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:06Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", - "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", - "consensus_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "next_validators_hash": "2B141A0A08B7EF0A65BC5F4D92F00BDEF0279124DEAC497BEF4C4336D0A3CE6F", + "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "5DBF7A9A5E9D6C6FC111C041E7BE0019AD09568C2406FC82BAED700C8EB99940", - "parts": null + "hash": "6B7DFF67CD01C0AD7132845B00D3BA18CC909384B80DA6DD5FA6F91B4398C1D0", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "2ttq/1XYCdzEnR8hxX4HHXQ5VLN4Mzb8vgCvbRvlfEtOSm92UmBEd3cAXAY9/9HU7XvyxeFli5eGtSo4j+d9Dg==" + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:06Z", + "signature": "OokXT2v9ItLVTfVoPuNL5ld3ZQdj4mmrlsHDpmpKnhc/uX+TlGv2QtRCiYxkyFKbbvbBPzX52gfn7+dfRj0LAw==" } ] } @@ -631,20 +646,20 @@ "validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null @@ -652,6 +667,15 @@ }, "next_validator_set": { "validators": [ + { + "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { @@ -663,17 +687,17 @@ } ], "proposer": { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:08Z", + "now": "1970-01-01T00:23:24Z", "verdict": "SUCCESS" } ] diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustSuccess.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustSuccess.tla index 7276ee338..6e68a8e2c 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustSuccess.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_Test3NotEnoughTrustSuccess.tla @@ -11,39 +11,39 @@ TRUE State2 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 :> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3] @@ 3 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5] @@ 4 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4] + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n2", "n4" }, height |-> 5, - lastCommit |-> {"n3"}, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -52,44 +52,44 @@ State2 == :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" /\ nextHeight = 4 -/\ now = 5 +/\ now = 7 /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ prevNow = 5 +/\ prevNow = 7 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -101,112 +101,112 @@ State2 == State3 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 :> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3] @@ 3 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5] @@ 4 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4] + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n2", "n4" }, height |-> 5, - lastCommit |-> {"n3"}, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 4 - :> [Commits |-> {"n3"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 5, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 4 :> "StateUnverified" /\ nextHeight = 3 -/\ now = 6 +/\ now = 7 /\ nprobes = 1 -/\ prevCurrent = [Commits |-> {"n3"}, +/\ prevCurrent = [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] -/\ prevNow = 5 + time |-> 6]] +/\ prevNow = 7 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -218,39 +218,39 @@ State3 == State4 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 :> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3] @@ 3 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5] @@ 4 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4] + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n2", "n4" }, height |-> 5, - lastCommit |-> {"n3"}, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -258,53 +258,53 @@ State4 == @@ 3 :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] @@ 4 - :> [Commits |-> {"n3"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 5, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -313,44 +313,44 @@ State4 == :> [current |-> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]], - now |-> 6, + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" /\ nextHeight = 2 -/\ now = 7 +/\ now = 8 /\ nprobes = 2 /\ prevCurrent = [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] -/\ prevNow = 6 + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] +/\ prevNow = 7 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -362,101 +362,101 @@ State4 == State5 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 :> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3] @@ 3 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5] @@ 4 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4] + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n2", "n4" }, height |-> 5, - lastCommit |-> {"n3"}, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n2", "n3", "n4" }, + :> [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] @@ 3 :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] @@ 4 - :> [Commits |-> {"n3"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 5, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -465,66 +465,66 @@ State5 == :> [current |-> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]], - now |-> 6, + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]], - now |-> 7, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]], + now |-> 8, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] -/\ latestVerified = [Commits |-> { "n2", "n3", "n4" }, +/\ latestVerified = [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" /\ nextHeight = 4 -/\ now = 7 +/\ now = 8 /\ nprobes = 3 -/\ prevCurrent = [Commits |-> { "n2", "n3", "n4" }, +/\ prevCurrent = [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] -/\ prevNow = 7 + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] +/\ prevNow = 8 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -536,101 +536,101 @@ State5 == State6 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 :> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3] @@ 3 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5] @@ 4 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4] + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n2", "n4" }, height |-> 5, - lastCommit |-> {"n3"}, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n2", "n3", "n4" }, + :> [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] @@ 3 :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] @@ 4 - :> [Commits |-> {"n3"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 5, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -639,89 +639,89 @@ State6 == :> [current |-> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]], - now |-> 6, + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]], - now |-> 7, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]], + now |-> 8, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 4 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 7, + time |-> 6]], + now |-> 8, verdict |-> "NOT_ENOUGH_TRUST", verified |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]]] -/\ latestVerified = [Commits |-> { "n2", "n3", "n4" }, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]]] +/\ latestVerified = [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" /\ nextHeight = 3 -/\ now = 8 +/\ now = 1402 /\ nprobes = 4 -/\ prevCurrent = [Commits |-> {"n3"}, +/\ prevCurrent = [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] -/\ prevNow = 7 + time |-> 6]] +/\ prevNow = 8 /\ prevVerdict = "NOT_ENOUGH_TRUST" -/\ prevVerified = [Commits |-> { "n2", "n3", "n4" }, +/\ prevVerified = [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] /\ state = "working" (* Transition 0 to State7 *) @@ -729,101 +729,101 @@ State6 == State7 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 :> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3] @@ 3 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5] @@ 4 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4] + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n2", "n4" }, height |-> 5, - lastCommit |-> {"n3"}, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n2", "n3", "n4" }, + :> [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] @@ 3 :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] @@ 4 - :> [Commits |-> {"n3"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 5, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -832,108 +832,108 @@ State7 == :> [current |-> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]], - now |-> 6, + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]], - now |-> 7, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]], + now |-> 8, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 4 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 7, + time |-> 6]], + now |-> 8, verdict |-> "NOT_ENOUGH_TRUST", verified |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]]] @@ 5 :> [current |-> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]], - now |-> 8, + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]], + now |-> 1402, verdict |-> "SUCCESS", verified |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]]] /\ latestVerified = [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateVerified" @@ 4 :> "StateUnverified" /\ nextHeight = 4 -/\ now = 8 +/\ now = 1404 /\ nprobes = 5 /\ prevCurrent = [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] -/\ prevNow = 8 + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] +/\ prevNow = 1402 /\ prevVerdict = "SUCCESS" -/\ prevVerified = [Commits |-> { "n2", "n3", "n4" }, +/\ prevVerified = [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] /\ state = "working" (* Transition 0 to State8 *) @@ -941,101 +941,101 @@ State7 == State8 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 :> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3] @@ 3 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5] @@ 4 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4] + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n2", "n4" }, height |-> 5, - lastCommit |-> {"n3"}, - time |-> 5] + lastCommit |-> {"n4"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n2", "n3", "n4" }, + :> [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]] @@ 3 :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] @@ 4 - :> [Commits |-> {"n3"}, + :> [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 5, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 5, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -1044,127 +1044,127 @@ State8 == :> [current |-> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]], - now |-> 6, + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]], - now |-> 7, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]], + now |-> 8, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 4 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 7, + time |-> 6]], + now |-> 8, verdict |-> "NOT_ENOUGH_TRUST", verified |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]]] @@ 5 :> [current |-> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]], - now |-> 8, + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]], + now |-> 1402, verdict |-> "SUCCESS", verified |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n1", "n3", "n4" }, header |-> [NextVS |-> {"n2"}, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 3]]] @@ 6 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]], - now |-> 8, + time |-> 6]], + now |-> 1404, verdict |-> "SUCCESS", verified |-> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]]] -/\ latestVerified = [Commits |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]]] +/\ latestVerified = [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] + time |-> 6]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateVerified" @@ 4 :> "StateVerified" /\ nextHeight = 4 -/\ now = 8 +/\ now = 1404 /\ nprobes = 6 -/\ prevCurrent = [Commits |-> {"n3"}, +/\ prevCurrent = [Commits |-> {"n4"}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n3"}, + [NextVS |-> { "n2", "n4" }, + VS |-> {"n4"}, height |-> 4, lastCommit |-> {"n2"}, - time |-> 4]] -/\ prevNow = 8 + time |-> 6]] +/\ prevNow = 1404 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> {"n4"}, VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 3]] + lastCommit |-> { "n1", "n3", "n4" }, + time |-> 5]] /\ state = "finishedSuccess" (* The following formula holds true in the last state and violates the invariant *) @@ -1180,5 +1180,5 @@ InvariantViolation == /\ history[s3$2]["verdict"] = "NOT_ENOUGH_TRUST")))))) ================================================================================ -\* Created by Apalache on Fri Sep 25 14:59:18 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:20:21 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestFailure.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestFailure.json index 2eb0cc509..2dfc5ece4 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestFailure.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestFailure.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_TestFailure.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -14,7 +14,7 @@ "last_commit_hash": null, "data_hash": null, "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "5F7419DA4B1BCFC2D2EB8C663405D9FF67DDE3BF88DB0A8A5D579E6FF1AD814E", + "next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, @@ -25,33 +25,36 @@ "height": "1", "round": 1, "block_id": { - "hash": "1973C202D9C2330B4DA1AFEC6E0F7365102BCED56D5E3FEEB5B0A1A0A94A587D", - "parts": null + "hash": "037EDD75748E835B951090EA56AFBA5E537D6BCBFD8833450FFED37BCB947352", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "0XfqibgwjAen6HKjiPRh4Zth0yaPhElCzAzcBNRenXvRPofYtsREvcAT5n9Igvjj2Nh833ZyQ/7aKlM4vt7CDg==" + "signature": "dyC/98kdQ9pBcjRMngvmxm4OJ5f1Ddzw/l8mT7V+G/uKuH3Il618O7YN40/ATTHtu517DFm+tsfHcDLY8KvgCg==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "mhpKma0IWrq1Bv9z6xLtVJt1+Kq0IR+BvYfWvP5zdMAKw34+GTrZZLL6JEa1L85gaO78ahuBR2xcSt5RLp/0CA==" + "signature": "w/035jufehur92XKIpEV/ddEaGd8zNK1IBxyOeK6c4zSKDN65KTk83IoRUZorPxm5WdG3qpouGAjYZKXNGh1Ag==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "eneQdcJC9vcZuergm+N8oZCvWA6TIiRH8jIbU3lO6OqsPFdBCq40vK/MhAndMmAdzjcxrQr4V4dHNInD/vRWBQ==" + "signature": "CZGS/p05b+r0Y3py9tb2N6yQF1rxPhzdQwnm7XAldTqDBbVH9/6qSm+2N4pPrytM4RmooSX2WlDM+lKjyw7cBg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "6OMKjuZuXqdim4AIYPUZs2cjYfTpdekDg9tQo1s5BxmyYlwCvPB2o9u1qTwQOND5TPg5VEnTt88WXgqS+rISBQ==" + "signature": "idu2/K9v9auv81wUKZJHNUP1ke5AEFjVYwBYpdsglHJTI2WDd2O8u6c2Pg0O2ZDliiv7/ChM+snLAFKrrMs8Ag==" } ] } @@ -59,45 +62,27 @@ "next_validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null } }, "trusting_period": "1400000000000", - "now": "2020-09-25T12:05:08.634698330Z" + "now": "2020-10-07T14:19:26.1602080366Z" }, "input": [ { @@ -110,37 +95,40 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:05Z", + "time": "1970-01-01T00:00:04Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", - "next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", - "consensus_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", + "validators_hash": "E624CE5E2693812E58E8DBB64C7A05149A58157114D34F08CB5992FE2BECC0A7", + "next_validators_hash": "E624CE5E2693812E58E8DBB64C7A05149A58157114D34F08CB5992FE2BECC0A7", + "consensus_hash": "E624CE5E2693812E58E8DBB64C7A05149A58157114D34F08CB5992FE2BECC0A7", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "37F9DD5CC10581FA1551D51801799CF1682BBAF6A1795D82E40C8671331F662F", - "parts": null + "hash": "0A187BC8F4371F2A905EB9206BC5A9619D8EA8FA9E410AD4E127330C9D1CDEEB", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:05Z", - "signature": "tfx6Hdc2pzMHO6D++cwkx6eJFhoCjkWDBZErdxoRtpgRwQx1gJVgQUF8/IySOGn2Vn1a1t6P0itVwUc2afxDBA==" + "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "timestamp": "1970-01-01T00:00:04Z", + "signature": "iO7Exvq3qiBaHMkUAA6NzB1ksQRvBnyx7NM4dqxjnyrmR7mwFPlYeFs4qGquqpXeidw/Oc27h9EjRyhuT8VtCw==" }, { "block_id_flag": 2, - "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:05Z", - "signature": "dn8skO6fhJzEXzAJx0O+4SGonLv0wCUa5dwObJv+3b9RYCVSxaHDIAQ8fKMqiu2JGSyw4ge9eUMrDFMaMCw8Cg==" + "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", + "timestamp": "1970-01-01T00:00:04Z", + "signature": "2JZ20Ks2rzOkrSS10wELlJqhG+Gq5pKBeJhuYO73VxND10BYd/bmnEYMpw9ZNosO/HJNPlzZrLRoMTjLPnS4AQ==" } ] } @@ -148,29 +136,29 @@ "validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null }, { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null @@ -179,27 +167,36 @@ "next_validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, + { + "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:18Z", + "now": "1970-01-01T00:00:05Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -211,59 +208,41 @@ "app": "0" }, "chain_id": "test-chain", - "height": "2", + "height": "3", "time": "1970-01-01T00:00:03Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "5F7419DA4B1BCFC2D2EB8C663405D9FF67DDE3BF88DB0A8A5D579E6FF1AD814E", - "next_validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "consensus_hash": "5F7419DA4B1BCFC2D2EB8C663405D9FF67DDE3BF88DB0A8A5D579E6FF1AD814E", + "validators_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", + "next_validators_hash": "E624CE5E2693812E58E8DBB64C7A05149A58157114D34F08CB5992FE2BECC0A7", + "consensus_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "81D85BE9567F7069A4760C663062E66660DADF34" }, "commit": { - "height": "2", + "height": "3", "round": 1, "block_id": { - "hash": "0227F2A3F368B147AE7DAFB5A6F0EF3727A3ABA8C8A4358CFBBB0950CBCE87DA", - "parts": null + "hash": "C269BB8E62E3D3C39E9F3AC031594CEFF7DA0CCADE118760D41DBCC648FC6FB8", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ - { - "block_id_flag": 2, - "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:03Z", - "signature": "6MsSX9qr8kCdOvK5fHaaMQsKJS8xBtTDXJI32r43n+jr2Rh4rQqDF2R9OsXHFIW6RD5Apyjek93SfPciXz7OCg==" - }, - { - "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:03Z", - "signature": "BHmfDcAvlecpn4Ace6rb0tc33U+gJJa68+mn3sV/vDHGPqTf/avdqngmHEaDttlzMGKNRIsu9CrRzjc1P83DBQ==" - }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:03Z", - "signature": "hnkM9wMZA3VM2BnBqgBB4YaFNGBFkCaY+rDMY3CzHEwo7vHpxMAdaP2d7AngMDS7kCotu7jKB0POs7AnWYVWDQ==" + "signature": "ZKwiRr7lpXPtiC8ckbsEu/Aqw3UGDXOim0AxaEK+Npe/j6T19QsPSm0Hi8+cdU8q/xL1I3/SGD1HzR4QSiGVDw==" } ] } }, "validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -272,22 +251,13 @@ }, "voting_power": "50", "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null @@ -312,24 +282,6 @@ }, "voting_power": "50", "proposer_priority": null - }, - { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null } ], "proposer": { @@ -343,8 +295,8 @@ } } }, - "now": "1970-01-01T00:23:18Z", - "verdict": "SUCCESS" + "now": "1970-01-01T00:00:05Z", + "verdict": "NOT_ENOUGH_TRUST" }, { "block": { @@ -355,74 +307,41 @@ "app": "0" }, "chain_id": "test-chain", - "height": "3", - "time": "1970-01-01T00:00:04Z", + "height": "2", + "time": "1970-01-01T00:00:02Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", - "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "next_validators_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", + "consensus_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF" }, "commit": { - "height": "3", + "height": "2", "round": 1, "block_id": { - "hash": "7B50ED6FE2C26B6194175462AA284CD7E21AE6BABD10A77FFCD4D005E9BD8876", - "parts": null + "hash": "BA8BCA0EEEA2CF3D47560EE4DB39D3329EB16F156C5F25C0248B3F5B40E693E6", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ - { - "block_id_flag": 2, - "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "k7RjY2Ayk4f2CGIZ6NZ/Ly4FTuATSonJ9F9azWUvW/zqAEGUcs/CzxdoE9QfRlV2ute7ZV8ZrxU7wgyuizZTBQ==" - }, - { - "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "mpSnGLm6qb0OvXj0bu+t32YRPa44yDMz51U2Ii2iXOxlFD1WCR8rkp/9cOP/aX5+0RFbDMn2cBPPRX93kmH4BQ==" - }, - { - "block_id_flag": 1, - "validator_address": null, - "timestamp": null, - "signature": null - }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "2LDtv5dUpXTuzpkLOlUHTpHne54qdwVsHwdhftGYj2ycqylEMJzzQOEY+dtXulWNB70ImL9lC/wJAdPRb97WCA==" + "timestamp": "1970-01-01T00:00:02Z", + "signature": "HoGiINR7+OMhkn9tacVFncJ2pVjGIatSkPA0NoCrxk90BBwo2ZW4dZ5achMQ5W6KmpNQtaCfby/bpWm3KBFgBQ==" } ] } }, "validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -431,22 +350,13 @@ }, "voting_power": "50", "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null @@ -455,36 +365,27 @@ "next_validator_set": { "validators": [ { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:23Z", + "now": "1970-01-01T00:23:22Z", "verdict": "INVALID" } ] diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestFailure.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestFailure.tla index a42582afc..894a6068e 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestFailure.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestFailure.tla @@ -11,39 +11,39 @@ TRUE State2 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, + :> [NextVS |-> {"n2"}, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n2", "n4" }, + time |-> 2] @@ 3 - :> [NextVS |-> { "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + :> [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n3"}, + VS |-> { "n1", "n2" }, height |-> 5, - lastCommit |-> { "n3", "n4" }, - time |-> 6] + lastCommit |-> { "n1", "n2" }, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -52,44 +52,44 @@ State2 == :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1398, + now |-> 5, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" /\ nextHeight = 4 -/\ now = 1398 +/\ now = 5 /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ prevNow = 1398 +/\ prevNow = 5 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -101,256 +101,256 @@ State2 == State3 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, + :> [NextVS |-> {"n2"}, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n2", "n4" }, + time |-> 2] @@ 3 - :> [NextVS |-> { "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + :> [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n3"}, + VS |-> { "n1", "n2" }, height |-> 5, - lastCommit |-> { "n3", "n4" }, - time |-> 6] + lastCommit |-> { "n1", "n2" }, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 4 - :> [Commits |-> { "n3", "n4" }, + :> [Commits |-> { "n1", "n2" }, header |-> - [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5]] + lastCommit |-> {"n2"}, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1398, + now |-> 5, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n3", "n4" }, + [Commits |-> { "n1", "n2" }, header |-> - [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5]], - now |-> 1398, + lastCommit |-> {"n2"}, + time |-> 4]], + now |-> 5, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 4 :> "StateUnverified" -/\ nextHeight = 2 -/\ now = 1398 +/\ nextHeight = 3 +/\ now = 5 /\ nprobes = 1 -/\ prevCurrent = [Commits |-> { "n3", "n4" }, +/\ prevCurrent = [Commits |-> { "n1", "n2" }, header |-> - [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5]] -/\ prevNow = 1398 + lastCommit |-> {"n2"}, + time |-> 4]] +/\ prevNow = 5 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ state = "working" -(* Transition 0 to State4 *) +(* Transition 1 to State4 *) State4 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, + :> [NextVS |-> {"n2"}, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n2", "n4" }, + time |-> 2] @@ 3 - :> [NextVS |-> { "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + :> [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n3"}, + VS |-> { "n1", "n2" }, height |-> 5, - lastCommit |-> { "n3", "n4" }, - time |-> 6] + lastCommit |-> { "n1", "n2" }, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] - @@ 2 - :> [Commits |-> { "n1", "n2", "n4" }, + @@ 3 + :> [Commits |-> {"n2"}, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, - height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, + height |-> 3, + lastCommit |-> {"n3"}, time |-> 3]] @@ 4 - :> [Commits |-> { "n3", "n4" }, + :> [Commits |-> { "n1", "n2" }, header |-> - [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5]] + lastCommit |-> {"n2"}, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1398, + now |-> 5, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n3", "n4" }, + [Commits |-> { "n1", "n2" }, header |-> - [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5]], - now |-> 1398, + lastCommit |-> {"n2"}, + time |-> 4]], + now |-> 5, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> { "n1", "n2", "n4" }, + [Commits |-> {"n2"}, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, - height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, + height |-> 3, + lastCommit |-> {"n3"}, time |-> 3]], - now |-> 1398, - verdict |-> "SUCCESS", + now |-> 5, + verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] -/\ latestVerified = [Commits |-> { "n1", "n2", "n4" }, +/\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, - height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3]] -/\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 4 :> "StateUnverified" -/\ nextHeight = 3 -/\ now = 1403 + [NextVS |-> {"n3"}, + VS |-> { "n1", "n2", "n3", "n4" }, + height |-> 1, + lastCommit |-> {}, + time |-> 1]] +/\ lightBlockStatus = 1 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" +/\ nextHeight = 2 +/\ now = 1402 /\ nprobes = 2 -/\ prevCurrent = [Commits |-> { "n1", "n2", "n4" }, +/\ prevCurrent = [Commits |-> {"n2"}, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, - height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, + height |-> 3, + lastCommit |-> {"n3"}, time |-> 3]] -/\ prevNow = 1398 -/\ prevVerdict = "SUCCESS" +/\ prevNow = 5 +/\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -362,173 +362,173 @@ State4 == State5 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n4" }, + :> [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, + :> [NextVS |-> {"n2"}, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3] + lastCommit |-> { "n1", "n2", "n4" }, + time |-> 2] @@ 3 - :> [NextVS |-> { "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 4] + lastCommit |-> {"n3"}, + time |-> 3] @@ 4 - :> [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + :> [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n3"}, + VS |-> { "n1", "n2" }, height |-> 5, - lastCommit |-> { "n3", "n4" }, - time |-> 6] + lastCommit |-> { "n1", "n2" }, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n1", "n2", "n4" }, + :> [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n2"}, + VS |-> {"n3"}, height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3]] + lastCommit |-> { "n1", "n2", "n4" }, + time |-> 2]] @@ 3 - :> [Commits |-> { "n1", "n3", "n4" }, + :> [Commits |-> {"n2"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, - time |-> 4]] + lastCommit |-> {"n3"}, + time |-> 3]] @@ 4 - :> [Commits |-> { "n3", "n4" }, + :> [Commits |-> { "n1", "n2" }, header |-> - [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5]] + lastCommit |-> {"n2"}, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1398, + now |-> 5, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n3", "n4" }, + [Commits |-> { "n1", "n2" }, header |-> - [NextVS |-> {"n3"}, - VS |-> { "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> { "n1", "n2" }, height |-> 4, - lastCommit |-> { "n2", "n3", "n4" }, - time |-> 5]], - now |-> 1398, + lastCommit |-> {"n2"}, + time |-> 4]], + now |-> 5, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> { "n1", "n2", "n4" }, + [Commits |-> {"n2"}, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, - height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n1", "n2" }, + VS |-> {"n2"}, + height |-> 3, + lastCommit |-> {"n3"}, time |-> 3]], - now |-> 1398, - verdict |-> "SUCCESS", + now |-> 5, + verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n1", "n3", "n4" }, + [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 3, + [NextVS |-> {"n2"}, + VS |-> {"n3"}, + height |-> 2, lastCommit |-> { "n1", "n2", "n4" }, - time |-> 4]], - now |-> 1403, + time |-> 2]], + now |-> 1402, verdict |-> "INVALID", verified |-> - [Commits |-> { "n1", "n2", "n4" }, + [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, - height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3]]] -/\ latestVerified = [Commits |-> { "n1", "n2", "n4" }, + [NextVS |-> {"n3"}, + VS |-> { "n1", "n2", "n3", "n4" }, + height |-> 1, + lastCommit |-> {}, + time |-> 1]]] +/\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, - height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3]] + [NextVS |-> {"n3"}, + VS |-> { "n1", "n2", "n3", "n4" }, + height |-> 1, + lastCommit |-> {}, + time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" - @@ 2 :> "StateVerified" - @@ 3 :> "StateFailed" + @@ 2 :> "StateFailed" + @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" -/\ nextHeight = 3 -/\ now = 1403 +/\ nextHeight = 2 +/\ now = 1402 /\ nprobes = 3 -/\ prevCurrent = [Commits |-> { "n1", "n3", "n4" }, +/\ prevCurrent = [Commits |-> {"n3"}, header |-> - [NextVS |-> { "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 3, + [NextVS |-> {"n2"}, + VS |-> {"n3"}, + height |-> 2, lastCommit |-> { "n1", "n2", "n4" }, - time |-> 4]] -/\ prevNow = 1403 + time |-> 2]] +/\ prevNow = 1402 /\ prevVerdict = "INVALID" -/\ prevVerified = [Commits |-> { "n1", "n2", "n4" }, +/\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n4" }, - height |-> 2, - lastCommit |-> { "n1", "n2", "n3", "n4" }, - time |-> 3]] + [NextVS |-> {"n3"}, + VS |-> { "n1", "n2", "n3", "n4" }, + height |-> 1, + lastCommit |-> {}, + time |-> 1]] /\ state = "finishedFailure" (* The following formula holds true in the last state and violates the invariant *) @@ -537,5 +537,5 @@ InvariantViolation == state = "finishedFailure" /\ Cardinality((DOMAIN fetchedLightBlocks)) = 4 ================================================================================ -\* Created by Apalache on Fri Sep 25 14:05:08 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:19:25 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestHeaderFromFuture.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestHeaderFromFuture.json index 04c67b56f..6c3d810a5 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestHeaderFromFuture.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestHeaderFromFuture.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_TestHeaderFromFuture.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -14,7 +14,7 @@ "last_commit_hash": null, "data_hash": null, "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "next_validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, @@ -25,48 +25,42 @@ "height": "1", "round": 1, "block_id": { - "hash": "A1227FA5ABACADB137F59906C4A604E806190C9991D6D965C50BED0D28CA8375", - "parts": null + "hash": "765CAC565626BF7405C8B07ECFC06BF202F969A1F1066897BEFD09A1866BF588", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "6pKtB84HEN/nVin25bXP3LrYtn+w1QtYC3+jWjo0bAZrDVVRjpr6u0AHmkHNIjpDCBZwPxoc3Lrpe6bkckc2Dw==" + "signature": "4+XbEjav4FPgXtVKTINGTvMpDRD5B8d8aXdYlSpGWvsEMEjy2piHeNpGTXanK1cEQK+6upFDOwDdeWbF8Q2xAA==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "iYdpbTw2CanDKKHE0JUNa4a8DPkvZAwXFI2jvgUw9Wy4MKof8dnQGWUc7idLnU1AqCJRq31jokYx5uS1GJklAw==" + "signature": "Fqul88ticG0rmDZ5auj0kNGlommKOkHKlI/HTrAqIqkKu3pmEI/kIpGBGOfoAaHyEtWoGrsRdb+W8FJTghzrDw==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "z86oIuIYg6wDVqN4u16Oxn9zybsfQmmwzGkhTU7x4y9Z9QaXBV1S7fIYVB7xIoljCc+IBufyg5c1aaCFa0ncCQ==" + "signature": "R70pC8Z3AinU6B9WBZjP3Wjdm0FP+gvUg5GohstMKnVOZb/sVLzhBLo7C7rAzrdrxaW4sD0ti7mEsFiTzoryBg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "71uebWj6TqfykfaVTew96byLAPw6X7memRyWoHNqtQQV7F3eThTZtRTsZdFwhxl5qYl+/5MbZbX1lYer8SL1Dw==" + "signature": "3YhDOz02vbnR1YCYsqsYHFCaKSTgcxPkqLntB0kfrwv8hjhsldwWNIdlvt4x7+Aw5zrHtDjr3s9Gt4aXfT+EDw==" } ] } }, "next_validator_set": { "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -84,29 +78,20 @@ }, "voting_power": "50", "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } }, "trusting_period": "1400000000000", - "now": "2020-09-25T13:00:43.364143936Z" + "now": "2020-10-07T14:21:10.1602080470Z" }, "input": [ { @@ -123,75 +108,56 @@ "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "E624CE5E2693812E58E8DBB64C7A05149A58157114D34F08CB5992FE2BECC0A7", - "next_validators_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", - "consensus_hash": "E624CE5E2693812E58E8DBB64C7A05149A58157114D34F08CB5992FE2BECC0A7", + "validators_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "consensus_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" + "proposer_address": "730D3D6B2E9F4F0F23879458F2D02E0004F0F241" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "F044F56B3878A321401BA5AC13F9315B24A8618F97D52BA4A78372439559CF28", - "parts": null - }, - "signatures": [ - { - "block_id_flag": 1, - "validator_address": null, - "timestamp": null, - "signature": null - }, - { - "block_id_flag": 1, - "validator_address": null, - "timestamp": null, - "signature": null + "hash": "84AB6C8869EE93568CD06D65261704285EFFD993150E4220A49D3C3B7000F2B5", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" } - ] + }, + "signatures": [] } }, "validator_set": { - "validators": [ - { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" - }, - "voting_power": "50", - "proposer_priority": null - } - ], + "validators": [], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "730D3D6B2E9F4F0F23879458F2D02E0004F0F241", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "YnT69eNDaRaNU7teDTcyBedSD0B/Ziqx+sejm0wQba0=" }, "voting_power": "50", "proposer_priority": null } }, "next_validator_set": { - "validators": [], + "validators": [ + { + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + }, + "voting_power": "50", + "proposer_priority": null + } + ], "proposer": { - "address": "730D3D6B2E9F4F0F23879458F2D02E0004F0F241", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "YnT69eNDaRaNU7teDTcyBedSD0B/Ziqx+sejm0wQba0=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestHeaderFromFuture.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestHeaderFromFuture.tla index 2a0e81251..4dd8bcb92 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestHeaderFromFuture.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestHeaderFromFuture.tla @@ -9,41 +9,41 @@ TRUE (* Transition 0 to State2 *) State2 == -/\ Faulty = {"n2"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> {"n3"}, - VS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n2", "n3", "n4" }, + VS |-> { "n2", "n3" }, height |-> 2, lastCommit |-> { "n1", "n2", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> {"n3"}, + :> [NextVS |-> {"n1"}, + VS |-> { "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n2", "n3" }, time |-> 3] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n3"}, + lastCommit |-> { "n2", "n3", "n4" }, time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n1", "n4" }, + lastCommit |-> {"n1"}, time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -52,7 +52,7 @@ State2 == :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -62,14 +62,14 @@ State2 == verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -80,7 +80,7 @@ State2 == /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -89,7 +89,7 @@ State2 == /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -99,41 +99,41 @@ State2 == (* Transition 5 to State3 *) State3 == -/\ Faulty = {"n2"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> {"n3"}, - VS |-> { "n1", "n2", "n3", "n4" }, + :> [NextVS |-> { "n2", "n3", "n4" }, + VS |-> { "n2", "n3" }, height |-> 2, lastCommit |-> { "n1", "n2", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> {"n3"}, + :> [NextVS |-> {"n1"}, + VS |-> { "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n2", "n3" }, time |-> 3] @@ 4 - :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n3"}, + lastCommit |-> { "n2", "n3", "n4" }, time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n1", "n2", "n3", "n4" }, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n1", "n4" }, + lastCommit |-> {"n1"}, time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -141,16 +141,16 @@ State3 == @@ 4 :> [Commits |-> {}, header |-> - [NextVS |-> {}, - VS |-> { "n1", "n2" }, + [NextVS |-> {"n4"}, + VS |-> {}, height |-> 4, - lastCommit |-> { "n1", "n2", "n3", "n4" }, + lastCommit |-> { "n2", "n3", "n4" }, time |-> 1402]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -160,7 +160,7 @@ State3 == verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -169,24 +169,24 @@ State3 == :> [current |-> [Commits |-> {}, header |-> - [NextVS |-> {}, - VS |-> { "n1", "n2" }, + [NextVS |-> {"n4"}, + VS |-> {}, height |-> 4, - lastCommit |-> { "n1", "n2", "n3", "n4" }, + lastCommit |-> { "n2", "n3", "n4" }, time |-> 1402]], now |-> 1401, verdict |-> "INVALID", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -197,16 +197,16 @@ State3 == /\ nprobes = 1 /\ prevCurrent = [Commits |-> {}, header |-> - [NextVS |-> {}, - VS |-> { "n1", "n2" }, + [NextVS |-> {"n4"}, + VS |-> {}, height |-> 4, - lastCommit |-> { "n1", "n2", "n3", "n4" }, + lastCommit |-> { "n2", "n3", "n4" }, time |-> 1402]] /\ prevNow = 1401 /\ prevVerdict = "INVALID" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -220,5 +220,5 @@ InvariantViolation == history[s$2]["now"] < history[s$2]["current"]["header"]["time"])) ================================================================================ -\* Created by Apalache on Fri Sep 25 15:00:43 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:21:09 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestSuccess.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestSuccess.json index 5839baff1..29f6bbbb5 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestSuccess.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestSuccess.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_TestSuccess.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -14,7 +14,7 @@ "last_commit_hash": null, "data_hash": null, "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "next_validators_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, @@ -25,39 +25,51 @@ "height": "1", "round": 1, "block_id": { - "hash": "A5FD63E864304F723654E74CDFA836C563A1682081E74C4B718D38442075128C", - "parts": null + "hash": "54BD5EF1D284E0C21E1F1B36CC355275D7394B39F8AF10837D680EB32C7D776D", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "8y8HuUGmkm5w9Tt9UAtQmg/+v23HlysfX7rW0QNWYYnmyFqQBZz3QVypdFloIiqjn7Djyy8H6hwbwvQui77jCw==" + "signature": "GgOVVVxrRwdFob0atNnPys0fJ8l/xcvknvsJxtgeiShup8aIgZJd445J976JtLBbWgoTBhCfY7Hyc9YnScwPCA==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "ikGWS0RuuNlyRirvrsRfa+BrmtRy5TihH/Sn8Bf/mUfzdiQ8LNBMuZn//lZ2Mvp/+vCEkLOo3yHdniiwXA9SDw==" + "signature": "u76LJKtjHSF8GPayHDDhGfowGpXLHxMLg4KS0S0QTL2eWxAAH5LgAD1Tz80W8Vr/U458ZLppU9J6QvEB5CIrAg==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "OkL+uDWm0pSoGLWUdeIGuqHj47fsHo6Ss3Our1NE2HMmRTA2WHfIMc1xWdwM5iJcHVbpbgVe5pZ7jbv2ysTtCg==" + "signature": "ZpOcjQDpiFdI3xYpuIw5kGUzU7kyLLs+jfXDFzgxTGHQbWT/+HmL2chLUM1Fq2p9aNdAhWcFNhnnBh6NH7/nAg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "VcWm48595Mty9Bu3pU2gCZI37uUiRmv8vr6fEqDF+sn6roSVUbxi4gHdTJs1J7cGH3TVnFV7AQCFZiThc4ueBA==" + "signature": "cTzFxyrl1j2C7P/y5qN850JFbxZmHCiva6cY9NYQXahZ4cvnQchkQLvoCnE+jMDQKddDMySQLNGoI/AKb/2sCQ==" } ] } }, "next_validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -66,20 +78,29 @@ }, "voting_power": "50", "proposer_priority": null + }, + { + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + }, + "voting_power": "50", + "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } }, "trusting_period": "1400000000000", - "now": "2020-09-25T12:04:59.335586579Z" + "now": "2020-10-07T14:19:14.1602080354Z" }, "input": [ { @@ -92,37 +113,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:06Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "AAFE392AA939DA2A051F3C57707569B1836F93ACC8F35B57BB3CDF615B649013", - "next_validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "consensus_hash": "AAFE392AA939DA2A051F3C57707569B1836F93ACC8F35B57BB3CDF615B649013", + "validators_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", + "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "consensus_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "81D85BE9567F7069A4760C663062E66660DADF34" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "77889C526BF5F215F1090CB489A62C5360DAC865CD5D8F971CB51C8B8B2CC145", - "parts": null + "hash": "8CBE618E2A1BD3A01105A0B3C5634CF794E2F994D0BE7807E65B16B9FDB3E687", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "1b6R/s08WneHAsb/ATBi6NHdWkmquVA4r6YHWIt4yM0v67wiAlxTm95PmYAcQvZgroSckp2s01UHexgTVjmhCw==" - }, - { - "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "13iL54lGOTAeIYVTB+gsQsoddEuu5nGwyJetJ2rrismsFGxz7S9DLBU9dTOheNqprDlEsKoRWG6AIGS3xTJ6CA==" + "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", + "timestamp": "1970-01-01T00:00:06Z", + "signature": "H+it4dPg11oKjbn7OXKf+DISLBQYXuG5SHuO0RO2xTmHMqciCnXwI+jWrNZVlAHA2d2VJg4/mCTnDUL6anLqCw==" } ] } @@ -130,29 +148,20 @@ "validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null @@ -161,27 +170,27 @@ "next_validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:06Z", + "now": "1970-01-01T00:00:07Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -198,33 +207,57 @@ "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", - "next_validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "consensus_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "validators_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", + "next_validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "consensus_hash": "010ED897B4B347175BC54ADF87D640393862FF3D5038302CD523B0E97FC20079", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "2", "round": 1, "block_id": { - "hash": "BE47A6D9844176D39E2A2EE24E48C1763901766D4A4E376D3E1C696BA2EA79C1", - "parts": null + "hash": "724CC2AD6419EA2B4828696CA5FCE1E3F5291FDDF3710EBE2D4B853B68583D36", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ + { + "block_id_flag": 2, + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "timestamp": "1970-01-01T00:00:02Z", + "signature": "dq1nZMRGsZJ9AAX9n4ZCFeFFyWaLEzfgw2IWpJN0mT6PZ7nVXMsubKMe3h6hozuv9X2EKMmWZXZJ3PawsgiKDQ==" + }, + { + "block_id_flag": 2, + "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "timestamp": "1970-01-01T00:00:02Z", + "signature": "9jnlwZZ1mHOnE98b4fRcI7jIQ9l1q6S3J5dxYEnKYBDNsx+rmezzeVuJO85J08k11aFNX6FW83aMgx80dNrkDA==" + }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:02Z", - "signature": "lHT2cfBFHPIPTJubgRPwTgR+6RtsJ8Mg8w/SsM50CaGIBYYW0YStiDhU0L7yZCZMSOU27kAY6qiE3R/dOW9DAA==" + "signature": "TnfzsL/xcTcGAygA4MKx+q5rDhYHkyanRvIyr1S3aVkc44/UsmLPz0OpcZM5UYImTk7/nPIdyXj/5sNqz2BCAA==" } ] } }, "validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -233,13 +266,22 @@ }, "voting_power": "50", "proposer_priority": null + }, + { + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + }, + "voting_power": "50", + "proposer_priority": null } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null @@ -247,6 +289,15 @@ }, "next_validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -264,20 +315,29 @@ }, "voting_power": "50", "proposer_priority": null + }, + { + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + }, + "voting_power": "50", + "proposer_priority": null } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:00:06Z", + "now": "1970-01-01T00:00:07Z", "verdict": "SUCCESS" }, { @@ -294,39 +354,63 @@ "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "next_validators_hash": "AAFE392AA939DA2A051F3C57707569B1836F93ACC8F35B57BB3CDF615B649013", - "consensus_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", + "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", + "next_validators_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", + "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "81D85BE9567F7069A4760C663062E66660DADF34" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { "height": "3", "round": 1, "block_id": { - "hash": "51F1395CFAE6340D7C6FFB44831CA2A4B9431FA7F1C0A82AD391800BF124C725", - "parts": null + "hash": "ABD4E8F073C17D1101A78CF28C4BBB7134A8FDC55AA1214CD7C7565683E57937", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", + "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:03Z", - "signature": "mexfD28dqR67Dj62eiUv4SoypcnceFoXJpn3NkhbCl0k4evGja5/zGkjJXY8gu4PZloNvDvTF/PvGU1Gpr5qDw==" + "signature": "rfELxH0LjlaNiwwwXVQuvZjyPKtqxAuFQr3+79VfyomjZXm2nNUQNFlU4WEQJ1Gy+wmZ3ehzHdFCLqGec9X3DQ==" }, { "block_id_flag": 2, - "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "timestamp": "1970-01-01T00:00:03Z", + "signature": "EDHrTTaoNvkYMQcF7qCOWQlvVc5Jojy/IXvK3z9QS+EOOO/2dBI+HRqdAo6czLjLRUgWC/NpqnNBr6BUXcbRBQ==" + }, + { + "block_id_flag": 2, + "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:03Z", - "signature": "su/h01QtOfgJxa4yGz3U2LDyKgetV6e9abAiSu5lmVXFKFfh4TUvAKhhBRQTbSeGBp1+Dr2RNk1zJ3kRVguSCw==" + "signature": "EoDtn6AvTVqEpT3Of2Kw+NIodiFOeryYPhhGtyRZtJhJmaHqzpLdC7Xk96SST4m1xOXiBcNJWfViDmLva6XJDg==" + }, + { + "block_id_flag": 1, + "validator_address": null, + "timestamp": null, + "signature": null } ] } }, "validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -344,13 +428,22 @@ }, "voting_power": "50", "proposer_priority": null + }, + { + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + }, + "voting_power": "50", + "proposer_priority": null } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null @@ -359,36 +452,27 @@ "next_validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:21Z", + "now": "1970-01-01T00:00:08Z", "verdict": "SUCCESS" }, { @@ -401,37 +485,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:04Z", + "time": "1970-01-01T00:00:06Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "AAFE392AA939DA2A051F3C57707569B1836F93ACC8F35B57BB3CDF615B649013", - "next_validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "consensus_hash": "AAFE392AA939DA2A051F3C57707569B1836F93ACC8F35B57BB3CDF615B649013", + "validators_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", + "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "consensus_hash": "F49C3E794533450FEA327755F5962F99C88F5545453E6D517BBDD96EA066B50C", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "81D85BE9567F7069A4760C663062E66660DADF34" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "77889C526BF5F215F1090CB489A62C5360DAC865CD5D8F971CB51C8B8B2CC145", - "parts": null + "hash": "8CBE618E2A1BD3A01105A0B3C5634CF794E2F994D0BE7807E65B16B9FDB3E687", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "1b6R/s08WneHAsb/ATBi6NHdWkmquVA4r6YHWIt4yM0v67wiAlxTm95PmYAcQvZgroSckp2s01UHexgTVjmhCw==" - }, - { - "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "13iL54lGOTAeIYVTB+gsQsoddEuu5nGwyJetJ2rrismsFGxz7S9DLBU9dTOheNqprDlEsKoRWG6AIGS3xTJ6CA==" + "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", + "timestamp": "1970-01-01T00:00:06Z", + "signature": "H+it4dPg11oKjbn7OXKf+DISLBQYXuG5SHuO0RO2xTmHMqciCnXwI+jWrNZVlAHA2d2VJg4/mCTnDUL6anLqCw==" } ] } @@ -439,29 +520,20 @@ "validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" }, "voting_power": "50", "proposer_priority": null @@ -470,27 +542,27 @@ "next_validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:21Z", + "now": "1970-01-01T00:00:08Z", "verdict": "SUCCESS" } ] diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestSuccess.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestSuccess.tla index ae5a16df4..9bcb6e255 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestSuccess.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestSuccess.tla @@ -11,39 +11,39 @@ TRUE State2 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3] @@ 4 - :> [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n1"}, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -52,44 +52,44 @@ State2 == :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" /\ nextHeight = 4 -/\ now = 6 +/\ now = 7 /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ prevNow = 6 +/\ prevNow = 7 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -101,112 +101,112 @@ State2 == State3 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3] @@ 4 - :> [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n1"}, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 4 - :> [Commits |-> { "n1", "n4" }, + :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n1", "n4" }, + [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 6, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 4 :> "StateUnverified" /\ nextHeight = 2 -/\ now = 6 +/\ now = 7 /\ nprobes = 1 -/\ prevCurrent = [Commits |-> { "n1", "n4" }, +/\ prevCurrent = [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] -/\ prevNow = 6 + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]] +/\ prevNow = 7 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -218,139 +218,139 @@ State3 == State4 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3] @@ 4 - :> [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n1"}, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> {"n3"}, + :> [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]] @@ 4 - :> [Commits |-> { "n1", "n4" }, + :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n1", "n4" }, + [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 6, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]], - now |-> 6, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] -/\ latestVerified = [Commits |-> {"n3"}, +/\ latestVerified = [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 4 :> "StateUnverified" /\ nextHeight = 3 -/\ now = 1401 +/\ now = 8 /\ nprobes = 2 -/\ prevCurrent = [Commits |-> {"n3"}, +/\ prevCurrent = [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]] -/\ prevNow = 6 +/\ prevNow = 7 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -362,172 +362,172 @@ State4 == State5 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3] @@ 4 - :> [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n1"}, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> {"n3"}, + :> [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]] @@ 3 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3]] @@ 4 - :> [Commits |-> { "n1", "n4" }, + :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n1", "n4" }, + [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 6, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]], - now |-> 6, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3]], - now |-> 1401, + now |-> 8, verdict |-> "SUCCESS", verified |-> - [Commits |-> {"n3"}, + [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]]] -/\ latestVerified = [Commits |-> { "n2", "n3" }, +/\ latestVerified = [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateVerified" @@ 4 :> "StateUnverified" /\ nextHeight = 4 -/\ now = 1401 +/\ now = 8 /\ nprobes = 3 -/\ prevCurrent = [Commits |-> { "n2", "n3" }, +/\ prevCurrent = [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3]] -/\ prevNow = 1401 +/\ prevNow = 8 /\ prevVerdict = "SUCCESS" -/\ prevVerified = [Commits |-> {"n3"}, +/\ prevVerified = [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]] /\ state = "working" @@ -536,191 +536,191 @@ State5 == State6 == /\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + :> [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3] @@ 4 - :> [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + :> [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n1"}, + VS |-> {"n4"}, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 5] + lastCommit |-> {"n2"}, + time |-> 7] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> {"n3"}, + :> [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]] @@ 3 - :> [Commits |-> { "n2", "n3" }, + :> [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3]] @@ 4 - :> [Commits |-> { "n1", "n4" }, + :> [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 6, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n1", "n4" }, + [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 6, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]], + now |-> 7, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n3"}, + [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]], - now |-> 6, + now |-> 7, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n3", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3]], - now |-> 1401, + now |-> 8, verdict |-> "SUCCESS", verified |-> - [Commits |-> {"n3"}, + [Commits |-> { "n1", "n3", "n4" }, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n3", "n4" }, height |-> 2, - lastCommit |-> { "n1", "n2", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]]] @@ 4 :> [current |-> - [Commits |-> { "n1", "n4" }, + [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]], - now |-> 1401, + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]], + now |-> 8, verdict |-> "SUCCESS", verified |-> - [Commits |-> { "n2", "n3" }, + [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3]]] -/\ latestVerified = [Commits |-> { "n1", "n4" }, +/\ latestVerified = [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 3 :> "StateVerified" @@ 4 :> "StateVerified" /\ nextHeight = 4 -/\ now = 1401 +/\ now = 8 /\ nprobes = 4 -/\ prevCurrent = [Commits |-> { "n1", "n4" }, +/\ prevCurrent = [Commits |-> {"n2"}, header |-> - [NextVS |-> {"n1"}, - VS |-> { "n1", "n4" }, + [NextVS |-> {"n4"}, + VS |-> {"n2"}, height |-> 4, - lastCommit |-> { "n2", "n3" }, - time |-> 4]] -/\ prevNow = 1401 + lastCommit |-> { "n2", "n3", "n4" }, + time |-> 6]] +/\ prevNow = 8 /\ prevVerdict = "SUCCESS" -/\ prevVerified = [Commits |-> { "n2", "n3" }, +/\ prevVerified = [Commits |-> { "n1", "n2", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> { "n2", "n3" }, + [NextVS |-> {"n2"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n3", "n4" }, time |-> 3]] /\ state = "finishedSuccess" @@ -730,5 +730,5 @@ InvariantViolation == state = "finishedSuccess" /\ Cardinality((DOMAIN fetchedLightBlocks)) = 4 ================================================================================ -\* Created by Apalache on Fri Sep 25 14:04:59 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:19:13 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestUntrustedBeforeTrusted.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestUntrustedBeforeTrusted.json index d7568f00b..e7e1966cb 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestUntrustedBeforeTrusted.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestUntrustedBeforeTrusted.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_TestUntrustedBeforeTrusted.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -14,7 +14,7 @@ "last_commit_hash": null, "data_hash": null, "validators_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", - "next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A", + "next_validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", "consensus_hash": "5A69ACB73672274A2C020C7FAE539B2086D30F3B7E5B168A8031A21931FCA07D", "app_hash": "", "last_results_hash": null, @@ -25,39 +25,60 @@ "height": "1", "round": 1, "block_id": { - "hash": "A5FD63E864304F723654E74CDFA836C563A1682081E74C4B718D38442075128C", - "parts": null + "hash": "67A2F8253E1545321561A82A23D87B984E11621D2B877EB236FE649A20442932", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "8y8HuUGmkm5w9Tt9UAtQmg/+v23HlysfX7rW0QNWYYnmyFqQBZz3QVypdFloIiqjn7Djyy8H6hwbwvQui77jCw==" + "signature": "yJFAxO4S7lWyeJYsQ+ZXD8qqOEJMea6qJI4emHXiz1G8toYIN31z7gcsXj3P0DUbdzIVUvCgPvvgVwoiLCKTDQ==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "ikGWS0RuuNlyRirvrsRfa+BrmtRy5TihH/Sn8Bf/mUfzdiQ8LNBMuZn//lZ2Mvp/+vCEkLOo3yHdniiwXA9SDw==" + "signature": "hrdfvpMuSAwpAdG/apS8astAtVzL1GE1pV+b2LoSZwxx7XG78LbjvVzy9noKSY4XT6UlNaScd24ds0Dg1KnwBQ==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "OkL+uDWm0pSoGLWUdeIGuqHj47fsHo6Ss3Our1NE2HMmRTA2WHfIMc1xWdwM5iJcHVbpbgVe5pZ7jbv2ysTtCg==" + "signature": "RM39gQxzEDoC6uc0x+KW2ULfNiFXhetirKHn9J/suisjslOcWaanyhB9YFeJC2XQ42amV3b6lveGE3pauA1cBg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "VcWm48595Mty9Bu3pU2gCZI37uUiRmv8vr6fEqDF+sn6roSVUbxi4gHdTJs1J7cGH3TVnFV7AQCFZiThc4ueBA==" + "signature": "SB2j93BXgPL20kTmEhBFlHKmw6LtACQYCILz67xRhsUmXRAsIXQt5AQXW4bU5BHOYpHog8lz/5ZmSQ7If1rFAw==" } ] } }, "next_validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, + { + "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { @@ -69,17 +90,17 @@ } ], "proposer": { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } }, "trusting_period": "1400000000000", - "now": "2020-09-25T13:00:49.206940344Z" + "now": "2020-10-07T14:21:18.1602080478Z" }, "input": [ { @@ -96,83 +117,53 @@ "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", - "next_validators_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", - "consensus_hash": "C8F8530F1A2E69409F2E0B4F86BB568695BC9790BA77EAC1505600D5506E22DA", + "validators_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "next_validators_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "consensus_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "730D3D6B2E9F4F0F23879458F2D02E0004F0F241" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "01331A18928F9B800352E15C7F005164D35682DAE5A79861512EDB61E3178349", - "parts": null - }, - "signatures": [ - { - "block_id_flag": 1, - "validator_address": null, - "timestamp": null, - "signature": null - }, - { - "block_id_flag": 2, - "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:00Z", - "signature": "qj7kWZ2alFTMuOsHCbQkv/5NLDVXVC0B95OCix5eL7HsmVmsblLB/AQWuv/OasQ52JTgGZY4v5QWNBJJkIxhCw==" + "hash": "36A702AEF4687C7B27B0809AB552F689527C7A80D0E35C6158A05BCC4E3D0169", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" } - ] + }, + "signatures": [] } }, "validator_set": { - "validators": [ - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null - } - ], + "validators": [], "proposer": { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "730D3D6B2E9F4F0F23879458F2D02E0004F0F241", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "YnT69eNDaRaNU7teDTcyBedSD0B/Ziqx+sejm0wQba0=" }, "voting_power": "50", "proposer_priority": null } }, "next_validator_set": { - "validators": [ - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null - } - ], + "validators": [], "proposer": { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", + "address": "730D3D6B2E9F4F0F23879458F2D02E0004F0F241", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" + "value": "YnT69eNDaRaNU7teDTcyBedSD0B/Ziqx+sejm0wQba0=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:24Z", + "now": "1970-01-01T00:23:21Z", "verdict": "INVALID" } ] diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestUntrustedBeforeTrusted.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestUntrustedBeforeTrusted.tla index a51a5b272..59ad3f354 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestUntrustedBeforeTrusted.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestUntrustedBeforeTrusted.tla @@ -9,41 +9,41 @@ TRUE (* Transition 0 to State2 *) State2 == -/\ Faulty = {"n1"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n2", "n3" }, time |-> 3] @@ 4 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 4, - lastCommit |-> {"n4"}, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n3"}, + VS |-> { "n1", "n2", "n4" }, height |-> 5, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -52,44 +52,44 @@ State2 == :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1404, + now |-> 1401, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" /\ nextHeight = 4 -/\ now = 1404 +/\ now = 1401 /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ prevNow = 1404 +/\ prevNow = 1401 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -99,114 +99,114 @@ State2 == (* Transition 5 to State3 *) State3 == -/\ Faulty = {"n1"} +/\ Faulty = {} /\ blockchain = 1 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> {"n4"}, - VS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, height |-> 2, lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n4"}, + VS |-> { "n1", "n2", "n3", "n4" }, height |-> 3, - lastCommit |-> {"n3"}, + lastCommit |-> { "n1", "n2", "n3" }, time |-> 3] @@ 4 - :> [NextVS |-> {"n3"}, + :> [NextVS |-> { "n1", "n2", "n4" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 4, - lastCommit |-> {"n4"}, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> {"n3"}, + VS |-> { "n1", "n2", "n4" }, height |-> 5, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] @@ 4 - :> [Commits |-> {"n1"}, + :> [Commits |-> {}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, + [NextVS |-> {}, + VS |-> {}, height |-> 4, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 0]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1404, + now |-> 1401, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> {}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, + [NextVS |-> {}, + VS |-> {}, height |-> 4, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 0]], - now |-> 1404, + now |-> 1401, verdict |-> "INVALID", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]]] /\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 4 :> "StateFailed" /\ nextHeight = 4 -/\ now = 1404 +/\ now = 1401 /\ nprobes = 1 -/\ prevCurrent = [Commits |-> {"n1"}, +/\ prevCurrent = [Commits |-> {}, header |-> - [NextVS |-> {"n4"}, - VS |-> {"n4"}, + [NextVS |-> {}, + VS |-> {}, height |-> 4, - lastCommit |-> { "n2", "n3" }, + lastCommit |-> { "n1", "n2", "n4" }, time |-> 0]] -/\ prevNow = 1404 +/\ prevNow = 1401 /\ prevVerdict = "INVALID" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> - [NextVS |-> {"n3"}, + [NextVS |-> { "n1", "n2", "n3" }, VS |-> { "n1", "n2", "n3", "n4" }, height |-> 1, lastCommit |-> {}, @@ -221,5 +221,5 @@ InvariantViolation == < history[s$2]["verified"]["header"]["time"])) ================================================================================ -\* Created by Apalache on Fri Sep 25 15:00:49 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:21:18 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestValsetDifferentAllSteps.json b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestValsetDifferentAllSteps.json index 805a68395..9f2fd4486 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestValsetDifferentAllSteps.json +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestValsetDifferentAllSteps.json @@ -1,5 +1,5 @@ { - "description": "MC4_4_faulty_TestValsetDifferentAllSteps.json; auto-generated from Apalache counterexample", + "description": "auto-generated from Apalache counterexample", "initial": { "signed_header": { "header": { @@ -25,33 +25,36 @@ "height": "1", "round": 1, "block_id": { - "hash": "7C2E7AF220BDECBF15B2339DD4C2E93FBF598E4477FF7B3D60EC1361EC8D14D5", - "parts": null + "hash": "67A2F8253E1545321561A82A23D87B984E11621D2B877EB236FE649A20442932", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "timestamp": "1970-01-01T00:00:01Z", - "signature": "3xA5Saw50OrH5MX9S5qehZlYq3zNI9KcY21Xs4DlycmD6Zk5E3lv2nj08Zc1NFEx+VXUATbgbTYjW/I9ZgzVDA==" + "signature": "yJFAxO4S7lWyeJYsQ+ZXD8qqOEJMea6qJI4emHXiz1G8toYIN31z7gcsXj3P0DUbdzIVUvCgPvvgVwoiLCKTDQ==" }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", "timestamp": "1970-01-01T00:00:01Z", - "signature": "rOZjc1oJFr+8YODvmLi7+RWa+YLek487NaqiZIjGZFLMT9ht3GxuxBpnSTdPuanmrLRnPzaoIanwd/G2kujEBw==" + "signature": "hrdfvpMuSAwpAdG/apS8astAtVzL1GE1pV+b2LoSZwxx7XG78LbjvVzy9noKSY4XT6UlNaScd24ds0Dg1KnwBQ==" }, { "block_id_flag": 2, "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", "timestamp": "1970-01-01T00:00:01Z", - "signature": "16Zxot0E0fyCezvsudgXvoawsSnz7HJfYCDGLaN/hmN6oyGvWN68p4kod7SmeDLH0oWYKQOIy3AkZvl/qp7TDQ==" + "signature": "RM39gQxzEDoC6uc0x+KW2ULfNiFXhetirKHn9J/suisjslOcWaanyhB9YFeJC2XQ42amV3b6lveGE3pauA1cBg==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "timestamp": "1970-01-01T00:00:01Z", - "signature": "ZIwH0BAOGiFRoHK3zAEjFbW2//v2RB4umT7hN9dflCvv0jIbqO+odx/kIMaWEDvcw0Y3kDeib6/jeuSdAo/5Cw==" + "signature": "SB2j93BXgPL20kTmEhBFlHKmw6LtACQYCILz67xRhsUmXRAsIXQt5AQXW4bU5BHOYpHog8lz/5ZmSQ7If1rFAw==" } ] } @@ -97,7 +100,7 @@ } }, "trusting_period": "1400000000000", - "now": "2020-09-25T13:00:37.397336923Z" + "now": "2020-10-07T14:21:01.1602080461Z" }, "input": [ { @@ -110,37 +113,34 @@ }, "chain_id": "test-chain", "height": "4", - "time": "1970-01-01T00:00:05Z", + "time": "1970-01-01T00:00:04Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "AAFE392AA939DA2A051F3C57707569B1836F93ACC8F35B57BB3CDF615B649013", - "next_validators_hash": "C4DFBC98F77BE756D7EB3B475471189E82F7760DD111754AA2A25CF548AE6EF8", - "consensus_hash": "AAFE392AA939DA2A051F3C57707569B1836F93ACC8F35B57BB3CDF615B649013", + "validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "next_validators_hash": "5F7419DA4B1BCFC2D2EB8C663405D9FF67DDE3BF88DB0A8A5D579E6FF1AD814E", + "consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" + "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" }, "commit": { "height": "4", "round": 1, "block_id": { - "hash": "F3CA43CC09E15D7BFE7F80BAFF46AD5F955CD11B5889139445C13468C8A72071", - "parts": null + "hash": "3CAEB0BC5FF6215FD9C5B8066A6AC70172FBED7DCCC70E52FA362050818875A1", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ - { - "block_id_flag": 2, - "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:05Z", - "signature": "+0eo1EKY8bX1jvOEy8q/MsR0uXbHLiXwwoUK6ztGgJ+VSECIxY4Wcgyy87ppknBExSpqZvcJUx2I/+8s9NJ1Bg==" - }, { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:05Z", - "signature": "xSNUAK3hevHA+JPgqb8om9HYXJ+d1wKs3bbbzaNRBAaJG9Nm3i9ndVGPSRHj6rqF+E/QOCElXYRO6uWXGlcCDw==" + "timestamp": "1970-01-01T00:00:04Z", + "signature": "906ZZfMro9iSNdUYKBZPRp2Z+hI1LDN0TyTCJKx6nm912kcMm7Xi950+b8KB4KfskfLQck5BN4AeI49CTo4SAw==" } ] } @@ -155,15 +155,6 @@ }, "voting_power": "50", "proposer_priority": null - }, - { - "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" - }, - "voting_power": "50", - "proposer_priority": null } ], "proposer": { @@ -178,6 +169,15 @@ }, "next_validator_set": { "validators": [ + { + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + }, + "voting_power": "50", + "proposer_priority": null + }, { "address": "81D85BE9567F7069A4760C663062E66660DADF34", "pub_key": { @@ -188,27 +188,27 @@ "proposer_priority": null }, { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "6AE5C701F508EB5B63343858E068C5843F28105F", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:20Z", + "now": "1970-01-01T00:00:05Z", "verdict": "NOT_ENOUGH_TRUST" }, { @@ -220,32 +220,47 @@ "app": "0" }, "chain_id": "test-chain", - "height": "3", - "time": "1970-01-01T00:00:04Z", + "height": "2", + "time": "1970-01-01T00:00:02Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "next_validators_hash": "AAFE392AA939DA2A051F3C57707569B1836F93ACC8F35B57BB3CDF615B649013", - "consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", + "validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", + "next_validators_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", + "consensus_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", "app_hash": "", "last_results_hash": null, "evidence_hash": null, "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" }, "commit": { - "height": "3", + "height": "2", "round": 1, "block_id": { - "hash": "D51B3B1961428D77FA9977FC8BCF317F3303618A3E3106327999C026B51EF2DE", - "parts": null + "hash": "00C1B20811F24EDC72673D79AC54F258F9C419DC0C0151BE91C867A0D5BF0CF2", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "timestamp": "1970-01-01T00:00:04Z", - "signature": "77AlzqGGAhVKOatATnP1Bxt2zNkvFMh7fUIPTSeVYHP+gsBeFGDvg1/1JyLZzS5A28rLhKARJokupyNpx5UsDg==" + "timestamp": "1970-01-01T00:00:02Z", + "signature": "scegdXJBQ/ulXYaYUnrMsTV16k0VEYNgTE8gYkO9yHmXicRv9DiX5ANBAL3OQLDjKX0BEjIr3OQSlZkHDvCnBw==" + }, + { + "block_id_flag": 2, + "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", + "timestamp": "1970-01-01T00:00:02Z", + "signature": "Y9SaaCm5SziKCcQOJymDFEd279KjevVaQ1e+QBXebeTkQwREeEhGkdAm3gkXXi2G03hu4wUxccHPrW4lsjO1Dw==" + }, + { + "block_id_flag": 2, + "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "timestamp": "1970-01-01T00:00:02Z", + "signature": "BOvwFsWxXmYKlwkOZ8snlTnlNN9a8Np3b9rkMi4+facah4VcVmQ8EiNQYJX9sVu8/OWkric/GRuILAGWXqcQAw==" } ] } @@ -260,6 +275,24 @@ }, "voting_power": "50", "proposer_priority": null + }, + { + "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + }, + "voting_power": "50", + "proposer_priority": null + }, + { + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + }, + "voting_power": "50", + "proposer_priority": null } ], "proposer": { @@ -275,10 +308,10 @@ "next_validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null @@ -294,18 +327,18 @@ } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null } } }, - "now": "1970-01-01T00:23:20Z", - "verdict": "NOT_ENOUGH_TRUST" + "now": "1970-01-01T00:00:05Z", + "verdict": "SUCCESS" }, { "block": { @@ -316,50 +349,41 @@ "app": "0" }, "chain_id": "test-chain", - "height": "2", - "time": "1970-01-01T00:00:02Z", + "height": "3", + "time": "1970-01-01T00:00:03Z", "last_block_id": null, "last_commit_hash": null, "data_hash": null, - "validators_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", + "validators_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", "next_validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068", - "consensus_hash": "F6AF3B9193F2672E2E3830EC49F0D7E527291DEDA4326EDB7A6FB812BE8F3251", + "consensus_hash": "A4AC4A82A6DA63B5F3F3862C625F5D14B5FD0BEE6E34DCA44E91EBBA4BA44365", "app_hash": "", "last_results_hash": null, "evidence_hash": null, - "proposer_address": "6AE5C701F508EB5B63343858E068C5843F28105F" + "proposer_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A" }, "commit": { - "height": "2", + "height": "3", "round": 1, "block_id": { - "hash": "B465A6F4508944E417746C30FC22895BCA0F0B763F118495C77211F89A83C43C", - "parts": null + "hash": "05598FB87D7AA5B077F7024F1AE8C7056726EB8D53E3DA79EB9AFB4992414062", + "parts": { + "total": 0, + "hash": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "signatures": [ { "block_id_flag": 2, "validator_address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "oxSqbpbIX3m7yykhmcE77ZnYP2tkn9d5LBz9ELxGy0WoOtMsGUxAU5ZJsizME0rsTzW33DYwaozC6uyBCfq5CQ==" - }, - { - "block_id_flag": 1, - "validator_address": null, - "timestamp": null, - "signature": null - }, - { - "block_id_flag": 2, - "validator_address": "81D85BE9567F7069A4760C663062E66660DADF34", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "fuLGnaCplmUrK925RDKDzsFqIU57rdx0Np72GDdjjEarZ1fYpTctt4TsZCV2HHKspb+CFQXPMDwxMzrzTnRwBA==" + "timestamp": "1970-01-01T00:00:03Z", + "signature": "Ja3/8/KA0cF3VX7r4p7yoJNeux7XmRdhzepsaNJGyxB1+wJQgjWDkPVR6ZjvWjJBKwJfdErW2HmhVYsqXQLKCw==" }, { "block_id_flag": 2, "validator_address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", - "timestamp": "1970-01-01T00:00:02Z", - "signature": "mNLglv9h+lw2OYJeGxxnoy9OS7TWxQV3bmDGxrfLVixYxZlGvoYD6gTte/FBF+xnJOkRN+uzhpLu9Uo3J0TCDw==" + "timestamp": "1970-01-01T00:00:03Z", + "signature": "Sl/Wv0RE1AIdWaGLuy6daPMFZs/aP32S1TTm9gumhcWyMYz4buiN5mJYwM0V4vaAoxCSCBoqO9Siy+5NbxHWAw==" } ] } @@ -367,38 +391,29 @@ "validator_set": { "validators": [ { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" - }, - "voting_power": "50", - "proposer_priority": null - }, - { - "address": "81D85BE9567F7069A4760C663062E66660DADF34", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "Lk4zm2cJO4FpzXFF9WUV9NzOLfr5jV+ps7EhwUDKlZM=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null }, { - "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", + "address": "0616A636E7D0579A632EC37ED3C3F2B7E8522A0A", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" + "value": "kwd8trZ8t5ASwgUbBEAnDq49nRRrrKvt2onhS4JSfQM=" }, "voting_power": "50", "proposer_priority": null } ], "proposer": { - "address": "6AE5C701F508EB5B63343858E068C5843F28105F", + "address": "C479DB6F37AB9757035CFBE10B687E27668EE7DF", "pub_key": { "type": "tendermint/PubKeyEd25519", - "value": "GQEC/HB4sDBAVhHtUzyv4yct9ZGnudaP209QQBSTfSQ=" + "value": "3wf60CidQcsIO7TksXzEZsJefMUFF73k6nP1YeEo9to=" }, "voting_power": "50", "proposer_priority": null @@ -427,8 +442,8 @@ } } }, - "now": "1970-01-01T00:23:22Z", - "verdict": "INVALID" + "now": "1970-01-01T00:00:05Z", + "verdict": "SUCCESS" } ] } \ No newline at end of file diff --git a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestValsetDifferentAllSteps.tla b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestValsetDifferentAllSteps.tla index 62ea694c7..281dfa70e 100644 --- a/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestValsetDifferentAllSteps.tla +++ b/light-client/tests/support/model_based/single_step/MC4_4_faulty_TestValsetDifferentAllSteps.tla @@ -17,29 +17,29 @@ State2 == lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> {"n1"}, + VS |-> { "n3", "n4" }, height |-> 3, lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4] + time |-> 3] @@ 4 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + :> [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5] + lastCommit |-> { "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n2", "n3" }, + VS |-> { "n1", "n2", "n4" }, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 6] + lastCommit |-> {"n1"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -57,7 +57,7 @@ State2 == height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1400, + now |-> 5, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -76,7 +76,7 @@ State2 == time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" /\ nextHeight = 4 -/\ now = 1400 +/\ now = 5 /\ nprobes = 0 /\ prevCurrent = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -85,7 +85,7 @@ State2 == height |-> 1, lastCommit |-> {}, time |-> 1]] -/\ prevNow = 1400 +/\ prevNow = 5 /\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -107,29 +107,29 @@ State3 == lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> {"n1"}, + VS |-> { "n3", "n4" }, height |-> 3, lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4] + time |-> 3] @@ 4 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + :> [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5] + lastCommit |-> { "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n2", "n3" }, + VS |-> { "n1", "n2", "n4" }, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 6] + lastCommit |-> {"n1"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -139,13 +139,13 @@ State3 == lastCommit |-> {}, time |-> 1]] @@ 4 - :> [Commits |-> { "n1", "n4" }, + :> [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5]] + lastCommit |-> { "n3", "n4" }, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -155,7 +155,7 @@ State3 == height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1400, + now |-> 5, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -167,14 +167,14 @@ State3 == time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n1", "n4" }, + [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5]], - now |-> 1400, + lastCommit |-> { "n3", "n4" }, + time |-> 4]], + now |-> 5, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -192,17 +192,17 @@ State3 == lastCommit |-> {}, time |-> 1]] /\ lightBlockStatus = 1 :> "StateVerified" @@ 4 :> "StateUnverified" -/\ nextHeight = 3 -/\ now = 1400 +/\ nextHeight = 2 +/\ now = 5 /\ nprobes = 1 -/\ prevCurrent = [Commits |-> { "n1", "n4" }, +/\ prevCurrent = [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5]] -/\ prevNow = 1400 + lastCommit |-> { "n3", "n4" }, + time |-> 4]] +/\ prevNow = 5 /\ prevVerdict = "NOT_ENOUGH_TRUST" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -213,7 +213,7 @@ State3 == time |-> 1]] /\ state = "working" -(* Transition 1 to State4 *) +(* Transition 0 to State4 *) State4 == /\ Faulty = {} @@ -224,29 +224,29 @@ State4 == lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> {"n1"}, + VS |-> { "n3", "n4" }, height |-> 3, lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4] + time |-> 3] @@ 4 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + :> [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5] + lastCommit |-> { "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n2", "n3" }, + VS |-> { "n1", "n2", "n4" }, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 6] + lastCommit |-> {"n1"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -255,22 +255,22 @@ State4 == height |-> 1, lastCommit |-> {}, time |-> 1]] - @@ 3 - :> [Commits |-> {"n1"}, + @@ 2 + :> [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, - height |-> 3, - lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4]] + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, + height |-> 2, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 2]] @@ 4 - :> [Commits |-> { "n1", "n4" }, + :> [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5]] + lastCommit |-> { "n3", "n4" }, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -280,7 +280,7 @@ State4 == height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1400, + now |-> 5, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -292,14 +292,14 @@ State4 == time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n1", "n4" }, + [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5]], - now |-> 1400, + lastCommit |-> { "n3", "n4" }, + time |-> 4]], + now |-> 5, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -311,15 +311,15 @@ State4 == time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, - height |-> 3, - lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4]], - now |-> 1400, - verdict |-> "NOT_ENOUGH_TRUST", + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, + height |-> 2, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 2]], + now |-> 5, + verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -328,26 +328,26 @@ State4 == height |-> 1, lastCommit |-> {}, time |-> 1]]] -/\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, +/\ latestVerified = [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]] -/\ lightBlockStatus = 1 :> "StateVerified" @@ 3 :> "StateUnverified" @@ 4 :> "StateUnverified" -/\ nextHeight = 2 -/\ now = 1402 + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, + height |-> 2, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 2]] +/\ lightBlockStatus = 1 :> "StateVerified" @@ 2 :> "StateVerified" @@ 4 :> "StateUnverified" +/\ nextHeight = 3 +/\ now = 5 /\ nprobes = 2 -/\ prevCurrent = [Commits |-> {"n1"}, +/\ prevCurrent = [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, - height |-> 3, - lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4]] -/\ prevNow = 1400 -/\ prevVerdict = "NOT_ENOUGH_TRUST" + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, + height |-> 2, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 2]] +/\ prevNow = 5 +/\ prevVerdict = "SUCCESS" /\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> [NextVS |-> { "n1", "n2", "n3" }, @@ -357,7 +357,7 @@ State4 == time |-> 1]] /\ state = "working" -(* Transition 5 to State5 *) +(* Transition 3 to State5 *) State5 == /\ Faulty = {} @@ -368,29 +368,29 @@ State5 == lastCommit |-> {}, time |-> 1] @@ 2 - :> [NextVS |-> {"n1"}, + :> [NextVS |-> { "n3", "n4" }, VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2] @@ 3 - :> [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, + :> [NextVS |-> {"n1"}, + VS |-> { "n3", "n4" }, height |-> 3, lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4] + time |-> 3] @@ 4 - :> [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + :> [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5] + lastCommit |-> { "n3", "n4" }, + time |-> 4] @@ 5 :> [NextVS |-> { "n1", "n2", "n3", "n4" }, - VS |-> { "n2", "n3" }, + VS |-> { "n1", "n2", "n4" }, height |-> 5, - lastCommit |-> { "n1", "n4" }, - time |-> 6] + lastCommit |-> {"n1"}, + time |-> 5] /\ fetchedLightBlocks = 1 :> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -400,29 +400,29 @@ State5 == lastCommit |-> {}, time |-> 1]] @@ 2 - :> [Commits |-> { "n2", "n3", "n4" }, + :> [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> {"n1"}, + [NextVS |-> { "n3", "n4" }, VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]] @@ 3 - :> [Commits |-> {"n1"}, + :> [Commits |-> { "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, + [NextVS |-> {"n1"}, + VS |-> { "n3", "n4" }, height |-> 3, lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4]] + time |-> 3]] @@ 4 - :> [Commits |-> { "n1", "n4" }, + :> [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5]] + lastCommit |-> { "n3", "n4" }, + time |-> 4]] /\ history = 0 :> [current |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -432,7 +432,7 @@ State5 == height |-> 1, lastCommit |-> {}, time |-> 1]], - now |-> 1400, + now |-> 5, verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -444,14 +444,14 @@ State5 == time |-> 1]]] @@ 1 :> [current |-> - [Commits |-> { "n1", "n4" }, + [Commits |-> {"n1"}, header |-> - [NextVS |-> { "n2", "n3" }, - VS |-> { "n1", "n4" }, + [NextVS |-> { "n1", "n2", "n4" }, + VS |-> {"n1"}, height |-> 4, - lastCommit |-> {"n1"}, - time |-> 5]], - now |-> 1400, + lastCommit |-> { "n3", "n4" }, + time |-> 4]], + now |-> 5, verdict |-> "NOT_ENOUGH_TRUST", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, @@ -463,15 +463,15 @@ State5 == time |-> 1]]] @@ 2 :> [current |-> - [Commits |-> {"n1"}, + [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n1", "n4" }, - VS |-> {"n1"}, - height |-> 3, - lastCommit |-> { "n1", "n2", "n3" }, - time |-> 4]], - now |-> 1400, - verdict |-> "NOT_ENOUGH_TRUST", + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, + height |-> 2, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 2]], + now |-> 5, + verdict |-> "SUCCESS", verified |-> [Commits |-> { "n1", "n2", "n3", "n4" }, header |-> @@ -482,66 +482,65 @@ State5 == time |-> 1]]] @@ 3 :> [current |-> - [Commits |-> { "n2", "n3", "n4" }, + [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n1"}, - VS |-> { "n1", "n2", "n3" }, - height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, - time |-> 2]], - now |-> 1402, - verdict |-> "INVALID", + VS |-> { "n3", "n4" }, + height |-> 3, + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]], + now |-> 5, + verdict |-> "SUCCESS", verified |-> - [Commits |-> { "n1", "n2", "n3", "n4" }, + [Commits |-> { "n1", "n2", "n3" }, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]]] -/\ latestVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, + [NextVS |-> { "n3", "n4" }, + VS |-> { "n1", "n2", "n3" }, + height |-> 2, + lastCommit |-> { "n1", "n2", "n3", "n4" }, + time |-> 2]]] +/\ latestVerified = [Commits |-> { "n3", "n4" }, header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]] + [NextVS |-> {"n1"}, + VS |-> { "n3", "n4" }, + height |-> 3, + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]] /\ lightBlockStatus = 1 :> "StateVerified" - @@ 2 :> "StateFailed" - @@ 3 :> "StateUnverified" + @@ 2 :> "StateVerified" + @@ 3 :> "StateVerified" @@ 4 :> "StateUnverified" -/\ nextHeight = 2 -/\ now = 1402 +/\ nextHeight = 4 +/\ now = 5 /\ nprobes = 3 -/\ prevCurrent = [Commits |-> { "n2", "n3", "n4" }, +/\ prevCurrent = [Commits |-> { "n3", "n4" }, header |-> [NextVS |-> {"n1"}, + VS |-> { "n3", "n4" }, + height |-> 3, + lastCommit |-> { "n1", "n2", "n3" }, + time |-> 3]] +/\ prevNow = 5 +/\ prevVerdict = "SUCCESS" +/\ prevVerified = [Commits |-> { "n1", "n2", "n3" }, + header |-> + [NextVS |-> { "n3", "n4" }, VS |-> { "n1", "n2", "n3" }, height |-> 2, - lastCommit |-> { "n1", "n3", "n4" }, + lastCommit |-> { "n1", "n2", "n3", "n4" }, time |-> 2]] -/\ prevNow = 1402 -/\ prevVerdict = "INVALID" -/\ prevVerified = [Commits |-> { "n1", "n2", "n3", "n4" }, - header |-> - [NextVS |-> { "n1", "n2", "n3" }, - VS |-> { "n1", "n2", "n3", "n4" }, - height |-> 1, - lastCommit |-> {}, - time |-> 1]] -/\ state = "finishedFailure" +/\ state = "working" (* The following formula holds true in the last state and violates the invariant *) InvariantViolation == - state = "finishedFailure" - /\ (Cardinality((DOMAIN fetchedLightBlocks)) = 4 - /\ (\A s1$2 \in DOMAIN history: - \A s2$2 \in DOMAIN history: - s1$2 = s2$2 - \/ ~(history[s1$2]["current"]["header"]["VS"] - = history[s2$2]["current"]["header"]["VS"]))) + Cardinality((DOMAIN fetchedLightBlocks)) = 4 + /\ (\A s1$2 \in DOMAIN history: + \A s2$2 \in DOMAIN history: + s1$2 = s2$2 + \/ ~(history[s1$2]["current"]["header"]["VS"] + = history[s2$2]["current"]["header"]["VS"])) ================================================================================ -\* Created by Apalache on Fri Sep 25 15:00:37 CEST 2020 +\* Created by Apalache on Wed Oct 07 14:21:01 UTC 2020 \* https://github.com/informalsystems/apalache diff --git a/light-node/src/commands/initialize.rs b/light-node/src/commands/initialize.rs index 182d14170..a7b581842 100644 --- a/light-node/src/commands/initialize.rs +++ b/light-node/src/commands/initialize.rs @@ -15,6 +15,7 @@ use abscissa_core::Runnable; use tendermint::{hash, Hash}; +use std::convert::TryInto; use tendermint_light_client::builder::LightClientBuilder; use tendermint_light_client::store::sled::SledStore; use tendermint_light_client::store::LightStore; @@ -48,7 +49,7 @@ impl Runnable for InitCmd { let light_client_config = node_config.light_clients.first().unwrap(); if let Err(e) = initialize_subjectively( - self.height.into(), + self.height.try_into().unwrap(), subjective_header_hash, &node_config, &light_client_config, diff --git a/rpc/src/client/transport/http.rs b/rpc/src/client/transport/http.rs index c7a36028f..fb77d14ec 100644 --- a/rpc/src/client/transport/http.rs +++ b/rpc/src/client/transport/http.rs @@ -33,7 +33,6 @@ use tendermint::net; /// [`Client`]: trait.Client.html /// [`Event`]: ./event/struct.Event.html /// [`WebSocketClient`]: struct.WebSocketClient.html -/// #[derive(Debug, Clone)] pub struct HttpClient { host: String, diff --git a/rpc/src/client/transport/mock.rs b/rpc/src/client/transport/mock.rs index 3b41fc18b..b9fdd6e5d 100644 --- a/rpc/src/client/transport/mock.rs +++ b/rpc/src/client/transport/mock.rs @@ -116,6 +116,7 @@ impl MockRequestMethodMatcher { #[cfg(test)] mod test { use super::*; + use std::convert::TryFrom; use std::path::PathBuf; use tendermint::block::Height; use tendermint::chain::Id; @@ -138,10 +139,17 @@ mod test { let abci_info = client.abci_info().await.unwrap(); assert_eq!("GaiaApp".to_string(), abci_info.data); - assert_eq!(Height::from(488120_u32), abci_info.last_block_height); + assert_eq!( + Height::try_from(488120_u64).unwrap(), + abci_info.last_block_height + ); - let block = client.block(Height::from(10_u32)).await.unwrap().block; - assert_eq!(Height::from(10_u32), block.header.height); + let block = client + .block(Height::try_from(10_u64).unwrap()) + .await + .unwrap() + .block; + assert_eq!(Height::try_from(10_u64).unwrap(), block.header.height); assert_eq!("cosmoshub-2".parse::().unwrap(), block.header.chain_id); } } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 0eb4ea847..d879de464 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -10,8 +10,13 @@ //! //! | Feature | Description | //! | ------- | ----------- | -//! | `http-client` | Provides [`HttpClient`], which is a basic RPC client that interacts with remote Tendermint nodes via **JSON-RPC over HTTP**. This client does not provide [`Event`] subscription functionality. See the [Tendermint RPC] for more details. | -//! | `websocket-client` | Provides [`WebSocketClient`], which currently only provides [`Event`] subscription functionality over a WebSocket connection. See the [`/subscribe` endpoint] in the Tendermint RPC for more details. This client does not yet provide access to the RPC methods provided by the [`Client`] trait (this is planned for a future release). | +//! | `http-client` | Provides [`HttpClient`], which is a basic RPC client that interacts with +//! remote Tendermint nodes via **JSON-RPC over HTTP**. This client does not provide [`Event`] +//! subscription functionality. See the [Tendermint RPC] for more details. | +//! | `websocket-client` | Provides [`WebSocketClient`], which currently only provides [`Event`] +//! subscription functionality over a WebSocket connection. See the [`/subscribe` endpoint] in the +//! Tendermint RPC for more details. This client does not yet provide access to the RPC methods +//! provided by the [`Client`] trait (this is planned for a future release). | //! //! ### Mock Clients //! diff --git a/rpc/tests/integration.rs b/rpc/tests/integration.rs index 9ac9f0bba..3b06e7111 100644 --- a/rpc/tests/integration.rs +++ b/rpc/tests/integration.rs @@ -208,7 +208,7 @@ fn broadcast_tx_commit_null_data() { fn commit() { let response = endpoint::commit::Response::from_string(&read_json_fixture("commit")).unwrap(); let header = response.signed_header.header; - assert_eq!(header.chain_id.as_ref(), EXAMPLE_CHAIN); + assert_eq!(header.chain_id.as_ref(), "dockerchain"); // For now we just want to make sure the commit including precommits and a block_id exist // in SignedHeader; later we should verify some properties: e.g. block_id.hash matches the // header etc: diff --git a/rpc/tests/support/commit.json b/rpc/tests/support/commit.json index 552fe18c8..1f0e55472 100644 --- a/rpc/tests/support/commit.json +++ b/rpc/tests/support/commit.json @@ -1,49 +1,49 @@ { "jsonrpc": "2.0", - "id": "", + "id": 1, "result": { "signed_header": { "header": { "version": { - "block": "10", + "block": "11", "app": "1" }, - "chain_id": "cosmoshub-2", + "chain_id": "dockerchain", "height": "10", - "time": "2020-03-15T16:57:08.151Z", + "time": "2020-10-01T13:39:16.446728262Z", "last_block_id": { - "hash": "760E050B2404A4BC661635CA552FF45876BCD927C367ADF88961E389C01D32FF", + "hash": "F039C21B34127537B56D653A108ECC847EA0178E65FE69476D2F97F044A69E1C", "parts": { "total": 1, - "hash": "485070D01F9543827B3F9BAF11BDCFFBFD2BDED0B63D7192FA55649B94A1D5DE" + "hash": "D31DCBFF294D3CEFA57EAEF7D411350FD6D700A1E9ED4F79711B5CC83F5BE5BC" } }, - "last_commit_hash": "594F029060D5FAE6DDF82C7DC4612055EC7F941DFED34D43B2754008DC3BBC77", - "data_hash": "", - "validators_hash": "3C0A744897A1E0DBF1DEDE1AF339D65EDDCF10E6338504368B20C508D6D578DC", - "next_validators_hash": "3C0A744897A1E0DBF1DEDE1AF339D65EDDCF10E6338504368B20C508D6D578DC", + "last_commit_hash": "4332A4CA94EA4F73C195640A1913654C086576BB43DDF0FF87B631A09F1F7E52", + "data_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "validators_hash": "7CEBEAF9DBAE9E3488A7468BC999E620DAB6395CBF80BC9BAAC1DF71EB816139", + "next_validators_hash": "7CEBEAF9DBAE9E3488A7468BC999E620DAB6395CBF80BC9BAAC1DF71EB816139", "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", "app_hash": "0000000000000000", - "last_results_hash": "", - "evidence_hash": "", - "proposer_address": "12CC3970B3AE9F19A4B1D98BE1799F2CB923E0A3" + "last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "proposer_address": "DC30B689DABDCAAA92FF79FBAE619362AD97293C" }, "commit": { "height": "10", "round": 0, "block_id": { - "hash": "6DFCE2EB94FB52CE538E84ADB43568C05FD954AB92F1E2CAA95F79BAF9BE77EA", + "hash": "EDEF6D800E431D29A2EEC727408F24540104449246A28A71AE335AED8E892D1E", "parts": { "total": 1, - "hash": "BBA710736635FA20CDB4F48732563869E90871D31FE9E7DE3D900CD4334D8775" + "hash": "1AA0DDA243CCC5FA0DC0C958DE5CBC12C1B91B9472BE2DF7C1D797C4BBA87436" } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "12CC3970B3AE9F19A4B1D98BE1799F2CB923E0A3", - "timestamp": "2020-03-15T16:57:09.208721Z", - "signature": "B8x8sYHWiDalvf1m5yb1l1NQJRb3z5QYNCKxbjGIGI+HQB7Ss1cV5vPn4fh2jg1pMN+gFwLxAZGfdyBLQIuoCQ==" + "validator_address": "DC30B689DABDCAAA92FF79FBAE619362AD97293C", + "timestamp": "2020-10-01T13:39:16.96959972Z", + "signature": "wlPr5XjCfaX5u432QUpjnsTQmJkcNJ37R78QaIQNSv3NyzJMMW0jbeSlF2Bi83CKhrGDhGL7aq/mKaIZMrlfCQ==" } ] } diff --git a/rpc/tests/support/commit_1.json b/rpc/tests/support/commit_1.json index 6e681ff93..96ebce12b 100644 --- a/rpc/tests/support/commit_1.json +++ b/rpc/tests/support/commit_1.json @@ -1,16 +1,16 @@ { "jsonrpc": "2.0", - "id": -1, + "id": 1, "result": { "signed_header": { "header": { "version": { - "block": "10", + "block": "11", "app": "1" }, "chain_id": "dockerchain", "height": "1", - "time": "2020-07-09T14:24:44.7157258Z", + "time": "2020-09-30T15:53:38.3317756Z", "last_block_id": { "hash": "", "parts": { @@ -18,32 +18,32 @@ "hash": "" } }, - "last_commit_hash": "", - "data_hash": "", - "validators_hash": "74F2AC2B6622504D08DD2509E28CE731985CFE4D133C9DB0CB85763EDCA95AA3", - "next_validators_hash": "74F2AC2B6622504D08DD2509E28CE731985CFE4D133C9DB0CB85763EDCA95AA3", + "last_commit_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "data_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "validators_hash": "7CEBEAF9DBAE9E3488A7468BC999E620DAB6395CBF80BC9BAAC1DF71EB816139", + "next_validators_hash": "7CEBEAF9DBAE9E3488A7468BC999E620DAB6395CBF80BC9BAAC1DF71EB816139", "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", "app_hash": "", - "last_results_hash": "", - "evidence_hash": "", - "proposer_address": "AD358F20C8CE80889E0F0248FDDC454595D632AE" + "last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "proposer_address": "DC30B689DABDCAAA92FF79FBAE619362AD97293C" }, "commit": { "height": "1", "round": 0, "block_id": { - "hash": "E593C2A5FFF56F060034BE5CCC79AEC1DC396B7A1E137148E743B6B8CA79A7DF", + "hash": "14FE58148FBF37743B360D1B92BB8528ADA50E22BA219DA417B16379EEE306D3", "parts": { "total": 1, - "hash": "BF5130E879A02AC4BB83E392732ED4A37BE2F01304A615467EE7960858774E57" + "hash": "F45A469B007676CC8A65DEB6C194D04A9166F4690F36ECA7C71E730E2F1D916E" } }, "signatures": [ { "block_id_flag": 2, - "validator_address": "AD358F20C8CE80889E0F0248FDDC454595D632AE", - "timestamp": "2020-07-10T23:47:42.8655562Z", - "signature": "HWADptT75yH6Y558j268oItSorBwngMsqfldKgXQaUT02Gd6OqpzFHZgPUzoaLuVa1rk6EM7W0Rx1dDdpOIoDg==" + "validator_address": "DC30B689DABDCAAA92FF79FBAE619362AD97293C", + "timestamp": "2020-10-01T13:39:12.243358745Z", + "signature": "/PI3gfFri14erU4//7C16XXGZZVzldjVx14cBM+b2hRenLTBsn2dNGz33t+MFWEOBe/vGvURkApciVrID3ihAA==" } ] } diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index 0b0c6b39e..a7382a96b 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -57,7 +57,6 @@ tendermint-proto = { path = "../proto" } toml = { version = "0.5" } zeroize = { version = "1.1", features = ["zeroize_derive"] } ripemd160 = { version = "0.9", optional = true } - [dev-dependencies] tendermint-rpc = { path = "../rpc", features = [ "http-client", "websocket-client" ] } tokio = { version = "0.2", features = [ "macros" ] } diff --git a/tendermint/src/account.rs b/tendermint/src/account.rs index b31236dc6..99fd707c5 100644 --- a/tendermint/src/account.rs +++ b/tendermint/src/account.rs @@ -19,6 +19,8 @@ use subtle_encoding::hex; use crate::public_key::Secp256k1; #[cfg(feature = "secp256k1")] use ripemd160::Ripemd160; +use std::convert::TryFrom; +use tendermint_proto::DomainType; /// Size of an account ID in bytes pub const LENGTH: usize = 20; @@ -27,6 +29,27 @@ pub const LENGTH: usize = 20; #[derive(Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] pub struct Id([u8; LENGTH]); +impl DomainType> for Id {} + +impl TryFrom> for Id { + type Error = Error; + + fn try_from(value: Vec) -> Result { + if value.len() != LENGTH { + return Err(Kind::InvalidAccountIdLength.into()); + } + let mut slice: [u8; LENGTH] = [0; LENGTH]; + slice.copy_from_slice(&value[..]); + Ok(Id(slice)) + } +} + +impl From for Vec { + fn from(value: Id) -> Self { + value.as_bytes().to_vec() + } +} + impl Id { /// Create a new account ID from raw bytes pub fn new(bytes: [u8; LENGTH]) -> Id { diff --git a/tendermint/src/amino_types.rs b/tendermint/src/amino_types.rs deleted file mode 100644 index 417161c04..000000000 --- a/tendermint/src/amino_types.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Message types serialized using the Amino serialization format -//! - -#![allow(missing_docs)] - -pub mod block_id; -pub mod ed25519; -pub mod message; -pub mod proposal; -pub mod signature; -pub mod validate; -pub mod vote; - -pub use self::{ - block_id::{BlockId, CanonicalBlockId, CanonicalPartSetHeader, PartSetHeader}, - ed25519::{PubKeyRequest, PubKeyResponse}, - proposal::{SignProposalRequest, SignedProposalResponse}, - signature::SignableMsg, - validate::ConsensusMessage, -}; diff --git a/tendermint/src/amino_types/block_id.rs b/tendermint/src/amino_types/block_id.rs deleted file mode 100644 index f70b41400..000000000 --- a/tendermint/src/amino_types/block_id.rs +++ /dev/null @@ -1,231 +0,0 @@ -use super::validate::{ConsensusMessage, Kind::InvalidHashSize}; -use crate::block::parts; -use crate::{ - block, - error::Error, - hash, - hash::{Hash, SHA256_HASH_SIZE}, -}; -use std::convert::TryFrom; -use tendermint_proto::types::BlockId as RawBlockId; -use tendermint_proto::types::CanonicalBlockId as RawCanonicalBlockId; -use tendermint_proto::types::CanonicalPartSetHeader as RawCanonicalPartSetHeader; -use tendermint_proto::types::PartSetHeader as RawPartSetHeader; -use tendermint_proto::DomainType; - -impl DomainType for BlockId {} - -/// BlockID -#[derive(Clone, PartialEq, Debug)] -pub struct BlockId { - pub hash: Vec, - pub part_set_header: ::std::option::Option, -} - -impl TryFrom for BlockId { - type Error = Error; - - fn try_from(value: RawBlockId) -> Result { - Ok(BlockId { - hash: value.hash, - part_set_header: match value.part_set_header { - None => None, - Some(raw_part_set_header) => Some(PartSetHeader::try_from(raw_part_set_header)?), - }, - }) - } -} - -impl From for RawBlockId { - fn from(value: BlockId) -> Self { - RawBlockId { - hash: value.hash, - part_set_header: match value.part_set_header { - None => None, - Some(part_set_header) => Some(RawPartSetHeader::from(part_set_header)), - }, - } - } -} - -impl BlockId { - pub fn new(hash: Vec, part_set_header: Option) -> Self { - BlockId { - hash, - part_set_header, - } - } -} - -impl block::ParseId for BlockId { - fn parse_block_id(&self) -> Result { - let hash = Hash::new(hash::Algorithm::Sha256, &self.hash)?; - let part_set_header = self - .part_set_header - .as_ref() - .and_then(PartSetHeader::parse_part_set_header); - Ok(block::Id::new(hash, part_set_header)) - } -} - -impl From<&block::Id> for BlockId { - fn from(bid: &block::Id) -> Self { - let bid_hash = bid.hash.as_bytes(); - BlockId::new( - bid_hash.to_vec(), - bid.parts.as_ref().map(PartSetHeader::from), - ) - } -} - -impl ConsensusMessage for BlockId { - fn validate_basic(&self) -> Result<(), Error> { - // Hash can be empty in case of POLBlockID in Proposal. - if !self.hash.is_empty() && self.hash.len() != SHA256_HASH_SIZE { - return Err(InvalidHashSize.into()); - } - self.part_set_header - .as_ref() - .map_or(Ok(()), ConsensusMessage::validate_basic) - } -} - -impl DomainType for CanonicalBlockId {} - -#[derive(Clone, PartialEq)] -pub struct CanonicalBlockId { - pub hash: Vec, - pub part_set_header: Option, -} - -impl TryFrom for CanonicalBlockId { - type Error = Error; - - fn try_from(value: RawCanonicalBlockId) -> Result { - Ok(CanonicalBlockId { - hash: value.hash, - part_set_header: match value.part_set_header { - None => None, - Some(raw_part_set_header) => { - Some(CanonicalPartSetHeader::try_from(raw_part_set_header)?) - } - }, - }) - } -} - -impl From for RawCanonicalBlockId { - fn from(value: CanonicalBlockId) -> Self { - RawCanonicalBlockId { - hash: value.hash, - part_set_header: match value.part_set_header { - None => None, - Some(part_set_header) => Some(part_set_header.into()), - }, - } - } -} - -impl DomainType for PartSetHeader {} - -impl block::ParseId for CanonicalBlockId { - fn parse_block_id(&self) -> Result { - let hash = Hash::new(hash::Algorithm::Sha256, &self.hash)?; - let part_set_header = self - .part_set_header - .as_ref() - .and_then(CanonicalPartSetHeader::parse_part_set_header); - Ok(block::Id::new(hash, part_set_header)) - } -} -/// PartsetHeader -#[derive(Clone, PartialEq, Debug)] -pub struct PartSetHeader { - pub total: i64, - pub hash: Vec, -} - -impl TryFrom for PartSetHeader { - type Error = Error; - - fn try_from(value: RawPartSetHeader) -> Result { - Ok(PartSetHeader { - total: value.total as i64, - hash: value.hash, - }) - } -} - -impl From for RawPartSetHeader { - fn from(value: PartSetHeader) -> Self { - RawPartSetHeader { - total: value.total as u32, - hash: value.hash, - } - } -} - -impl PartSetHeader { - pub fn new(total: i64, hash: Vec) -> Self { - PartSetHeader { total, hash } - } -} - -impl From<&parts::Header> for PartSetHeader { - fn from(parts: &parts::Header) -> Self { - PartSetHeader::new(parts.total as i64, parts.hash.as_bytes().to_vec()) - } -} - -impl PartSetHeader { - fn parse_part_set_header(&self) -> Option { - Hash::new(hash::Algorithm::Sha256, &self.hash) - .map(|hash| block::parts::Header::new(self.total as u64, hash)) - .ok() - } -} - -impl ConsensusMessage for PartSetHeader { - fn validate_basic(&self) -> Result<(), Error> { - // Hash can be empty in case of POLBlockID.PartsHeader in Proposal. - if !self.hash.is_empty() && self.hash.len() != SHA256_HASH_SIZE { - return Err(InvalidHashSize.into()); - } - Ok(()) - } -} - -impl DomainType for CanonicalPartSetHeader {} -#[derive(Clone, PartialEq)] -pub struct CanonicalPartSetHeader { - pub total: u32, - pub hash: Vec, -} - -impl TryFrom for CanonicalPartSetHeader { - type Error = Error; - - fn try_from(value: RawCanonicalPartSetHeader) -> Result { - Ok(CanonicalPartSetHeader { - total: value.total, - hash: value.hash, - }) - } -} - -impl From for RawCanonicalPartSetHeader { - fn from(value: CanonicalPartSetHeader) -> Self { - RawCanonicalPartSetHeader { - total: value.total, - hash: value.hash, - } - } -} - -impl CanonicalPartSetHeader { - fn parse_part_set_header(&self) -> Option { - Hash::new(hash::Algorithm::Sha256, &self.hash) - .map(|hash| block::parts::Header::new(self.total as u64, hash)) - .ok() - } -} diff --git a/tendermint/src/amino_types/ed25519.rs b/tendermint/src/amino_types/ed25519.rs deleted file mode 100644 index 00c04b7a9..000000000 --- a/tendermint/src/amino_types/ed25519.rs +++ /dev/null @@ -1,241 +0,0 @@ -use crate::{ - error, - public_key::{Ed25519, PublicKey}, - Error, -}; -use anomaly::format_err; -use std::convert::TryFrom; -use tendermint_proto::crypto::public_key::Sum; -use tendermint_proto::privval::PubKeyRequest as RawPubKeyRequest; -use tendermint_proto::privval::PubKeyResponse as RawPubKeyResponse; -use tendermint_proto::DomainType; - -// Note:On the golang side this is generic in the sense that it could everything that implements -// github.com/tendermint/tendermint/crypto.PubKey -// While this is meant to be used with different key-types, it currently only uses a PubKeyEd25519 -// version. -// TODO(ismail): make this more generic (by modifying prost and adding a trait for PubKey) - -impl DomainType for PubKeyResponse {} -/// PubKeyResponse is a response message containing the public key. -#[derive(Clone, PartialEq, Debug)] -pub struct PubKeyResponse { - pub pub_key: Option, - pub error: Option, -} - -impl TryFrom for PubKeyResponse { - type Error = Error; - - fn try_from(value: RawPubKeyResponse) -> Result { - Ok(PubKeyResponse { - pub_key: value.pub_key, - error: value.error, - }) - } -} - -impl From for RawPubKeyResponse { - fn from(value: PubKeyResponse) -> Self { - RawPubKeyResponse { - pub_key: value.pub_key, - error: value.error, - } - } -} - -impl DomainType for PubKeyRequest {} -/// PubKeyRequest requests the consensus public key from the remote signer. -#[derive(Clone, PartialEq, Debug)] -pub struct PubKeyRequest { - pub chain_id: String, -} - -impl TryFrom for PubKeyRequest { - type Error = Error; - - fn try_from(value: RawPubKeyRequest) -> Result { - Ok(PubKeyRequest { - chain_id: value.chain_id, - }) - } -} - -impl From for RawPubKeyRequest { - fn from(value: PubKeyRequest) -> Self { - RawPubKeyRequest { - chain_id: value.chain_id, - } - } -} - -impl TryFrom for PublicKey { - type Error = Error; - - // This does not check if the underlying pub_key_ed25519 has the right size. - // The caller needs to make sure that this is actually the case. - fn try_from(response: PubKeyResponse) -> Result { - match &response - .pub_key - .ok_or_else(|| format_err!(error::Kind::InvalidKey, "empty pubkey"))? - .sum - .ok_or_else(|| format_err!(error::Kind::InvalidKey, "empty sum"))? - { - Sum::Ed25519(b) => Ed25519::from_bytes(b), - } - .map(Into::into) - .map_err(|_| format_err!(error::Kind::InvalidKey, "malformed key").into()) - } -} - -impl From for PubKeyResponse { - fn from(public_key: PublicKey) -> PubKeyResponse { - match public_key { - PublicKey::Ed25519(ref pk) => PubKeyResponse { - pub_key: Some(tendermint_proto::crypto::PublicKey { - sum: Some(tendermint_proto::crypto::public_key::Sum::Ed25519( - pk.as_bytes().to_vec(), - )), - }), - error: None, - }, - #[cfg(feature = "secp256k1")] - PublicKey::Secp256k1(_) => panic!("secp256k1 PubKeyResponse unimplemented"), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use ed25519_dalek::PUBLIC_KEY_LENGTH; - use std::convert::TryInto; - use tendermint_proto::DomainType; - - #[test] - fn test_empty_pubkey_msg() { - // test-vector generated via the following go code: - /* - import ( - "fmt" - "github.com/tendermint/tendermint/proto/tendermint/privval" - ) - func ed25519_empty() { - pkr := &privval.PubKeyRequest{ - ChainId: "", - } - pbpk, _ := pkr.Marshal() - fmt.Printf("%#v\n", pbpk) - - } - */ - - let want: Vec = vec![]; - let msg = PubKeyRequest { - chain_id: "".to_string(), - }; - let mut got = vec![]; - let _have = msg.encode(&mut got); - - assert_eq!(got, want); - - match PubKeyRequest::decode(want.as_ref()) { - Ok(have) => assert_eq!(have, msg), - Err(err) => panic!(err.to_string()), - } - } - - #[test] - fn test_ed25519_pubkey_msg() { - // test-vector generated from Go - /* - import ( - "fmt" - "github.com/tendermint/tendermint/proto/tendermint/crypto" - "github.com/tendermint/tendermint/proto/tendermint/privval" - ) - - func ed25519_key() { - pkr := &privval.PubKeyResponse{ - PubKey: &crypto.PublicKey{ - Sum: &crypto.PublicKey_Ed25519{Ed25519: []byte{ - 0x79, 0xce, 0xd, 0xe0, 0x43, 0x33, 0x4a, 0xec, 0xe0, - 0x8b, 0x7b, 0xb5, 0x61, 0xbc, 0xe7, 0xc1, 0xd4, 0x69, - 0xc3, 0x44, 0x26, 0xec, 0xef, 0xc0, 0x72, 0xa, 0x52, - 0x4d, 0x37, 0x32, 0xef, 0xed, - }, - }, - }, - Error: nil, - } - pbpk, _ := pkr.Marshal() - fmt.Printf("%#v\n", pbpk) - - } - */ - let encoded = vec![ - 0xa, 0x22, 0xa, 0x20, 0x79, 0xce, 0xd, 0xe0, 0x43, 0x33, 0x4a, 0xec, 0xe0, 0x8b, 0x7b, - 0xb5, 0x61, 0xbc, 0xe7, 0xc1, 0xd4, 0x69, 0xc3, 0x44, 0x26, 0xec, 0xef, 0xc0, 0x72, - 0xa, 0x52, 0x4d, 0x37, 0x32, 0xef, 0xed, - ]; - - let msg = PubKeyResponse { - pub_key: Some(tendermint_proto::crypto::PublicKey { - sum: Some(tendermint_proto::crypto::public_key::Sum::Ed25519(vec![ - 0x79, 0xce, 0xd, 0xe0, 0x43, 0x33, 0x4a, 0xec, 0xe0, 0x8b, 0x7b, 0xb5, 0x61, - 0xbc, 0xe7, 0xc1, 0xd4, 0x69, 0xc3, 0x44, 0x26, 0xec, 0xef, 0xc0, 0x72, 0xa, - 0x52, 0x4d, 0x37, 0x32, 0xef, 0xed, - ])), - }), - error: None, - }; - let mut got = vec![]; - let _have = msg.encode(&mut got); - - assert_eq!(got, encoded); - - match PubKeyResponse::decode(encoded.as_ref()) { - Ok(have) => assert_eq!(have, msg), - Err(err) => panic!(err), - } - } - - #[test] - fn test_into() { - let raw_pk: [u8; PUBLIC_KEY_LENGTH] = [ - 0xaf, 0xf3, 0x94, 0xc5, 0xb7, 0x5c, 0xfb, 0xd, 0xd9, 0x28, 0xe5, 0x8a, 0x92, 0xdd, - 0x76, 0x55, 0x2b, 0x2e, 0x8d, 0x19, 0x6f, 0xe9, 0x12, 0x14, 0x50, 0x80, 0x6b, 0xd0, - 0xd9, 0x3f, 0xd0, 0xcb, - ]; - let want = PublicKey::Ed25519(Ed25519::from_bytes(&raw_pk).unwrap()); - let pk = PubKeyResponse { - pub_key: Some(tendermint_proto::crypto::PublicKey { - sum: Some(tendermint_proto::crypto::public_key::Sum::Ed25519(vec![ - 0xaf, 0xf3, 0x94, 0xc5, 0xb7, 0x5c, 0xfb, 0xd, 0xd9, 0x28, 0xe5, 0x8a, 0x92, - 0xdd, 0x76, 0x55, 0x2b, 0x2e, 0x8d, 0x19, 0x6f, 0xe9, 0x12, 0x14, 0x50, 0x80, - 0x6b, 0xd0, 0xd9, 0x3f, 0xd0, 0xcb, - ])), - }), - error: None, - }; - let orig = pk.clone(); - let got: PublicKey = pk.try_into().unwrap(); - - assert_eq!(got, want); - - // and back: - let round_trip_pk: PubKeyResponse = got.into(); - assert_eq!(round_trip_pk, orig); - } - - #[test] - #[should_panic] - fn test_empty_into() { - let empty_msg = PubKeyResponse { - pub_key: None, - error: None, - }; - // we expect this to panic: - let _got: PublicKey = empty_msg.try_into().unwrap(); - } -} diff --git a/tendermint/src/amino_types/message.rs b/tendermint/src/amino_types/message.rs deleted file mode 100644 index 283a3ae88..000000000 --- a/tendermint/src/amino_types/message.rs +++ /dev/null @@ -1,39 +0,0 @@ -use prost::encoding::encoded_len_varint; -use std::convert::TryInto; - -/// Extend the original prost::Message trait with a few helper functions in order to -/// reduce boiler-plate code (and without modifying the prost dependency). -pub trait AminoMessage: prost::Message { - /// Directly encode a prost message into a freshly created Vec. - /// This can be useful when passing those bytes directly to a hasher, or, - /// to reduce boiler plate code when working with the encoded bytes. - /// - /// Warning: Only use this method, if you are in control what will be encoded. - /// If there is an encoding error, this method will panic. - fn bytes_vec(&self) -> Vec - where - Self: Sized, - { - let mut res = Vec::with_capacity(self.encoded_len()); - self.encode(&mut res).unwrap(); - res - } - - /// Encode prost message as length delimited. - /// - /// Warning: Only use this method, if you are in control what will be encoded. - /// If there is an encoding error, this method will panic. - fn bytes_vec_length_delimited(&self) -> Vec - where - Self: Sized, - { - let len = self.encoded_len(); - let mut res = - Vec::with_capacity(len + encoded_len_varint(len.try_into().expect("length overflow"))); - self.encode_length_delimited(&mut res).unwrap(); - res - } -} -impl AminoMessage for M { - // blanket impl -} diff --git a/tendermint/src/amino_types/proposal.rs b/tendermint/src/amino_types/proposal.rs deleted file mode 100644 index 2e1106faa..000000000 --- a/tendermint/src/amino_types/proposal.rs +++ /dev/null @@ -1,477 +0,0 @@ -use super::{ - block_id::{BlockId, CanonicalBlockId, CanonicalPartSetHeader}, - signature::SignableMsg, - validate::{ - self, ConsensusMessage, Kind::InvalidMessageType, Kind::MissingConsensusMessage, - Kind::NegativeHeight, Kind::NegativePOLRound, Kind::NegativeRound, - }, -}; -use crate::{ - block::{self, ParseId}, - chain, consensus, error, -}; -use bytes::BufMut; -use prost::{EncodeError, Message}; -use prost_types::Timestamp; -use std::convert::{TryFrom, TryInto}; -use tendermint_proto::privval::RemoteSignerError; -use tendermint_proto::privval::SignProposalRequest as RawSignProposalRequest; -use tendermint_proto::privval::SignedProposalResponse as RawSignedProposalResponse; -use tendermint_proto::types::CanonicalProposal as RawCanonicalProposal; -use tendermint_proto::types::Proposal as RawProposal; -use tendermint_proto::types::SignedMsgType; -use tendermint_proto::DomainType; - -impl DomainType for Proposal {} -#[derive(Clone, PartialEq, Debug)] -pub struct Proposal { - pub msg_type: u16, - pub height: u32, - pub round: u16, - pub pol_round: Option, - pub block_id: Option, - pub timestamp: Option, - pub signature: Vec, -} - -impl Proposal { - pub fn pol_round_to_i32(&self) -> i32 { - match &self.pol_round { - Some(u) => *u as i32, - None => -1, - } - } -} - -impl TryFrom for Proposal { - type Error = validate::Error; - - fn try_from(value: RawProposal) -> Result { - if value.r#type < 0 { - return Err(InvalidMessageType.into()); - } - if value.height < 0 { - return Err(NegativeHeight.into()); - } - if value.round < 0 { - return Err(NegativeRound.into()); - } - if value.pol_round < -1 { - return Err(NegativePOLRound.into()); - } - let pol_round = match value.pol_round { - -1 => None, - n => Some(n as u16), - }; - let result = Proposal { - msg_type: value.r#type as u16, - height: value.height as u32, - round: value.round as u16, - pol_round, - block_id: match value.block_id { - None => None, - Some(raw_block_id) => Some(BlockId::try_from(raw_block_id).unwrap()), - }, - timestamp: value.timestamp, - signature: value.signature, - }; - result.validate_basic().map(|_| result) - } -} - -impl From for RawProposal { - fn from(value: Proposal) -> Self { - RawProposal { - r#type: value.msg_type as i32, - height: value.height as i64, - round: value.round as i32, - pol_round: value.pol_round_to_i32(), - block_id: match value.block_id { - None => None, - Some(block_id) => Some(block_id.into()), - }, - timestamp: value.timestamp, - signature: value.signature, - } - } -} - -// TODO(tony): custom derive proc macro for this e.g. `derive(ParseBlockHeight)` -impl block::ParseHeight for Proposal { - fn parse_block_height(&self) -> Result { - Ok(block::Height::from(self.height)) - } -} - -impl DomainType for SignProposalRequest {} -/// SignProposalRequest is a request to sign a proposal -#[derive(Clone, PartialEq, Debug)] -pub struct SignProposalRequest { - pub proposal: Option, - pub chain_id: String, -} - -impl TryFrom for SignProposalRequest { - type Error = validate::Error; - - fn try_from(value: RawSignProposalRequest) -> Result { - Ok(SignProposalRequest { - proposal: match value.proposal { - None => None, - Some(proposal) => Some(Proposal::try_from(proposal)?), - }, - chain_id: value.chain_id, - }) - } -} - -impl From for RawSignProposalRequest { - fn from(value: SignProposalRequest) -> Self { - RawSignProposalRequest { - proposal: match value.proposal { - None => None, - Some(proposal) => Some(proposal.into()), - }, - chain_id: value.chain_id, - } - } -} - -impl DomainType for CanonicalProposal {} - -#[derive(Clone, PartialEq)] -pub struct CanonicalProposal { - /// type alias for byte - pub msg_type: u16, - /// canonicalization requires fixed size encoding here - pub height: u32, - /// canonicalization requires fixed size encoding here - pub round: u32, - pub pol_round: Option, - pub block_id: Option, - pub timestamp: Option, - pub chain_id: String, -} - -impl CanonicalProposal { - pub fn pol_round_to_i64(&self) -> i64 { - match &self.pol_round { - None => -1, - Some(u) => *u as i64, - } - } -} - -impl TryFrom for CanonicalProposal { - type Error = validate::Error; - - fn try_from(value: RawCanonicalProposal) -> Result { - if value.r#type < 0 { - return Err(InvalidMessageType.into()); - } - if value.height < 0 { - return Err(NegativeHeight.into()); - } - if value.round < 0 { - return Err(NegativeRound.into()); - } - if value.pol_round < -1 { - return Err(NegativePOLRound.into()); - } - let pol_round = match value.pol_round { - -1 => None, - n => Some(n as u32), - }; - Ok(CanonicalProposal { - msg_type: value.r#type as u16, - height: value.height as u32, - round: value.round as u32, - pol_round, - block_id: match value.block_id { - None => None, - Some(block_id) => Some(block_id.try_into()?), - }, - timestamp: value.timestamp, - chain_id: value.chain_id, - }) - } -} - -impl From for RawCanonicalProposal { - fn from(value: CanonicalProposal) -> Self { - RawCanonicalProposal { - r#type: value.msg_type as i32, - height: value.height as i64, - round: value.round as i64, - pol_round: value.pol_round_to_i64(), - block_id: match value.block_id { - None => None, - Some(block_id) => Some(block_id.into()), - }, - timestamp: value.timestamp, - chain_id: value.chain_id, - } - } -} - -impl chain::ParseId for CanonicalProposal { - fn parse_chain_id(&self) -> Result { - self.chain_id.parse() - } -} - -impl block::ParseHeight for CanonicalProposal { - fn parse_block_height(&self) -> Result { - Ok(block::Height::from(self.height)) - } -} - -impl DomainType for SignedProposalResponse {} - -/// SignedProposalResponse is response containing a signed proposal or an error -#[derive(Clone, PartialEq)] -pub struct SignedProposalResponse { - pub proposal: Option, - pub error: Option, -} - -impl TryFrom for SignedProposalResponse { - type Error = validate::Error; - - fn try_from(value: RawSignedProposalResponse) -> Result { - Ok(SignedProposalResponse { - proposal: match value.proposal { - None => None, - Some(proposal) => Some(Proposal::try_from(proposal)?), - }, - error: value.error, - }) - } -} - -impl From for RawSignedProposalResponse { - fn from(value: SignedProposalResponse) -> Self { - RawSignedProposalResponse { - proposal: match value.proposal { - None => None, - Some(proposal) => Some(proposal.into()), - }, - error: value.error, - } - } -} - -impl SignableMsg for SignProposalRequest { - fn sign_bytes(&self, chain_id: chain::Id, sign_bytes: &mut B) -> Result - where - B: BufMut, - { - let mut spr = self.clone(); - if let Some(ref mut pr) = spr.proposal { - pr.signature = vec![]; - } - let proposal = spr.proposal.unwrap(); - let cp = CanonicalProposal { - chain_id: chain_id.to_string(), - msg_type: SignedMsgType::Proposal as u16, - height: proposal.height, - block_id: match proposal.block_id { - Some(bid) => Some(CanonicalBlockId { - hash: bid.hash, - part_set_header: match bid.part_set_header { - Some(psh) => Some(CanonicalPartSetHeader { - hash: psh.hash, - total: psh.total as u32, - }), - None => None, - }, - }), - None => None, - }, - pol_round: proposal.pol_round.map(|n| n as u32), - round: proposal.round as u32, - timestamp: proposal.timestamp, - }; - - RawCanonicalProposal::from(cp).encode_length_delimited(sign_bytes)?; - Ok(true) - } - fn set_signature(&mut self, sig: &ed25519::Signature) { - if let Some(ref mut prop) = self.proposal { - prop.signature = sig.as_ref().to_vec(); - } - } - fn validate(&self) -> Result<(), validate::Error> { - match self.proposal { - Some(ref p) => p.validate_basic(), - None => Err(MissingConsensusMessage.into()), - } - } - fn consensus_state(&self) -> Option { - match self.proposal { - Some(ref p) => Some(consensus::State { - height: block::Height::from(p.height), - round: p.round as i64, - step: 3, - block_id: { - match p.block_id { - Some(ref b) => match b.parse_block_id() { - Ok(id) => Some(id), - Err(_) => None, - }, - None => None, - } - }, - }), - None => None, - } - } - - fn height(&self) -> Option { - self.proposal - .as_ref() - .map(|proposal| proposal.height as i64) - } - - fn msg_type(&self) -> Option { - Some(SignedMsgType::Proposal) - } -} - -impl ConsensusMessage for Proposal { - fn validate_basic(&self) -> Result<(), validate::Error> { - if self.msg_type != SignedMsgType::Proposal as u16 { - return Err(InvalidMessageType.into()); - } - // TODO validate proposal's block_id - - // signature will be missing as the KMS provides it - - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::amino_types::block_id::{BlockId, PartSetHeader}; - use crate::chain::Id; - use chrono::{DateTime, Utc}; - - #[test] - fn test_serialization() { - let dt = "2018-02-11T07:09:22.765Z".parse::>().unwrap(); - let t = Timestamp { - seconds: dt.timestamp(), - nanos: dt.timestamp_subsec_nanos() as i32, - }; - let proposal = Proposal { - msg_type: SignedMsgType::Proposal as u16, - height: 12345, - round: 23456, - pol_round: None, - block_id: Some(BlockId { - hash: b"DEADBEEFDEADBEEFBAFBAFBAFBAFBAFA".to_vec(), - part_set_header: Some(PartSetHeader { - total: 65535, - hash: b"0022446688AACCEE1133557799BBDDFF".to_vec(), - }), - }), - timestamp: Some(t), - signature: vec![], - }; - let mut got = vec![]; - - let request = SignProposalRequest { - proposal: Some(proposal), - chain_id: "test_chain_id".to_string(), - }; - let _have = request.sign_bytes(Id::from("test_chain_id"), &mut got); - - // the following vector is generated via: - /* - import ( - "fmt" - prototypes "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/tendermint/tendermint/types" - "strings" - "time" - ) - func proposalSerialize() { - stamp, _ := time.Parse(time.RFC3339Nano, "2018-02-11T07:09:22.765Z") - proposal := &types.Proposal{ - Type: prototypes.SignedMsgType(prototypes.ProposalType), - Height: 12345, - Round: 23456, - POLRound: -1, - BlockID: types.BlockID{ - Hash: []byte("DEADBEEFDEADBEEFBAFBAFBAFBAFBAFA"), - PartSetHeader: types.PartSetHeader{ - Hash: []byte("0022446688AACCEE1133557799BBDDFF"), - Total: 65535, - }, - }, - Timestamp: stamp, - } - signBytes := types.ProposalSignBytes("test_chain_id",proposal.ToProto()) - fmt.Println(strings.Join(strings.Split(fmt.Sprintf("%v", signBytes), " "), ", ")) - } - */ - - let want = vec![ - 136, 1, 8, 32, 17, 57, 48, 0, 0, 0, 0, 0, 0, 25, 160, 91, 0, 0, 0, 0, 0, 0, 32, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 1, 42, 74, 10, 32, 68, 69, 65, 68, 66, 69, 69, - 70, 68, 69, 65, 68, 66, 69, 69, 70, 66, 65, 70, 66, 65, 70, 66, 65, 70, 66, 65, 70, 66, - 65, 70, 65, 18, 38, 8, 255, 255, 3, 18, 32, 48, 48, 50, 50, 52, 52, 54, 54, 56, 56, 65, - 65, 67, 67, 69, 69, 49, 49, 51, 51, 53, 53, 55, 55, 57, 57, 66, 66, 68, 68, 70, 70, 50, - 12, 8, 162, 216, 255, 211, 5, 16, 192, 242, 227, 236, 2, 58, 13, 116, 101, 115, 116, - 95, 99, 104, 97, 105, 110, 95, 105, 100, - ]; - - assert_eq!(got, want) - } - - #[test] - fn test_deserialization() { - let dt = "2018-02-11T07:09:22.765Z".parse::>().unwrap(); - let t = Timestamp { - seconds: dt.timestamp(), - nanos: dt.timestamp_subsec_nanos() as i32, - }; - let proposal = Proposal { - msg_type: SignedMsgType::Proposal as u16, - height: 12345, - round: 23456, - timestamp: Some(t), - - pol_round: None, - block_id: Some(BlockId { - hash: b"DEADBEEFDEADBEEFBAFBAFBAFBAFBAFA".to_vec(), - part_set_header: Some(PartSetHeader { - total: 65535, - hash: b"0022446688AACCEE1133557799BBDDFF".to_vec(), - }), - }), - signature: vec![], - }; - let want = SignProposalRequest { - proposal: Some(proposal), - chain_id: "test_chain_id".to_string(), - }; - - let data = vec![ - 10, 110, 8, 32, 16, 185, 96, 24, 160, 183, 1, 32, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 1, 42, 74, 10, 32, 68, 69, 65, 68, 66, 69, 69, 70, 68, 69, 65, 68, 66, 69, - 69, 70, 66, 65, 70, 66, 65, 70, 66, 65, 70, 66, 65, 70, 66, 65, 70, 65, 18, 38, 8, 255, - 255, 3, 18, 32, 48, 48, 50, 50, 52, 52, 54, 54, 56, 56, 65, 65, 67, 67, 69, 69, 49, 49, - 51, 51, 53, 53, 55, 55, 57, 57, 66, 66, 68, 68, 70, 70, 50, 12, 8, 162, 216, 255, 211, - 5, 16, 192, 242, 227, 236, 2, 18, 13, 116, 101, 115, 116, 95, 99, 104, 97, 105, 110, - 95, 105, 100, - ]; - - match SignProposalRequest::decode(data.as_ref()) { - Ok(have) => assert_eq!(have, want), - Err(err) => panic!(err.to_string()), - } - } -} diff --git a/tendermint/src/amino_types/signature.rs b/tendermint/src/amino_types/signature.rs deleted file mode 100644 index 4609eaed9..000000000 --- a/tendermint/src/amino_types/signature.rs +++ /dev/null @@ -1,22 +0,0 @@ -use super::validate; -use crate::{chain, consensus}; -use bytes::BufMut; -use prost::EncodeError; -use tendermint_proto::types::SignedMsgType; - -/// Amino messages which are signable within a Tendermint network -pub trait SignableMsg { - /// Sign this message as bytes - fn sign_bytes( - &self, - chain_id: chain::Id, - sign_bytes: &mut B, - ) -> Result; - - /// Set the Ed25519 signature on the underlying message - fn set_signature(&mut self, sig: &ed25519::Signature); - fn validate(&self) -> Result<(), validate::Error>; - fn consensus_state(&self) -> Option; - fn height(&self) -> Option; - fn msg_type(&self) -> Option; -} diff --git a/tendermint/src/amino_types/validate.rs b/tendermint/src/amino_types/validate.rs deleted file mode 100644 index 4cc7ad60c..000000000 --- a/tendermint/src/amino_types/validate.rs +++ /dev/null @@ -1,30 +0,0 @@ -use thiserror::Error; - -pub trait ConsensusMessage { - fn validate_basic(&self) -> Result<(), Error>; -} - -pub type Error = anomaly::BoxError; - -/// Kinds of validation errors -#[derive(Copy, Clone, Eq, PartialEq, Debug, Error)] -pub enum Kind { - #[error("invalid Type")] - InvalidMessageType, - #[error("consensus message is missing")] - MissingConsensusMessage, - #[error("negative height")] - NegativeHeight, - #[error("negative round")] - NegativeRound, - #[error("negative POLRound (exception: -1)")] - NegativePOLRound, - #[error("negative ValidatorIndex")] - NegativeValidatorIndex, - #[error("expected ValidatorAddress size to be 20 bytes")] - InvalidValidatorAddressSize, - #[error("Wrong hash: expected Hash size to be 32 bytes")] - InvalidHashSize, - #[error("negative total")] - NegativeTotal, -} diff --git a/tendermint/src/amino_types/vote.rs b/tendermint/src/amino_types/vote.rs deleted file mode 100644 index 09bfe835d..000000000 --- a/tendermint/src/amino_types/vote.rs +++ /dev/null @@ -1,646 +0,0 @@ -use super::{ - block_id::{BlockId, CanonicalBlockId, CanonicalPartSetHeader}, - signature::SignableMsg, - validate, - validate::{ConsensusMessage, Kind::*}, -}; -use crate::amino_types::PartSetHeader; -use crate::{ - block::{self, ParseId}, - chain, consensus, - error::Error, - vote, -}; -use bytes::BufMut; -use prost::EncodeError; -use prost_types::Timestamp; -use std::convert::{TryFrom, TryInto}; -use tendermint_proto::privval::SignedVoteResponse as RawSignedVoteResponse; -use tendermint_proto::privval::{RemoteSignerError, SignVoteRequest as RawSignVoteRequest}; -use tendermint_proto::types::CanonicalVote as RawCanonicalVote; -use tendermint_proto::types::SignedMsgType; -use tendermint_proto::types::Vote as RawVote; -use tendermint_proto::DomainType; - -const VALIDATOR_ADDR_SIZE: usize = 20; - -impl DomainType for Vote {} - -/// Vote represents a prevote, precommit, or commit vote from validators for consensus. -#[derive(Clone, PartialEq, Default, Debug)] -pub struct Vote { - pub vote_type: u16, - pub height: u32, - pub round: u16, - /// zero if vote is nil. - pub block_id: ::std::option::Option, - pub timestamp: ::std::option::Option<::prost_types::Timestamp>, - pub validator_address: Vec, - pub validator_index: u16, - pub signature: Vec, -} - -impl TryFrom for Vote { - type Error = validate::Error; - - fn try_from(value: RawVote) -> Result { - if value.r#type < 0 { - return Err(InvalidMessageType.into()); - } - if value.height < 0 { - return Err(NegativeHeight.into()); - } - if value.round < 0 { - return Err(NegativeRound.into()); - } - if value.validator_index < 0 { - return Err(NegativeValidatorIndex.into()); - } - Ok(Vote { - vote_type: value.r#type as u16, - height: value.height as u32, - round: value.round as u16, - block_id: value.block_id.map(|f| BlockId::try_from(f).unwrap()), - timestamp: value.timestamp, - validator_address: value.validator_address, - validator_index: value.validator_index as u16, - signature: value.signature, - }) - } -} - -impl From for RawVote { - fn from(value: Vote) -> Self { - RawVote { - r#type: value.vote_type as i32, - height: value.height as i64, - round: value.round as i32, - block_id: value.block_id.map(|b| b.into()), - timestamp: value.timestamp, - validator_address: value.validator_address, - validator_index: value.validator_index as i32, - signature: value.signature, - } - } -} - -impl Vote { - fn msg_type(&self) -> Option { - if self.vote_type == SignedMsgType::Prevote as u16 { - Some(SignedMsgType::Prevote) - } else if self.vote_type == SignedMsgType::Precommit as u16 { - Some(SignedMsgType::Precommit) - } else { - None - } - } -} - -impl From<&vote::Vote> for Vote { - fn from(vote: &vote::Vote) -> Self { - Vote { - vote_type: vote.vote_type as u16, - height: vote.height.value() as u32, // TODO potential overflow :-/ - round: vote.round as u16, // TODO potential overflow :-/ - block_id: vote.block_id.as_ref().map(|block_id| BlockId { - hash: block_id.hash.as_bytes().to_vec(), - part_set_header: block_id.parts.as_ref().map(PartSetHeader::from), - }), - timestamp: Some(Timestamp::from(vote.timestamp.to_system_time().unwrap())), - validator_address: vote.validator_address.as_bytes().to_vec(), - validator_index: vote.validator_index, - signature: vote.signature.as_bytes().to_vec(), - } - } -} - -impl block::ParseHeight for Vote { - fn parse_block_height(&self) -> Result { - Ok(block::Height::from(self.height as u64)) - } -} - -impl DomainType for SignVoteRequest {} - -/// SignVoteRequest is a request to sign a vote -#[derive(Clone, PartialEq, Debug)] -pub struct SignVoteRequest { - pub vote: Option, - pub chain_id: String, -} - -impl TryFrom for SignVoteRequest { - type Error = validate::Error; - - fn try_from(value: RawSignVoteRequest) -> Result { - Ok(SignVoteRequest { - vote: match value.vote { - None => None, - Some(vote) => Some(Vote::try_from(vote)?), - }, - chain_id: value.chain_id, - }) - } -} - -impl From for RawSignVoteRequest { - fn from(value: SignVoteRequest) -> Self { - RawSignVoteRequest { - vote: match value.vote { - None => None, - Some(vote) => Some(vote.into()), - }, - chain_id: value.chain_id, - } - } -} - -/// SignedVoteResponse is a response containing a signed vote or an error -#[derive(Clone, PartialEq)] -pub struct SignedVoteResponse { - pub vote: Option, - pub error: Option, -} - -impl TryFrom for SignedVoteResponse { - type Error = validate::Error; - - fn try_from(value: RawSignedVoteResponse) -> Result { - Ok(SignedVoteResponse { - vote: match value.vote { - None => None, - Some(vote) => Some(Vote::try_from(vote)?), - }, - error: value.error, - }) - } -} - -impl TryFrom for RawSignedVoteResponse { - type Error = validate::Error; - - fn try_from(value: SignedVoteResponse) -> Result { - Ok(RawSignedVoteResponse { - vote: match value.vote { - None => None, - Some(vote) => Some(RawVote::try_from(vote)?), - }, - error: value.error, - }) - } -} - -impl DomainType for CanonicalVote {} - -#[derive(Clone, PartialEq)] -pub struct CanonicalVote { - pub vote_type: u16, - pub height: i64, - pub round: i64, - pub block_id: Option, - pub timestamp: Option, - pub chain_id: String, -} - -impl TryFrom for CanonicalVote { - type Error = validate::Error; - - fn try_from(value: RawCanonicalVote) -> Result { - if value.r#type < 0 { - return Err(InvalidMessageType.into()); - } - Ok(CanonicalVote { - vote_type: value.r#type as u16, - height: value.height, - round: value.round, - block_id: value.block_id.map(|r| r.try_into().unwrap()), - timestamp: value.timestamp, - chain_id: value.chain_id, - }) - } -} - -impl From for RawCanonicalVote { - fn from(value: CanonicalVote) -> Self { - RawCanonicalVote { - r#type: value.vote_type as i32, - height: value.height, - round: value.round, - block_id: value.block_id.map(|b| b.into()), - timestamp: value.timestamp, - chain_id: value.chain_id, - } - } -} - -impl chain::ParseId for CanonicalVote { - fn parse_chain_id(&self) -> Result { - self.chain_id.parse() - } -} - -impl block::ParseHeight for CanonicalVote { - fn parse_block_height(&self) -> Result { - block::Height::try_from(self.height) - } -} - -impl CanonicalVote { - pub fn new(vote: Vote, chain_id: &str) -> CanonicalVote { - CanonicalVote { - vote_type: vote.vote_type, - chain_id: chain_id.to_string(), - block_id: match vote.block_id { - Some(bid) => Some(CanonicalBlockId { - hash: bid.hash, - part_set_header: match bid.part_set_header { - Some(psh) => Some(CanonicalPartSetHeader { - hash: psh.hash, - total: psh.total as u32, - }), - None => None, - }, - }), - None => None, - }, - height: vote.height as i64, - round: vote.round as i64, - timestamp: match vote.timestamp { - None => Some(Timestamp { - seconds: -62_135_596_800, - nanos: 0, - }), - Some(t) => Some(t), - }, - } - } -} - -impl SignableMsg for SignVoteRequest { - fn sign_bytes(&self, chain_id: chain::Id, sign_bytes: &mut B) -> Result - where - B: BufMut, - { - let mut svr = self.clone(); - if let Some(ref mut vo) = svr.vote { - vo.signature = vec![]; - } - let vote = svr.vote.unwrap(); - let cv = CanonicalVote::new(vote, chain_id.as_str()); - - cv.encode_length_delimited(sign_bytes).unwrap(); // Todo: Handle the single "EncodeError" - Ok(true) - } - fn set_signature(&mut self, sig: &ed25519::Signature) { - if let Some(ref mut vt) = self.vote { - vt.signature = sig.as_ref().to_vec(); - } - } - fn validate(&self) -> Result<(), validate::Error> { - match self.vote { - Some(ref v) => v.validate_basic(), - None => Err(MissingConsensusMessage.into()), - } - } - fn consensus_state(&self) -> Option { - match self.vote { - Some(ref v) => Some(consensus::State { - height: block::Height::from(v.height as u64), - round: v.round as i64, - step: 6, - block_id: { - match v.block_id { - Some(ref b) => match b.parse_block_id() { - Ok(id) => Some(id), - Err(_) => None, - }, - None => None, - } - }, - }), - None => None, - } - } - fn height(&self) -> Option { - self.vote.as_ref().map(|vote| vote.height as i64) - } - fn msg_type(&self) -> Option { - self.vote.as_ref().and_then(|vote| vote.msg_type()) - } -} - -impl ConsensusMessage for Vote { - fn validate_basic(&self) -> Result<(), validate::Error> { - if self.msg_type().is_none() { - return Err(InvalidMessageType.into()); - } - if self.validator_address.len() != VALIDATOR_ADDR_SIZE { - return Err(InvalidValidatorAddressSize.into()); - } - - self.block_id - .as_ref() - .map_or(Ok(()), ConsensusMessage::validate_basic) - - // signature will be missing as the KMS provides it - } -} - -#[cfg(test)] -mod tests { - use super::super::PartSetHeader; - use super::*; - use crate::chain::Id; - use chrono::{DateTime, Utc}; - use tendermint_proto::types::SignedMsgType; - use tendermint_proto::DomainType; - - #[test] - fn test_vote_serialization() { - let dt = "2017-12-25T03:00:01.234Z".parse::>().unwrap(); - let t = Timestamp { - seconds: dt.timestamp(), - nanos: dt.timestamp_subsec_nanos() as i32, - }; - let vote = Vote { - vote_type: SignedMsgType::Prevote as u16, - height: 12345, - round: 2, - timestamp: Some(t), - block_id: Some(BlockId { - hash: b"DEADBEEFDEADBEEFBAFBAFBAFBAFBAFA".to_vec(), - part_set_header: Some(PartSetHeader { - total: 1_000_000, - hash: b"0022446688AACCEE1133557799BBDDFF".to_vec(), - }), - }), - validator_address: vec![ - 0xa3, 0xb2, 0xcc, 0xdd, 0x71, 0x86, 0xf1, 0x68, 0x5f, 0x21, 0xf2, 0x48, 0x2a, 0xf4, - 0xfb, 0x34, 0x46, 0xa8, 0x4b, 0x35, - ], - validator_index: 56789, - signature: vec![], - /* signature: vec![130u8, 246, 183, 50, 153, 248, 28, 57, 51, 142, 55, 217, 194, 24, - * 134, 212, 233, 100, 211, 10, 24, 174, 179, 117, 41, 65, 141, 134, 149, 239, 65, - * 174, 217, 42, 6, 184, 112, 17, 7, 97, 255, 221, 252, 16, 60, 144, 30, 212, 167, - * 39, 67, 35, 118, 192, 133, 130, 193, 115, 32, 206, 152, 91, 173, 10], */ - }; - let mut got = vec![]; - - let request = SignVoteRequest { - vote: Some(vote), - chain_id: "test_chain_id".to_string(), - }; - let _have = request.sign_bytes(Id::from("test_chain_id"), &mut got); - - // the following vector is generated via: - /* - import ( - "fmt" - prototypes "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/tendermint/tendermint/types" - "strings" - "time" - ) - func voteSerialize() { - stamp, _ := time.Parse(time.RFC3339Nano, "2017-12-25T03:00:01.234Z") - vote := &types.Vote{ - Type: prototypes.PrevoteType, // pre-vote - Height: 12345, - Round: 2, - Timestamp: stamp, - BlockID: types.BlockID{ - Hash: []byte("DEADBEEFDEADBEEFBAFBAFBAFBAFBAFA"), - PartSetHeader: types.PartSetHeader{ - Total: 1000000, - Hash: []byte("0022446688AACCEE1133557799BBDDFF"), - }, - }, - ValidatorAddress: []byte{0xa3, 0xb2, 0xcc, 0xdd, 0x71, 0x86, 0xf1, 0x68, 0x5f, 0x21, - 0xf2, 0x48, 0x2a, 0xf4, 0xfb, 0x34, 0x46, 0xa8, 0x4b, 0x35}, ValidatorIndex: 56789} - signBytes := types.VoteSignBytes("test_chain_id", vote.ToProto()) - fmt.Println(strings.Join(strings.Split(fmt.Sprintf("%v", signBytes), " "), ", ")) - } - */ - - let want = vec![ - 124, 8, 1, 17, 57, 48, 0, 0, 0, 0, 0, 0, 25, 2, 0, 0, 0, 0, 0, 0, 0, 34, 74, 10, 32, - 68, 69, 65, 68, 66, 69, 69, 70, 68, 69, 65, 68, 66, 69, 69, 70, 66, 65, 70, 66, 65, 70, - 66, 65, 70, 66, 65, 70, 66, 65, 70, 65, 18, 38, 8, 192, 132, 61, 18, 32, 48, 48, 50, - 50, 52, 52, 54, 54, 56, 56, 65, 65, 67, 67, 69, 69, 49, 49, 51, 51, 53, 53, 55, 55, 57, - 57, 66, 66, 68, 68, 70, 70, 42, 11, 8, 177, 211, 129, 210, 5, 16, 128, 157, 202, 111, - 50, 13, 116, 101, 115, 116, 95, 99, 104, 97, 105, 110, 95, 105, 100, - ]; - assert_eq!(got, want); - } - - #[test] - fn test_sign_bytes_compatibility() { - let cv = CanonicalVote::new(Vote::default(), ""); - let mut got = vec![]; - // SignBytes are encoded using MarshalBinary and not MarshalBinaryBare - cv.encode_length_delimited(&mut got).unwrap(); - let want = vec![ - 0xd, 0x2a, 0xb, 0x8, 0x80, 0x92, 0xb8, 0xc3, 0x98, 0xfe, 0xff, 0xff, 0xff, 0x1, - ]; - assert_eq!(got, want); - - // with proper (fixed size) height and round (Precommit): - { - let mut vt_precommit = Vote::default(); - vt_precommit.height = 1; - vt_precommit.round = 1; - vt_precommit.vote_type = SignedMsgType::Precommit as u16; // precommit - println!("{:?}", vt_precommit); - let cv_precommit = CanonicalVote::new(vt_precommit, ""); - //let got = AminoMessage::bytes_vec(&cv_precommit); //Todo: Greg reintroduce Vec - // converted encode/decode - let mut got = vec![]; - cv_precommit.encode(&mut got).unwrap(); - let want = vec![ - 0x8, // (field_number << 3) | wire_type - 0x2, // PrecommitType - 0x11, // (field_number << 3) | wire_type - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // height - 0x19, // (field_number << 3) | wire_type - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // round - 0x2a, // (field_number << 3) | wire_type - // remaining fields (timestamp): - 0xb, 0x8, 0x80, 0x92, 0xb8, 0xc3, 0x98, 0xfe, 0xff, 0xff, 0xff, 0x1, - ]; - assert_eq!(got, want); - } - // with proper (fixed size) height and round (Prevote): - { - let mut vt_prevote = Vote::default(); - vt_prevote.height = 1; - vt_prevote.round = 1; - vt_prevote.vote_type = SignedMsgType::Prevote as u16; - - let cv_prevote = CanonicalVote::new(vt_prevote, ""); - - //let got = AminoMessage::bytes_vec(&cv_prevote); // Todo: Greg reintroduce Vec - // encode. - let mut got = vec![]; - cv_prevote.encode(&mut got).unwrap(); - - let want = vec![ - 0x8, // (field_number << 3) | wire_type - 0x1, // PrevoteType - 0x11, // (field_number << 3) | wire_type - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // height - 0x19, // (field_number << 3) | wire_type - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // round - 0x2a, // (field_number << 3) | wire_type - // remaining fields (timestamp): - 0xb, 0x8, 0x80, 0x92, 0xb8, 0xc3, 0x98, 0xfe, 0xff, 0xff, 0xff, 0x1, - ]; - assert_eq!(got, want); - } - // with proper (fixed size) height and round (msg typ missing): - { - let mut vt_no_type = Vote::default(); - vt_no_type.height = 1; - vt_no_type.round = 1; - - let cv = CanonicalVote::new(vt_no_type, ""); - //let got = AminoMessage::bytes_vec(&cv); - let mut got = vec![]; - cv.encode(&mut got).unwrap(); - - let want = vec![ - 0x11, // (field_number << 3) | wire_type - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // height - 0x19, // (field_number << 3) | wire_type - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // round - // remaining fields (timestamp): - 0x2a, 0xb, 0x8, 0x80, 0x92, 0xb8, 0xc3, 0x98, 0xfe, 0xff, 0xff, 0xff, 0x1, - ]; - assert_eq!(got, want); - } - // containing non-empty chain_id: - { - let mut no_vote_type2 = Vote::default(); - no_vote_type2.height = 1; - no_vote_type2.round = 1; - - let with_chain_id = CanonicalVote::new(no_vote_type2, "test_chain_id"); - //got = AminoMessage::bytes_vec(&with_chain_id); - let mut got = vec![]; - with_chain_id.encode(&mut got).unwrap(); - - let want = vec![ - 0x11, // (field_number << 3) | wire_type - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // height - 0x19, // (field_number << 3) | wire_type - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // round - // remaining fields: - 0x2a, // (field_number << 3) | wire_type - 0xb, 0x8, 0x80, 0x92, 0xb8, 0xc3, 0x98, 0xfe, 0xff, 0xff, 0xff, - 0x1, // timestamp - 0x32, // (field_number << 3) | wire_type - 0xd, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, - 0x64, // chainID - ]; - assert_eq!(got, want); - } - } - - #[test] - fn test_vote_rountrip_with_sig() { - let dt = "2017-12-25T03:00:01.234Z".parse::>().unwrap(); - let t = Timestamp { - seconds: dt.timestamp(), - nanos: dt.timestamp_subsec_nanos() as i32, - }; - let vote = Vote { - validator_address: vec![ - 0xa3, 0xb2, 0xcc, 0xdd, 0x71, 0x86, 0xf1, 0x68, 0x5f, 0x21, 0xf2, 0x48, 0x2a, 0xf4, - 0xfb, 0x34, 0x46, 0xa8, 0x4b, 0x35, - ], - validator_index: 56789, - height: 12345, - round: 2, - timestamp: Some(t), - vote_type: 0x01, - block_id: Some(BlockId { - hash: b"hash".to_vec(), - part_set_header: Some(PartSetHeader { - total: 1_000_000, - hash: b"parts_hash".to_vec(), - }), - }), - // signature: None, - signature: vec![ - 130u8, 246, 183, 50, 153, 248, 28, 57, 51, 142, 55, 217, 194, 24, 134, 212, 233, - 100, 211, 10, 24, 174, 179, 117, 41, 65, 141, 134, 149, 239, 65, 174, 217, 42, 6, - 184, 112, 17, 7, 97, 255, 221, 252, 16, 60, 144, 30, 212, 167, 39, 67, 35, 118, - 192, 133, 130, 193, 115, 32, 206, 152, 91, 173, 10, - ], - }; - let mut got = vec![]; - let _have = vote.encode(&mut got); - let v = Vote::decode(got.as_ref()).unwrap(); - - assert_eq!(v, vote); - // SignVoteRequest - { - let svr = SignVoteRequest { - vote: Some(vote), - chain_id: "test_chain_id".to_string(), - }; - let mut got = vec![]; - let _have = svr.encode(&mut got); - - let svr2 = SignVoteRequest::decode(got.as_ref()).unwrap(); - assert_eq!(svr, svr2); - } - } - - #[test] - fn test_deserialization() { - let encoded = vec![ - 10, 122, 8, 1, 16, 185, 96, 24, 2, 34, 74, 10, 32, 68, 69, 65, 68, 66, 69, 69, 70, 68, - 69, 65, 68, 66, 69, 69, 70, 66, 65, 70, 66, 65, 70, 66, 65, 70, 66, 65, 70, 66, 65, 70, - 65, 18, 38, 8, 192, 132, 61, 18, 32, 48, 48, 50, 50, 52, 52, 54, 54, 56, 56, 65, 65, - 67, 67, 69, 69, 49, 49, 51, 51, 53, 53, 55, 55, 57, 57, 66, 66, 68, 68, 70, 70, 42, 11, - 8, 177, 211, 129, 210, 5, 16, 128, 157, 202, 111, 50, 20, 163, 178, 204, 221, 113, 134, - 241, 104, 95, 33, 242, 72, 42, 244, 251, 52, 70, 168, 75, 53, 56, 213, 187, 3, 18, 13, - 116, 101, 115, 116, 95, 99, 104, 97, 105, 110, 95, 105, 100, - ]; - let dt = "2017-12-25T03:00:01.234Z".parse::>().unwrap(); - let t = Timestamp { - seconds: dt.timestamp(), - nanos: dt.timestamp_subsec_nanos() as i32, - }; - let vote = Vote { - validator_address: vec![ - 0xa3, 0xb2, 0xcc, 0xdd, 0x71, 0x86, 0xf1, 0x68, 0x5f, 0x21, 0xf2, 0x48, 0x2a, 0xf4, - 0xfb, 0x34, 0x46, 0xa8, 0x4b, 0x35, - ], - validator_index: 56789, - height: 12345, - round: 2, - timestamp: Some(t), - vote_type: 0x01, - block_id: Some(BlockId { - hash: b"DEADBEEFDEADBEEFBAFBAFBAFBAFBAFA".to_vec(), - part_set_header: Some(PartSetHeader { - total: 1_000_000, - hash: b"0022446688AACCEE1133557799BBDDFF".to_vec(), - }), - }), - signature: vec![], - }; - let want = SignVoteRequest { - vote: Some(vote), - chain_id: "test_chain_id".to_string(), - }; - match SignVoteRequest::decode(encoded.as_ref()) { - Ok(have) => { - assert_eq!(have, want); - } - Err(err) => panic!(err.to_string()), - } - } -} diff --git a/tendermint/src/block.rs b/tendermint/src/block.rs index 3ffc6a6d7..96aa8847e 100644 --- a/tendermint/src/block.rs +++ b/tendermint/src/block.rs @@ -7,6 +7,7 @@ mod height; mod id; mod meta; pub mod parts; +mod round; pub mod signed_header; mod size; @@ -17,6 +18,7 @@ pub use self::{ height::*, id::{Id, ParseId}, meta::Meta, + round::*, size::Size, }; use crate::{abci::transaction, evidence, serializers}; diff --git a/tendermint/src/block/header.rs b/tendermint/src/block/header.rs index 776836bf6..7b9431cbf 100644 --- a/tendermint/src/block/header.rs +++ b/tendermint/src/block/header.rs @@ -1,13 +1,12 @@ //! Block headers -use crate::amino_types::{message::AminoMessage, BlockId}; use crate::merkle::simple_hash_from_byte_vectors; use crate::serializers; -use crate::{account, block, chain, Hash, Time}; -use prost_types::Timestamp; +use crate::{account, block, chain, AppHash, Hash, Time}; use serde::{Deserialize, Serialize}; -use tendermint_proto::types::BlockId as RawBlockId; +use std::convert::TryFrom; use tendermint_proto::version::Consensus as RawConsensusVersion; +use tendermint_proto::DomainType; /// Block `Header` values contain metadata about the block and about the /// consensus, as well as commitments to the data in the current block, the @@ -50,8 +49,7 @@ pub struct Header { pub consensus_hash: Hash, /// State after txs from the previous block - #[serde(with = "serializers::bytes::hexstring")] - pub app_hash: Vec, + pub app_hash: AppHash, /// Root hash of all results from the txs from the previous block #[serde(deserialize_with = "serializers::parse_non_empty_hash")] @@ -73,61 +71,36 @@ impl Header { // https://github.com/tendermint/tendermint/blob/134fe2896275bb926b49743c1e25493f6b24cc31/types/block.go#L393 // https://github.com/tendermint/tendermint/blob/134fe2896275bb926b49743c1e25493f6b24cc31/types/encoding_helper.go#L9:6 - let raw_consensus_version: RawConsensusVersion = self.version.clone().into(); - - let mut fields_bytes: Vec> = Vec::with_capacity(16); - fields_bytes.push(AminoMessage::bytes_vec(&raw_consensus_version)); - fields_bytes.push(encode_bytes(self.chain_id.as_bytes())); - fields_bytes.push(encode_varint(self.height.value())); - fields_bytes.push(AminoMessage::bytes_vec(&Timestamp::from( - self.time.to_system_time().unwrap(), - ))); - match &self.last_block_id { - None => { - let raw_block_id: RawBlockId = BlockId::new(vec![], None).into(); - AminoMessage::bytes_vec(&raw_block_id); - } - Some(id) => { - let raw_block_id: RawBlockId = BlockId::from(id).into(); - AminoMessage::bytes_vec(&raw_block_id); - } - } - fields_bytes.push(self.last_commit_hash.as_ref().map_or(vec![], encode_hash)); - fields_bytes.push(self.data_hash.as_ref().map_or(vec![], encode_hash)); - fields_bytes.push(encode_hash(&self.validators_hash)); - fields_bytes.push(encode_hash(&self.next_validators_hash)); - fields_bytes.push(encode_hash(&self.consensus_hash)); - fields_bytes.push(encode_bytes(&self.app_hash)); - fields_bytes.push(self.last_results_hash.as_ref().map_or(vec![], encode_hash)); - fields_bytes.push(self.evidence_hash.as_ref().map_or(vec![], encode_hash)); - fields_bytes.push(encode_bytes(self.proposer_address.as_bytes())); + let mut fields_bytes: Vec> = Vec::with_capacity(14); + fields_bytes.push(self.version.encode_vec().unwrap()); + fields_bytes.push(self.chain_id.encode_vec().unwrap()); + fields_bytes.push(self.height.encode_vec().unwrap()); + fields_bytes.push(self.time.encode_vec().unwrap()); + fields_bytes.push(self.last_block_id.unwrap_or_default().encode_vec().unwrap()); + fields_bytes.push( + self.last_commit_hash + .unwrap_or_default() + .encode_vec() + .unwrap(), + ); + fields_bytes.push(self.data_hash.unwrap_or_default().encode_vec().unwrap()); + fields_bytes.push(self.validators_hash.encode_vec().unwrap()); + fields_bytes.push(self.next_validators_hash.encode_vec().unwrap()); + fields_bytes.push(self.consensus_hash.encode_vec().unwrap()); + fields_bytes.push(self.app_hash.encode_vec().unwrap()); + fields_bytes.push( + self.last_results_hash + .unwrap_or_default() + .encode_vec() + .unwrap(), + ); + fields_bytes.push(self.evidence_hash.unwrap_or_default().encode_vec().unwrap()); + fields_bytes.push(self.proposer_address.encode_vec().unwrap()); Hash::Sha256(simple_hash_from_byte_vectors(fields_bytes)) } } -fn encode_bytes(bytes: &[u8]) -> Vec { - let bytes_len = bytes.len(); - if bytes_len > 0 { - let mut encoded = vec![]; - prost::encode_length_delimiter(bytes_len, &mut encoded).unwrap(); - encoded.append(&mut bytes.to_vec()); - encoded - } else { - vec![] - } -} - -fn encode_hash(hash: &Hash) -> Vec { - encode_bytes(hash.as_bytes()) -} - -fn encode_varint(val: u64) -> Vec { - let mut val_enc = vec![]; - prost::encoding::encode_varint(val, &mut val_enc); - val_enc -} - /// `Version` contains the protocol version for the blockchain and the /// application. /// @@ -146,12 +119,16 @@ pub struct Version { pub app: u64, } -impl From for Version { - fn from(value: RawConsensusVersion) -> Self { - Version { +impl DomainType for Version {} + +impl TryFrom for Version { + type Error = anomaly::BoxError; + + fn try_from(value: RawConsensusVersion) -> Result { + Ok(Version { block: value.block, app: value.app, - } + }) } } @@ -167,7 +144,9 @@ impl From for RawConsensusVersion { #[cfg(test)] mod tests { use super::{Header, Version}; + use crate::hash::Algorithm; use crate::test::test_serialization_roundtrip; + use crate::Hash; #[test] fn serialization_roundtrip() { @@ -175,6 +154,20 @@ mod tests { test_serialization_roundtrip::
(json_data); } + #[test] + fn header_hashing() { + let expected_hash = Hash::from_hex_upper( + Algorithm::Sha256, + "F30A71F2409FB15AACAEDB6CC122DFA2525BEE9CAE521721B06BFDCA291B8D56", + ) + .unwrap(); + let header: Header = serde_json::from_str(include_str!( + "../../tests/support/serialization/block/header_with_known_hash.json" + )) + .unwrap(); + assert_eq!(expected_hash, header.hash()); + } + #[test] fn empty_header_version_app_field() { let json_data = r#"{"block": "11"}"#; diff --git a/tendermint/src/block/height.rs b/tendermint/src/block/height.rs index 4d3b142d7..98ce7e467 100644 --- a/tendermint/src/block/height.rs +++ b/tendermint/src/block/height.rs @@ -1,27 +1,62 @@ use crate::error::{Error, Kind}; use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; +use std::convert::TryInto; use std::{ convert::TryFrom, fmt::{self, Debug, Display}, str::FromStr, }; +use tendermint_proto::DomainType; /// Block height for a particular chain (i.e. number of blocks created since /// the chain began) /// /// A height of 0 represents a chain which has not yet produced a block. #[derive(Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] -pub struct Height(pub u64); +pub struct Height(u64); + +impl DomainType for Height {} + +impl TryFrom for Height { + type Error = Error; + + fn try_from(value: i64) -> Result { + Ok(Height(value.try_into().map_err(|_| Kind::NegativeHeight)?)) + } +} + +impl From for i64 { + fn from(value: Height) -> Self { + value.value() as i64 // does not overflow. The value is <= i64::MAX + } +} + +impl TryFrom for Height { + type Error = Error; + + fn try_from(value: u64) -> Result { + if value > i64::MAX as u64 { + return Err(Kind::IntegerOverflow.into()); + } + Ok(Height(value)) + } +} + +impl From for u64 { + fn from(value: Height) -> Self { + value.value() + } +} impl Height { /// Get inner integer value. Alternative to `.0` or `.into()` - pub fn value(self) -> u64 { + pub fn value(&self) -> u64 { self.0 } /// Increment the block height by 1 pub fn increment(self) -> Self { - Height(self.0.checked_add(1).expect("height overflow")) + Height::try_from(self.0.checked_add(1).expect("height overflow")).unwrap() } } @@ -43,47 +78,11 @@ impl Display for Height { } } -impl TryFrom for Height { - type Error = Error; - - fn try_from(n: i64) -> Result { - if n >= 0 { - Ok(Height(n as u64)) - } else { - Err(Kind::OutOfRange.into()) - } - } -} - -impl From for Height { - fn from(n: u32) -> Height { - Height(n as u64) - } -} - -impl From for Height { - fn from(n: u64) -> Height { - Height(n) - } -} - -impl From for u64 { - fn from(height: Height) -> u64 { - height.0 - } -} - -impl From for i64 { - fn from(height: Height) -> i64 { - height.0 as i64 - } -} - impl FromStr for Height { type Err = Error; fn from_str(s: &str) -> Result { - Ok(s.parse::().map_err(|_| Kind::Parse)?.into()) + Height::try_from(s.parse::().map_err(|_| Kind::Parse)?) } } diff --git a/tendermint/src/block/id.rs b/tendermint/src/block/id.rs index 62a62c690..381182018 100644 --- a/tendermint/src/block/id.rs +++ b/tendermint/src/block/id.rs @@ -1,13 +1,19 @@ -use super::parts; use crate::{ - error::Error, + block::parts::Header as PartSetHeader, + error::{Error, Kind}, hash::{Algorithm, Hash}, }; use serde::{Deserialize, Serialize}; +use std::convert::{TryFrom, TryInto}; use std::{ fmt::{self, Display}, str::{self, FromStr}, }; +use tendermint_proto::types::{ + BlockId as RawBlockId, CanonicalBlockId as RawCanonicalBlockId, + PartSetHeader as RawPartSetHeader, +}; +use tendermint_proto::DomainType; /// Length of a block ID prefix displayed for debugging purposes pub const PREFIX_LENGTH: usize = 10; @@ -16,7 +22,12 @@ pub const PREFIX_LENGTH: usize = 10; /// as well as the number of parts in the block. /// /// -#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +/// +/// Default implementation is an empty Id as defined by the Go implementation in +/// https://github.com/tendermint/tendermint/blob/1635d1339c73ae6a82e062cd2dc7191b029efa14/types/block.go#L1204 . +#[derive( + Serialize, Deserialize, Copy, Clone, Debug, Default, Hash, Eq, PartialEq, PartialOrd, Ord, +)] pub struct Id { /// The block's main hash is the Merkle root of all the fields in the /// block header. @@ -34,15 +45,76 @@ pub struct Id { /// way to propagate a large file over a gossip network. /// /// - pub parts: Option, + /// + /// PartSetHeader in protobuf is defined as never nil using the gogoproto + /// annotations. This does not translate to Rust, but we can indicate this + /// in the DomainType. + pub parts: PartSetHeader, } -impl Id { - /// Create a new `Id` from a hash byte slice - pub fn new(hash: Hash, parts: Option) -> Self { - Self { hash, parts } +impl DomainType for Id {} + +impl TryFrom for Id { + type Error = Error; + + fn try_from(value: RawBlockId) -> Result { + if value.part_set_header.is_none() { + return Err(Kind::InvalidPartSetHeader.into()); + } + Ok(Self { + hash: value.hash.try_into()?, + parts: value.part_set_header.unwrap().try_into()?, + }) + } +} + +impl From for RawBlockId { + fn from(value: Id) -> Self { + // https://github.com/tendermint/tendermint/blob/1635d1339c73ae6a82e062cd2dc7191b029efa14/types/block.go#L1204 + // The Go implementation encodes a nil value into an empty struct. We try our best to + // anticipate an empty struct by using the default implementation which would otherwise be + // invalid. + if value == Id::default() { + RawBlockId { + hash: vec![], + part_set_header: Some(RawPartSetHeader { + total: 0, + hash: vec![], + }), + } + } else { + RawBlockId { + hash: value.hash.into(), + part_set_header: Some(value.parts.into()), + } + } } +} + +impl TryFrom for Id { + type Error = Error; + + fn try_from(value: RawCanonicalBlockId) -> Result { + if value.part_set_header.is_none() { + return Err(Kind::InvalidPartSetHeader.into()); + } + Ok(Self { + hash: value.hash.try_into()?, + parts: value.part_set_header.unwrap().try_into()?, + }) + } +} +impl From for RawCanonicalBlockId { + fn from(value: Id) -> Self { + RawCanonicalBlockId { + hash: value.hash.as_bytes().to_vec(), + part_set_header: Some(value.parts.into()), + } + } +} + +impl Id { /// Get a shortened 12-character prefix of a block ID (ala git) pub fn prefix(&self) -> String { let mut result = self.to_string(); @@ -63,7 +135,10 @@ impl FromStr for Id { type Err = Error; fn from_str(s: &str) -> Result { - Ok(Self::new(Hash::from_hex_upper(Algorithm::Sha256, s)?, None)) + Ok(Self { + hash: Hash::from_hex_upper(Algorithm::Sha256, s)?, + parts: PartSetHeader::default(), + }) } } diff --git a/tendermint/src/block/parts.rs b/tendermint/src/block/parts.rs index ef8585e1f..f108380ab 100644 --- a/tendermint/src/block/parts.rs +++ b/tendermint/src/block/parts.rs @@ -1,21 +1,80 @@ //! Block parts +use crate::hash::Algorithm; +use crate::hash::SHA256_HASH_SIZE; use crate::Hash; +use crate::{Error, Kind}; use serde::{Deserialize, Serialize}; +use std::convert::TryFrom; +use tendermint_proto::types::{ + CanonicalPartSetHeader as RawCanonicalPartSetHeader, PartSetHeader as RawPartSetHeader, +}; +use tendermint_proto::DomainType; /// Block parts header -#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive( + Serialize, Deserialize, Clone, Copy, Debug, Default, Hash, Eq, PartialEq, PartialOrd, Ord, +)] pub struct Header { /// Number of parts in this block - pub total: u64, + pub total: u32, /// Hash of the parts set header, pub hash: Hash, } +impl DomainType for Header {} +impl DomainType for Header {} + +impl TryFrom for Header { + type Error = Error; + + fn try_from(value: RawPartSetHeader) -> Result { + if !value.hash.is_empty() && value.hash.len() != SHA256_HASH_SIZE { + return Err(Kind::InvalidHashSize.into()); + } + Ok(Self { + total: value.total, + hash: Hash::from_bytes(Algorithm::Sha256, &value.hash)?, + }) + } +} + +impl From
for RawPartSetHeader { + fn from(value: Header) -> Self { + RawPartSetHeader { + total: value.total, + hash: value.hash.into(), + } + } +} + +impl TryFrom for Header { + type Error = Error; + + fn try_from(value: RawCanonicalPartSetHeader) -> Result { + if !value.hash.is_empty() && value.hash.len() != SHA256_HASH_SIZE { + return Err(Kind::InvalidHashSize.into()); + } + Ok(Self { + total: value.total, + hash: Hash::from_bytes(Algorithm::Sha256, &value.hash)?, + }) + } +} + +impl From
for RawCanonicalPartSetHeader { + fn from(value: Header) -> Self { + RawCanonicalPartSetHeader { + total: value.total, + hash: value.hash.into(), + } + } +} + impl Header { /// Create a new parts header - pub fn new(total: u64, hash: Hash) -> Self { + pub fn new(total: u32, hash: Hash) -> Self { Header { total, hash } } } diff --git a/tendermint/src/block/round.rs b/tendermint/src/block/round.rs new file mode 100644 index 000000000..d01438f79 --- /dev/null +++ b/tendermint/src/block/round.rs @@ -0,0 +1,104 @@ +use crate::error::{Error, Kind}; +use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; +use std::convert::TryInto; +use std::{ + convert::TryFrom, + fmt::{self, Debug, Display}, + str::FromStr, +}; + +/// Block round for a particular chain +#[derive(Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] +pub struct Round(u32); + +impl TryFrom for Round { + type Error = Error; + + fn try_from(value: i32) -> Result { + Ok(Round(value.try_into().map_err(|_| Kind::NegativeRound)?)) + } +} + +impl From for i32 { + fn from(value: Round) -> Self { + value.value() as i32 // does not overflow. The value is <= i32::MAX + } +} + +impl TryFrom for Round { + type Error = Error; + + fn try_from(value: u32) -> Result { + if value > i32::MAX as u32 { + return Err(Kind::IntegerOverflow.into()); + } + Ok(Round(value)) + } +} + +impl From for u32 { + fn from(value: Round) -> Self { + value.value() + } +} + +impl Round { + /// Get inner integer value. Alternative to `.0` or `.into()` + pub fn value(&self) -> u32 { + self.0 + } + + /// Increment the block round by 1 + pub fn increment(self) -> Self { + Round::try_from(self.0.checked_add(1).expect("round overflow")).unwrap() + } +} + +impl Debug for Round { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "block::Round({})", self.0) + } +} + +impl Default for Round { + fn default() -> Self { + Round(0) + } +} + +impl Display for Round { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +impl FromStr for Round { + type Err = Error; + + fn from_str(s: &str) -> Result { + Round::try_from(s.parse::().map_err(|_| Kind::Parse)?) + } +} + +impl<'de> Deserialize<'de> for Round { + fn deserialize>(deserializer: D) -> Result { + Ok(Self::from_str(&String::deserialize(deserializer)?) + .map_err(|e| D::Error::custom(format!("{}", e)))?) + } +} + +impl Serialize for Round { + fn serialize(&self, serializer: S) -> Result { + self.to_string().serialize(serializer) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn increment_by_one() { + assert_eq!(Round::default().increment().value(), 1); + } +} diff --git a/tendermint/src/chain.rs b/tendermint/src/chain.rs index f8550a1d3..b8d89aa90 100644 --- a/tendermint/src/chain.rs +++ b/tendermint/src/chain.rs @@ -3,7 +3,4 @@ pub mod id; mod info; -pub use self::{ - id::{Id, ParseId}, - info::*, -}; +pub use self::{id::Id, info::Info}; diff --git a/tendermint/src/chain/id.rs b/tendermint/src/chain/id.rs index c538f837b..20b5f1227 100644 --- a/tendermint/src/chain/id.rs +++ b/tendermint/src/chain/id.rs @@ -2,12 +2,14 @@ use crate::error::{Error, Kind}; use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; +use std::convert::TryFrom; use std::{ cmp::Ordering, fmt::{self, Debug, Display}, hash::{Hash, Hasher}, str::{self, FromStr}, }; +use tendermint_proto::DomainType; /// Maximum length of a `chain::Id` name. Matches `MaxChainIDLen` from: /// @@ -15,49 +17,71 @@ use std::{ pub const MAX_LENGTH: usize = 50; /// Chain identifier (e.g. 'gaia-9000') -#[derive(Copy, Clone)] -pub struct Id([u8; MAX_LENGTH]); +#[derive(Clone)] +pub struct Id(String); + +impl DomainType for Id {} + +impl TryFrom for Id { + type Error = Error; + + fn try_from(value: String) -> Result { + if value.is_empty() || value.len() > MAX_LENGTH { + return Err(Kind::Length.into()); + } + + for byte in value.as_bytes() { + match byte { + b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-' | b'_' | b'.' => (), + _ => return Err(Kind::Parse.into()), + } + } + + Ok(Id(value)) + } +} + +impl From for String { + fn from(value: Id) -> Self { + value.0 + } +} impl Id { /// Get the chain ID as a `str` pub fn as_str(&self) -> &str { - let byte_slice = match self.0.as_ref().iter().position(|b| *b == b'\0') { - Some(pos) => &self.0[..pos], - None => self.0.as_ref(), - }; - - // We assert above the ID only has characters in the valid UTF-8 range, - // so in theory this should never panic - str::from_utf8(byte_slice).unwrap() + self.0.as_str() } /// Get the chain ID as a raw bytes. pub fn as_bytes(&self) -> &[u8] { - &self.as_str().as_bytes() + &self.0.as_str().as_bytes() } } impl AsRef for Id { fn as_ref(&self) -> &str { - self.as_str() + self.0.as_str() } } impl Debug for Id { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "chain::Id({})", self.as_str()) + write!(f, "chain::Id({})", self.0.as_str()) } } impl Display for Id { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.as_str()) + write!(f, "{}", self.0) } } -impl<'a> From<&'a str> for Id { - fn from(s: &str) -> Id { - Self::from_str(s).unwrap() +impl<'a> TryFrom<&'a str> for Id { + type Error = Error; + + fn try_from(s: &str) -> Result { + Self::try_from(s.to_string()) } } @@ -65,26 +89,13 @@ impl FromStr for Id { type Err = Error; /// Parses string to create a new chain ID fn from_str(name: &str) -> Result { - if name.is_empty() || name.len() > MAX_LENGTH { - return Err(Kind::Length.into()); - } - - for byte in name.as_bytes() { - match byte { - b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-' | b'_' | b'.' => (), - _ => return Err(Kind::Parse.into()), - } - } - - let mut bytes = [0u8; MAX_LENGTH]; - bytes[..name.as_bytes().len()].copy_from_slice(name.as_bytes()); - Ok(Id(bytes)) + Self::try_from(name.to_string()) } } impl Hash for Id { fn hash(&self, state: &mut H) { - self.as_str().hash(state) + self.0.as_str().hash(state) } } @@ -96,13 +107,13 @@ impl PartialOrd for Id { impl Ord for Id { fn cmp(&self, other: &Id) -> Ordering { - self.as_str().cmp(other.as_str()) + self.0.as_str().cmp(other.as_str()) } } impl PartialEq for Id { fn eq(&self, other: &Id) -> bool { - self.as_str() == other.as_str() + self.0.as_str() == other.as_str() } } @@ -110,7 +121,7 @@ impl Eq for Id {} impl Serialize for Id { fn serialize(&self, serializer: S) -> Result { - self.as_str().serialize(serializer) + self.0.as_str().serialize(serializer) } } @@ -121,12 +132,6 @@ impl<'de> Deserialize<'de> for Id { } } -/// Parse `chain::Id` from a type -pub trait ParseId { - /// Parse `chain::Id`, or return an `Error` if parsing failed - fn parse_chain_id(&self) -> Result; -} - #[cfg(test)] mod tests { use super::*; diff --git a/tendermint/src/consensus/state.rs b/tendermint/src/consensus/state.rs index 3c2479802..2e11d4ed3 100644 --- a/tendermint/src/consensus/state.rs +++ b/tendermint/src/consensus/state.rs @@ -1,11 +1,8 @@ //! Tendermint consensus state pub use crate::block; +use serde::{Deserialize, Serialize}; pub use std::{cmp::Ordering, fmt}; -use { - crate::serializers, - serde::{Deserialize, Serialize}, -}; /// Placeholder string to show when block ID is absent. Syntax from: /// @@ -18,8 +15,7 @@ pub struct State { pub height: block::Height, /// Current consensus round - #[serde(with = "serializers::from_str")] - pub round: i64, + pub round: block::Round, /// Current consensus step pub step: i8, @@ -68,33 +64,34 @@ impl PartialOrd for State { mod tests { use super::State; use crate::block; + use std::convert::TryFrom; #[test] fn state_ord_test() { let new = State { - height: block::Height::from(9001u64), - round: 0, + height: block::Height::try_from(9001u64).unwrap(), + round: block::Round::try_from(0).unwrap(), step: 0, block_id: None, }; let old = State { - height: block::Height::from(1001u64), - round: 1, + height: block::Height::try_from(1001u64).unwrap(), + round: block::Round::try_from(1).unwrap(), step: 0, block_id: None, }; let older = State { - height: block::Height::from(1001u64), - round: 0, + height: block::Height::try_from(1001u64).unwrap(), + round: block::Round::try_from(0).unwrap(), step: 0, block_id: None, }; let oldest = State { height: block::Height::default(), - round: 0, + round: block::Round::try_from(0).unwrap(), step: 0, block_id: None, }; diff --git a/tendermint/src/error.rs b/tendermint/src/error.rs index a6bc7d835..68a5323ab 100644 --- a/tendermint/src/error.rs +++ b/tendermint/src/error.rs @@ -40,6 +40,62 @@ pub enum Kind { /// Signature invalid #[error("bad signature")] SignatureInvalid, + + /// invalid message type + #[error("invalid message type")] + InvalidMessageType, + + /// Negative block height + #[error("negative height")] + NegativeHeight, + + /// Negative voting round + #[error("negative round")] + NegativeRound, + + /// Negative POL round + #[error("negative POL round")] + NegativePolRound, + + /// Negative validator index in vote + #[error("negative validator index")] + NegativeValidatorIndex, + + /// Invalid hash size in part_set_header + #[error("invalid hash: expected hash size to be 32 bytes")] + InvalidHashSize, + + /// No timestamp in vote + #[error("no timestamp")] + NoTimestamp, + + /// Invalid account ID length + #[error("invalid account ID length")] + InvalidAccountIdLength, + + /// Invalid signature ID length + #[error("invalid signature ID length")] + InvalidSignatureIdLength, + + /// Overflow during conversion + #[error("integer overflow")] + IntegerOverflow, + + /// No Vote found during conversion + #[error("no vote found")] + NoVoteFound, + + /// No Proposal found during conversion + #[error("no proposal found")] + NoProposalFound, + + /// Invalid AppHash length found during conversion + #[error("invalid app hash Length")] + InvalidAppHashLength, + + /// Invalid PartSetHeader + #[error("invalid part set header")] + InvalidPartSetHeader, } impl Kind { diff --git a/tendermint/src/hash.rs b/tendermint/src/hash.rs index 512b12d90..0b5d5e67d 100644 --- a/tendermint/src/hash.rs +++ b/tendermint/src/hash.rs @@ -2,11 +2,13 @@ use crate::error::{Error, Kind}; use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; +use std::convert::TryFrom; use std::{ fmt::{self, Debug, Display}, str::FromStr, }; use subtle_encoding::{Encoding, Hex}; +use tendermint_proto::DomainType; /// Output size for the SHA-256 hash function pub const SHA256_HASH_SIZE: usize = 32; @@ -25,10 +27,31 @@ pub enum Hash { Sha256([u8; SHA256_HASH_SIZE]), } +impl DomainType> for Hash {} + +/// Default conversion from Vec is SHA256 Hash +impl TryFrom> for Hash { + type Error = Error; + + fn try_from(value: Vec) -> Result { + Hash::from_bytes(Algorithm::Sha256, &value) + } +} + +impl From for Vec { + fn from(value: Hash) -> Self { + if value == Hash::default() { + return vec![]; + } + match value { + Hash::Sha256(s) => s.to_vec(), + } + } +} + impl Hash { - #[allow(clippy::new_ret_no_self)] /// Create a new `Hash` with the given algorithm type - pub fn new(alg: Algorithm, bytes: &[u8]) -> Result { + pub fn from_bytes(alg: Algorithm, bytes: &[u8]) -> Result { match alg { Algorithm::Sha256 => { if bytes.len() == SHA256_HASH_SIZE { @@ -76,6 +99,12 @@ impl Debug for Hash { } } +impl Default for Hash { + fn default() -> Self { + Hash::from_bytes(Algorithm::Sha256, &[0; SHA256_HASH_SIZE]).unwrap() + } +} + impl Display for Hash { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let hex = match self { @@ -111,3 +140,88 @@ impl Serialize for Hash { self.to_string().serialize(serializer) } } + +/// AppHash is usually a SHA256 hash, but in reality it can be any kind of data +#[derive(Clone)] +pub struct AppHash(Vec); + +impl DomainType> for AppHash {} + +impl TryFrom> for AppHash { + type Error = Error; + + fn try_from(value: Vec) -> Result { + Ok(AppHash(value)) + } +} +impl From for Vec { + fn from(value: AppHash) -> Self { + value.0 + } +} + +impl AppHash { + /// Return AppHash value as vec + pub fn value(&self) -> Vec { + self.0.clone() + } + + /// Decode a `Hash` from upper-case hexadecimal + pub fn from_hex_upper(s: &str) -> Result { + if s.len() % 2 != 0 { + return Err(Kind::InvalidAppHashLength.into()); + } + let mut h = vec![0; s.len() / 2]; + Hex::upper_case().decode_to_slice(s.as_bytes(), &mut h)?; + Ok(AppHash(h)) + } +} + +impl AsRef<[u8]> for AppHash { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Debug for AppHash { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "hash::AppHash({:?})", self.0) + } +} + +impl Display for AppHash { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "{}", + Hex::upper_case().encode_to_string(&self.0).unwrap() + ) + } +} + +impl PartialEq for AppHash { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl FromStr for AppHash { + type Err = Error; + + fn from_str(s: &str) -> Result { + Self::from_hex_upper(s) + } +} + +impl<'de> Deserialize<'de> for AppHash { + fn deserialize>(deserializer: D) -> Result { + let hex = String::deserialize(deserializer)?; + Ok(Self::from_str(&hex).map_err(|e| D::Error::custom(format!("{}", e)))?) + } +} + +impl Serialize for AppHash { + fn serialize(&self, serializer: S) -> Result { + self.to_string().serialize(serializer) + } +} diff --git a/tendermint/src/lib.rs b/tendermint/src/lib.rs index f0eccf481..ab40f4502 100644 --- a/tendermint/src/lib.rs +++ b/tendermint/src/lib.rs @@ -24,7 +24,6 @@ pub mod error; pub mod abci; pub mod account; -pub mod amino_types; pub mod block; pub mod chain; pub mod channel; @@ -38,6 +37,7 @@ mod moniker; pub mod net; pub mod node; pub mod private_key; +pub mod proposal; pub mod public_key; pub mod serializers; pub mod signature; @@ -55,9 +55,11 @@ pub use crate::{ block::Block, error::{Error, Kind}, genesis::Genesis, + hash::AppHash, hash::Hash, moniker::Moniker, private_key::PrivateKey, + proposal::Proposal, public_key::{PublicKey, TendermintKey}, signature::Signature, time::Time, diff --git a/tendermint/src/proposal.rs b/tendermint/src/proposal.rs new file mode 100644 index 000000000..be03c3bef --- /dev/null +++ b/tendermint/src/proposal.rs @@ -0,0 +1,261 @@ +//! Proposals from validators + +mod canonical_proposal; +mod msg_type; +mod sign_proposal; + +pub use self::canonical_proposal::CanonicalProposal; +pub use msg_type::Type; +pub use sign_proposal::{SignProposalRequest, SignedProposalResponse}; + +use crate::block::{Height, Id as BlockId, Round}; +use crate::chain::Id as ChainId; +use crate::consensus::State; +use crate::Signature; +use crate::Time; +use crate::{Error, Kind}; +use bytes::BufMut; +use std::convert::{TryFrom, TryInto}; +use tendermint_proto::types::Proposal as RawProposal; +use tendermint_proto::{DomainType, Error as DomainTypeError}; + +/// Proposal +#[derive(Clone, PartialEq, Debug)] +pub struct Proposal { + /// Proposal message type + pub msg_type: Type, + /// Height + pub height: Height, + /// Round + pub round: Round, + /// POL Round + pub pol_round: Option, + /// Block ID + pub block_id: Option, + /// Timestamp + pub timestamp: Option