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

Evaluation order of transactions in a block #244

Closed
dahlia opened this issue May 17, 2019 · 3 comments · Fixed by #511
Closed

Evaluation order of transactions in a block #244

dahlia opened this issue May 17, 2019 · 3 comments · Fixed by #511
Assignees
Labels
discussion needed We need to dicuss about this

Comments

@dahlia
Copy link
Contributor

dahlia commented May 17, 2019

Currently the evaluation order of transactions signed by multiple signers in a block are arbitrary and can be reoredered (fabricated) by a miner. This indeterministic order makes games unfair.

For example, suppose there are two actions, Attack which decreases target's health and Defend which invalidates one succeeding Attack against on the signer. A signs a transaction tA to Attack B, and B signs a transaction tB to Defend itself. If two transactions try to belong to a block, a block miner can determine whether to decrease B's health or not. If tA is followed by tB B gets damage, whereas if tB is followed by tA A loses its chance.

Therefore, the evaluation order of transactions in a block should not be determined by any certain party.

One idea I have is to make the evaluation order determined after a block is mined so that a miner can't deal with it:

  1. First of all, make Block<T>.Mine() to take a set of transactions instead of a sequence of transactions. These transactions are unordered.
  2. When transactions (actions) in a block is being evaluated, sort them in the order of each one's nonce, which is derived from both a block hash and a transaction's signature.

This makes the order of evaluation impossible to predict until a block is mined. The order is still arbitrary, but it makes game play in general more fair.

Any opinions are welcome.

@moreal
Copy link
Contributor

moreal commented Jul 8, 2019

I started to work on this issue 😁

@moreal moreal modified the milestone: 0.6.0 Aug 28, 2019
@moreal
Copy link
Contributor

moreal commented Sep 9, 2019

It's resolved by #355.

@moreal moreal closed this as completed Sep 9, 2019
@moreal moreal reopened this Sep 10, 2019
@moreal
Copy link
Contributor

moreal commented Sep 11, 2019

In #355, I decided to order transactions by its nonce for hash. But it can cause undetermined hash, which also affects the order in which transactions are executed.

limebell pushed a commit to limebell/libplanet that referenced this issue Jul 7, 2021
…brunnr-battle

Fix mimisbrunnr battle action
OnedgeLee pushed a commit to OnedgeLee/libplanet that referenced this issue Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion needed We need to dicuss about this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants