diff --git a/pkg/settings/blockchain_settings.go b/pkg/settings/blockchain_settings.go index f3442cb65..e3acdc8e8 100644 --- a/pkg/settings/blockchain_settings.go +++ b/pkg/settings/blockchain_settings.go @@ -62,6 +62,7 @@ type FunctionalitySettings struct { MinimalGeneratingBalanceCheckAfterTime uint64 `json:"minimal_generating_balance_check_after_time"` InternalInvokePaymentsValidationAfterHeight uint64 `json:"internal_invoke_payments_validation_after_height"` InternalInvokeCorrectFailRejectBehaviourAfterHeight uint64 `json:"internal_invoke_correct_fail_reject_behaviour_after_height"` + InvokeNoZeroPaymentsAfterHeight uint64 `json:"invoke_no_zero_payments_after_height"` // Diff in milliseconds. MaxTxTimeBackOffset uint64 `json:"max_tx_time_back_offset"` diff --git a/pkg/settings/embedded/mainnet.json b/pkg/settings/embedded/mainnet.json index 1632e4af0..793802725 100644 --- a/pkg/settings/embedded/mainnet.json +++ b/pkg/settings/embedded/mainnet.json @@ -21,6 +21,7 @@ "minimal_generating_balance_check_after_time": 1479168000000, "internal_invoke_payments_validation_after_height": 2959400, "internal_invoke_correct_fail_reject_behaviour_after_height": 2792473, + "invoke_no_zero_payments_after_height": 0, "max_tx_time_back_offset": 7200000, "max_tx_time_forward_offset": 5400000, "address_scheme_character": 87, diff --git a/pkg/settings/embedded/stagenet.json b/pkg/settings/embedded/stagenet.json index bc2a2cb3a..68586303a 100644 --- a/pkg/settings/embedded/stagenet.json +++ b/pkg/settings/embedded/stagenet.json @@ -35,6 +35,7 @@ "minimal_generating_balance_check_after_time": 0, "internal_invoke_payments_validation_after_height": 966180, "internal_invoke_correct_fail_reject_behaviour_after_height": 390000, + "invoke_no_zero_payments_after_height": 1317000, "max_tx_time_back_offset": 7200000, "max_tx_time_forward_offset": 5400000, "address_scheme_character": 83, diff --git a/pkg/settings/embedded/testnet.json b/pkg/settings/embedded/testnet.json index 403fc4e98..00097dd39 100644 --- a/pkg/settings/embedded/testnet.json +++ b/pkg/settings/embedded/testnet.json @@ -21,6 +21,7 @@ "minimal_generating_balance_check_after_time": 0, "internal_invoke_payments_validation_after_height": 1698800, "internal_invoke_correct_fail_reject_behaviour_after_height": 1727461, + "invoke_no_zero_payments_after_height": 0, "max_tx_time_back_offset": 7200000, "max_tx_time_forward_offset": 5400000, "address_scheme_character": 84, diff --git a/pkg/state/script_caller.go b/pkg/state/script_caller.go index 29da735ae..f64edc5a3 100644 --- a/pkg/state/script_caller.go +++ b/pkg/state/script_caller.go @@ -325,6 +325,9 @@ func (a *scriptCaller) invokeFunction(tree *ast.Tree, tx proto.Transaction, info abiPayments := transaction.TxKind.DecodedData().Payments scriptPayments := make([]proto.ScriptPayment, 0, len(abiPayments)) for _, p := range abiPayments { + if p.Amount <= 0 && info.checkerInfo.height > a.settings.InvokeNoZeroPaymentsAfterHeight { + return nil, errors.Errorf("invalid payment amount '%d'", p.Amount) + } optAsset := proto.NewOptionalAsset(p.PresentAssetID, p.AssetID) scriptPayment := proto.ScriptPayment{Amount: uint64(p.Amount), Asset: optAsset} scriptPayments = append(scriptPayments, scriptPayment) diff --git a/pkg/state/transaction_checker.go b/pkg/state/transaction_checker.go index 98b06bb51..7d6feaa5a 100644 --- a/pkg/state/transaction_checker.go +++ b/pkg/state/transaction_checker.go @@ -431,6 +431,9 @@ func (tc *transactionChecker) checkEthereumTransactionWithProofs(transaction pro paymentAssets := make([]proto.OptionalAsset, 0, len(abiPayments)) for _, p := range abiPayments { + if p.Amount <= 0 && info.height > tc.settings.InvokeNoZeroPaymentsAfterHeight { + return nil, errors.Errorf("invalid payment amount '%d'", p.Amount) + } optAsset := proto.NewOptionalAsset(p.PresentAssetID, p.AssetID) if optAsset.Present { if err := tc.checkAsset(&optAsset); err != nil {