Skip to content

Commit

Permalink
Merge pull request #1267 from libangzhu/plugin-nonce
Browse files Browse the repository at this point in the history
update execEvmNonce
  • Loading branch information
bysomeone authored May 26, 2023
2 parents d9568f9 + 16bcd9f commit 3549ed0
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions plugin/dapp/evm/executor/exec_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,26 @@ func (evm *EVMExecutor) execEvmNonce(dbSet *types.LocalDBSet, tx *types.Transact
nonceV, err := evm.GetLocalDB().Get(nonceLocalKey)
if err == nil {
_ = types.Decode(nonceV, evmNonce)
}
if evmNonce.GetNonce() == tx.GetNonce() {
evmNonce.Nonce++

if evm.GetAPI().GetConfig().IsDappFork(evm.GetHeight(), "evm", evmtypes.ForkEvmExecNonce) &&
evmNonce.GetNonce() != tx.GetNonce() { //nonce 错误 返回异常
elog.Error("execEvmNonce err", "height", evm.GetHeight(), "idx", index, "txHash", common.ToHex(tx.Hash()),
"from", fromAddr, "expect", evmNonce.GetNonce(), "actual", tx.GetNonce())
return errInvalidEvmNonce
} else { //nonce 不匹配
if evm.GetAPI().GetConfig().IsDappFork(evm.GetHeight(), "evm", evmtypes.ForkEvmExecNonce) { //分叉之后的逻辑
elog.Error("execEvmNonce err", "height", evm.GetHeight(), "idx", index, "txHash", common.ToHex(tx.Hash()),
"from", fromAddr, "expect", evmNonce.GetNonce(), "actual", tx.GetNonce())
return errInvalidEvmNonce
} else {
//分叉之前 不做任何处理
}
}

} else { //不存在nonceLocalKey
evmNonce.Addr = tx.From()
evmNonce.Nonce = 1
}
evmNonce.Addr = fromAddr
evmNonce.Nonce++

//evmNonce.Addr = fromAddr
//evmNonce.Nonce++
dbSet.KV = append(dbSet.KV, &types.KeyValue{Key: nonceLocalKey, Value: types.Encode(evmNonce)})
return nil
}
Expand Down

0 comments on commit 3549ed0

Please sign in to comment.