Page MenuHomePhabricator

[avalanche] Make sure to update the block template when a tx is finalized
ClosedPublic

Authored by Fabien on Aug 13 2025, 14:27.

Details

Summary

If the template was requested after the tx entered the mempool but before it is finalized, then it's not updated with the tx once it becomes final. This diff fixes this.

Test Plan
./test/functional/test_runner.py abc_mining_avalanche_preconsensus

Diff Detail

Repository
rABC Bitcoin ABC
Branch
avalanche_preconsensus_transactions_updated
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34140
Build 67748: Build Difflint-circular-dependencies · build-without-wallet · build-diff · build-debug · build-clang-tidy · build-clang
Build 67747: arc lint + arc unit

Event Timeline

Fabien requested review of this revision.Aug 13 2025, 14:27

Tail of the build log:

[14:27:23]i: Processing combined checkout rule for 'Bitcoin ABC Staging' 
[14:27:23]i: VCS root 'Bitcoin ABC Staging': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper15127979083523450810.sh ls-remote origin
[14:27:23]i: VCS root 'Bitcoin ABC Staging': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[14:27:25]i: VCS root 'Bitcoin ABC Staging': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper4769821636465964245.sh remote prune origin
[14:27:25]i: VCS root 'Bitcoin ABC Staging': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[14:27:26]i: VCS root 'Bitcoin ABC Staging': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper8240578556726768249.sh fetch --progress --no-tags --recurse-submodules=no ssh://vcs@reviews.bitcoinabc.org:2221/source/bitcoin-abc-staging.git +refs/*:refs/*
[14:27:26]i: VCS root 'Bitcoin ABC Staging': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Enumerating objects: 13, done.        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:   7% (1/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  15% (2/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  23% (3/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  30% (4/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  38% (5/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  46% (6/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  53% (7/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  61% (8/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  69% (9/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  76% (10/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  84% (11/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects:  92% (12/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects: 100% (13/13)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Counting objects: 100% (13/13), done.        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Compressing objects:  14% (1/7)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Compressing objects:  28% (2/7)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Compressing objects:  42% (3/7)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Compressing objects:  57% (4/7)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Compressing objects:  71% (5/7)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Compressing objects:  85% (6/7)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Compressing objects: 100% (7/7)        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Compressing objects: 100% (7/7), done.        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': remote: Total 7 (delta 6), reused 0 (delta 0), pack-reused 0        
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Receiving objects:  14% (1/7)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Receiving objects:  28% (2/7)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Receiving objects:  42% (3/7)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Receiving objects:  57% (4/7)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Receiving objects:  71% (5/7)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Receiving objects:  85% (6/7)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Receiving objects: 100% (7/7)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Receiving objects: 100% (7/7), 1.40 KiB | 1.40 MiB/s, done.
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Resolving deltas:   0% (0/6)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Resolving deltas:  16% (1/6)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Resolving deltas:  33% (2/6)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Resolving deltas:  50% (3/6)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Resolving deltas:  66% (4/6)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Resolving deltas:  83% (5/6)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Resolving deltas: 100% (6/6)
[14:27:27]i: VCS root 'Bitcoin ABC Staging': Resolving deltas: 100% (6/6), completed with 6 local objects.
[14:27:28]i: VCS root 'Bitcoin ABC Staging': From ssh://reviews.bitcoinabc.org:2221/source/bitcoin-abc-staging
[14:27:28]i: VCS root 'Bitcoin ABC Staging':  * [new tag]               phabricator/base/55230 -> phabricator/base/55230
[14:27:28]i: VCS root 'Bitcoin ABC Staging':  * [new tag]               phabricator/diff/55230 -> phabricator/diff/55230
[14:27:29]i: Done collecting changes for 'Bitcoin ABC Staging': 1 changes collected 1 changes persisted, total time: 5s,525ms, persisting time: 6ms
[14:27:29] : Compute revision for 'Bitcoin ABC Staging'
[14:27:29] :	 [Compute revision for 'Bitcoin ABC Staging'] Upper limit revision: 9d8f4017054e8b21144b5f940187529c93551182
[14:27:29]i:	 [Compute revision for 'Bitcoin ABC Staging'] MaxModId = 84053
[14:27:29] : Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout
[14:27:29] :	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] Upper limit revision: 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[14:27:29]i:	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] MaxModId = 83296
[14:27:29] :	 [Compute revision for 'Bitcoin ABC Staging'] Computed revision: 9d8f4017054e8b21144b5f940187529c93551182
[14:27:29] :	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] Computed revision: 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[14:27:33]W: Build was removed from the queue with comment: This build has not been started because some of the builds it depends on failed to start
Fabien planned changes to this revision.Aug 13 2025, 14:31

Tail of the build log:

Build 'Bitcoin ABC Diffs / Diff Testing' #N/A, branch 'refs/tags/phabricator/diff/55230'
Triggered 2025-08-13 14:32:52 by 'Phabricator Staging (phabricator-staging)'
Started 2025-08-13 14:32:58 on agent 'N/A'
Finished 2025-08-13 14:32:58 with status FAILURE 'Snapshot dependency failed to start: Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout'
VCS revisions: 'BitcoinABC_BitcoinAbcStaging' (Git, instance id 22): '9d8f4017054e8b21144b5f940187529c93551182' (branch: 'refs/tags/phabricator/diff/55230', checkout rules: '+:. => ./bitcoin-abc')
TeamCity URL https://build.bitcoinabc.org/buildConfiguration/BitcoinABC_BitcoinAbcStaging/976587 
TeamCity server version is 2025.03.1 (build 186125), server timezone: GMT (UTC)

[14:32:52]W: bt15 (5s)
[14:32:52]i: TeamCity server version is 2025.03.1 (build 186125)
[14:32:52] : Finalize build settings
[14:32:52] : Collecting changes in 2 VCS roots
[14:32:52] :	 [Collecting changes in 2 VCS roots] VCS Root details
[14:32:52] :		 [VCS Root details] "Bitcoin ABC Staging" {instance id=22, parent internal id=3, parent id=BitcoinABC_BitcoinAbcStaging, description: "ssh://vcs@reviews.bitcoinabc.org:2221/source/bitcoin-abc-staging.git#refs/heads/master"}
[14:32:52] :		 [VCS Root details] "abc-infrastructure" {instance id=24, parent internal id=7, parent id=AutomatedDeployments_BitcoinAbcDeveloperTools_AbcInfrastructure, description: "ssh://vcs@reviews.bitcoinabc.org:2221/source/infrastructure.git#refs/heads/master"}
[14:32:52]i: Loading current repository state for VCS root 'Bitcoin ABC Staging' (1s)
[14:32:52]i:	 [Loading current repository state for VCS root 'Bitcoin ABC Staging'] Loading current repository state for VCS root 'abc-infrastructure' (1s)
[14:32:52]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'abc-infrastructure': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper2283254540313500428.sh ls-remote origin
[14:32:52]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper2938648000082031367.sh ls-remote origin
[14:32:52]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'abc-infrastructure': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[14:32:52]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[14:32:53]i: Detecting changes in VCS root 'abc-infrastructure' (used in 'Bitcoin-ABC Infra Checkout', 'Extract Electrum ABC from ABC' and 5 other configurations)
[14:32:53]i: Will collect changes for 'abc-infrastructure' starting from revision 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[14:32:53]i: Detecting changes in VCS root 'Bitcoin ABC Staging' (used in 'Diff Testing', 'Staging Checkout Dummy')
[14:32:53]i: Will collect changes for 'Bitcoin ABC Staging' starting from revision 979907a6cdf8719f81a43bc56b723ecf0e8c7f4c
[14:32:53] : Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout
[14:32:53] :	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] Upper limit revision: 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[14:32:53]i:	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] MaxModId = 83296
[14:32:53] : Compute revision for 'Bitcoin ABC Staging'
[14:32:53] :	 [Compute revision for 'Bitcoin ABC Staging'] Upper limit revision: 9d8f4017054e8b21144b5f940187529c93551182
[14:32:53]i:	 [Compute revision for 'Bitcoin ABC Staging'] MaxModId = 84053
[14:32:53] :	 [Compute revision for 'Bitcoin ABC Staging'] Computed revision: 9d8f4017054e8b21144b5f940187529c93551182
[14:32:53] :	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] Computed revision: 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[14:32:58]W: Build was removed from the queue with comment: This build has not been started because some of the builds it depends on failed to start

Tail of the build log:

Build 'Bitcoin ABC Diffs / Diff Testing' #N/A, branch 'refs/tags/phabricator/diff/55230'
Triggered 2025-08-13 14:32:53 by 'Phabricator Staging (phabricator-staging)'
Started 2025-08-13 14:33:01 on agent 'N/A'
Finished 2025-08-13 14:33:01 with status FAILURE 'Snapshot dependency failed to start: Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout'
VCS revisions: 'BitcoinABC_BitcoinAbcStaging' (Git, instance id 22): '9d8f4017054e8b21144b5f940187529c93551182' (branch: 'refs/tags/phabricator/diff/55230', checkout rules: '+:. => ./bitcoin-abc')
TeamCity URL https://build.bitcoinabc.org/buildConfiguration/BitcoinABC_BitcoinAbcStaging/976597 
TeamCity server version is 2025.03.1 (build 186125), server timezone: GMT (UTC)

[14:32:53]W: bt15 (8s)
[14:32:53]i: TeamCity server version is 2025.03.1 (build 186125)
[14:32:53] : Finalize build settings
[14:32:53] : Collecting changes in 2 VCS roots
[14:32:53] :	 [Collecting changes in 2 VCS roots] VCS Root details
[14:32:53] :		 [VCS Root details] "Bitcoin ABC Staging" {instance id=22, parent internal id=3, parent id=BitcoinABC_BitcoinAbcStaging, description: "ssh://vcs@reviews.bitcoinabc.org:2221/source/bitcoin-abc-staging.git#refs/heads/master"}
[14:32:53] :		 [VCS Root details] "abc-infrastructure" {instance id=24, parent internal id=7, parent id=AutomatedDeployments_BitcoinAbcDeveloperTools_AbcInfrastructure, description: "ssh://vcs@reviews.bitcoinabc.org:2221/source/infrastructure.git#refs/heads/master"}
[14:32:53]i: Loading current repository state for VCS root 'Bitcoin ABC Staging' (1s)
[14:32:53]i:	 [Loading current repository state for VCS root 'Bitcoin ABC Staging'] VCS root 'Bitcoin ABC Staging': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper7271765228803535107.sh ls-remote origin
[14:32:53]i:	 [Loading current repository state for VCS root 'Bitcoin ABC Staging'] Loading current repository state for VCS root 'abc-infrastructure' (1s)
[14:32:53]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'abc-infrastructure': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper5762795060442846354.sh ls-remote origin
[14:32:53]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[14:32:53]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'abc-infrastructure': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[14:32:54]i: Detecting changes in VCS root 'abc-infrastructure' (used in 'Bitcoin-ABC Infra Checkout', 'Extract Electrum ABC from ABC' and 5 other configurations)
[14:32:54]i: Will collect changes for 'abc-infrastructure' starting from revision 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[14:32:54]i: Detecting changes in VCS root 'Bitcoin ABC Staging' (used in 'Diff Testing', 'Staging Checkout Dummy')
[14:32:54]i: Will collect changes for 'Bitcoin ABC Staging' starting from revision 979907a6cdf8719f81a43bc56b723ecf0e8c7f4c
[14:32:54] : Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout
[14:32:54] :	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] Upper limit revision: 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[14:32:54]i:	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] MaxModId = 83296
[14:32:54] :	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] Computed revision: 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[14:32:54] : Compute revision for 'Bitcoin ABC Staging'
[14:32:54] :	 [Compute revision for 'Bitcoin ABC Staging'] Upper limit revision: 9d8f4017054e8b21144b5f940187529c93551182
[14:32:54]i:	 [Compute revision for 'Bitcoin ABC Staging'] MaxModId = 84053
[14:32:54] :	 [Compute revision for 'Bitcoin ABC Staging'] Computed revision: 9d8f4017054e8b21144b5f940187529c93551182
[14:33:01]W: Build was removed from the queue with comment: This build has not been started because some of the builds it depends on failed to start
Mengerian added inline comments.
src/txmempool.cpp
193

Question: Should this be gated behind the avalanchepreconsensus flag?

Because with pre-consensus the block template doesn't change on mempool entry, but of transaction finalization

src/txmempool.cpp
193

I don't think it really matters. It's indeed no longer needed but it doesn't really hurt either so I'd better too often for now. Note that in practice miners only poll once every 30s or so, and only the longpoll miners will be updated by this which they are already after a minute anyway.

Fabien requested review of this revision.Aug 13 2025, 14:43
src/txmempool.cpp
353

Also, should nTransactionsUpdated be incremented in here somewhere also? Since the radix tree is also changing here

Also update after a block is finalized. This makes no practical difference since the block template filters for mempool txs already but this is more correct.

This revision is now accepted and ready to land.Aug 14 2025, 17:02