diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 19045208f..6ffdba4ed 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -2341,6 +2341,9 @@ func (bc *Blockchain) RegisterPostBlock(f func(func(*transaction.Transaction, *m // GetBaseExecFee return execution price for `NOP`. func (bc *Blockchain) GetBaseExecFee() int64 { + if bc.BlockHeight() == 0 { + return interop.DefaultBaseExecFee + } return bc.contracts.Policy.GetExecFeeFactorInternal(bc.dao) } diff --git a/pkg/core/blockchain_core_test.go b/pkg/core/blockchain_core_test.go index 4a68fb16c..fbfe43213 100644 --- a/pkg/core/blockchain_core_test.go +++ b/pkg/core/blockchain_core_test.go @@ -11,10 +11,12 @@ import ( "github.com/nspcc-dev/neo-go/internal/testchain" "github.com/nspcc-dev/neo-go/pkg/config" "github.com/nspcc-dev/neo-go/pkg/core/block" + "github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/smartcontract" + "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util/slice" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" @@ -320,3 +322,22 @@ func setSigner(tx *transaction.Transaction, h util.Uint160) { Scopes: transaction.Global, }} } + +// This test checks that value of BaseExecFee returned from corresponding Blockchain's method matches +// the one provided to the constructor of new interop context. +func TestBlockchain_BaseExecFeeBaseStoragePrice_Compat(t *testing.T) { + bc := newTestChain(t) + + check := func(t *testing.T) { + ic := bc.newInteropContext(trigger.Application, dao.NewSimple(storage.NewMemoryStore(), bc.config.StateRootInHeader, bc.config.P2PSigExtensions), bc.topBlock.Load().(*block.Block), nil) + require.Equal(t, bc.GetBaseExecFee(), ic.BaseExecFee()) + require.Equal(t, bc.GetStoragePrice(), ic.BaseStorageFee()) + } + t.Run("zero block", func(t *testing.T) { + check(t) + }) + t.Run("non-zero block", func(t *testing.T) { + require.NoError(t, bc.AddBlock(bc.newBlock())) + check(t) + }) +}