native: make registering as a candidate cost more
Follow neo-project/neo#2252.
This commit is contained in:
parent
8fad05c5bb
commit
476cbbebdc
4 changed files with 8 additions and 8 deletions
|
@ -21,7 +21,7 @@ func TestRegisterCandidate(t *testing.T) {
|
|||
"--wallet", validatorWallet,
|
||||
"--from", validatorAddr,
|
||||
"NEO:"+validatorPriv.Address()+":10",
|
||||
"GAS:"+validatorPriv.Address()+":100")
|
||||
"GAS:"+validatorPriv.Address()+":10000")
|
||||
e.checkTxPersisted(t)
|
||||
|
||||
e.In.WriteString("one\r")
|
||||
|
|
|
@ -71,14 +71,14 @@ func newValidatorCommands() []cli.Command {
|
|||
}
|
||||
|
||||
func handleRegister(ctx *cli.Context) error {
|
||||
return handleCandidate(ctx, "registerCandidate")
|
||||
return handleCandidate(ctx, "registerCandidate", 1001*100000000) // registering costs 1000 GAS
|
||||
}
|
||||
|
||||
func handleUnregister(ctx *cli.Context) error {
|
||||
return handleCandidate(ctx, "unregisterCandidate")
|
||||
return handleCandidate(ctx, "unregisterCandidate", -1)
|
||||
}
|
||||
|
||||
func handleCandidate(ctx *cli.Context, method string) error {
|
||||
func handleCandidate(ctx *cli.Context, method string, sysGas int64) error {
|
||||
wall, err := openWallet(ctx.String("wallet"))
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -108,7 +108,7 @@ func handleCandidate(ctx *cli.Context, method string) error {
|
|||
w := io.NewBufBinWriter()
|
||||
emit.AppCall(w.BinWriter, neoContractHash, method, callflag.WriteStates, acc.PrivateKey().PublicKey().Bytes())
|
||||
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
||||
tx, err := c.CreateTxFromScript(w.Bytes(), acc, -1, int64(gas), transaction.Signer{
|
||||
tx, err := c.CreateTxFromScript(w.Bytes(), acc, sysGas, int64(gas), transaction.Signer{
|
||||
Account: acc.Contract.ScriptHash(),
|
||||
Scopes: transaction.CalledByEntry,
|
||||
})
|
||||
|
|
|
@ -59,7 +59,7 @@ func initServiceNextConsensus(t *testing.T, newAcc *wallet.Account, offset uint3
|
|||
acc.Contract.ScriptHash().BytesBE(), newPriv.GetScriptHash().BytesBE(), int64(native.NEOTotalSupply), nil)
|
||||
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
||||
emit.AppCall(w.BinWriter, bc.UtilityTokenHash(), "transfer", callflag.All,
|
||||
acc.Contract.ScriptHash().BytesBE(), newPriv.GetScriptHash().BytesBE(), int64(1_000_000_000), nil)
|
||||
acc.Contract.ScriptHash().BytesBE(), newPriv.GetScriptHash().BytesBE(), int64(10000_000_000_000), nil)
|
||||
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
||||
require.NoError(t, w.Err)
|
||||
|
||||
|
@ -78,7 +78,7 @@ func initServiceNextConsensus(t *testing.T, newAcc *wallet.Account, offset uint3
|
|||
emit.AppCall(w.BinWriter, bc.GoverningTokenHash(), "registerCandidate", callflag.All, newPriv.PublicKey().Bytes())
|
||||
require.NoError(t, w.Err)
|
||||
|
||||
tx = transaction.New(netmode.UnitTestNet, w.Bytes(), 20_000_000)
|
||||
tx = transaction.New(netmode.UnitTestNet, w.Bytes(), 1001_00000000)
|
||||
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
||||
tx.NetworkFee = 20_000_000
|
||||
tx.Signers = []transaction.Signer{{Scopes: transaction.Global, Account: newPriv.GetScriptHash()}}
|
||||
|
|
|
@ -115,7 +115,7 @@ func newNEO() *NEO {
|
|||
|
||||
desc = newDescriptor("registerCandidate", smartcontract.BoolType,
|
||||
manifest.NewParameter("pubkey", smartcontract.ByteArrayType))
|
||||
md = newMethodAndPrice(n.registerCandidate, 5000000, callflag.WriteStates)
|
||||
md = newMethodAndPrice(n.registerCandidate, 1000_00000000, callflag.WriteStates)
|
||||
n.AddMethod(md, desc)
|
||||
|
||||
desc = newDescriptor("unregisterCandidate", smartcontract.BoolType,
|
||||
|
|
Loading…
Reference in a new issue