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

feat: add validation for zero confirmation block sync #6237

Merged

Conversation

hansieodendaal
Copy link
Contributor

@hansieodendaal hansieodendaal commented Mar 26, 2024

Description

Added validation checks to ensure an input in a block that is also an output in the same block will be accepted when syncing blocks.

Motivation and Context

Blocks with zero confirmation inputs and outputs could not be synced with block sync.

Previous for block #3316 and input/output 00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425:

2024-03-26 11:40:08.989607400 [c::cs::lmdb_db::lmdb_db] DEBUG Fetch output: 00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425
2024-03-26 11:40:08.989617600 [c::cs::lmdb_db::lmdb_db] DEBUG Fetch output: 00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425 NOT found in index
2024-03-26 11:40:08.991003900 [c::cs::lmdb_db::lmdb_db] TRACE [apply_db_transaction] WriteOperation: Delete orphan with hash: 8a0ac6b1581eedffffcde3b05613b5ec525cd0575cb5a93a5f2bcbe0917957f6
2024-03-26 11:40:08.991035700 [c::cs::lmdb_db::lmdb_db] DEBUG delete_orphan: request to delete orphan block 8a0ac6b1581eedffffcde3b05613b5ec525cd0575cb5a93a5f2bcbe0917957f6 that was not found.
2024-03-26 11:40:08.991047800 [c::cs::lmdb_db::lmdb_db] TRACE [apply_db_transaction] WriteOperation: Insert bad block #3316 8a0ac6b1581eedffffcde3b05613b5ec525cd0575cb5a93a5f2bcbe0917957f6
2024-03-26 11:40:08.991068000 [c::cs::lmdb_db::lmdb_db] DEBUG Cleaned out 0 stale bad blocks
2024-03-26 11:40:08.993916100 [c::cs::lmdb_db::lmdb_db] TRACE Database completed 2 operation(s) in 3ms
2024-03-26 11:40:08.996400500 [c::bn::block_sync] WARN  Block validation failed: Contains an unknown input
2024-03-26 11:40:08.997329500 [c::bn::block_sync] WARN  Block validation failed: Contains an unknown input
2024-03-26 11:40:08.997882300 [c::bn::sync] DEBUG Sync peer 7dcc333714f9b31ebda93edec1 removed from the sync peer list because Contains an unknown input
2024-03-26 11:40:08.997900900 [c::bn::sync] WARN  Banned sync peer 7dcc333714f9b31ebda93edec1 for 7200s because Contains an unknown input
2024-03-26 11:40:08.997914500 [c::bn::block_sync] WARN  Block sync failed: No more sync peers available: Block sync failed

This PR:

2024-03-26 13:57:51.006006700 [c::cs::lmdb_db::lmdb_db] DEBUG Fetch output: 00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425
2024-03-26 13:57:51.006025600 [c::cs::lmdb_db::lmdb_db] DEBUG Fetch output: 00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425 NOT found in index
2024-03-26 13:57:51.008880000 [c::cs::lmdb_db::lmdb_db] DEBUG Fetch output: 00f6bce621663a88a0dd0a156d3d4adabb7fc7f38077052f54da5297c52def10
2024-03-26 13:57:51.008910600 [c::cs::lmdb_db::lmdb_db] DEBUG Fetch output: 00f6bce621663a88a0dd0a156d3d4adabb7fc7f38077052f54da5297c52def10 Found (0ee73f94629ecacd0d9118d5852e42831b8f71a0ce56e2b18cc20506b1d3135c00f6bce621663a88a0dd0a156d3d4adabb7fc7f38077052f54da5297c52def10)
...
2024-03-26 13:57:51.463387100 [c::cs::lmdb_db::lmdb_db] DEBUG Fetch output: 00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425 NOT found in index
2024-03-26 13:57:51.463541300 [c::val::helpers] WARN  Input: (6c8f19486e43c051fb9f308d5eaa6b06a726d0cf1c17c713453d904faf405c56, 00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425) does not exist in the database yet
...
2024-03-26 13:57:55.618675800 [c::cs::lmdb_db::lmdb_db] TRACE Inserting output (`6c8f19486e43c051fb9f308d5eaa6b06a726d0cf1c17c713453d904faf405c56`, `00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425`)
2024-03-26 13:57:55.618713200 [c::cs::lmdb_db::lmdb] TRACE Inserted 72 bytes with key '00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425' into 'txos_hash_to_index_db'
2024-03-26 13:57:55.618729500 [c::cs::lmdb_db::lmdb] TRACE Inserted 1121 bytes with key '8a0ac6b1581eedffffcde3b05613b5ec525cd0575cb5a93a5f2bcbe0917957f600eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425' into 'utxos_db'
2024-03-26 13:57:55.745300700 [c::cs::lmdb_db::lmdb_db] TRACE Inserting input (`6c8f19486e43c051fb9f308d5eaa6b06a726d0cf1c17c713453d904faf405c56`, `00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425`)
2024-03-26 13:57:55.745324500 [c::cs::lmdb_db::lmdb] TRACE Inserted 72 bytes with key '00eaffe31d4c535fb678248078524f9b91f183ca344e6ed52c4ca56f6e50a425' into 'deleted_txo_hash_to_header_index'

How Has This Been Tested?

System-level testing

What process can a PR reviewer use to test or verify this change?

Code review

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

@hansieodendaal hansieodendaal requested a review from a team as a code owner March 26, 2024 12:36
@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Mar 26, 2024
Copy link

github-actions bot commented Mar 26, 2024

Test Results (CI)

    3 files    120 suites   36m 34s ⏱️
1 269 tests 1 269 ✅ 0 💤 0 ❌
3 799 runs  3 799 ✅ 0 💤 0 ❌

Results for commit 9f5b1cc.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Mar 26, 2024

Test Results (Integration tests)

 2 files  11 suites   34m 19s ⏱️
32 tests 31 ✅ 0 💤 1 ❌
33 runs  32 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 9f5b1cc.

♻️ This comment has been updated with latest results.

Added validation checks to ensure an input in a block that is also an output
in the same block will be accepted when syncing blocks.
@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Mar 27, 2024
@SWvheerden SWvheerden merged commit 55077ce into tari-project:development Apr 2, 2024
14 of 16 checks passed
@hansieodendaal hansieodendaal deleted the ho_zero_conf_sync branch April 2, 2024 09:35
sdbondi added a commit to sdbondi/tari that referenced this pull request Apr 15, 2024
* development:
  fix!: avoid `Encryptable` domain collisions (tari-project#6275)
  ci(fix): docker image build fix and ci improvements (tari-project#6270)
  feat: keep smt memory (tari-project#6265)
  feat: show warning when GRPC method is disallowed (tari-project#6246)
  fix(chat): metadata panic (tari-project#6247)
  feat: add monerod detection as an option to the merge mining proxy (tari-project#6248)
  chore(deps): bump h2 from 0.3.24 to 0.3.26 (tari-project#6250)
  feat: improve lmdb dynamic growth (tari-project#6242)
  feat: allow wallet type from db to have preference (tari-project#6245)
  feat: prevent mempool panic (tari-project#6239)
  ci: bump nightly version (tari-project#6241)
  feat: add validation for zero confirmation block sync (tari-project#6237)
  feat: new template with coinbase call (tari-project#6226)
  feat: improve wallet sql queries (tari-project#6232)
  chore: remove ahash as dependancy (tari-project#6238)
  feat: add dynamic growth to lmdb (tari-project#6231)
  chore(deps): bump borsh from 0.10.3 to 1.0.0 in /applications/minotari_ledger_wallet (tari-project#6236)
sdbondi added a commit to sdbondi/tari that referenced this pull request Apr 15, 2024
* development:
  fix!: avoid `Encryptable` domain collisions (tari-project#6275)
  ci(fix): docker image build fix and ci improvements (tari-project#6270)
  feat: keep smt memory (tari-project#6265)
  feat: show warning when GRPC method is disallowed (tari-project#6246)
  fix(chat): metadata panic (tari-project#6247)
  feat: add monerod detection as an option to the merge mining proxy (tari-project#6248)
  chore(deps): bump h2 from 0.3.24 to 0.3.26 (tari-project#6250)
  feat: improve lmdb dynamic growth (tari-project#6242)
  feat: allow wallet type from db to have preference (tari-project#6245)
  feat: prevent mempool panic (tari-project#6239)
  ci: bump nightly version (tari-project#6241)
  feat: add validation for zero confirmation block sync (tari-project#6237)
  feat: new template with coinbase call (tari-project#6226)
  feat: improve wallet sql queries (tari-project#6232)
  chore: remove ahash as dependancy (tari-project#6238)
  feat: add dynamic growth to lmdb (tari-project#6231)
  chore(deps): bump borsh from 0.10.3 to 1.0.0 in /applications/minotari_ledger_wallet (tari-project#6236)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants