From d3672eb14a8d30400f2d1d9f18840bdd034ed783 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 8 Apr 2022 12:31:55 +0300 Subject: [PATCH] core: use BaseExecFee from InteropContext instead of Blockchain's one The InteropContext's one contains all relevant fee changes applied in the prevouse transactions of the current block. --- pkg/consensus/consensus.go | 1 + pkg/core/interop/context.go | 1 - pkg/core/native/interop.go | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index e7a389f03..585e34aa8 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -56,6 +56,7 @@ type Ledger interface { PoolTx(t *transaction.Transaction, pools ...*mempool.Pool) error SubscribeForBlocks(ch chan<- *coreb.Block) UnsubscribeFromBlocks(ch chan<- *coreb.Block) + GetBaseExecFee() int64 interop.Ledger mempool.Feer } diff --git a/pkg/core/interop/context.go b/pkg/core/interop/context.go index 22c1486e8..9217e8d58 100644 --- a/pkg/core/interop/context.go +++ b/pkg/core/interop/context.go @@ -37,7 +37,6 @@ const ( type Ledger interface { BlockHeight() uint32 CurrentBlockHash() util.Uint256 - GetBaseExecFee() int64 GetBlock(hash util.Uint256) (*block.Block, error) GetConfig() config.ProtocolConfiguration GetHeaderHash(int) util.Uint256 diff --git a/pkg/core/native/interop.go b/pkg/core/native/interop.go index 92fdf3717..3fd2ab57a 100644 --- a/pkg/core/native/interop.go +++ b/pkg/core/native/interop.go @@ -42,7 +42,7 @@ func Call(ic *interop.Context) error { return fmt.Errorf("missing call flags for native %d `%s` operation call: %05b vs %05b", version, m.MD.Name, ic.VM.Context().GetCallFlags(), m.RequiredFlags) } - invokeFee := m.CPUFee*ic.Chain.GetBaseExecFee() + + invokeFee := m.CPUFee*ic.BaseExecFee() + m.StorageFee*ic.BaseStorageFee() if !ic.VM.AddGas(invokeFee) { return errors.New("gas limit exceeded")