f-o-a-m / kepler

A Haskell framework that facilitates writing ABCI applications
https://kepler.dev
Apache License 2.0
34 stars 10 forks source link

Add nonce to transactions #183

Closed IvantheTricourne closed 4 years ago

IvantheTricourne commented 4 years ago

We want to be able to commit multiple semantically equivalent transactions (e.g. a transfer between the same 2 accounts for the same value). Currently, this fails during the checkTx phase with the error:

"Error on broadcastTxCommit: Tx already exists in cache"

To address this, we should propagate the nonce from the Auth module to transactions performed by respective account. This will probably take the shape of an AnteHandler check which happens before message routing and validation. This AnteHandler is responsible for validating that the appropriate nonce is updated for a given transaction.

IvantheTricourne commented 4 years ago

Both Ethereum and Cosmos increment nonces by 1 for each transaction performed by a given account. Ethereum specifies that transaction nonces should be kept in order (i.e., 1 should always happen before 2, and 2 cannot exist without 1).