Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comments and clarify Tendermint code #1447

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion block-production/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ rand = "0.8"
[dev-dependencies]
nimiq-test-log = { path = "../test-log" }
# This adds a circular dev-dependency which is fine but breaks VS code rust-analyzer.
# See https://github.com/rust-analyzer/rust-analyzer/issues/2414
# See https://github.com/rust-analyzer/rust-analyzer/issues/14167
nimiq-genesis-builder = { path = "../genesis-builder" }
nimiq-test-utils = { path = "../test-utils" }
nimiq-trie = { path = "../primitives/trie" }
Expand Down
2 changes: 1 addition & 1 deletion blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ nimiq-block-production = { path = "../block-production", features = ["test-utils
nimiq-test-log = { path = "../test-log" }
nimiq-transaction-builder = { path = "../transaction-builder" }
# This adds a circular dev-dependency which is fine but breaks VS code rust-analyzer.
# See https://github.com/rust-analyzer/rust-analyzer/issues/2414
# See https://github.com/rust-analyzer/rust-analyzer/issues/14167
nimiq-test-utils = { path = "../test-utils" }
nimiq-zkp-primitives = { path = "../zkp-primitives" }

Expand Down
2 changes: 1 addition & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ nimiq-network-mock = { path = "../network-mock" }
nimiq-network-libp2p = { path = "../network-libp2p" }
nimiq-test-log = { path = "../test-log" }
# This adds a circular dev-dependency which is fine but breaks VS code rust-analyzer.
# See https://github.com/rust-analyzer/rust-analyzer/issues/2414
# See https://github.com/rust-analyzer/rust-analyzer/issues/14167
nimiq-test-utils = { path = "../test-utils" }
nimiq-zkp-component = { path = "../zkp-component", features = ["zkp-prover", "parallel"] }

Expand Down
2 changes: 1 addition & 1 deletion validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ nimiq-network-libp2p = { path = "../network-libp2p" }
nimiq-network-mock = { path = "../network-mock" }
nimiq-test-log = { path = "../test-log" }
# This adds a circular dev-dependency which is fine but breaks VS code rust-analyzer.
# See https://github.com/rust-analyzer/rust-analyzer/issues/2414
# See https://github.com/rust-analyzer/rust-analyzer/issues/14167
nimiq-test-utils = { path = "../test-utils" }

[features]
Expand Down
12 changes: 8 additions & 4 deletions validator/src/tendermint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,23 +407,27 @@ where
debug!(%error, "Tendermint - await_proposal: Invalid block header, VRF seed verification failed");
Err(ProposalError::InvalidProposal)
} else {
// Get a write transaction to the database.
let mut txn = blockchain.write_transaction();

// Get the blockchain state.
let state = blockchain.state();

// Get a write transaction to the database, even if we don't intend to actually write
// anything out.
let mut txn = blockchain.write_transaction();

// Update our blockchain state using the received proposal. If we can't update the state, we
// return a proposal timeout.
if blockchain.commit_accounts(state, &block, &mut txn).is_err() {
txn.abort();
debug!("Tendermint - await_proposal: Can't update state");
return Err(ProposalError::InvalidProposal);
}

// Check the validity of the block against our state. If it is invalid, we return a proposal
// timeout. This also returns the block body that matches the block header
// (assuming that the block is valid).
match blockchain.verify_block_state(state, &block, Some(&txn)) {
let verification_result = blockchain.verify_block_state(state, &block, Some(&txn));
txn.abort();
match verification_result {
Ok(Some(inherent)) => Ok(Body(inherent)),
Ok(None) => Ok(precalculated_inherent.unwrap()),
Err(error) => {
Expand Down
2 changes: 1 addition & 1 deletion zkp-component/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ nimiq-network-mock = { path = "../network-mock" }
nimiq-network-libp2p = { path = "../network-libp2p" }
nimiq-test-log = { path = "../test-log" }
# This adds a circular dev-dependency which is fine but breaks VS code rust-analyzer.
# See https://github.com/rust-analyzer/rust-analyzer/issues/2414
# See https://github.com/rust-analyzer/rust-analyzer/issues/14167
nimiq-test-utils = { path = "../test-utils" }

[features]
Expand Down