Skip to content

Conversation

@HGuillemet
Copy link
Contributor

Currently, Firedancer discards transactions before sending them to bank tile by considering the slot difference between the reference block and the current slot. This is deviating from the protocol and causes transactions to be wrongly ignored if at least 1 slot was skipped during the last 151 slots. The difference in block heights should be used instead.

Fixes #7052

  • Blockhash map in resolv now maps block hashes to block heights instead of to slots.
  • resolv forwards to pack the txs that have a reference block height earlier or equal to 151 before last root block height, instead of the last completed slot.
  • pack now receives from resolv the last root block height as message signature instead of the last observed slot. Only the root block has a finalized block height that we can base on to discard expired txs. When a transaction is received with a new root block height, it discards all buffered txs referencing a slot with a block height earlier than 151 before.
  • When we become leader, pack discards all txs based on leader slot block height.
  • Add block height in Firedancer replay->resolv "root advanced" message.
  • Add block height to "became leader" message
  • Add block height to Frankendancer bank->resolv "rooted bank" message.
  • Replace slot by block height in Frankendancer bank->resolv "blockhash completed" message.

In resolv, I kept the last completed block height to initialize the reference block height when a transaction is received with an unknown blockhash, but I'm not sure it is useful, since it will be replaced by flushing_block_height when it leaves the stash. completed_block_height is probably removable.

The changes to agave
Shall I open a PR against some branch of firedancer agave repo ?

Tested with frankendancer. Not with full firedancer.

uint actual_consumed_cus; /* non_execution_cus+real execution CUs+real account data cus. PoH reads this for block CU counting. */
} bank_cu; /* Populated by bank. */
ulong blockhash_slot; /* Slot provided by resolv tile when txn arrives at the pack tile. Used when txn is in extra storage in pack. */
ulong block_height; /* Block height provided by resolv tile when txn arrives at the pack tile. Used when txn is in extra storage in pack. */
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the blockhash_block_height, not block_height

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I missed that because this field seems only used when FD_PACK_USE_EXTRA_STORAGE is on.

if( FD_UNLIKELY( (ctx->leader_slot==ULONG_MAX) & (sig>ctx->highest_observed_slot) ) ) {
/* Using the resolv tile's knowledge of the current slot is a bit
if( FD_UNLIKELY( (ctx->leader_slot==ULONG_MAX) & (sig>ctx->root_block_height) ) ) {
/* Using the resolv tile's knowledge of the current last root block height is a bit
Copy link
Contributor

Choose a reason for hiding this comment

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

Rewrap to 72 columns

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Comments are 72-wide but not the code ?

happen if we are getting transactions. */
ctx->highest_observed_slot = sig;
ulong exp_cnt = fd_pack_expire_before( ctx->pack, fd_ulong_max( ctx->highest_observed_slot, TRANSACTION_LIFETIME_SLOTS )-TRANSACTION_LIFETIME_SLOTS );
ctx->root_block_height = sig;
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't the root block height though? It's the block height of the referenced blockhash, I don't think this logic works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is to pass the root block height as the sig, and use it to discard already buffered txs, and the reference (= blockhash) block height of the sent tx in the reference_block_height of the fd_txn_m.
Why do you think it won't work ?

Copy link
Contributor

@mmcgee-jump mmcgee-jump left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

ulong deleted;
long insert_duration = -fd_tickcount();
int result = fd_pack_insert_txn_fini( ctx->pack, ctx->cur_spot, blockhash_slot, &deleted );
int result = fd_pack_insert_txn_fini( ctx->pack, ctx->cur_spot, block_height, &deleted );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a problem here though. fd_pack_insert_txn_fini should be called with the reference block hash, not the root block hash passed using sig.
Couldn't we remove this third argument and use ctx->cur_spot->txnp->reference_block_height instead, ctx->cur_sport being the second argument ?

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.

resolv: wrong expiration logic

2 participants