Skip to content

Commit

Permalink
Merge pull request #25 from datachainlab/multi-operators
Browse files Browse the repository at this point in the history
Multi-operators support

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored Jun 18, 2024
2 parents a46b91d + 45fc5a7 commit f6fbd71
Show file tree
Hide file tree
Showing 45 changed files with 3,377 additions and 920 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ jobs:
- run: echo -e 'no\n/opt' | ./sgx_linux_x64_sdk_2.19.100.3.bin
- run: make tendermint-images
- run: source /opt/sgxsdk/environment && make e2e-test
- run: source /opt/sgxsdk/environment && make E2E_OPTIONS=--operators_enabled e2e-test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tendermint-images:

.PHONY: e2e-test
e2e-test: yrly lcp
./scripts/run_e2e_test.sh
./scripts/run_e2e_test.sh $(E2E_OPTIONS)

.PHONY: proto-gen proto-update-deps
proto-gen:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/deckarep/golang-set/v2 v2.1.0
github.com/ethereum/go-ethereum v1.12.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hyperledger-labs/yui-relayer v0.5.3
github.com/hyperledger-labs/yui-relayer v0.5.4
github.com/oasisprotocol/oasis-core/go v0.2201.11
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
Expand Down
26 changes: 24 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
Expand Down Expand Up @@ -479,6 +483,8 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
Expand All @@ -491,6 +497,8 @@ github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJ
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
Expand All @@ -502,6 +510,8 @@ github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0=
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0=
Expand Down Expand Up @@ -707,8 +717,8 @@ github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0Jr
github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw=
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/hyperledger-labs/yui-relayer v0.5.3 h1:K7lcqkaqsGtpXImcz/cuClZsTtWCobLC9zh76KGzhP8=
github.com/hyperledger-labs/yui-relayer v0.5.3/go.mod h1:GeCb1dtZjtQdkBNw1L9+LAUHzNQQhQK+kkoOnZYffw0=
github.com/hyperledger-labs/yui-relayer v0.5.4 h1:yhvWI28Rcel55UsdmYWX0QE0W3P9aBSRetQh1k8VpZA=
github.com/hyperledger-labs/yui-relayer v0.5.4/go.mod h1:GeCb1dtZjtQdkBNw1L9+LAUHzNQQhQK+kkoOnZYffw0=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down Expand Up @@ -762,6 +772,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
Expand Down Expand Up @@ -794,6 +806,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g=
Expand Down Expand Up @@ -844,6 +858,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
Expand Down Expand Up @@ -957,6 +973,8 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
Expand Down Expand Up @@ -1021,6 +1039,10 @@ github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2l
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI=
github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4=
github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
Expand Down
2 changes: 1 addition & 1 deletion lcp
Submodule lcp updated 34 files
+6 −0 Cargo.lock
+50 −2 app/src/commands/attestation.rs
+2 −0 app/src/commands/enclave.rs
+3 −3 enclave-modules/ecall-handler/src/enclave_manage/attestation.rs
+1 −1 enclave-modules/ecall-handler/src/light_client/aggregate_messages.rs
+1 −1 enclave-modules/ecall-handler/src/light_client/init_client.rs
+2 −2 enclave-modules/ecall-handler/src/light_client/update_client.rs
+2 −2 enclave-modules/ecall-handler/src/light_client/verify_state.rs
+1 −2 enclave-modules/remote-attestation/src/attestation.rs
+1 −0 enclave/Cargo.lock
+1 −0 modules/attestation-report/Cargo.toml
+9 −0 modules/attestation-report/src/errors.rs
+3 −1 modules/attestation-report/src/lib.rs
+68 −10 modules/attestation-report/src/report.rs
+1 −1 modules/attestation-report/src/verification.rs
+3 −13 modules/commitments/src/message.rs
+4 −14 modules/commitments/src/proof.rs
+2 −7 modules/commitments/src/prover.rs
+4 −7 modules/crypto/src/key.rs
+2 −0 modules/ecall-commands/src/enclave_manage.rs
+0 −5 modules/ecall-commands/src/msgs.rs
+4 −0 modules/lcp-client/Cargo.toml
+377 −98 modules/lcp-client/src/client_def.rs
+32 −1 modules/lcp-client/src/client_state.rs
+11 −1 modules/lcp-client/src/errors.rs
+121 −15 modules/lcp-client/src/message.rs
+1 −1 modules/light-client/src/context.rs
+15 −3 proto/definitions/ibc/lightclients/lcp/v1/lcp.proto
+5 −10 proto/definitions/lcp/service/elc/v1/tx.proto
+ proto/src/descriptor.bin
+28 −6 proto/src/prost/ibc.lightclients.lcp.v1.rs
+0 −10 proto/src/prost/lcp.service.elc.v1.rs
+1 −0 tests/integration/Cargo.toml
+45 −2 tests/integration/src/lib.rs
37 changes: 28 additions & 9 deletions light-clients/lcp/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)

Expand Down Expand Up @@ -70,6 +71,28 @@ func (cs ClientState) Initialize(_ sdk.Context, cdc codec.BinaryCodec, clientSto
if !ok {
return errorsmod.Wrapf(clienttypes.ErrInvalidConsensus, "unexpected consensus state type: expected=%T got=%T", &ConsensusState{}, consensusState)
}

if cs.OperatorsNonce != 0 {
return errorsmod.Wrapf(clienttypes.ErrInvalidClient, "`OperatorsNonce` must be zero")
}
if len(cs.Operators) != 0 && (cs.OperatorsThresholdNumerator == 0 || cs.OperatorsThresholdDenominator == 0) {
return errorsmod.Wrapf(clienttypes.ErrInvalidClient, "`OperatorsThresholdNumerator` and `OperatorsThresholdDenominator` must be non-zero")
}
var zeroAddr common.Address
operators := cs.GetOperators()
for i, op := range operators {
if op == zeroAddr {
return errorsmod.Wrapf(clienttypes.ErrInvalidClient, "operator address cannot be empty")
}
// check if the operator is ordered correctly
if i > 0 && bytes.Compare(operators[i-1].Bytes(), op.Bytes()) > 0 {
return errorsmod.Wrapf(clienttypes.ErrInvalidClient, "operator addresses must be ordered: %v > %v", operators[i-1].String(), op.String())
}
}
if cs.OperatorsThresholdNumerator > cs.OperatorsThresholdDenominator {
return errorsmod.Wrapf(clienttypes.ErrInvalidClient, "`OperatorsThresholdNumerator` must be less than or equal to `OperatorsThresholdDenominator`")
}

setClientState(clientStore, cdc, &cs)
setConsensusState(clientStore, cdc, consState, cs.GetLatestHeight())
return nil
Expand Down Expand Up @@ -148,11 +171,11 @@ func (cs ClientState) VerifyMembership(
if err != nil {
return errorsmod.Wrapf(clienttypes.ErrConsensusStateNotFound, "please ensure the proof was constructed against a height that exists on the client: err=%v", err)
}
commitmentProof, err := EthABIDecodeCommitmentProof(proof)
commitmentProofs, err := EthABIDecodeCommitmentProofs(proof)
if err != nil {
return err
}
m, err := commitmentProof.GetMessage()
m, err := commitmentProofs.GetMessage()
if err != nil {
return err
}
Expand All @@ -177,13 +200,9 @@ func (cs ClientState) VerifyMembership(
if !msg.StateID.EqualBytes(consensusState.StateId) {
return errorsmod.Wrapf(ErrInvalidStateCommitment, "invalid state ID: expected=%v got=%v", consensusState.StateId, msg.StateID)
}
if err := VerifySignatureWithSignBytes(commitmentProof.Message, commitmentProof.Signature, commitmentProof.Signer); err != nil {
return errorsmod.Wrapf(ErrInvalidStateCommitmentProof, "failed to verify state commitment proof: %v", err)
}
if !cs.IsActiveKey(ctx.BlockTime(), clientStore, commitmentProof.Signer) {
return errorsmod.Wrapf(ErrExpiredEnclaveKey, "key '%v' has expired", commitmentProof.Signer.Hex())
}
return nil

commitment := crypto.Keccak256Hash(commitmentProofs.Message)
return cs.VerifySignatures(ctx, clientStore, commitment, commitmentProofs.Signatures)
}

// VerifyNonMembership is a generic proof verification method which verifies the absence of a given CommitmentPath at a specified height.
Expand Down
1 change: 1 addition & 0 deletions light-clients/lcp/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
(*exported.ClientMessage)(nil),
&UpdateClientMessage{},
&RegisterEnclaveKeyMessage{},
&UpdateOperatorsMessage{},
)
}
1 change: 1 addition & 0 deletions light-clients/lcp/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ var (
ErrProcessedHeightNotFound = errorsmod.Register(ModuleName, 5, "processed height not found")
ErrDelayPeriodNotPassed = errorsmod.Register(ModuleName, 6, "packet-specified delay period has not been reached")
ErrInvalidMisbehaviour = errorsmod.Register(ModuleName, 7, "invalid misbehaviour")
ErrRetrieveClientID = errorsmod.Register(ModuleName, 8, "failed to retrieve client id")
)
12 changes: 9 additions & 3 deletions light-clients/lcp/types/events.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package types

const (
EventTypeRegisteredEnclaveKey = "registered_enclave_key"
EventTypeRegisterEnclaveKey = "register_enclave_key"
AttributeKeyEnclaveKey = "enclave_key"
AttributeKeyExpiredAt = "expired_at"
AttributeKeyOperator = "operator"

AttributeKeyEnclaveKey = "enclave_key"
AttributeExpiredAt = "expired_at"
EventTypeUpdateOperators = "update_operators"
AttributeKeyNonce = "nonce"
AttributeKeyNewOperators = "new_operators"
AttributeKeyThresholdNumerator = "threshold_numerator"
AttributeKeyThresholdDenominator = "threshold_denominator"
)
34 changes: 34 additions & 0 deletions light-clients/lcp/types/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/ethereum/go-ethereum/common"
)

type ProxyMessage interface{}
Expand Down Expand Up @@ -60,3 +61,36 @@ func (RegisterEnclaveKeyMessage) ClientType() string {
func (RegisterEnclaveKeyMessage) ValidateBasic() error {
return nil
}

var _ exported.ClientMessage = (*UpdateOperatorsMessage)(nil)

func (UpdateOperatorsMessage) ClientType() string {
return ClientTypeLCP
}

func (m UpdateOperatorsMessage) GetNewOperators() ([]common.Address, error) {
ops := make([]common.Address, len(m.NewOperators))
for i, op := range m.NewOperators {
if len(op) != 20 {
return nil, fmt.Errorf("invalid operator address length: expected=%v actual=%v", 20, len(op))
}
ops[i] = common.BytesToAddress(op)
}
return ops, nil
}

func (m UpdateOperatorsMessage) ValidateBasic() error {
if m.NewOperatorsThresholdNumerator == 0 {
return fmt.Errorf("new operators threshold numerator cannot be zero")
}
if m.NewOperatorsThresholdDenominator == 0 {
return fmt.Errorf("new operators threshold denominator cannot be zero")
}
if m.NewOperatorsThresholdNumerator > m.NewOperatorsThresholdDenominator {
return fmt.Errorf("new operators threshold numerator cannot be greater than denominator")
}
if len(m.Signatures) == 0 {
return fmt.Errorf("signatures cannot be empty")
}
return nil
}
Loading

0 comments on commit f6fbd71

Please sign in to comment.