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

fix(validators): check input metadata matches spending output #3761

Merged
merged 5 commits into from
Jan 28, 2022

Conversation

sdbondi
Copy link
Member

@sdbondi sdbondi commented Jan 27, 2022

Description

  • Add validation to check input metadata matches utxo to spend
  • Add more tests for consensus de/encoding and hash writer
  • Remove some unused protobuf types (MmrTree)
  • Add bad block check to add_block header validator
  • Unit tests for validation of metadata mismatch for async validator (already working) and body only validator (previously not working)

Motivation and Context

  • Find and reject blocks/txns where the metadata mismatches the UTXO
  • Ensure correctness of consensus encoding impl

How Has This Been Tested?

New unit tests, manually by testing the invalid faucet utxo is rejected

@sdbondi sdbondi changed the title tests(core): add unit tests for all consensus encoding impls test(core): add unit tests for all consensus encoding impls Jan 27, 2022
@sdbondi sdbondi force-pushed the core-hash-fix branch 3 times, most recently from 08a9ea5 to 494d966 Compare January 27, 2022 10:43
delta1
delta1 previously approved these changes Jan 27, 2022
@sdbondi sdbondi changed the title test(core): add unit tests for all consensus encoding impls fix(core): validate input metadata matches spent utxo Jan 28, 2022
@sdbondi sdbondi changed the title fix(core): validate input metadata matches spent utxo fix(validators): check input metadata matches spending output Jan 28, 2022
stringhandler
stringhandler previously approved these changes Jan 28, 2022
Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
I just have a NIT about some of the logs

@@ -374,6 +374,8 @@ where B: BlockchainBackend + 'static
.await?,
self.consensus_manager.get_block_reward_at(height),
);

debug!(target: LOG_TARGET, "New template block: {}", block_template);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debug!(target: LOG_TARGET, "New template block: {}", block_template);
trace!(target: LOG_TARGET, "New template block: {}", block_template);

this can be a very large log

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I'll leave that for another PR so that we dont have to rerun tests

@@ -716,7 +716,8 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {
let block = Block::try_from(request)
.map_err(|e| Status::invalid_argument(format!("Failed to convert arguments. Invalid block: {:?}", e)))?;
let block_height = block.header.height;
debug!(
debug!(target: LOG_TARGET, "Miner submitted block: {}", block);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debug!(target: LOG_TARGET, "Miner submitted block: {}", block);
trace!(target: LOG_TARGET, "Miner submitted block: {}", block);

This will be a very large log

@@ -384,6 +386,7 @@ where B: BlockchainBackend + 'static
Ok(NodeCommsResponse::NewBlockTemplate(block_template))
},
NodeCommsRequest::GetNewBlock(block_template) => {
debug!(target: LOG_TARGET, "Prepared block: {}", block_template);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debug!(target: LOG_TARGET, "Prepared block: {}", block_template);
trace!(target: LOG_TARGET, "Prepared block: {}", block_template);

@@ -675,6 +679,7 @@ where B: BlockchainBackend + 'static
.map(|p| format!("remote peer: {}", p))
.unwrap_or_else(|| "local services".to_string())
);
debug!(target: LOG_TARGET, "Incoming block: {}", block);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debug!(target: LOG_TARGET, "Incoming block: {}", block);
trace!(target: LOG_TARGET, "Incoming block: {}", block);

@stringhandler stringhandler merged commit 8d9c7f4 into tari-project:development Jan 28, 2022
@sdbondi sdbondi deleted the core-hash-fix branch January 28, 2022 12:25
@stringhandler
Copy link
Collaborator

Debug is fine. Info would be a problem

sdbondi added a commit to sdbondi/tari that referenced this pull request Jan 31, 2022
* development: (29 commits)
  feat(base-node): add base node prometheus metrics (tari-project#3773)
  fix(ffi): mut pointers should be const (tari-project#3775)
  chore: update launchpad for dibbler (tari-project#3769)
  v0.27.3
  fix(ffi): missing param in header.h (tari-project#3774)
  v0.27.2
  v0.27.2
  fix(ffi): fix bad access (tari-project#3772)
  chore(collectibles): fix eslint
  v0.27.1
  fix(ffi): fix null pointer assignment in import_utxo (tari-project#3770)
  fix(validators): check input metadata matches spending output (tari-project#3761)
  v0.27.0
  feat(ffi)!: Add commitment_signature_create and destroy (tari-project#3768)
  feat(ffi)!: add features, metadata_signature and sender_offset_public_key to import_utxo (tari-project#3767)
  feat(explorer): better view on mempool (tari-project#3763)
  feat: update the available balance in console wallet (tari-project#3760)
  chore: reclassify very long log message (tari-project#3752)
  fix: fix cucumber test for standard recovery (tari-project#3757)
  style: format with prettier (same settings as in integration tests) (tari-project#3756)
  ...
@sdbondi sdbondi restored the core-hash-fix branch February 3, 2022 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants