Skip to content

Commit

Permalink
Merge pull request #330 from ava-labs/signature-logs
Browse files Browse the repository at this point in the history
Add signature collection logs
  • Loading branch information
cam-schultz authored Jun 14, 2024
2 parents 3a031a9 + b767192 commit 3dc9967
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions relayer/application_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,17 @@ func (r *ApplicationRelayer) createSignedMessage(unsignedMessage *avalancheWarp.

// createSignedMessageAppRequest collects signatures from nodes by directly querying them via AppRequest, then aggregates the signatures, and constructs the signed warp message.
func (r *ApplicationRelayer) createSignedMessageAppRequest(unsignedMessage *avalancheWarp.UnsignedMessage, requestID uint32) (*avalancheWarp.Message, error) {
r.logger.Info("Fetching aggregate signature from the source chain validators via AppRequest")
r.logger.Info(
"Fetching aggregate signature from the source chain validators via AppRequest",
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
)
connectedValidators, err := r.network.ConnectToCanonicalValidators(r.signingSubnetID)
if err != nil {
r.logger.Error(
"Failed to connect to canonical validators",
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.Error(err),
)
return nil, err
Expand Down Expand Up @@ -368,6 +374,7 @@ func (r *ApplicationRelayer) createSignedMessageAppRequest(unsignedMessage *aval
if err != nil {
r.logger.Error(
"Failed to create app request message",
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.Error(err),
)
return nil, err
Expand All @@ -382,6 +389,7 @@ func (r *ApplicationRelayer) createSignedMessageAppRequest(unsignedMessage *aval
r.logger.Debug(
"Relayer collecting signatures from peers.",
zap.Int("attempt", attempt),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
zap.Int("validatorSetSize", len(connectedValidators.ValidatorSet)),
zap.Int("signatureMapSize", len(signatureMap)),
Expand All @@ -401,6 +409,9 @@ func (r *ApplicationRelayer) createSignedMessageAppRequest(unsignedMessage *aval
r.logger.Debug(
"Added node ID to query.",
zap.String("nodeID", nodeID.String()),
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
)

// Register a timeout response for each queried node
Expand All @@ -418,8 +429,10 @@ func (r *ApplicationRelayer) createSignedMessageAppRequest(unsignedMessage *aval
sentTo := r.network.Network.Send(outMsg, vdrSet, r.sourceBlockchain.GetSubnetID(), subnets.NoOpAllower)
r.logger.Debug(
"Sent signature request to network",
zap.String("messageID", unsignedMessage.ID().String()),
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.Any("sentTo", sentTo),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
)
for nodeID := range vdrSet {
if !sentTo.Contains(nodeID) {
Expand All @@ -440,6 +453,9 @@ func (r *ApplicationRelayer) createSignedMessageAppRequest(unsignedMessage *aval
r.logger.Debug(
"Processing response from node",
zap.String("nodeID", response.NodeID().String()),
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
)
signedMsg, relevant, err := r.handleResponse(
response,
Expand All @@ -460,6 +476,9 @@ func (r *ApplicationRelayer) createSignedMessageAppRequest(unsignedMessage *aval
if signedMsg != nil {
r.logger.Info(
"Created signed message.",
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.Uint64("signatureWeight", accumulatedSignatureWeight.Uint64()),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
)
return signedMsg, nil
Expand All @@ -480,6 +499,9 @@ func (r *ApplicationRelayer) createSignedMessageAppRequest(unsignedMessage *aval
r.logger.Warn(
"Failed to collect a threshold of signatures",
zap.Int("attempts", maxRelayerQueryAttempts),
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.Uint64("accumulatedWeight", accumulatedSignatureWeight.Uint64()),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
)
return nil, errNotEnoughSignatures
Expand Down Expand Up @@ -528,13 +550,21 @@ func (r *ApplicationRelayer) handleResponse(
r.logger.Debug(
"Got valid signature response",
zap.String("nodeID", nodeID.String()),
zap.Uint64("stakeWeight", validator.Weight),
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
)
signatureMap[vdrIndex] = signature
accumulatedSignatureWeight.Add(accumulatedSignatureWeight, new(big.Int).SetUint64(validator.Weight))
} else {
r.logger.Debug(
"Got invalid signature response",
zap.String("nodeID", nodeID.String()),
zap.Uint64("stakeWeight", validator.Weight),
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
)
return nil, true, nil
}
Expand All @@ -550,7 +580,9 @@ func (r *ApplicationRelayer) handleResponse(
if err != nil {
r.logger.Error(
"Failed to aggregate signature.",
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.Error(err),
)
return nil, true, err
Expand All @@ -563,6 +595,9 @@ func (r *ApplicationRelayer) handleResponse(
if err != nil {
r.logger.Error(
"Failed to create new signed message",
zap.String("sourceBlockchainID", r.sourceBlockchain.GetBlockchainID().String()),
zap.String("destinationBlockchainID", r.relayerID.DestinationBlockchainID.String()),
zap.String("warpMessageID", unsignedMessage.ID().String()),
zap.Error(err),
)
return nil, true, err
Expand Down

0 comments on commit 3dc9967

Please sign in to comment.