From 238174cfcadc9c2a7a48fc6dd1449992cc6650a6 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 11 Nov 2020 19:07:39 +0100 Subject: [PATCH] Adapt virtual gas Signed-off-by: Jakub Sztandera --- chain/vm/gas_v0.go | 3 ++- chain/vm/runtime.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/chain/vm/gas_v0.go b/chain/vm/gas_v0.go index 555ffeb11..7c864b7f9 100644 --- a/chain/vm/gas_v0.go +++ b/chain/vm/gas_v0.go @@ -208,7 +208,8 @@ func (pl *pricelistV0) OnVerifyPost(info proof2.WindowPoStVerifyInfo) GasCharge gasUsed /= 2 // XXX: this is an artificial discount } - return newGasCharge("OnVerifyPost", gasUsed, 0).WithVirtual(117680921+43780len(info.ChallengedSectors), 0) + return newGasCharge("OnVerifyPost", gasUsed, 0). + WithVirtual(117680921+43780*int64(len(info.ChallengedSectors)), 0). WithExtra(map[string]interface{}{ "type": sectorSize, "size": len(info.ChallengedSectors), diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index e8ad3265b..d8a950bc0 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -545,6 +545,12 @@ func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError Callers: callers[:cout], } + if gasTrace.VirtualStorageGas == 0 { + gasTrace.VirtualStorageGas = gasTrace.StorageGas + } + if gasTrace.VirtualComputeGas == 0 { + gasTrace.VirtualComputeGas = gasTrace.ComputeGas + } rt.executionTrace.GasCharges = append(rt.executionTrace.GasCharges, &gasTrace) rt.lastGasChargeTime = now rt.lastGasCharge = &gasTrace