Skip to content

Commit a8c7424

Browse files
minghinmatthewlamceyonur
andauthored
Add error handling to Warp (#1068)
* add error handling * Update warp/backend.go Co-authored-by: Ceyhun Onur <[email protected]> Signed-off-by: minghinmatthewlam <[email protected]> * Update warp/backend.go Co-authored-by: Ceyhun Onur <[email protected]> Signed-off-by: minghinmatthewlam <[email protected]> --------- Signed-off-by: minghinmatthewlam <[email protected]> Co-authored-by: Ceyhun Onur <[email protected]>
1 parent 214aced commit a8c7424

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

warp/aggregator/signature_getter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func (s *NetworkSignatureGetter) GetSignature(ctx context.Context, nodeID ids.No
105105
if _, err := message.Codec.Unmarshal(signatureRes, &response); err != nil {
106106
return nil, fmt.Errorf("failed to unmarshal signature res: %w", err)
107107
}
108+
if response.Signature == [bls.SignatureLen]byte{} {
109+
return nil, fmt.Errorf("received empty signature response")
110+
}
108111
blsSignature, err := bls.SignatureFromBytes(response.Signature[:])
109112
if err != nil {
110113
return nil, fmt.Errorf("failed to parse signature from res: %w", err)

warp/backend.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ func (b *backend) initOffChainMessages(offchainMessages [][]byte) error {
9494
return fmt.Errorf("%w at index %d: %w", errParsingOffChainMessage, i, err)
9595
}
9696

97+
if unsignedMsg.NetworkID != b.networkID {
98+
return fmt.Errorf("%w at index %d", avalancheWarp.ErrWrongNetworkID, i)
99+
}
100+
101+
if unsignedMsg.SourceChainID != b.sourceChainID {
102+
return fmt.Errorf("%w at index %d", avalancheWarp.ErrWrongSourceChainID, i)
103+
}
104+
97105
_, err = payload.ParseAddressedCall(unsignedMsg.Payload)
98106
if err != nil {
99107
return fmt.Errorf("%w at index %d as AddressedCall: %w", errParsingOffChainMessage, i, err)

0 commit comments

Comments
 (0)