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

[Exec] Update sequence number independent of transaction invocation result #602

Merged
merged 20 commits into from
Apr 15, 2021

Conversation

ramtinms
Copy link
Member

@ramtinms ramtinms commented Apr 8, 2021

This PR

  • changes the behaviour of sequence number update as follows

    • FVM should not update the seq number if seq number verification fails (invalid signatures, invalid seq number, non-existence proposal account, ...) .
    • FVM should do update the seq number no matter the results of tx invocation and storage limiting.
    • Execution and Verification node should always merge back the tx View
  • fixes error handling of meta transactions. (the txErrors were ignored previously)

Most of the heavy lifting has been done in previous PRs, this PR adds few tests and fix exec node's computer and chunk verifier and adds some extra unit test.

What does this mean?

Starting next spork, when running a transaction, the proposer key sequence number would always be incremented unless any of the following conditions occur:

  • invalid transaction (transaction rejected by collection nodes)
  • any of the transaction signatures are not valid
  • the transaction is missing the signature(s) by the proposer
  • the proposal sequence number is invalid (not match with the one stored on the chain)
    In other words, the new behaviour increments the sequence number even if the transaction fails at runtime or any other condition that is not mentioned above. The new behaviour protects the network against some cases of spamming attacks and protects users from double transaction submission attacks.

@ramtinms ramtinms changed the title [WIP] update seq number even if tx invocation fails. [WIP] update seq number even if tx invocation fails Apr 9, 2021
prepareTx(t, tx6, account, privKey, 4, chain)
prepareTx(t, tx6, account, privKey, 5, chain)
Copy link
Member Author

Choose a reason for hiding this comment

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

the previous call in the test supposed to fail due to runtime error (failed in updating contract), previously we didn't increment the sequence number but with the new behaviour it needs to increment.

Comment on lines +315 to +316
// we don't set the proper sequence number of this one
_, col2, block2, proposal2, _ := makePanicBlock(t, conID, colID, chain, uint64(0), block1.Header, genesis)
Copy link
Member Author

Choose a reason for hiding this comment

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

same here

}),
)

t.Run("Transaction invocation fails but sequence number is incremented", newVMTest().withBootstrapProcedureOptions(
Copy link
Member Author

Choose a reason for hiding this comment

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

We also have added this test before

@@ -25,7 +26,12 @@ func (d *TransactionFeeDeductor) Process(
defer span.Finish()
}

return d.deductFees(vm, ctx, proc.Transaction, sth, programs)
txErr, fatalErr := d.deductFees(vm, ctx, proc.Transaction, sth, programs)
// TODO handle deduct fee failures, for now just return as error
Copy link
Member Author

Choose a reason for hiding this comment

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

we need to address this case on fee deduction PR

_ = led.Set("00", "", "", []byte{'F'})
_ = led.Set("05", "", "", []byte{'B'})
Copy link
Member Author

Choose a reason for hiding this comment

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

this needs to change the state commitment as the sequence number is applied.


tx := flow.TransactionBody{}
tx.SetProposalKey(address, 0, 0)
signEnvelope(&tx, address, *privKey)
Copy link
Member Author

Choose a reason for hiding this comment

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

signatures are not needed for this test but I added them here, so in the future when we move proposal signature verification to this component, the test will check it.

@ramtinms ramtinms changed the title [WIP] update seq number even if tx invocation fails Update seq number even if tx invocation fails Apr 13, 2021
@ramtinms ramtinms marked this pull request as ready for review April 13, 2021 23:22
@ramtinms ramtinms changed the title Update seq number even if tx invocation fails [Exec] Update sequence number independent of transaction invocation result Apr 13, 2021
engine/execution/computation/computer/computer.go Outdated Show resolved Hide resolved
fvm/env.go Outdated Show resolved Hide resolved
fvm/bootstrap.go Outdated Show resolved Hide resolved
@ramtinms ramtinms merged commit ad6c469 into master Apr 15, 2021
@ramtinms ramtinms deleted the ramtin/4107-seq-number-updates-on-failed-tx branch April 15, 2021 18:37
Kay-Zee added a commit that referenced this pull request Apr 27, 2021
Kay-Zee added a commit that referenced this pull request Apr 27, 2021
* Revert "[Exec] Update sequence number independent of transaction invocation result (#602)"

This reverts commit ad6c469.

* Keep fvm changes
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

3 participants