Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/derod/rpc/rpc_dero_estimategas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion dvm/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion dvm/simulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down