Implement eth_pendingTransactions, bump sdk version (#124)

* Update sdk version, implement pending txs, fix nonce check

* Bump cached dependencies in circleCI

* bump circleci go version

* updated linter and fixed bugs relating to go version 1.13
This commit is contained in:
Austin Abell
2019-10-19 08:23:09 +09:00
committed by GitHub
parent 9802cbc98e
commit 160e82b2ad
11 changed files with 210 additions and 78 deletions
+2 -2
View File
@@ -64,7 +64,7 @@ func handleETHTxMsg(ctx sdk.Context, keeper Keeper, msg types.EthereumTxMsg) sdk
Recipient: msg.Data.Recipient,
Amount: msg.Data.Amount,
Payload: msg.Data.Payload,
Csdb: keeper.csdb,
Csdb: keeper.csdb.WithContext(ctx),
ChainID: intChainID,
THash: &ethHash,
}
@@ -95,7 +95,7 @@ func handleEmintMsg(ctx sdk.Context, keeper Keeper, msg types.EmintMsg) sdk.Resu
GasLimit: msg.GasLimit,
Amount: msg.Amount.BigInt(),
Payload: msg.Payload,
Csdb: keeper.csdb,
Csdb: keeper.csdb.WithContext(ctx),
ChainID: intChainID,
}
+16
View File
@@ -31,6 +31,10 @@ type StateTransition struct {
func (st StateTransition) TransitionCSDB(ctx sdk.Context) (sdk.Result, *big.Int) {
contractCreation := st.Recipient == nil
if res := st.checkNonce(); !res.IsOK() {
return res, nil
}
// This gas limit the the transaction gas limit with intrinsic gas subtracted
gasLimit := ctx.GasMeter().Limit()
@@ -97,3 +101,15 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (sdk.Result, *big.Int)
return sdk.Result{Data: returnData, GasUsed: st.GasLimit - leftOverGas}, bloomInt
}
func (st *StateTransition) checkNonce() sdk.Result {
// Make sure this transaction's nonce is correct.
nonce := st.Csdb.GetNonce(st.Sender)
if nonce < st.AccountNonce {
return emint.ErrInvalidNonce("nonce too high").Result()
} else if nonce > st.AccountNonce {
return emint.ErrInvalidNonce("nonce too low").Result()
}
return sdk.Result{}
}