From c5ac475d32cb60978a41257eb737bf9f9daf2f21 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 7 Jul 2021 18:33:53 +0300 Subject: [PATCH] [#105] processing: Add docs Signed-off-by: Alex Vanin --- processing/doc.go | 22 +++++++++++++++++++++- processing/processing_contract.go | 6 ++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/processing/doc.go b/processing/doc.go index d197159..a1544fb 100644 --- a/processing/doc.go +++ b/processing/doc.go @@ -1,2 +1,22 @@ -// Processing contract description. +/* +Processing contract is a contract deployed in NeoFS main chain. + +Processing contract pays for all multi signature transaction executions when notary +service enabled in main chain. Notary service prepares multi signed transaction, +however they should contain side chain GAS to be executed. It is inconvenient to +ask Alphabet nodes to pay for these transactions: nodes can change over time, +some nodes will spend side chain GAS faster, it creates economic instability. + +Processing contract exists to solve this issue. At the Withdraw invocation of +NeoFS contract, user pays fee directly to this contract. This fee is used to +pay for Cheque invocation of NeoFS contract that returns main chain GAS back +to the user. Address of the Processing contract is uses as the first signer in +the multi signature transaction. Therefore NeoVM executes Verify method of the +contract and if invocation is verified, then Processing contract pays for the +execution. + +Contract notifications + +Processing contract does not produce notifications to process. +*/ package processing diff --git a/processing/processing_contract.go b/processing/processing_contract.go index 8ea8a4e..bdeafad 100644 --- a/processing/processing_contract.go +++ b/processing/processing_contract.go @@ -18,6 +18,7 @@ const ( multiaddrMethod = "alphabetAddress" ) +// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract. func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) { caller := runtime.GetCallingScriptHash() if !common.BytesEqual(caller, []byte(gas.Hash)) { @@ -50,6 +51,8 @@ func _deploy(data interface{}, isUpdate bool) { runtime.Log("processing contract initialized") } +// Migrate method updates contract source code and manifest. Can be invoked +// only by contract owner. func Migrate(script []byte, manifest []byte, data interface{}) bool { ctx := storage.GetReadOnlyContext() @@ -64,6 +67,8 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return true } +// Verify method returns true if transaction contains valid multi signature of +// Alphabet nodes of the Inner Ring. func Verify() bool { ctx := storage.GetContext() neofsContractAddr := storage.Get(ctx, neofsContractKey).(interop.Hash160) @@ -72,6 +77,7 @@ func Verify() bool { return runtime.CheckWitness(multiaddr) } +// Version returns version of the contract. func Version() int { return version }