Skip to content

Commit 5d5ec5b

Browse files
envestccLiuhaaiCoderZhi
authored
Fix archive simulate bugs (#4711)
Co-authored-by: Liuhaai <[email protected]> Co-authored-by: CoderZhi <[email protected]>
1 parent 19b0a95 commit 5d5ec5b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

api/coreservice.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ func (core *coreService) readContract(
657657
}
658658
var (
659659
g = core.bc.Genesis()
660-
blockGasLimit = g.BlockGasLimitByHeight(height)
660+
blockGasLimit = g.BlockGasLimitByHeight(height + 1)
661661
)
662662
if elp.Gas() == 0 || blockGasLimit < elp.Gas() {
663663
elp.SetGas(blockGasLimit)
@@ -2004,7 +2004,7 @@ func (core *coreService) SimulateExecution(ctx context.Context, addr address.Add
20042004
var (
20052005
g = core.bc.Genesis()
20062006
tipHeight = core.bc.TipHeight()
2007-
blockGasLimit = g.BlockGasLimitByHeight(tipHeight)
2007+
blockGasLimit = g.BlockGasLimitByHeight(tipHeight + 1)
20082008
)
20092009
elp.SetGas(blockGasLimit)
20102010
return core.simulateExecution(ctx, tipHeight, false, addr, elp)
@@ -2108,7 +2108,7 @@ func (core *coreService) TraceCall(ctx context.Context,
21082108
}
21092109
var (
21102110
g = core.bc.Genesis()
2111-
blockGasLimit = g.BlockGasLimitByHeight(height)
2111+
blockGasLimit = g.BlockGasLimitByHeight(height + 1)
21122112
)
21132113
if gasLimit == 0 {
21142114
gasLimit = blockGasLimit

api/coreservice_with_height.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ type (
3232
)
3333

3434
func newCoreServiceWithHeight(cs *coreService, height uint64) *coreServiceReaderWithHeight {
35+
if height == 0 {
36+
height = cs.TipHeight()
37+
}
3538
return &coreServiceReaderWithHeight{
3639
cs: cs,
3740
height: height,

0 commit comments

Comments
 (0)