core: change Create[Standard, Multisig]Account prices
And make a hard-fork from this change.
This commit is contained in:
parent
e70bf7d12e
commit
5505acf10e
5 changed files with 85 additions and 2 deletions
|
@ -20,6 +20,8 @@ ProtocolConfiguration:
|
||||||
RoleManagement: [0]
|
RoleManagement: [0]
|
||||||
OracleContract: [0]
|
OracleContract: [0]
|
||||||
Notary: [0]
|
Notary: [0]
|
||||||
|
Hardforks:
|
||||||
|
HF_2712_FixSyscallFees: 25
|
||||||
|
|
||||||
ApplicationConfiguration:
|
ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
|
|
|
@ -29,6 +29,8 @@ ProtocolConfiguration:
|
||||||
RoleManagement: [0]
|
RoleManagement: [0]
|
||||||
OracleContract: [0]
|
OracleContract: [0]
|
||||||
Notary: [0]
|
Notary: [0]
|
||||||
|
Hardforks:
|
||||||
|
HF_2712_FixSyscallFees: 25
|
||||||
|
|
||||||
ApplicationConfiguration:
|
ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
|
|
|
@ -8,7 +8,9 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"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/block"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/fee"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||||
istorage "github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
|
istorage "github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
||||||
|
@ -215,6 +217,16 @@ func contractCreateMultisigAccount(ic *interop.Context) error {
|
||||||
}
|
}
|
||||||
pubs[i] = p
|
pubs[i] = p
|
||||||
}
|
}
|
||||||
|
var invokeFee int64
|
||||||
|
if ic.IsHardforkEnabled(config.HF2712FixSyscallFees) {
|
||||||
|
invokeFee = fee.ECDSAVerifyPrice * int64(len(pubs))
|
||||||
|
} else {
|
||||||
|
invokeFee = 1 << 8
|
||||||
|
}
|
||||||
|
invokeFee *= ic.BaseExecFee()
|
||||||
|
if !ic.VM.AddGas(invokeFee) {
|
||||||
|
return errors.New("gas limit exceeded")
|
||||||
|
}
|
||||||
script, err := smartcontract.CreateMultiSigRedeemScript(int(mu64), pubs)
|
script, err := smartcontract.CreateMultiSigRedeemScript(int(mu64), pubs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -230,6 +242,16 @@ func contractCreateStandardAccount(ic *interop.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
var invokeFee int64
|
||||||
|
if ic.IsHardforkEnabled(config.HF2712FixSyscallFees) {
|
||||||
|
invokeFee = fee.ECDSAVerifyPrice
|
||||||
|
} else {
|
||||||
|
invokeFee = 1 << 8
|
||||||
|
}
|
||||||
|
invokeFee *= ic.BaseExecFee()
|
||||||
|
if !ic.VM.AddGas(invokeFee) {
|
||||||
|
return errors.New("gas limit exceeded")
|
||||||
|
}
|
||||||
ic.VM.Estack().PushItem(stackitem.NewByteArray(p.GetScriptHash().BytesBE()))
|
ic.VM.Estack().PushItem(stackitem.NewByteArray(p.GetScriptHash().BytesBE()))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/internal/contracts"
|
"github.com/nspcc-dev/neo-go/internal/contracts"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
|
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
|
@ -19,6 +20,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neotest/chain"
|
"github.com/nspcc-dev/neo-go/pkg/neotest/chain"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/emit"
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -254,3 +256,58 @@ func TestSystemRuntimeBurnGas(t *testing.T) {
|
||||||
cInvoker.InvokeFail(t, "GAS must be positive", "burnGas", int64(0))
|
cInvoker.InvokeFail(t, "GAS must be positive", "burnGas", int64(0))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSystemContractCreateAccount_Hardfork(t *testing.T) {
|
||||||
|
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.ProtocolConfiguration) {
|
||||||
|
c.P2PSigExtensions = true // `initBasicChain` requires Notary enabled
|
||||||
|
c.Hardforks = map[string]uint32{
|
||||||
|
config.HF2712FixSyscallFees.String(): 2,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
e := neotest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
|
priv, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
pub := priv.PublicKey()
|
||||||
|
|
||||||
|
w := io.NewBufBinWriter()
|
||||||
|
emit.Array(w.BinWriter, []interface{}{pub.Bytes(), pub.Bytes(), pub.Bytes()}...)
|
||||||
|
emit.Int(w.BinWriter, int64(2))
|
||||||
|
emit.Syscall(w.BinWriter, interopnames.SystemContractCreateMultisigAccount)
|
||||||
|
require.NoError(t, w.Err)
|
||||||
|
multisigScript := slice.Copy(w.Bytes())
|
||||||
|
|
||||||
|
w.Reset()
|
||||||
|
emit.Bytes(w.BinWriter, pub.Bytes())
|
||||||
|
emit.Syscall(w.BinWriter, interopnames.SystemContractCreateStandardAccount)
|
||||||
|
require.NoError(t, w.Err)
|
||||||
|
standardScript := slice.Copy(w.Bytes())
|
||||||
|
|
||||||
|
createAccTx := func(t *testing.T, script []byte) *transaction.Transaction {
|
||||||
|
tx := e.PrepareInvocation(t, script, []neotest.Signer{e.Committee}, bc.BlockHeight()+1)
|
||||||
|
return tx
|
||||||
|
}
|
||||||
|
|
||||||
|
// blocks #1, #2: old prices
|
||||||
|
tx1Standard := createAccTx(t, standardScript)
|
||||||
|
tx1Multisig := createAccTx(t, multisigScript)
|
||||||
|
e.AddNewBlock(t, tx1Standard, tx1Multisig)
|
||||||
|
e.CheckHalt(t, tx1Standard.Hash())
|
||||||
|
e.CheckHalt(t, tx1Multisig.Hash())
|
||||||
|
tx2Standard := createAccTx(t, standardScript)
|
||||||
|
tx2Multisig := createAccTx(t, multisigScript)
|
||||||
|
e.AddNewBlock(t, tx2Standard, tx2Multisig)
|
||||||
|
e.CheckHalt(t, tx2Standard.Hash())
|
||||||
|
e.CheckHalt(t, tx2Multisig.Hash())
|
||||||
|
|
||||||
|
// block #3: updated prices (larger than the previous ones)
|
||||||
|
tx3Standard := createAccTx(t, standardScript)
|
||||||
|
tx3Multisig := createAccTx(t, multisigScript)
|
||||||
|
e.AddNewBlock(t, tx3Standard, tx3Multisig)
|
||||||
|
e.CheckHalt(t, tx3Standard.Hash())
|
||||||
|
e.CheckHalt(t, tx3Multisig.Hash())
|
||||||
|
require.True(t, tx1Standard.SystemFee == tx2Standard.SystemFee)
|
||||||
|
require.True(t, tx1Multisig.SystemFee == tx2Multisig.SystemFee)
|
||||||
|
require.True(t, tx2Standard.SystemFee < tx3Standard.SystemFee)
|
||||||
|
require.True(t, tx2Multisig.SystemFee < tx3Multisig.SystemFee)
|
||||||
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ var systemInterops = []interop.Function{
|
||||||
{Name: interopnames.SystemContractCall, Func: contract.Call, Price: 1 << 15,
|
{Name: interopnames.SystemContractCall, Func: contract.Call, Price: 1 << 15,
|
||||||
RequiredFlags: callflag.ReadStates | callflag.AllowCall, ParamCount: 4},
|
RequiredFlags: callflag.ReadStates | callflag.AllowCall, ParamCount: 4},
|
||||||
{Name: interopnames.SystemContractCallNative, Func: native.Call, Price: 0, ParamCount: 1},
|
{Name: interopnames.SystemContractCallNative, Func: native.Call, Price: 0, ParamCount: 1},
|
||||||
{Name: interopnames.SystemContractCreateMultisigAccount, Func: contractCreateMultisigAccount, Price: 1 << 8, ParamCount: 2},
|
{Name: interopnames.SystemContractCreateMultisigAccount, Func: contractCreateMultisigAccount, Price: 0, ParamCount: 2},
|
||||||
{Name: interopnames.SystemContractCreateStandardAccount, Func: contractCreateStandardAccount, Price: 1 << 8, ParamCount: 1},
|
{Name: interopnames.SystemContractCreateStandardAccount, Func: contractCreateStandardAccount, Price: 0, ParamCount: 1},
|
||||||
{Name: interopnames.SystemContractGetCallFlags, Func: contractGetCallFlags, Price: 1 << 10},
|
{Name: interopnames.SystemContractGetCallFlags, Func: contractGetCallFlags, Price: 1 << 10},
|
||||||
{Name: interopnames.SystemContractNativeOnPersist, Func: native.OnPersist, Price: 0, RequiredFlags: callflag.States},
|
{Name: interopnames.SystemContractNativeOnPersist, Func: native.OnPersist, Price: 0, RequiredFlags: callflag.States},
|
||||||
{Name: interopnames.SystemContractNativePostPersist, Func: native.PostPersist, Price: 0, RequiredFlags: callflag.States},
|
{Name: interopnames.SystemContractNativePostPersist, Func: native.PostPersist, Price: 0, RequiredFlags: callflag.States},
|
||||||
|
|
Loading…
Reference in a new issue