Skip to content

tower: produce vote with parent bank's blockhash#10171

Open
ibhatt-jumptrading wants to merge 5 commits into
mainfrom
ibhatt/root_bhash_vote
Open

tower: produce vote with parent bank's blockhash#10171
ibhatt-jumptrading wants to merge 5 commits into
mainfrom
ibhatt/root_bhash_vote

Conversation

@ibhatt-jumptrading

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 10, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates tower vote-transaction generation to use the current tower root’s blockhash as the transaction’s recent blockhash, and adds a unit test to assert this behavior.

Changes:

  • Generate vote transactions using the root slot’s block_hash (recent blockhash) instead of the voted slot’s vote_block_hash.
  • Add a regression test that constructs a minimal tower state and verifies the serialized vote txn uses the root blockhash.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/discof/tower/fd_tower_tile.c Switch vote txn recent blockhash source to the root tower block’s block_hash.
src/discof/tower/test_tower_tile.c Add test coverage ensuring the vote txn recent blockhash matches the root blockhash.

Comment thread src/discof/tower/fd_tower_tile.c Outdated
Comment on lines +603 to +605
fd_txn_p_t txn[1];
fd_hash_t const * root_blockhash = fd_type_pun_const( fd_tower_blocks_query( ctx->tower, ctx->tower->root )->block_hash.uc );
fd_tower_to_vote_txn( ctx->tower, &out->vote_bank_hash, &out->vote_block_id, root_blockhash, ctx->identity_key, authority, ctx->vote_account, txn );
Comment thread src/discof/tower/test_tower_tile.c Outdated
Comment on lines +247 to +248
fd_hash_t const * root_blockhash = fd_type_pun_const( fd_tower_blocks_query( ctx->tower, ctx->tower->root )->block_hash.uc );
fd_tower_to_vote_txn( ctx->tower, &bank_hash, &block_id, root_blockhash, &validator_identity, &validator_identity, &vote_acc, txnp );
@github-actions

Copy link
Copy Markdown

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-424669000-perf per slot 0.046948 s 0.046955 s 0.015%
backtest mainnet-424669000-perf snapshot load 1.892 s 1.902 s 0.529%
backtest mainnet-424669000-perf total elapsed 60.844065 s 60.853469 s 0.015%
firedancer mem usage with mainnet.toml 504.41 GiB 504.41 GiB 0.000%

@greptile-jt

greptile-jt Bot commented Jun 10, 2026

Copy link
Copy Markdown

Greptile Summary

Changes the vote transaction's recent_blockhash field to use the root bank's blockhash instead of the voted-on block's blockhash. Previously, fd_tower_to_vote_txn received &out->vote_block_hash (the block hash of the slot being voted for); now it receives the block hash from fd_tower_blocks_query(ctx->tower, ctx->tower->root).

  • fd_tower_tile.c: Replaces the 4th argument to fd_tower_to_vote_txn with the root block's block_hash, queried via fd_tower_blocks_query. The root block is guaranteed to be in the tower's block map at this point: it is either the init slot (just inserted) or the latest root after advancing (old root blocks are removed but the new root block is preserved).
  • test_tower_tile.c: Adds test_root_vote_txn_recent_blockhash which constructs a tower with a root at slot 104, builds a vote transaction, parses the resulting payload, and asserts the embedded recent blockhash equals the root block's hash.
  • The vote_block_hash field in fd_tower_out_t is still populated by fd_tower_vote_and_reset but is no longer consumed by any caller after this change.

Confidence Score: 4/5

This PR is a targeted, well-tested behavioral change that is safe to merge.

The change is small, focused, and comes with a proper unit test. The root block is guaranteed to exist in the block map at the point of access (validated by tracing all code paths). The only minor concern is the now-unused vote_block_hash field in fd_tower_out_t, which is a cleanup opportunity but not a correctness issue.

No files require special attention. The vote_block_hash field in fd_tower.h is now unused and could be cleaned up in a follow-up.

Important Files Changed

Filename Overview
src/discof/tower/fd_tower_tile.c Changes vote transaction's recent_blockhash source from the voted block's hash to the root block's hash via fd_tower_blocks_query. The root block is guaranteed to exist in the block map at this point. The vote_block_hash field in fd_tower_out_t is now unused.
src/discof/tower/test_tower_tile.c Adds test_root_vote_txn_recent_blockhash that verifies the vote transaction's recent blockhash is the root block's hash. Well-structured test with proper setup, execution, and assertion.

Sequence Diagram

sequenceDiagram
    participant RT as replay_slot_completed
    participant TT as tower_tile
    participant TV as fd_tower_vote_and_reset
    participant BM as tower block_map
    participant VTX as fd_tower_to_vote_txn

    RT->>TT: slot_completed msg
    TT->>BM: fd_tower_blocks_insert(slot)
    TT->>TV: fd_tower_vote_and_reset()
    TV-->>TT: out (vote_slot, root_slot, ...)
    alt root advanced
        TT->>BM: remove old root blocks
        TT->>TT: ctx->tower->root = out.root_slot
    end
    TT->>TT: publish_slot_done()
    TT->>BM: fd_tower_blocks_query(tower->root)
    BM-->>TT: root block (block_hash)
    TT->>VTX: fd_tower_to_vote_txn(..., root_blockhash, ...)
    VTX-->>TT: vote_txn with root's blockhash as recent_blockhash
Loading

Reviews (1): Last reviewed commit: "tower: produce vote with root bank's blo..." | Re-trigger Greptile

@yufeng-jump yufeng-jump left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.

@github-actions

Copy link
Copy Markdown

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-424669000-perf per slot 0.046753 s 0.046485 s -0.573%
backtest mainnet-424669000-perf snapshot load 1.862 s 1.864 s 0.107%
backtest mainnet-424669000-perf total elapsed 60.591667 s 60.244431 s -0.573%
firedancer mem usage with mainnet.toml 504.41 GiB 504.41 GiB 0.000%

Copilot AI review requested due to automatic review settings June 11, 2026 15:37
@github-actions

Copy link
Copy Markdown

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-424669000-perf per slot 0.046967 s 0.046955 s -0.026%
backtest mainnet-424669000-perf snapshot load 1.929 s 1.904 s -1.296%
backtest mainnet-424669000-perf total elapsed 60.869661 s 60.854281 s -0.025%
firedancer mem usage with mainnet.toml 504.41 GiB 504.41 GiB 0.000%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread src/discof/tower/fd_tower_tile.c Outdated
Comment thread src/discof/tower/test_tower_tile.c
Comment thread src/discof/tower/fd_tower_tile.c
@ibhatt-jumptrading ibhatt-jumptrading changed the title tower: produce vote with root bank's blockhash tower: produce vote with parent bank's blockhash Jun 12, 2026
@github-actions

Copy link
Copy Markdown

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-424669000-perf per slot 0.046629 s 0.046509 s -0.257%
backtest mainnet-424669000-perf snapshot load 1.823 s 1.836 s 0.713%
backtest mainnet-424669000-perf total elapsed 60.431523 s 60.27504 s -0.259%
firedancer mem usage with mainnet.toml 506.46 GiB 506.46 GiB 0.000%

Copilot AI review requested due to automatic review settings June 12, 2026 19:23
@github-actions

Copy link
Copy Markdown

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-424669000-perf per slot 0.050226 s 0.050209 s -0.034%
backtest mainnet-424669000-perf snapshot load 1.953 s 1.958 s 0.256%
backtest mainnet-424669000-perf total elapsed 65.093236 s 65.070313 s -0.035%
firedancer mem usage with mainnet.toml 506.46 GiB 506.46 GiB 0.000%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment on lines +629 to +632
fd_txn_p_t txn[1];
fd_tower_blk_t * parent_tower_blk = fd_tower_blocks_query( ctx->tower, slot_completed->parent_slot );
FD_TEST( parent_tower_blk );
fd_hash_t const * recent_blockhash = &parent_tower_blk->block_hash;

fd_tower_blk_t * recent_blockhash_blk = fd_tower_blocks_query( ctx->tower, slot_completed.parent_slot );
FD_TEST( recent_blockhash_blk );
fd_hash_t const * recent_blockhash = fd_type_pun_const( recent_blockhash_blk->block_hash.uc );
@ripatel-fd

Copy link
Copy Markdown
Contributor

why?

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