forked from cerc-io/laconicd-deprecated
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:
+2
-2
@@ -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: ðHash,
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user