Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 30a718d

Browse files
authoredAug 21, 2024
Merge pull request #422 from ava-labs/isuvak/sig-agg-acp-118
Signature Aggregator ACP-118 updates
2 parents b5cff9e + 811c97a commit 30a718d

File tree

7 files changed

+39
-22
lines changed

7 files changed

+39
-22
lines changed
 

‎go.mod‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/ava-labs/awm-relayer
33
go 1.21.12
44

55
require (
6-
github.com/ava-labs/avalanchego v1.11.11-0.20240729205337-a0f7e422bb84
7-
github.com/ava-labs/subnet-evm v0.6.8-acp-118-handlers
8-
github.com/ava-labs/teleporter v1.0.5-0.20240807150146-1c7df1ab5033
6+
github.com/ava-labs/avalanchego v1.11.11-0.20240813203340-ab83fb41528d
7+
github.com/ava-labs/subnet-evm v0.6.9-0.20240816202746-18633729a0cd
8+
github.com/ava-labs/teleporter v1.0.4
99
github.com/aws/aws-sdk-go-v2 v1.30.3
1010
github.com/aws/aws-sdk-go-v2/config v1.27.9
1111
github.com/aws/aws-sdk-go-v2/service/kms v1.35.3
@@ -25,7 +25,7 @@ require (
2525
)
2626

2727
require (
28-
github.com/ava-labs/coreth v0.13.7 // indirect
28+
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180 // indirect
2929
github.com/aws/aws-sdk-go-v2/credentials v1.17.9 // indirect
3030
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.0 // indirect
3131
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect

‎go.sum‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ github.com/alexliesenfeld/health v0.8.0/go.mod h1:TfNP0f+9WQVWMQRzvMUjlws4ceXKEL
5858
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
5959
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
6060
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
61-
github.com/ava-labs/avalanchego v1.11.11-0.20240729205337-a0f7e422bb84 h1:AmPZLlnVREbJ/viK/hDTIVn1bqX8QTB2CFtrBxHwnsw=
62-
github.com/ava-labs/avalanchego v1.11.11-0.20240729205337-a0f7e422bb84/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc=
63-
github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g=
64-
github.com/ava-labs/coreth v0.13.7/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
65-
github.com/ava-labs/subnet-evm v0.6.8-acp-118-handlers h1:2UVHP9TDh3eS/CuD/XzMy2+3ruu/U2ZUny1eqn4bNB4=
66-
github.com/ava-labs/subnet-evm v0.6.8-acp-118-handlers/go.mod h1:BryiYmD6HWmugkSUpDdj/KyMi7ou5pJzPRNPMbMgpbA=
67-
github.com/ava-labs/teleporter v1.0.5-0.20240807150146-1c7df1ab5033 h1:mqtcLphkixDnYY5h8eQlj058KiVpRJaQgGvuUZcAcXo=
68-
github.com/ava-labs/teleporter v1.0.5-0.20240807150146-1c7df1ab5033/go.mod h1:xDSsLZTLQ68ZXs9tb00VNd4fODqHTs6AD3MX6cyQ00Y=
61+
github.com/ava-labs/avalanchego v1.11.11-0.20240813203340-ab83fb41528d h1:LyrKJL9avIIxBY3uTcS2dFtUMBFmI2QpAgG6qYTdA6s=
62+
github.com/ava-labs/avalanchego v1.11.11-0.20240813203340-ab83fb41528d/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM=
63+
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180 h1:6aIHp7wbyGVYdhHVQUbG7BEcbCMEQ5SYopPPJyipyvk=
64+
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180/go.mod h1:/wNBVq7J7wlC2Kbov7kk6LV5xZvau7VF9zwTVOeyAjY=
65+
github.com/ava-labs/subnet-evm v0.6.9-0.20240816202746-18633729a0cd h1:5kJTOhmIhIiobseQ+RYuLg4UyodN+CSAdW1c0hx1R2Y=
66+
github.com/ava-labs/subnet-evm v0.6.9-0.20240816202746-18633729a0cd/go.mod h1:QfIzh7YxKj97jbendOHQbaAxM7SMj5MWdV13o1VLn70=
67+
github.com/ava-labs/teleporter v1.0.4 h1:+OAS3YyPc/LijR29qu3EqU6xAnQnjOgf4EtDlCMcDsc=
68+
github.com/ava-labs/teleporter v1.0.4/go.mod h1:bUiOSIGjFktkYg01XDjeaZdgLEx0ZpUDfJXI6Z0rHY8=
6969
github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=
7070
github.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc=
7171
github.com/aws/aws-sdk-go-v2/config v1.27.9 h1:gRx/NwpNEFSk+yQlgmk1bmxxvQ5TyJ76CWXs9XScTqg=

‎peers/external_handler.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ func (h *RelayerExternalHandler) HandleInbound(_ context.Context, inboundMessage
8888
zap.Stringer("from", inboundMessage.NodeID()),
8989
)
9090
if inboundMessage.Op() == message.AppResponseOp || inboundMessage.Op() == message.AppErrorOp {
91+
if inboundMessage.Op() == message.AppErrorOp {
92+
h.log.Debug("Received AppError message", zap.Stringer("message", inboundMessage.Message()))
93+
}
9194
h.registerAppResponse(inboundMessage)
9295
} else {
9396
h.log.Debug("Ignoring message", zap.Stringer("op", inboundMessage.Op()))

‎scripts/versions.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export GO_VERSION=${GO_VERSION:-$(getDepVersion go)}
1919
# Don't export them as they're used in the context of other calls
2020
# TODO: undo this hack once go.mod is referring to a tag rather than a commit
2121
#AVALANCHEGO_VERSION=${AVALANCHEGO_VERSION:-$(getDepVersion github.com/ava-labs/avalanchego)}
22-
AVALANCHEGO_VERSION=${AVALANCHEGO_VERSION:-a0f7e422bb8497186ebff434f12c4b957cec8d49}
22+
AVALANCHEGO_VERSION=${AVALANCHEGO_VERSION:-ab83fb41528de93c1790301cdd67a07dda9299f0}
2323
GINKGO_VERSION=${GINKGO_VERSION:-$(getDepVersion github.com/onsi/ginkgo/v2)}
2424

2525
# TODO: undo this hack once go.mod is referring to a tag rather than a commit
2626
#SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-$(getDepVersion github.com/ava-labs/subnet-evm)}
27-
SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-v0.6.8-acp-118-handlers}
27+
SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-18633729a0cde7d695616e14b77873957a2b59c2}
2828

2929
# Set golangci-lint version
3030
GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION:-'v1.55'}

‎signature-aggregator/aggregator/aggregator.go‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/ava-labs/avalanchego/ids"
1717
"github.com/ava-labs/avalanchego/message"
18+
networkP2P "github.com/ava-labs/avalanchego/network/p2p"
1819
"github.com/ava-labs/avalanchego/proto/pb/p2p"
1920
"github.com/ava-labs/avalanchego/proto/pb/sdk"
2021
"github.com/ava-labs/avalanchego/subnets"
@@ -24,7 +25,6 @@ import (
2425
avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp"
2526
"github.com/ava-labs/awm-relayer/peers"
2627
"github.com/ava-labs/awm-relayer/utils"
27-
msg "github.com/ava-labs/subnet-evm/plugin/evm/message"
2828
"go.uber.org/zap"
2929
"google.golang.org/protobuf/proto"
3030
)
@@ -120,9 +120,11 @@ func (s *SignatureAggregator) CreateSignedMessage(
120120
return nil, errNotEnoughConnectedStake
121121
}
122122

123-
reqBytes, err := proto.Marshal(
123+
reqBytes := networkP2P.ProtocolPrefix(networkP2P.SignatureRequestHandlerID)
124+
messageBytes, err := proto.Marshal(
124125
&sdk.SignatureRequest{Message: unsignedMessage.Bytes()},
125126
)
127+
reqBytes = append(reqBytes, messageBytes...)
126128
if err != nil {
127129
msg := "Failed to marshal request bytes"
128130
s.logger.Error(
@@ -426,8 +428,9 @@ func (s *SignatureAggregator) isValidSignatureResponse(
426428
return blsSignatureBuf{}, false
427429
}
428430

429-
var sigResponse msg.SignatureResponse
430-
if _, err := msg.Codec.Unmarshal(appResponse.AppBytes, &sigResponse); err != nil {
431+
sigResponse := sdk.SignatureResponse{}
432+
err := proto.Unmarshal(appResponse.AppBytes, &sigResponse)
433+
if err != nil {
431434
s.logger.Error(
432435
"Error unmarshaling signature response",
433436
zap.Error(err),
@@ -445,6 +448,15 @@ func (s *SignatureAggregator) isValidSignatureResponse(
445448
return blsSignatureBuf{}, false
446449
}
447450

451+
if len(signature) != bls.SignatureLen {
452+
s.logger.Debug(
453+
"Response signature has incorrect length",
454+
zap.Int("actual", len(signature)),
455+
zap.Int("expected", bls.SignatureLen),
456+
)
457+
return blsSignatureBuf{}, false
458+
}
459+
448460
sig, err := bls.SignatureFromBytes(signature[:])
449461
if err != nil {
450462
s.logger.Debug(
@@ -459,8 +471,9 @@ func (s *SignatureAggregator) isValidSignatureResponse(
459471
)
460472
return blsSignatureBuf{}, false
461473
}
462-
463-
return signature, true
474+
blsSig := blsSignatureBuf{}
475+
copy(blsSig[:], signature[:])
476+
return blsSig, true
464477
}
465478

466479
// aggregateSignatures constructs a BLS aggregate signature from the collected validator signatures. Also

‎signature-aggregator/api/api.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,13 @@ func signatureAggregationAPIHandler(logger logging.Logger, aggregator *aggregato
123123
return
124124
}
125125

126-
if isEmptyOrZeroes(message.Bytes()) || isEmptyOrZeroes(justification) {
126+
if isEmptyOrZeroes(message.Bytes()) && isEmptyOrZeroes(justification) {
127127
writeJSONError(
128128
logger,
129129
w,
130130
"Must provide either message or justification",
131131
)
132+
return
132133
}
133134

134135
quorumPercentage := req.QuorumPercentage

‎tests/contracts/lib/teleporter‎

0 commit comments

Comments
 (0)
Please sign in to comment.