diff --git a/cmd/derod/rpc/rpc_dero_estimategas.go b/cmd/derod/rpc/rpc_dero_estimategas.go index cf522ecb..d524b8a1 100644 --- a/cmd/derod/rpc/rpc_dero_estimategas.go +++ b/cmd/derod/rpc/rpc_dero_estimategas.go @@ -64,13 +64,14 @@ func GetGasEstimate(ctx context.Context, p rpc.GasEstimate_Params) (result rpc.G } } - toporecord, err := chain.Store.Topo_store.Read(chain.Load_TOPO_HEIGHT()) + topoHeight := chain.Load_TOPO_HEIGHT() + toporecord, err := chain.Store.Topo_store.Read(topoHeight) // we must now fill in compressed ring members if err == nil { var ss *graviton.Snapshot ss, err = chain.Store.Balance_store.LoadSnapshot(toporecord.State_Version) if err == nil { - s := dvm.SimulatorInitialize(ss) + s := dvm.SimulatorInitialize(ss, uint64(topoHeight)) if len(p.SC_Code) >= 1 { // we need to install the SC if _, result.GasCompute, result.GasStorage, err = s.SCInstall(p.SC_Code, incoming_values, p.SC_RPC, signer, 0); err != nil { return diff --git a/dvm/simulator.go b/dvm/simulator.go index 702e2e26..243f965d 100644 --- a/dvm/simulator.go +++ b/dvm/simulator.go @@ -45,7 +45,7 @@ type Simulator struct { Balances map[string]map[string]uint64 } -func SimulatorInitialize(ss *graviton.Snapshot) *Simulator { +func SimulatorInitialize(ss *graviton.Snapshot, topoHeight uint64) *Simulator { var s Simulator var err error @@ -63,6 +63,7 @@ func SimulatorInitialize(ss *graviton.Snapshot) *Simulator { } s.ss = ss + s.height = topoHeight s.balance_tree, err = ss.GetTree(config.BALANCE_TREE) if err != nil { panic(err) diff --git a/dvm/simulator_test.go b/dvm/simulator_test.go index 869217d0..24b5b805 100644 --- a/dvm/simulator_test.go +++ b/dvm/simulator_test.go @@ -117,7 +117,7 @@ This lottery smart contract will give lottery wins on every second try in follow // run the test func Test_Simulator_execution(t *testing.T) { - s := SimulatorInitialize(nil) + s := SimulatorInitialize(nil, 0) var addr *rpc.Address var err error