From 73cc0ffe0f07952d52f5cc7494158ff8fbad9d6e Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 23 Nov 2020 10:04:57 +0100 Subject: [PATCH] Improve docs around signature publication delays --- pkg/node/node.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pkg/node/node.go b/pkg/node/node.go index 80a23c2fa..c9fda3497 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -29,7 +29,7 @@ var logger = log.Logger("keep-ecdsa") const ( // Determines the delay which should be preserved before retrying - // actions within the signing process. + // actions within the key generation and signing process. retryDelay = 1 * time.Second // Number of blocks which should elapse before confirming @@ -39,7 +39,7 @@ const ( // Used to calculate the publication delay factor for the given signer index // to avoid all signers publishing the same signature for given keep at the // same time. - signerPublicationDelayStep = 5 * time.Minute + signaturePublicationDelayStep = 5 * time.Minute ) // Node holds interfaces to interact with the blockchain and network messages @@ -320,7 +320,7 @@ func (n *Node) publishSignature( digest [32]byte, signature *ecdsa.Signature, ) error { - n.waitSignerPublicationDelay(keepAddress) + n.waitSignaturePublicationDelay(keepAddress) attemptCounter := 0 for { @@ -433,14 +433,17 @@ func (n *Node) publishSignature( } } -func (n *Node) waitSignerPublicationDelay( +// waitSignaturePublicationDelay waits a certain amount of time appropriately +// for the given signer index to avoid all signers publishing the same signature +// for given keep at the same time. +func (n *Node) waitSignaturePublicationDelay( keepAddress common.Address, ) { signerIndex, err := n.getSignerIndex(keepAddress) if err != nil { - logger.Error( - "could not determine signer publication delay for keep [%s]: "+ - "[%v]; signer publication delay will not be preserved", + logger.Errorf( + "could not determine signature publication delay for keep [%s]: "+ + "[%v]; the signature publication will not be delayed", keepAddress.String(), err, ) @@ -449,17 +452,16 @@ func (n *Node) waitSignerPublicationDelay( // just in case this function is not invoked in the right context if signerIndex < 0 { - logger.Error( - "could not determine signer publication delay for keep [%s]: "+ - "[signer index is less than zero]; "+ - "signer publication delay will not be preserved", + logger.Errorf( + "could not determine signature publication delay for keep [%s], "+ + "signer index is less than zero; the signature publication "+ + "will not be delayed", keepAddress.String(), - err, ) return } - delay := time.Duration(signerIndex) * signerPublicationDelayStep + delay := time.Duration(signerIndex) * signaturePublicationDelayStep logger.Infof( "waiting [%v] before publishing signature for keep [%s]",