diff --git a/pkg/compiler/interop_test.go b/pkg/compiler/interop_test.go index b01cdd373..65c43b1f5 100644 --- a/pkg/compiler/interop_test.go +++ b/pkg/compiler/interop_test.go @@ -200,7 +200,7 @@ func TestAppCall(t *testing.T) { } fc := fakechain.NewFakeChain() - ic := interop.NewContext(trigger.Application, fc, dao.NewSimple(storage.NewMemoryStore(), false, false), contractGetter, nil, nil, nil, zaptest.NewLogger(t)) + ic := interop.NewContext(trigger.Application, fc, dao.NewSimple(storage.NewMemoryStore(), false, false), interop.DefaultBaseExecFee, contractGetter, nil, nil, nil, zaptest.NewLogger(t)) t.Run("valid script", func(t *testing.T) { src := getAppCallScript(fmt.Sprintf("%#v", ih.BytesBE())) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 6dff70d00..926e612de 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -2304,7 +2304,14 @@ func (bc *Blockchain) ManagementContractHash() util.Uint160 { } func (bc *Blockchain) newInteropContext(trigger trigger.Type, d *dao.Simple, block *block.Block, tx *transaction.Transaction) *interop.Context { - ic := interop.NewContext(trigger, bc, d, bc.contracts.Management.GetContract, bc.contracts.Contracts, block, tx, bc.log) + baseExecFee := int64(interop.DefaultBaseExecFee) + + if block == nil || block.Index != 0 { + // Use provided dao instead of Blockchain's one to fetch possible ExecFeeFactor + // changes that were not yet persisted to Blockchain's dao. + baseExecFee = bc.contracts.Policy.GetExecFeeFactorInternal(d) + } + ic := interop.NewContext(trigger, bc, d, baseExecFee, bc.contracts.Management.GetContract, bc.contracts.Contracts, block, tx, bc.log) ic.Functions = systemInterops switch { case tx != nil: diff --git a/pkg/core/interop/context.go b/pkg/core/interop/context.go index e5418a65f..f4792645a 100644 --- a/pkg/core/interop/context.go +++ b/pkg/core/interop/context.go @@ -67,15 +67,10 @@ type Context struct { } // NewContext returns new interop context. -func NewContext(trigger trigger.Type, bc Ledger, d *dao.Simple, +func NewContext(trigger trigger.Type, bc Ledger, d *dao.Simple, baseExecFee int64, getContract func(*dao.Simple, util.Uint160) (*state.Contract, error), natives []Contract, block *block.Block, tx *transaction.Transaction, log *zap.Logger) *Context { - baseExecFee := int64(DefaultBaseExecFee) dao := d.GetPrivate() - - if bc != nil && (block == nil || block.Index != 0) { - baseExecFee = bc.GetBaseExecFee() - } return &Context{ Chain: bc, Network: uint32(bc.GetConfig().Magic), diff --git a/pkg/core/interop/crypto/ecdsa_test.go b/pkg/core/interop/crypto/ecdsa_test.go index 3331d7f25..5f6839674 100644 --- a/pkg/core/interop/crypto/ecdsa_test.go +++ b/pkg/core/interop/crypto/ecdsa_test.go @@ -72,7 +72,7 @@ func initCheckMultisigVMNoArgs(container *transaction.Transaction) *vm.VM { trigger.Verification, fakechain.NewFakeChain(), dao.NewSimple(storage.NewMemoryStore(), false, false), - nil, nil, nil, + interop.DefaultBaseExecFee, nil, nil, nil, container, nil) ic.Container = container diff --git a/pkg/core/native/native_test/common_test.go b/pkg/core/native/native_test/common_test.go index bf9c900ce..851b18e16 100644 --- a/pkg/core/native/native_test/common_test.go +++ b/pkg/core/native/native_test/common_test.go @@ -55,16 +55,25 @@ func testGetSet(t *testing.T, c *neotest.ContractInvoker, name string, defaultVa c.AddNewBlock(t, txSet, txGet) c.CheckHalt(t, txSet.Hash(), stackitem.Null{}) - if name != "GasPerBlock" { // GasPerBlock is set on the next block - c.CheckHalt(t, txGet.Hash(), stackitem.Make(defaultValue+1)) - } else { + switch name { + case "GasPerBlock": + // GasPerBlock is set on the next block c.CheckHalt(t, txGet.Hash(), stackitem.Make(defaultValue)) c.AddNewBlock(t) randomInvoker.Invoke(t, defaultValue+1, getName) + case "ExecFeeFactor": + // ExecFeeFactor was risen, so the second transaction will fail because + // of gas limit exceeding (its fees are out-of-date). + c.CheckFault(t, txGet.Hash(), "gas limit exceeded") + // Set in a separate block. + committeeInvoker.Invoke(t, stackitem.Null{}, setName, defaultValue+1) + // Get in the next block. + randomInvoker.Invoke(t, defaultValue+1, getName) + default: + c.CheckHalt(t, txGet.Hash(), stackitem.Make(defaultValue+1)) + // Get in the next block. + randomInvoker.Invoke(t, defaultValue+1, getName) } - - // Get in the next block. - randomInvoker.Invoke(t, defaultValue+1, getName) }) }