Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate ACP-118 #408

Merged
merged 48 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c46fc41
go.mod: use latest subnet-evm commit
feuGeneA Aug 5, 2024
650c987
integrate w/ACP-118 protobuf SignatureRequest
feuGeneA Aug 5, 2024
a9c7768
test relayer & aggregator: log debug by default
feuGeneA Aug 5, 2024
9db9153
Merge branch 'signature-aggregation-api' into signature-aggregation-a…
feuGeneA Aug 5, 2024
557262a
add justification, rename message to drop Unsigned
feuGeneA Aug 6, 2024
b56e5d3
Merge remote-tracking branch 'origin/signature-aggregation-api' into …
feuGeneA Aug 6, 2024
adb8fb2
Merge remote-tracking branch 'origin/signature-aggregation-api' into …
feuGeneA Aug 7, 2024
f399cff
re-pin dependencies
feuGeneA Aug 7, 2024
fa3dbc0
Merge remote-tracking branch 'origin/signature-aggregation-api' into …
feuGeneA Aug 7, 2024
c771ca9
sync teleporter git submodule to go.mod version
feuGeneA Aug 7, 2024
fa60e03
version bumps, logging and handlerid packing hacks
iansuvak Aug 8, 2024
0108081
Update signature-aggregator/README.md
iansuvak Aug 8, 2024
cf689e5
Update signature-aggregator/README.md
iansuvak Aug 8, 2024
b186d1c
address review feedback
iansuvak Aug 8, 2024
95797af
invert utils.CheckStakeWeightPercentageExceedsThreshold
iansuvak Aug 8, 2024
b8735b0
Fix bugs in api and remove old testing code
iansuvak Aug 8, 2024
0be46eb
bump teleporter submodule
iansuvak Aug 9, 2024
e3cefff
Merge remote-tracking branch 'origin/main' into isuvak/sig-agg-acp-118
iansuvak Aug 9, 2024
79132a1
actually fix versions
iansuvak Aug 9, 2024
b5cff9e
Merge branch 'main' into signature-aggregation-api-acp-118
iansuvak Aug 9, 2024
2f337c9
Merge branch 'signature-aggregation-api-acp-118' into isuvak/sig-agg-…
iansuvak Aug 9, 2024
bce634d
replace feature branch commit references with default branch ones
iansuvak Aug 19, 2024
811c97a
add explicit check for signature length
iansuvak Aug 21, 2024
30a718d
Merge pull request #422 from ava-labs/isuvak/sig-agg-acp-118
iansuvak Aug 21, 2024
9f81123
Merge remote-tracking branch 'origin/main' into signature-aggregation…
feuGeneA Aug 20, 2024
e9eea93
Merge remote-tracking branch 'origin/main' into signature-aggregation…
feuGeneA Aug 21, 2024
29cac30
relay justification from handled request to AppReq
feuGeneA Aug 21, 2024
7fd79dc
Merge branch 'main' into signature-aggregation-api-acp-118
feuGeneA Aug 22, 2024
58af3de
Update signature-aggregator/api/api.go
feuGeneA Aug 23, 2024
e1edf7e
Merge branch 'main' into signature-aggregation-api-acp-118
feuGeneA Aug 23, 2024
70666da
Merge branch 'main' into signature-aggregation-api-acp-118
iansuvak Aug 27, 2024
77262bc
Etna timestamp switch
iansuvak Aug 27, 2024
ec5b830
Fix implementation and add E2E test
iansuvak Aug 28, 2024
0498f4a
update sample workflow docs for sig-agg
iansuvak Aug 28, 2024
440a52d
use PrefixMessage function to construct request bytes
iansuvak Aug 28, 2024
91c5016
make etna upgrade test just test the post-etna case
iansuvak Aug 28, 2024
47cfef6
use extract_commit instead of manually synced references in versions.sh
iansuvak Aug 28, 2024
b87bcc1
Revert "use extract_commit instead of manually synced references in v…
iansuvak Aug 29, 2024
5852f6c
Merge remote-tracking branch 'origin/main' into etna-time
iansuvak Aug 30, 2024
7f9488c
Add TODO to cleanup after Etna release
iansuvak Aug 30, 2024
0648123
Merge pull request #463 from ava-labs/etna-time
iansuvak Aug 30, 2024
ae43d72
Merge branch 'main' into signature-aggregation-api-acp-118
iansuvak Sep 4, 2024
ca06934
adapt to latest changes in `main`
feuGeneA Sep 4, 2024
6cd8245
pass nil, not empty slice
feuGeneA Sep 4, 2024
b04df21
Merge branch 'main' into signature-aggregation-api-acp-118
feuGeneA Sep 4, 2024
3d7707d
address review feedback
iansuvak Sep 5, 2024
2ba7b61
Merge remote-tracking branch 'origin/main' into signature-aggregation…
iansuvak Sep 5, 2024
576a375
address review feedback
iansuvak Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module github.com/ava-labs/awm-relayer
go 1.21.12

require (
github.com/ava-labs/avalanchego v1.11.10
github.com/ava-labs/coreth v0.13.7
github.com/ava-labs/subnet-evm v0.6.8
github.com/ava-labs/teleporter v1.0.3
github.com/ava-labs/avalanchego v1.11.11-0.20240729205337-a0f7e422bb84
github.com/ava-labs/subnet-evm v0.6.8-acp-118-handlers
github.com/ava-labs/teleporter v1.0.5-0.20240807150146-1c7df1ab5033
github.com/aws/aws-sdk-go-v2 v1.30.3
github.com/aws/aws-sdk-go-v2/config v1.27.9
github.com/aws/aws-sdk-go-v2/service/kms v1.35.3
Expand All @@ -26,6 +25,7 @@ require (
)

require (
github.com/ava-labs/coreth v0.13.7 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.9 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect
Expand Down Expand Up @@ -93,7 +93,7 @@ require (
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/tools v0.23.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down Expand Up @@ -152,12 +152,12 @@ require (
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/atomic v1.11.0
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.3.0 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
Expand Down
36 changes: 18 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ github.com/alexliesenfeld/health v0.8.0/go.mod h1:TfNP0f+9WQVWMQRzvMUjlws4ceXKEL
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.10 h1:QujciF5OEp5FwAoe/RciFF/i47rxU5rkEr6fVuUBS1Q=
github.com/ava-labs/avalanchego v1.11.10/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc=
github.com/ava-labs/avalanchego v1.11.11-0.20240729205337-a0f7e422bb84 h1:AmPZLlnVREbJ/viK/hDTIVn1bqX8QTB2CFtrBxHwnsw=
github.com/ava-labs/avalanchego v1.11.11-0.20240729205337-a0f7e422bb84/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc=
github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g=
github.com/ava-labs/coreth v0.13.7/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/ava-labs/subnet-evm v0.6.8 h1:IrHGajBYWs692YIYdd5J0oVWWt88Q/XAZQq/dOtkHFw=
github.com/ava-labs/subnet-evm v0.6.8/go.mod h1:qt8DXyGm40CY9yffNOe1+4yUyL9mD3v5RPWqAuGj5u4=
github.com/ava-labs/teleporter v1.0.3 h1:5Kwso1yk5dtuIg7356MF+cJFRFge8nvun/JK0MDAUAM=
github.com/ava-labs/teleporter v1.0.3/go.mod h1:h8wp8x7531OLeyQUzC2M20S6AVXSuj598Hmo8QSUVOM=
github.com/ava-labs/subnet-evm v0.6.8-acp-118-handlers h1:2UVHP9TDh3eS/CuD/XzMy2+3ruu/U2ZUny1eqn4bNB4=
github.com/ava-labs/subnet-evm v0.6.8-acp-118-handlers/go.mod h1:BryiYmD6HWmugkSUpDdj/KyMi7ou5pJzPRNPMbMgpbA=
github.com/ava-labs/teleporter v1.0.5-0.20240807150146-1c7df1ab5033 h1:mqtcLphkixDnYY5h8eQlj058KiVpRJaQgGvuUZcAcXo=
github.com/ava-labs/teleporter v1.0.5-0.20240807150146-1c7df1ab5033/go.mod h1:xDSsLZTLQ68ZXs9tb00VNd4fODqHTs6AD3MX6cyQ00Y=
github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=
github.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc=
github.com/aws/aws-sdk-go-v2/config v1.27.9 h1:gRx/NwpNEFSk+yQlgmk1bmxxvQ5TyJ76CWXs9XScTqg=
Expand Down Expand Up @@ -672,8 +672,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -757,8 +757,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -847,12 +847,12 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -863,8 +863,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -926,8 +926,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
5 changes: 3 additions & 2 deletions messages/teleporter/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ func (f *factory) parseTeleporterMessage(
)
return nil, err
}
teleporterMessage, err := teleportermessenger.UnpackTeleporterMessage(addressedPayload.Payload)
teleporterMessage := teleportermessenger.TeleporterMessage{}
err = teleporterMessage.Unpack(addressedPayload.Payload)
if err != nil {
f.logger.Error(
"Failed unpacking teleporter message.",
Expand All @@ -397,7 +398,7 @@ func (f *factory) parseTeleporterMessage(
return nil, err
}

return teleporterMessage, nil
return &teleporterMessage, nil
}

// getTeleporterMessenger returns the Teleporter messenger instance for the destination chain.
Expand Down
2 changes: 1 addition & 1 deletion messages/teleporter/message_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func init() {
}

func TestShouldSendMessage(t *testing.T) {
validMessageBytes, err := teleportermessenger.PackTeleporterMessage(validTeleporterMessage)
validMessageBytes, err := validTeleporterMessage.Pack()
require.NoError(t, err)

validAddressedCall, err := warpPayload.NewAddressedCall(
Expand Down
1 change: 1 addition & 0 deletions relayer/application_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co
if r.sourceWarpSignatureClient == nil {
signedMessage, err = r.signatureAggregator.CreateSignedMessage(
unsignedMessage,
make([]byte, 0),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't too clear to me what this justification field is meant for, and why it's always empty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Justification field is part of ACP-118 It's unused for now but is meant to be potentially extra data that would explain why the data in the message field should be signed. It's unused for now though so that's why it's always empty

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we can't just pass in nil here? Allocating a slice that's never assigned to seems odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 6cd8245

r.signingSubnetID,
r.warpQuorum.QuorumNumerator,
)
Expand Down
6 changes: 4 additions & 2 deletions scripts/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ function getDepVersion() {
export GO_VERSION=${GO_VERSION:-$(getDepVersion go)}

# Don't export them as they're used in the context of other calls
AVALANCHEGO_VERSION=${AVALANCHEGO_VERSION:-$(getDepVersion github.com/ava-labs/avalanchego)}
# TODO: undo this hack once go.mod is referring to a tag rather than a commit
#AVALANCHEGO_VERSION=${AVALANCHEGO_VERSION:-$(getDepVersion github.com/ava-labs/avalanchego)}
AVALANCHEGO_VERSION=${AVALANCHEGO_VERSION:-a0f7e422bb8497186ebff434f12c4b957cec8d49}
GINKGO_VERSION=${GINKGO_VERSION:-$(getDepVersion github.com/onsi/ginkgo/v2)}

# TODO: undo this hack once go.mod is referring to a tag rather than a commit
#SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-$(getDepVersion github.com/ava-labs/subnet-evm)}
SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-update-avago-teleporter}
SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-v0.6.8-acp-118-handlers}

# Set golangci-lint version
GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION:-'v1.55'}
24 changes: 6 additions & 18 deletions signature-aggregator/aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/message"
"github.com/ava-labs/avalanchego/proto/pb/p2p"
"github.com/ava-labs/avalanchego/proto/pb/sdk"
"github.com/ava-labs/avalanchego/subnets"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/set"
avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp"
"github.com/ava-labs/awm-relayer/peers"
"github.com/ava-labs/awm-relayer/utils"
coreEthMsg "github.com/ava-labs/coreth/plugin/evm/message"
msg "github.com/ava-labs/subnet-evm/plugin/evm/message"
"go.uber.org/zap"
"google.golang.org/protobuf/proto"
)

type blsSignatureBuf [bls.SignatureLen]byte
Expand All @@ -40,9 +40,6 @@ const (
)

var (
codec = msg.Codec
coreEthCodec = coreEthMsg.Codec

// Errors
errNotEnoughSignatures = errors.New("failed to collect a threshold of signatures")
errNotEnoughConnectedStake = errors.New("failed to connect to a threshold of stake")
Expand Down Expand Up @@ -76,6 +73,7 @@ func NewSignatureAggregator(

func (s *SignatureAggregator) CreateSignedMessage(
unsignedMessage *avalancheWarp.UnsignedMessage,
justification []byte,
inputSigningSubnet ids.ID,
quorumPercentage uint64,
) (*avalancheWarp.Message, error) {
Expand Down Expand Up @@ -122,19 +120,9 @@ func (s *SignatureAggregator) CreateSignedMessage(
return nil, errNotEnoughConnectedStake
}

// TODO: remove this special handling and replace with ACP-118 interface once available
var reqBytes []byte
if sourceSubnet == constants.PrimaryNetworkID {
req := coreEthMsg.MessageSignatureRequest{
MessageID: unsignedMessage.ID(),
}
reqBytes, err = coreEthMsg.RequestToBytes(coreEthCodec, req)
} else {
req := msg.MessageSignatureRequest{
MessageID: unsignedMessage.ID(),
}
reqBytes, err = msg.RequestToBytes(codec, req)
}
reqBytes, err := proto.Marshal(
&sdk.SignatureRequest{Message: unsignedMessage.Bytes()},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add justification bytes here as well as the API. In the API they should be hex encoded and since their meaning is VM specific we don't need to do any processing to them either just like with the message. We should only pass the non-zero fields since the ACP-118 spec but in the API layer we should do validation that at least one of message, justification fields is non-zero.

I would also rename our API to use Message instead of UnsignedMessage to match the ACP-118 spec while we are at it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 557262a

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't done yet. I added the justification everywhere (in the API) except for right here 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last piece addressed in 29cac30

)
if err != nil {
msg := "Failed to marshal request bytes"
s.logger.Error(
Expand Down
46 changes: 41 additions & 5 deletions signature-aggregator/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ const (

// Defines a request interface for signature aggregation for a raw unsigned message.
type AggregateSignatureRequest struct {
// Required: either Message or Justification must be provided
// Required. hex-encoded message, optionally prefixed with "0x".
feuGeneA marked this conversation as resolved.
Show resolved Hide resolved
UnsignedMessage string `json:"unsigned-message"`
Message string `json:"message"`
// hex-encoded justification, optionally prefixed with "0x".
Justification string `json:"justification"`
// Optional hex or cb58 encoded signing subnet ID. If omitted will default to the subnetID of the source blockchain
SigningSubnetID string `json:"signing-subnet-id"`
// Optional. Integer from 0 to 100 representing the percentage of the quorum that is required to sign the message
Expand Down Expand Up @@ -65,6 +68,15 @@ func writeJSONError(
}
}

func isEmptyOrZeroes(bytes []byte) bool {
for _, b := range bytes {
if b != 0 {
return false
}
}
return true
}

func signatureAggregationAPIHandler(logger logging.Logger, aggregator *aggregator.SignatureAggregator) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var req AggregateSignatureRequest
Expand All @@ -77,25 +89,48 @@ func signatureAggregationAPIHandler(logger logging.Logger, aggregator *aggregato
}
var decodedMessage []byte
decodedMessage, err = hex.DecodeString(
strings.TrimPrefix(req.UnsignedMessage, "0x"),
strings.TrimPrefix(req.Message, "0x"),
)
if err != nil {
msg := "Could not decode message"
logger.Warn(
msg,
zap.String("msg", req.UnsignedMessage),
zap.String("msg", req.Message),
zap.Error(err),
)
writeJSONError(logger, w, msg)
return
}
unsignedMessage, err := types.UnpackWarpMessage(decodedMessage)
message, err := types.UnpackWarpMessage(decodedMessage)
if err != nil {
msg := "Error unpacking warp message"
logger.Warn(msg, zap.Error(err))
writeJSONError(logger, w, msg)
return
}

justification, err := hex.DecodeString(
strings.TrimPrefix(req.Justification, "0x"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have HexOrCB58ToID and SanitizieHexString utils functions that might apply here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't decode to an ID but yeah we should call SanitizeHexString here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)
if err != nil {
msg := "Could not decode justification"
logger.Warn(
msg,
zap.String("justification", req.Justification),
zap.Error(err),
)
writeJSONError(logger, w, msg)
return
}

if isEmptyOrZeroes(message.Bytes()) || isEmptyOrZeroes(justification) {
writeJSONError(
logger,
w,
"Must provide either message or justification",
)
}

quorumPercentage := req.QuorumPercentage
if quorumPercentage == 0 {
quorumPercentage = QuorumPercentage
Expand All @@ -122,7 +157,8 @@ func signatureAggregationAPIHandler(logger logging.Logger, aggregator *aggregato
}

signedMessage, err := aggregator.CreateSignedMessage(
unsignedMessage,
message,
justification,
signingSubnetID,
quorumPercentage,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/contracts/lib/teleporter
Submodule teleporter updated 191 files
2 changes: 1 addition & 1 deletion tests/signature_aggregator_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func SignatureAggregatorAPI(network interfaces.LocalNetwork) {
warpMessage := getWarpMessageFromLog(ctx, receipt, subnetAInfo)

reqBody := api.AggregateSignatureRequest{
UnsignedMessage: "0x" + hex.EncodeToString(warpMessage.Bytes()),
Message: "0x" + hex.EncodeToString(warpMessage.Bytes()),
feuGeneA marked this conversation as resolved.
Show resolved Hide resolved
}

client := http.Client{
Expand Down
7 changes: 4 additions & 3 deletions tests/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func CreateDefaultRelayerConfig(
}

return config.Config{
LogLevel: logging.Info.LowerString(),
LogLevel: logging.Debug.LowerString(),
PChainAPI: &config.APIConfig{
BaseURL: sourceSubnetsInfo[0].NodeURIs[0],
},
Expand Down Expand Up @@ -287,7 +287,7 @@ func CreateDefaultSignatureAggregatorConfig(
)
// Construct the config values for each subnet
return signatureaggregatorcfg.Config{
LogLevel: logging.Info.LowerString(),
LogLevel: logging.Debug.LowerString(),
iansuvak marked this conversation as resolved.
Show resolved Hide resolved
PChainAPI: &config.APIConfig{
BaseURL: sourceSubnetsInfo[0].NodeURIs[0],
},
Expand Down Expand Up @@ -473,7 +473,8 @@ func RelayBasicMessage(
// Check that the teleporter message is correct
// We don't validate the entire message, since the message receipts
// are populated by the Teleporter contract
receivedTeleporterMessage, err := teleportermessenger.UnpackTeleporterMessage(addressedPayload.Payload)
receivedTeleporterMessage := teleportermessenger.TeleporterMessage{}
err = receivedTeleporterMessage.Unpack(addressedPayload.Payload)
Expect(err).Should(BeNil())

receivedMessageID, err := teleporterUtils.CalculateMessageID(
Expand Down
Loading