From ade185191bf3e859ccd979e24bdc3604b49b34e0 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Mon, 12 Oct 2020 14:34:13 +0300 Subject: [PATCH] [#47] Use less extra gas on netmap contract methods * 1.0 extra gas for new epoch vote * 0.5 extra gas for new peer approve Signed-off-by: Alex Vanin --- pkg/innerring/invoke/neofs.go | 5 +++++ pkg/innerring/invoke/netmap.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/innerring/invoke/neofs.go b/pkg/innerring/invoke/neofs.go index b6ace9926..e7ad54dc8 100644 --- a/pkg/innerring/invoke/neofs.go +++ b/pkg/innerring/invoke/neofs.go @@ -29,6 +29,11 @@ const ( // execution stage. Otherwise invocation will fail due to gas limit. extraFee = 1_5000_0000 // 1.5 Fixed8 gas + // Different methods need different extra fee values, so with this + // constants let's try to minimize spent GAS of inner ring node. + feeHalfGas = 50_000_000 // 0.5 Fixed8 gas + feeOneGas = feeHalfGas * 2 // 1.0 Fixed8 gas + checkIsInnerRingMethod = "isInnerRing" innerRingListMethod = "innerRingList" chequeMethod = "cheque" diff --git a/pkg/innerring/invoke/netmap.go b/pkg/innerring/invoke/netmap.go index f5100989e..7f71321f2 100644 --- a/pkg/innerring/invoke/netmap.go +++ b/pkg/innerring/invoke/netmap.go @@ -52,7 +52,7 @@ func SetNewEpoch(cli *client.Client, con util.Uint160, epoch uint64) error { return client.ErrNilClient } - return cli.Invoke(con, extraFee, setNewEpochMethod, int64(epoch)) + return cli.Invoke(con, feeOneGas, setNewEpochMethod, int64(epoch)) } // ApprovePeer invokes addPeer method. @@ -61,7 +61,7 @@ func ApprovePeer(cli *client.Client, con util.Uint160, peer []byte) error { return client.ErrNilClient } - return cli.Invoke(con, extraFee, approvePeerMethod, peer) + return cli.Invoke(con, feeHalfGas, approvePeerMethod, peer) } // UpdatePeerState invokes addPeer method.