Skip to content

Commit

Permalink
Merge pull request #1 from rarimo/feature/wordlcoin-identity
Browse files Browse the repository at this point in the history
Updating relayer to ingest and relay WorldCoin identity transfers instead of Iden3
  • Loading branch information
olegfomenko authored Dec 18, 2023
2 parents 7fbad1d + d3780ff commit 24b92c8
Show file tree
Hide file tree
Showing 26 changed files with 1,093 additions and 2,760 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ FROM golang:1.19-alpine as buildbase

RUN apk add git build-base

WORKDIR /go/src/github.com/rarimo/identity-relayer-svc
WORKDIR /go/src/github.com/rarimo/worldcoin-relayer-svc
COPY vendor .
COPY . .

ENV GO111MODULE="on"
ENV CGO_ENABLED=1
ENV GOOS="linux"

RUN GOOS=linux go build -o /usr/local/bin/relayer-svc /go/src/github.com/rarimo/identity-relayer-svc
RUN GOOS=linux go build -o /usr/local/bin/relayer-svc /go/src/github.com/rarimo/worldcoin-relayer-svc


FROM alpine:3.9
Expand Down
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
The Relayer service as a part of Rarimo cross-chain system designed to finalize transferring flow by submitting final
transaction to the target chain.

The goal of identity relayer is to observe and fetch information about new signatures for
`IDENTITY_STATE_TRANSFER` and `IDENTITY_GIST_TRANSFER` operations and after submit the state transit transactions to
configured EVM chain by request.

For more information about how the PolygonID identity transfer works
visit: [rarimo-core docs](https://rarimo.github.io/rarimo-core/docs/common/bridging/002-identity.html).
The goal of WorldCoin identity relayer is to observe and fetch information about new signatures
for `WORLDCOIN_IDENTITY_TRANSFER` operations and after submit the state transit transactions to configured EVM chain by
request.

----

Expand Down Expand Up @@ -132,16 +129,6 @@ volumes:
}
```

2. Execute the POST `/integrations/relayer/gist/relay` request with the following body to perform gist publishing:

```json
{
"chain": "The name of chain submit to according to the service configuration",
"hash": "The GIST hash (the same as on state contract) in 0x... hex format",
"waitConfirm": true
}
```

`"waitConfirm": true` - indicates if request should wait until transaction will be included into the block.
Default - `false`.

Expand Down
66 changes: 2 additions & 64 deletions docs/static/service.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,7 @@
"application/json"
],
"paths": {
"/integrations/relayer/gist/relay": {
"post": {
"operationId": "Service_GistRelay",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MsgRelayResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RelayBody"
}
}
],
"tags": [
"Service"
]
}
},
"/integrations/relayer/gist/relay/{hash}": {
"get": {
"operationId": "Service_GISTRelays",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MsgRelaysResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "hash",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"Service"
]
}
},
"/integrations/relayer/state/relay": {
"/integrations/relayer-wc/state/relay": {
"post": {
"operationId": "Service_StateRelay",
"responses": {
Expand Down Expand Up @@ -110,7 +48,7 @@
]
}
},
"/integrations/relayer/state/relay/{hash}": {
"/integrations/relayer-wc/state/relay/{hash}": {
"get": {
"operationId": "Service_StateRelays",
"responses": {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/rarimo/identity-relayer-svc
module github.com/rarimo/worldcoin-relayer-svc

go 1.19

require (
github.com/alecthomas/kingpin v2.2.6+incompatible
github.com/cosmos/cosmos-sdk v0.46.12
github.com/ethereum/go-ethereum v1.10.26
github.com/rarimo/rarimo-core v1.0.7-0.20231123231906-566dc0033e75
github.com/rarimo/rarimo-core v1.0.7-0.20231208125434-eaf4ddf6c070
github.com/spf13/cast v1.5.1
github.com/stretchr/testify v1.8.3 // indirect
github.com/tendermint/tendermint v0.34.27
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ github.com/rarimo/cosmos-sdk v0.46.7 h1:jU2PiWzc+19SF02cXM0O0puKPeH1C6Q6t2lzJ9s1
github.com/rarimo/cosmos-sdk v0.46.7/go.mod h1:fqKqz39U5IlEFb4nbQ72951myztsDzFKKDtffYJ63nk=
github.com/rarimo/go-merkle v0.0.0-20231004122345-36fa49031c66 h1:1KAU4rfWWJwAJ/kencagL3k5BXN3HhP004QNkEUgvDE=
github.com/rarimo/go-merkle v0.0.0-20231004122345-36fa49031c66/go.mod h1:5Pt9Lk8w7fWhyRO/NMb5x8DRhF2lESRVPT5uOlezInQ=
github.com/rarimo/rarimo-core v1.0.7-0.20231123231906-566dc0033e75 h1:gCVlgChRHbV6aemA+WM6BDyexRvr/V8MtG7cInwF/k4=
github.com/rarimo/rarimo-core v1.0.7-0.20231123231906-566dc0033e75/go.mod h1:S8d3kZWPFuNsy7llrzUd8Rj92WSCrjSH2YEUD+2A+Ww=
github.com/rarimo/rarimo-core v1.0.7-0.20231208125434-eaf4ddf6c070 h1:gug/AW6noXk5m1yff/1u2CBz8UDSWRonZPhfPAdm04k=
github.com/rarimo/rarimo-core v1.0.7-0.20231208125434-eaf4ddf6c070/go.mod h1:auP3KgxaSwkOUrLWBifjnMbbSQTSBA9Y/gVgq1WU/B4=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg=
Expand Down
21 changes: 0 additions & 21 deletions internal/assets/migrations/002_gist.sql

This file was deleted.

7 changes: 3 additions & 4 deletions internal/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package cli
import (
"context"

"github.com/rarimo/identity-relayer-svc/internal/services"
"github.com/rarimo/identity-relayer-svc/internal/services/ingester"
"github.com/rarimo/worldcoin-relayer-svc/internal/services"
"github.com/rarimo/worldcoin-relayer-svc/internal/services/ingester"

"github.com/rarimo/identity-relayer-svc/internal/config"
"github.com/rarimo/worldcoin-relayer-svc/internal/config"

"github.com/alecthomas/kingpin"
"gitlab.com/distributed_lab/kit/kv"
Expand Down Expand Up @@ -46,7 +46,6 @@ func Run(args []string) bool {
switch cmd {
case runAllCmd.FullCommand():
go ingester.NewService(cfg, ingester.NewStateIngester(cfg)).Run(ctx)
go ingester.NewService(cfg, ingester.NewGistIngester(cfg)).Run(ctx)
err = services.NewServer(cfg).Run()
case migrateUpCmd.FullCommand():
err = MigrateUp(cfg)
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/migrate.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cli

import (
"github.com/rarimo/identity-relayer-svc/internal/assets"
"github.com/rarimo/identity-relayer-svc/internal/config"
"github.com/rarimo/worldcoin-relayer-svc/internal/assets"
"github.com/rarimo/worldcoin-relayer-svc/internal/config"
migrate "github.com/rubenv/sql-migrate"
"gitlab.com/distributed_lab/logan/v3/errors"
)
Expand Down
4 changes: 1 addition & 3 deletions internal/config/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
)

type RelayConfig struct {
CatchupDisabled bool `fig:"catchup_disabled"`
IssuerID []string `fig:"issuer_id"`
DisableFiltration bool `fig:"disable_filtration"`
CatchupDisabled bool `fig:"catchup_disabled"`
}

func (c *config) Relay() RelayConfig {
Expand Down
38 changes: 2 additions & 36 deletions internal/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/ava-labs/subnet-evm/accounts/abi"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/rarimo/identity-relayer-svc/internal/config"
rarimocore "github.com/rarimo/rarimo-core/x/rarimocore/types"
"github.com/rarimo/worldcoin-relayer-svc/internal/config"
"gitlab.com/distributed_lab/logan/v3"
"gitlab.com/distributed_lab/logan/v3/errors"
)
Expand Down Expand Up @@ -60,7 +60,7 @@ func (c *Core) GetIdentityStateTransferProof(ctx context.Context, operationID st
return nil, errors.Wrap(err, "failed to get the operation")
}

transfer, err := pkg.GetIdentityStateTransfer(operation.Operation)
transfer, err := pkg.GetWorldCoinIdentityTransfer(operation.Operation)
if err != nil {
return nil, errors.Wrap(err, "failed to parse operation details")
}
Expand All @@ -74,37 +74,3 @@ func (c *Core) GetIdentityStateTransferProof(ctx context.Context, operationID st

return &result, nil
}

func (c *Core) GetIdentityGISTTransferProof(ctx context.Context, operationID string) (*IdentityGISTTransferDetails, error) {
proof, err := c.core.OperationProof(ctx, &rarimocore.QueryGetOperationProofRequest{Index: operationID})
if err != nil {
return nil, errors.Wrap(err, "failed to get the operation proof")
}

pathHashes := make([]common.Hash, 0, len(proof.Path))
for _, p := range proof.Path {
pathHashes = append(pathHashes, common.HexToHash(p))
}

signature := hexutil.MustDecode(proof.Signature)
signature[64] += 27

operation, err := c.core.Operation(context.TODO(), &rarimocore.QueryGetOperationRequest{Index: operationID})
if err != nil {
return nil, errors.Wrap(err, "failed to get the operation")
}

transfer, err := pkg.GetIdentityGISTTransfer(operation.Operation)
if err != nil {
return nil, errors.Wrap(err, "failed to parse operation details")
}

result := IdentityGISTTransferDetails{Operation: transfer}

result.Proof, err = proofArgs.Pack(pathHashes, signature)
if err != nil {
return nil, errors.Wrap(err, "failed to encode the proof")
}

return &result, nil
}
7 changes: 1 addition & 6 deletions internal/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ package core
import rarimocore "github.com/rarimo/rarimo-core/x/rarimocore/types"

type IdentityStateTransferDetails struct {
Operation *rarimocore.IdentityStateTransfer
Proof []byte
}

type IdentityGISTTransferDetails struct {
Operation *rarimocore.IdentityGISTTransfer
Operation *rarimocore.WorldCoinIdentityTransfer
Proof []byte
}
2 changes: 1 addition & 1 deletion internal/data/pg/schema.xo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 3 additions & 20 deletions internal/proto/service.proto
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
syntax = "proto3";

option go_package = "github.com/rarimo/identity-relayer-svc/internal/types";
option go_package = "github.com/rarimo/worldcoin-relayer-svc/internal/types";

import "google/protobuf/any.proto";
import "google/api/annotations.proto";

service Service {
rpc StateRelay(MsgStateRelayRequest) returns (MsgRelayResponse){
option (google.api.http) = {
post: "/integrations/relayer/state/relay"
body: "body"
};
};

rpc GistRelay(MsgGISTRelayRequest) returns (MsgRelayResponse){
option (google.api.http) = {
post: "/integrations/relayer/gist/relay"
post: "/integrations/relayer-wc/state/relay"
body: "body"
};
};

rpc StateRelays(MsgRelaysRequest) returns (MsgRelaysResponse){
option (google.api.http) = {
get: "/integrations/relayer/state/relay/{hash}"
};
};

rpc GISTRelays(MsgRelaysRequest) returns (MsgRelaysResponse){
option (google.api.http) = {
get: "/integrations/relayer/gist/relay/{hash}"
get: "/integrations/relayer-wc/state/relay/{hash}"
};
};
}
Expand All @@ -37,10 +24,6 @@ message MsgStateRelayRequest {
RelayBody body = 1;
}

message MsgGISTRelayRequest {
RelayBody body = 1;
}

message RelayBody {
string hash = 1;
string chain = 2;
Expand Down
Loading

0 comments on commit 24b92c8

Please sign in to comment.