forked from cerc-io/laconicd-deprecated
evm: refactor state transition (#41)
* evm: keeper statedb refactor * keeper: implement stateDB account, balance, nonce and suicide functions * keeper: implement stateDB code and iterator functions * keeper: implement stateDB log and preimage functions * update code to use CommitStateDB * tests updates * journal changes (wip) * cache fields * journal and logs * minor cleanup * evm: state transition refactor * evm: unpack revert errors * evm: update state transition (wip) * evm: remove journal related changes * evm: delete empty account code and storage state * update gas limit * evm: header hash to/from context * evm: minor params and state transition changes * ante: state transition changes * ante: refactor default sig gas consumer * ante: ignore gas costs from ops other than intrinsic gas * ante: CanTransferDecorator * evm: refund gas * update comments * state transition comments * ante: CanTransfer and AccessList decorator tests * evm: cleanup state transition * ignore nonce increment during ante handler on contract creation * fix ante tests * more test fixes
This commit is contained in:
+13
-36
@@ -3,7 +3,6 @@ package rpc
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
@@ -470,30 +469,16 @@ func (e *PublicEthAPI) Call(args rpctypes.CallArgs, blockNr rpctypes.BlockNumber
|
||||
return []byte{}, err
|
||||
}
|
||||
|
||||
if len(simRes.Result.Log) > 0 {
|
||||
var logs []rpctypes.SDKTxLogs
|
||||
|
||||
if err := json.Unmarshal([]byte(simRes.Result.Log), &logs); err != nil {
|
||||
e.logger.WithError(err).Errorln("failed to unmarshal simRes.Result.Log")
|
||||
}
|
||||
|
||||
if len(logs) > 0 && logs[0].Log == rpctypes.LogRevertedFlag {
|
||||
data, err := evmtypes.DecodeTxResponse(simRes.Result.Data)
|
||||
if err != nil {
|
||||
e.logger.WithError(err).Warningln("call result decoding failed")
|
||||
return []byte{}, err
|
||||
}
|
||||
|
||||
return []byte{}, rpctypes.ErrRevertedWith(data.Ret)
|
||||
}
|
||||
}
|
||||
|
||||
data, err := evmtypes.DecodeTxResponse(simRes.Result.Data)
|
||||
if err != nil {
|
||||
e.logger.WithError(err).Warningln("call result decoding failed")
|
||||
return []byte{}, err
|
||||
}
|
||||
|
||||
if data.Reverted {
|
||||
return []byte{}, rpctypes.ErrRevertedWith(data.Ret)
|
||||
}
|
||||
|
||||
return (hexutil.Bytes)(data.Ret), nil
|
||||
}
|
||||
|
||||
@@ -620,25 +605,17 @@ func (e *PublicEthAPI) EstimateGas(args rpctypes.CallArgs) (hexutil.Uint64, erro
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if len(simRes.Result.Log) > 0 {
|
||||
var logs []rpctypes.SDKTxLogs
|
||||
if err := json.Unmarshal([]byte(simRes.Result.Log), &logs); err != nil {
|
||||
e.logger.WithError(err).Errorln("failed to unmarshal simRes.Result.Log")
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if len(logs) > 0 && logs[0].Log == rpctypes.LogRevertedFlag {
|
||||
data, err := evmtypes.DecodeTxResponse(simRes.Result.Data)
|
||||
if err != nil {
|
||||
e.logger.WithError(err).Warningln("call result decoding failed")
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return 0, rpctypes.ErrRevertedWith(data.Ret)
|
||||
}
|
||||
data, err := evmtypes.DecodeTxResponse(simRes.Result.Data)
|
||||
if err != nil {
|
||||
e.logger.WithError(err).Warningln("call result decoding failed")
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// TODO: change 1000 buffer for more accurate buffer (eg: SDK's gasAdjusted)
|
||||
if data.Reverted {
|
||||
return 0, rpctypes.ErrRevertedWith(data.Ret)
|
||||
}
|
||||
|
||||
// TODO: Add Gas Info from state transition to MsgEthereumTxResponse fields and return that instead
|
||||
estimatedGas := simRes.GasInfo.GasUsed
|
||||
gas := estimatedGas + 200000
|
||||
|
||||
|
||||
Reference in New Issue
Block a user