Skip to content

Commit

Permalink
Add error handling to Warp (ava-labs#1068)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
minghinmatthewlam and ceyonur authored Jan 29, 2024
1 parent 214aced commit a8c7424
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions warp/aggregator/signature_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ func (s *NetworkSignatureGetter) GetSignature(ctx context.Context, nodeID ids.No
if _, err := message.Codec.Unmarshal(signatureRes, &response); err != nil {
return nil, fmt.Errorf("failed to unmarshal signature res: %w", err)
}
if response.Signature == [bls.SignatureLen]byte{} {
return nil, fmt.Errorf("received empty signature response")
}
blsSignature, err := bls.SignatureFromBytes(response.Signature[:])
if err != nil {
return nil, fmt.Errorf("failed to parse signature from res: %w", err)
Expand Down
8 changes: 8 additions & 0 deletions warp/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ func (b *backend) initOffChainMessages(offchainMessages [][]byte) error {
return fmt.Errorf("%w at index %d: %w", errParsingOffChainMessage, i, err)
}

if unsignedMsg.NetworkID != b.networkID {
return fmt.Errorf("%w at index %d", avalancheWarp.ErrWrongNetworkID, i)
}

if unsignedMsg.SourceChainID != b.sourceChainID {
return fmt.Errorf("%w at index %d", avalancheWarp.ErrWrongSourceChainID, i)
}

_, err = payload.ParseAddressedCall(unsignedMsg.Payload)
if err != nil {
return fmt.Errorf("%w at index %d as AddressedCall: %w", errParsingOffChainMessage, i, err)
Expand Down

0 comments on commit a8c7424

Please sign in to comment.