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: Smarter transaction expire logic #4802

Closed
wants to merge 1 commit into from

Conversation

SamHSmith
Copy link
Contributor

Description

Linked issue

Closes #{issue_number}

Benefits

Checklist

  • I've read CONTRIBUTING.md
  • I've used the standard signed-off commit format (or will squash just before merging)
  • All applicable CI checks pass (or I promised to make them pass later)
  • (optional) I've written unit tests for the code changes
  • I replied to all comments after code review, marking all implemented changes with thumbs up

@SamHSmith SamHSmith self-assigned this Jul 4, 2024
@SamHSmith SamHSmith changed the title [fix] Smarter transaction expire logic [fix]: Smarter transaction expire logic Jul 4, 2024
@SamHSmith SamHSmith changed the title [fix]: Smarter transaction expire logic fix: Smarter transaction expire logic Jul 4, 2024
Signed-off-by: Sam H. Smith <sam.henning.smith@protonmail.com>
Comment on lines -123 to +128
curr_time.saturating_sub(tx_creation_time) > time_limit
curr_time.saturating_sub(tx_creation_time) + time_padding > time_limit
Copy link
Contributor

Choose a reason for hiding this comment

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

This change argues that more transactions should be expired in sumeragi, right?
Where does this issue originate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The original issue is that the leader can create a block with transactions that will expire before the consensus round is over. When iroha is under transaction load and producing many blocks this becomes very common. This change makes sure that block production remains smooth by throwing away transactions that are not guaranteed to live long enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought it was at the time of block creation that determines whether transactions expire or not, and transactions only need to survive until the block creation.

Btw do we have some consensus mechanism on whether or not the leader should include a certain transaction in block, as noted here and here?

Copy link
Contributor

@Erigara Erigara Jul 9, 2024

Choose a reason for hiding this comment

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

I thought it was at the time of block creation that determines whether transactions expire or not, and transactions only need to survive until the block creation.

By looking at the code i think Sato is correct, we don't reject transaction from the block based on expired it or not.

is_expired is Queue method and we newer call in on block revalidation.

Copy link
Contributor

@Erigara Erigara Jul 9, 2024

Choose a reason for hiding this comment

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

Btw do we have some consensus mechanism on whether or not the leader should include a certain transaction in block, as noted here and here?

I far as i remember there were discussion that this mechanism is not really working because faulty peer can ignore sending receipt or smt like that.

EDIT: Relevant disscussion was here #2636

Copy link
Contributor

@mversic mversic Jul 9, 2024

Choose a reason for hiding this comment

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

is_expired is Queue method and we newer call in on block revalidation.

which seems like a bug because malicious leader can put expired transactions into the new block. This should be checked during consensus by other peeers. But only during consensus and not during block replay

Copy link
Contributor

Choose a reason for hiding this comment

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

this change might cause some problems because time is not synchronized across nodes

Copy link
Contributor

@s8sato s8sato Jul 9, 2024

Choose a reason for hiding this comment

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

Regardless of this PR, correct implementation of TTL might not be possible without time consensus:
the leader imposes a time window (with Queue.tx_time_to_live and Queue.future_threshold) on transactions from a client, but since there is no time consensus, even if the leader drops all transactions with its system time far away from the client's one, no one can sue the leader with certainty

Copy link
Contributor

@s8sato s8sato Jul 9, 2024

Choose a reason for hiding this comment

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

But it may also be true that there is no incentive for leaders to cheat in such a way. For example, they can't just ignore certain clients this way. Ignoring all transactions, they would simply result in being replaced immediately

EDIT:
Some clients might collude with the leader to shift the time and allow only their transactions to pass. But that's only for that round, and I'm not sure how much harm it can do

@mversic mversic closed this Jul 22, 2024
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.

None yet

4 participants