forked from cerc-io/laconicd-deprecated
Context block height fix on TraceTx (#1051)
This commit is contained in:
@@ -362,8 +362,15 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ
|
||||
return nil, status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", req.TraceConfig.Limit)
|
||||
}
|
||||
|
||||
// minus one to get the context of block beginning
|
||||
contextHeight := req.BlockNumber - 1
|
||||
if contextHeight < 1 {
|
||||
// 0 is a special value in `ContextWithHeight`
|
||||
contextHeight = 1
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
ctx = ctx.WithBlockHeight(req.BlockNumber)
|
||||
ctx = ctx.WithBlockHeight(contextHeight)
|
||||
ctx = ctx.WithBlockTime(req.BlockTime)
|
||||
ctx = ctx.WithHeaderHash(common.Hex2Bytes(req.BlockHash))
|
||||
|
||||
@@ -420,8 +427,15 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest)
|
||||
return nil, status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", req.TraceConfig.Limit)
|
||||
}
|
||||
|
||||
// minus one to get the context of block beginning
|
||||
contextHeight := req.BlockNumber - 1
|
||||
if contextHeight < 1 {
|
||||
// 0 is a special value in `ContextWithHeight`
|
||||
contextHeight = 1
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
ctx = ctx.WithBlockHeight(req.BlockNumber)
|
||||
ctx = ctx.WithBlockHeight(contextHeight)
|
||||
ctx = ctx.WithBlockTime(req.BlockTime)
|
||||
ctx = ctx.WithHeaderHash(common.Hex2Bytes(req.BlockHash))
|
||||
|
||||
|
||||
@@ -605,7 +605,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
||||
var (
|
||||
txMsg *types.MsgEthereumTx
|
||||
traceConfig *types.TraceConfig
|
||||
txIndex uint64
|
||||
predecessors []*types.MsgEthereumTx
|
||||
)
|
||||
|
||||
@@ -619,7 +618,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
||||
{
|
||||
msg: "default trace",
|
||||
malleate: func() {
|
||||
txIndex = 0
|
||||
traceConfig = nil
|
||||
predecessors = []*types.MsgEthereumTx{}
|
||||
},
|
||||
@@ -629,7 +627,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
||||
{
|
||||
msg: "default trace with filtered response",
|
||||
malleate: func() {
|
||||
txIndex = 0
|
||||
traceConfig = &types.TraceConfig{
|
||||
DisableStack: true,
|
||||
DisableStorage: true,
|
||||
@@ -644,7 +641,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
||||
{
|
||||
msg: "javascript tracer",
|
||||
malleate: func() {
|
||||
txIndex = 0
|
||||
traceConfig = &types.TraceConfig{
|
||||
Tracer: "{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == \"CALL\") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}",
|
||||
}
|
||||
@@ -656,7 +652,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
||||
{
|
||||
msg: "default trace with enableFeemarket",
|
||||
malleate: func() {
|
||||
txIndex = 0
|
||||
traceConfig = &types.TraceConfig{
|
||||
DisableStack: true,
|
||||
DisableStorage: true,
|
||||
@@ -671,7 +666,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
||||
{
|
||||
msg: "javascript tracer with enableFeemarket",
|
||||
malleate: func() {
|
||||
txIndex = 0
|
||||
traceConfig = &types.TraceConfig{
|
||||
Tracer: "{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == \"CALL\") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}",
|
||||
}
|
||||
@@ -684,7 +678,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
||||
{
|
||||
msg: "default tracer with predecessors",
|
||||
malleate: func() {
|
||||
txIndex = 1
|
||||
traceConfig = nil
|
||||
|
||||
// increase nonce to avoid address collision
|
||||
@@ -722,7 +715,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
||||
traceReq := types.QueryTraceTxRequest{
|
||||
Msg: txMsg,
|
||||
TraceConfig: traceConfig,
|
||||
TxIndex: txIndex,
|
||||
Predecessors: predecessors,
|
||||
}
|
||||
res, err := suite.queryClient.TraceTx(sdk.WrapSDKContext(suite.ctx), &traceReq)
|
||||
|
||||
Reference in New Issue
Block a user