From 50157b31cd3fa0d669d72c773b6fcabb9de42a6f Mon Sep 17 00:00:00 2001 From: AnnaShaleva Date: Tue, 1 Mar 2022 19:16:25 +0300 Subject: [PATCH] core: add maximum constraint to `setNotaryServiceFeePerKey` --- pkg/core/native/notary.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/core/native/notary.go b/pkg/core/native/notary.go index de3ea91fb..d965f6310 100644 --- a/pkg/core/native/notary.go +++ b/pkg/core/native/notary.go @@ -43,8 +43,9 @@ const ( // prefixDeposit is a prefix for storing Notary deposits. prefixDeposit = 1 defaultDepositDeltaTill = 5760 - defaultMaxNotValidBeforeDelta = 140 // 20 rounds for 7 validators, a little more than half an hour - defaultNotaryServiceFeePerKey = 1000_0000 // 0.1 GAS + defaultMaxNotValidBeforeDelta = 140 // 20 rounds for 7 validators, a little more than half an hour + defaultNotaryServiceFeePerKey = 1000_0000 // 0.1 GAS + maxNotaryServiceFeePerKey = 1_0000_0000 // 1 GAS ) var ( @@ -442,8 +443,8 @@ func (n *Notary) GetNotaryServiceFeePerKey(dao *dao.Simple) int64 { // setNotaryServiceFeePerKey is a Notary contract method and sets a reward per notary request key for notary nodes. func (n *Notary) setNotaryServiceFeePerKey(ic *interop.Context, args []stackitem.Item) stackitem.Item { value := toInt64(args[0]) - if value < 0 { - panic("NotaryServiceFeePerKey can't be negative") + if value < 0 || value > maxNotaryServiceFeePerKey { + panic("NotaryServiceFeePerKey value is out of range") } if !n.NEO.checkCommittee(ic) { panic("invalid committee signature")