diff --git a/Dockerfile b/Dockerfile index ce5abe12..93ad9b10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-bullseye AS builder +FROM golang:1.23.6-bookworm AS builder # Set working directory for the build WORKDIR /go/src/git.vdb.to/cerc-io/laconicd @@ -14,21 +14,24 @@ COPY . . RUN make build # Final image -FROM ubuntu:22.04 +# DEV golang image +FROM golang:1.23.6-bookworm AS base # Install ca-certificates, jq, curl, bash, and other necessary packages RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ - jq curl netcat bash bc \ + jq curl netcat-openbsd bash bc yq \ && rm -rf /var/lib/apt/lists/* -# Copy over binary from the builder -COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/build/laconicd /usr/bin/laconicd +# FROM base -# Copy over init script from builder -COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/scripts/init.sh scripts/init.sh +# # Copy over binary from the builder +# COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/build/laconicd /usr/bin/laconicd -WORKDIR / +# # Copy over init script from builder +# COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/scripts/init.sh scripts/init.sh + +# WORKDIR / # Run laconicd by default -CMD ["laconicd"] +ENTRYPOINT ["laconicd"] diff --git a/Makefile b/Makefile index ad6dfe3f..41f6a1c9 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ ifeq (,$(VERSION)) VERSION := $(shell git describe --exact-match 2>/dev/null) # if VERSION is empty, then populate it with branch's name and raw commit hash ifeq (,$(VERSION)) - VERSION := $(BRANCH)-$(COMMIT) + VERSION := $(BRANCH)-$(COMMIT) endif endif @@ -31,7 +31,7 @@ BUILDDIR ?= $(CURDIR)/build ########### go.sum: go.mod - echo "Ensure dependencies have not been modified ..." >&2 + @echo "Ensure dependencies have not been modified ..." >&2 go mod verify go mod tidy @@ -42,7 +42,7 @@ build-linux: GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build $(BUILD_TARGETS): go.sum $(BUILDDIR)/ - @echo "--> installing laconicd" + @echo "--> $@ing laconicd" go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/laconicd $(BUILDDIR)/: @@ -56,22 +56,23 @@ all: install ### Protobuf ### ################## -protoVer=0.14.0 +protoVer=0.17.1 protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) -protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) +protoVolumes=-v $(shell readlink -f ..):/mod +protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoVolumes) $(protoImageName) proto-all: proto-format proto-lint proto-gen proto-gen: @echo "Generating protobuf files..." - @$(protoImage) sh ./scripts/protocgen.sh + @$(protoRun) sh ./scripts/protocgen.sh @go mod tidy proto-format: - @$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \; + @$(protoRun) find ./ -name "*.proto" -exec clang-format -i {} \; proto-lint: - @$(protoImage) buf lint proto/ --error-format=json + @$(protoRun) buf lint proto/ --error-format=json .PHONY: proto-all proto-gen proto-format proto-lint @@ -106,3 +107,7 @@ test-e2e: test-unit: go test ./utils/... ./cmd/... -mod=readonly -test.v + +test-system: build + test -d ./tests/system/binaries || ln -sf $(BUILDDIR) ./tests/system/binaries + go test ./tests/system -v diff --git a/README.md b/README.md index 279aca92..07ff411e 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ Run tests: # integration tests make test-integration - # e2e tests - make test-e2e + # system tests + make test-system ``` ## Community diff --git a/api/cerc/auction/v1/query_grpc.pb.go b/api/cerc/auction/v1/query_grpc.pb.go index 5323a1a6..2d400bfd 100644 --- a/api/cerc/auction/v1/query_grpc.pb.go +++ b/api/cerc/auction/v1/query_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: cerc/auction/v1/query.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Query_Params_FullMethodName = "/cerc.auction.v1.Query/Params" @@ -32,6 +32,8 @@ const ( // QueryClient is the client API for Query service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Query defines the gRPC querier interface for the auction module type QueryClient interface { // Params queries auction module params Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) @@ -60,8 +62,9 @@ func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { } func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -69,8 +72,9 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . } func (c *queryClient) Auctions(ctx context.Context, in *QueryAuctionsRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryAuctionsResponse) - err := c.cc.Invoke(ctx, Query_Auctions_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Auctions_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -78,8 +82,9 @@ func (c *queryClient) Auctions(ctx context.Context, in *QueryAuctionsRequest, op } func (c *queryClient) GetAuction(ctx context.Context, in *QueryGetAuctionRequest, opts ...grpc.CallOption) (*QueryGetAuctionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetAuctionResponse) - err := c.cc.Invoke(ctx, Query_GetAuction_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetAuction_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -87,8 +92,9 @@ func (c *queryClient) GetAuction(ctx context.Context, in *QueryGetAuctionRequest } func (c *queryClient) GetBid(ctx context.Context, in *QueryGetBidRequest, opts ...grpc.CallOption) (*QueryGetBidResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetBidResponse) - err := c.cc.Invoke(ctx, Query_GetBid_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetBid_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -96,8 +102,9 @@ func (c *queryClient) GetBid(ctx context.Context, in *QueryGetBidRequest, opts . } func (c *queryClient) GetBids(ctx context.Context, in *QueryGetBidsRequest, opts ...grpc.CallOption) (*QueryGetBidsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetBidsResponse) - err := c.cc.Invoke(ctx, Query_GetBids_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetBids_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -105,8 +112,9 @@ func (c *queryClient) GetBids(ctx context.Context, in *QueryGetBidsRequest, opts } func (c *queryClient) AuctionsByBidder(ctx context.Context, in *QueryAuctionsByBidderRequest, opts ...grpc.CallOption) (*QueryAuctionsByBidderResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryAuctionsByBidderResponse) - err := c.cc.Invoke(ctx, Query_AuctionsByBidder_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_AuctionsByBidder_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -114,8 +122,9 @@ func (c *queryClient) AuctionsByBidder(ctx context.Context, in *QueryAuctionsByB } func (c *queryClient) AuctionsByOwner(ctx context.Context, in *QueryAuctionsByOwnerRequest, opts ...grpc.CallOption) (*QueryAuctionsByOwnerResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryAuctionsByOwnerResponse) - err := c.cc.Invoke(ctx, Query_AuctionsByOwner_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_AuctionsByOwner_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -123,8 +132,9 @@ func (c *queryClient) AuctionsByOwner(ctx context.Context, in *QueryAuctionsByOw } func (c *queryClient) GetAuctionModuleBalance(ctx context.Context, in *QueryGetAuctionModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetAuctionModuleBalanceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetAuctionModuleBalanceResponse) - err := c.cc.Invoke(ctx, Query_GetAuctionModuleBalance_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetAuctionModuleBalance_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -133,7 +143,9 @@ func (c *queryClient) GetAuctionModuleBalance(ctx context.Context, in *QueryGetA // QueryServer is the server API for Query service. // All implementations must embed UnimplementedQueryServer -// for forward compatibility +// for forward compatibility. +// +// Query defines the gRPC querier interface for the auction module type QueryServer interface { // Params queries auction module params Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) @@ -154,9 +166,12 @@ type QueryServer interface { mustEmbedUnimplementedQueryServer() } -// UnimplementedQueryServer must be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +// UnimplementedQueryServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedQueryServer struct{} func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") @@ -183,6 +198,7 @@ func (UnimplementedQueryServer) GetAuctionModuleBalance(context.Context, *QueryG return nil, status.Errorf(codes.Unimplemented, "method GetAuctionModuleBalance not implemented") } func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} +func (UnimplementedQueryServer) testEmbeddedByValue() {} // UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to QueryServer will @@ -192,6 +208,13 @@ type UnsafeQueryServer interface { } func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + // If the following call pancis, it indicates UnimplementedQueryServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Query_ServiceDesc, srv) } diff --git a/api/cerc/auction/v1/tx_grpc.pb.go b/api/cerc/auction/v1/tx_grpc.pb.go index fda2c039..1691eb3d 100644 --- a/api/cerc/auction/v1/tx_grpc.pb.go +++ b/api/cerc/auction/v1/tx_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: cerc/auction/v1/tx.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Msg_CreateAuction_FullMethodName = "/cerc.auction.v1.Msg/CreateAuction" @@ -29,6 +29,8 @@ const ( // MsgClient is the client API for Msg service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Tx defines the gRPC tx interface type MsgClient interface { // CreateAuction is the command for creating an auction CreateAuction(ctx context.Context, in *MsgCreateAuction, opts ...grpc.CallOption) (*MsgCreateAuctionResponse, error) @@ -52,8 +54,9 @@ func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { } func (c *msgClient) CreateAuction(ctx context.Context, in *MsgCreateAuction, opts ...grpc.CallOption) (*MsgCreateAuctionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgCreateAuctionResponse) - err := c.cc.Invoke(ctx, Msg_CreateAuction_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_CreateAuction_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -61,8 +64,9 @@ func (c *msgClient) CreateAuction(ctx context.Context, in *MsgCreateAuction, opt } func (c *msgClient) CommitBid(ctx context.Context, in *MsgCommitBid, opts ...grpc.CallOption) (*MsgCommitBidResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgCommitBidResponse) - err := c.cc.Invoke(ctx, Msg_CommitBid_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_CommitBid_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -70,8 +74,9 @@ func (c *msgClient) CommitBid(ctx context.Context, in *MsgCommitBid, opts ...grp } func (c *msgClient) RevealBid(ctx context.Context, in *MsgRevealBid, opts ...grpc.CallOption) (*MsgRevealBidResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgRevealBidResponse) - err := c.cc.Invoke(ctx, Msg_RevealBid_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_RevealBid_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -79,8 +84,9 @@ func (c *msgClient) RevealBid(ctx context.Context, in *MsgRevealBid, opts ...grp } func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -88,8 +94,9 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts } func (c *msgClient) ReleaseFunds(ctx context.Context, in *MsgReleaseFunds, opts ...grpc.CallOption) (*MsgReleaseFundsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgReleaseFundsResponse) - err := c.cc.Invoke(ctx, Msg_ReleaseFunds_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_ReleaseFunds_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -98,7 +105,9 @@ func (c *msgClient) ReleaseFunds(ctx context.Context, in *MsgReleaseFunds, opts // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer -// for forward compatibility +// for forward compatibility. +// +// Tx defines the gRPC tx interface type MsgServer interface { // CreateAuction is the command for creating an auction CreateAuction(context.Context, *MsgCreateAuction) (*MsgCreateAuctionResponse, error) @@ -114,9 +123,12 @@ type MsgServer interface { mustEmbedUnimplementedMsgServer() } -// UnimplementedMsgServer must be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} +// UnimplementedMsgServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMsgServer struct{} func (UnimplementedMsgServer) CreateAuction(context.Context, *MsgCreateAuction) (*MsgCreateAuctionResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateAuction not implemented") @@ -134,6 +146,7 @@ func (UnimplementedMsgServer) ReleaseFunds(context.Context, *MsgReleaseFunds) (* return nil, status.Errorf(codes.Unimplemented, "method ReleaseFunds not implemented") } func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} +func (UnimplementedMsgServer) testEmbeddedByValue() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to MsgServer will @@ -143,6 +156,13 @@ type UnsafeMsgServer interface { } func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { + // If the following call pancis, it indicates UnimplementedMsgServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Msg_ServiceDesc, srv) } diff --git a/api/cerc/bond/v1/query_grpc.pb.go b/api/cerc/bond/v1/query_grpc.pb.go index c429666d..7a19f40c 100644 --- a/api/cerc/bond/v1/query_grpc.pb.go +++ b/api/cerc/bond/v1/query_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: cerc/bond/v1/query.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Query_Params_FullMethodName = "/cerc.bond.v1.Query/Params" @@ -29,6 +29,8 @@ const ( // QueryClient is the client API for Query service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Query defines the gRPC querier service for bond module type QueryClient interface { // Params queries bonds module params. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) @@ -51,8 +53,9 @@ func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { } func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -60,8 +63,9 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . } func (c *queryClient) Bonds(ctx context.Context, in *QueryBondsRequest, opts ...grpc.CallOption) (*QueryBondsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryBondsResponse) - err := c.cc.Invoke(ctx, Query_Bonds_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Bonds_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -69,8 +73,9 @@ func (c *queryClient) Bonds(ctx context.Context, in *QueryBondsRequest, opts ... } func (c *queryClient) GetBondById(ctx context.Context, in *QueryGetBondByIdRequest, opts ...grpc.CallOption) (*QueryGetBondByIdResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetBondByIdResponse) - err := c.cc.Invoke(ctx, Query_GetBondById_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetBondById_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -78,8 +83,9 @@ func (c *queryClient) GetBondById(ctx context.Context, in *QueryGetBondByIdReque } func (c *queryClient) GetBondsByOwner(ctx context.Context, in *QueryGetBondsByOwnerRequest, opts ...grpc.CallOption) (*QueryGetBondsByOwnerResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetBondsByOwnerResponse) - err := c.cc.Invoke(ctx, Query_GetBondsByOwner_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetBondsByOwner_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -87,8 +93,9 @@ func (c *queryClient) GetBondsByOwner(ctx context.Context, in *QueryGetBondsByOw } func (c *queryClient) GetBondModuleBalance(ctx context.Context, in *QueryGetBondModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetBondModuleBalanceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetBondModuleBalanceResponse) - err := c.cc.Invoke(ctx, Query_GetBondModuleBalance_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetBondModuleBalance_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -97,7 +104,9 @@ func (c *queryClient) GetBondModuleBalance(ctx context.Context, in *QueryGetBond // QueryServer is the server API for Query service. // All implementations must embed UnimplementedQueryServer -// for forward compatibility +// for forward compatibility. +// +// Query defines the gRPC querier service for bond module type QueryServer interface { // Params queries bonds module params. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) @@ -112,9 +121,12 @@ type QueryServer interface { mustEmbedUnimplementedQueryServer() } -// UnimplementedQueryServer must be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +// UnimplementedQueryServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedQueryServer struct{} func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") @@ -132,6 +144,7 @@ func (UnimplementedQueryServer) GetBondModuleBalance(context.Context, *QueryGetB return nil, status.Errorf(codes.Unimplemented, "method GetBondModuleBalance not implemented") } func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} +func (UnimplementedQueryServer) testEmbeddedByValue() {} // UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to QueryServer will @@ -141,6 +154,13 @@ type UnsafeQueryServer interface { } func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + // If the following call pancis, it indicates UnimplementedQueryServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Query_ServiceDesc, srv) } diff --git a/api/cerc/bond/v1/tx_grpc.pb.go b/api/cerc/bond/v1/tx_grpc.pb.go index 7a1ae909..be99d024 100644 --- a/api/cerc/bond/v1/tx_grpc.pb.go +++ b/api/cerc/bond/v1/tx_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: cerc/bond/v1/tx.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Msg_CreateBond_FullMethodName = "/cerc.bond.v1.Msg/CreateBond" @@ -29,6 +29,8 @@ const ( // MsgClient is the client API for Msg service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Msg defines the bond Msg service. type MsgClient interface { // CreateBond defines a method for creating a new bond. CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error) @@ -52,8 +54,9 @@ func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { } func (c *msgClient) CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgCreateBondResponse) - err := c.cc.Invoke(ctx, Msg_CreateBond_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_CreateBond_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -61,8 +64,9 @@ func (c *msgClient) CreateBond(ctx context.Context, in *MsgCreateBond, opts ...g } func (c *msgClient) RefillBond(ctx context.Context, in *MsgRefillBond, opts ...grpc.CallOption) (*MsgRefillBondResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgRefillBondResponse) - err := c.cc.Invoke(ctx, Msg_RefillBond_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_RefillBond_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -70,8 +74,9 @@ func (c *msgClient) RefillBond(ctx context.Context, in *MsgRefillBond, opts ...g } func (c *msgClient) WithdrawBond(ctx context.Context, in *MsgWithdrawBond, opts ...grpc.CallOption) (*MsgWithdrawBondResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgWithdrawBondResponse) - err := c.cc.Invoke(ctx, Msg_WithdrawBond_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_WithdrawBond_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -79,8 +84,9 @@ func (c *msgClient) WithdrawBond(ctx context.Context, in *MsgWithdrawBond, opts } func (c *msgClient) CancelBond(ctx context.Context, in *MsgCancelBond, opts ...grpc.CallOption) (*MsgCancelBondResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgCancelBondResponse) - err := c.cc.Invoke(ctx, Msg_CancelBond_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_CancelBond_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -88,8 +94,9 @@ func (c *msgClient) CancelBond(ctx context.Context, in *MsgCancelBond, opts ...g } func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -98,7 +105,9 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer -// for forward compatibility +// for forward compatibility. +// +// Msg defines the bond Msg service. type MsgServer interface { // CreateBond defines a method for creating a new bond. CreateBond(context.Context, *MsgCreateBond) (*MsgCreateBondResponse, error) @@ -114,9 +123,12 @@ type MsgServer interface { mustEmbedUnimplementedMsgServer() } -// UnimplementedMsgServer must be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} +// UnimplementedMsgServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMsgServer struct{} func (UnimplementedMsgServer) CreateBond(context.Context, *MsgCreateBond) (*MsgCreateBondResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBond not implemented") @@ -134,6 +146,7 @@ func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (* return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} +func (UnimplementedMsgServer) testEmbeddedByValue() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to MsgServer will @@ -143,6 +156,13 @@ type UnsafeMsgServer interface { } func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { + // If the following call pancis, it indicates UnimplementedMsgServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Msg_ServiceDesc, srv) } diff --git a/api/cerc/onboarding/v1/onboarding.pulsar.go b/api/cerc/onboarding/v1/onboarding.pulsar.go index 692bdaf6..5f045198 100644 --- a/api/cerc/onboarding/v1/onboarding.pulsar.go +++ b/api/cerc/onboarding/v1/onboarding.pulsar.go @@ -426,7 +426,7 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { var ( md_Participant protoreflect.MessageDescriptor fd_Participant_cosmos_address protoreflect.FieldDescriptor - fd_Participant_nitro_address protoreflect.FieldDescriptor + fd_Participant_public_key protoreflect.FieldDescriptor fd_Participant_role protoreflect.FieldDescriptor fd_Participant_kyc_id protoreflect.FieldDescriptor ) @@ -435,7 +435,7 @@ func init() { file_cerc_onboarding_v1_onboarding_proto_init() md_Participant = File_cerc_onboarding_v1_onboarding_proto.Messages().ByName("Participant") fd_Participant_cosmos_address = md_Participant.Fields().ByName("cosmos_address") - fd_Participant_nitro_address = md_Participant.Fields().ByName("nitro_address") + fd_Participant_public_key = md_Participant.Fields().ByName("public_key") fd_Participant_role = md_Participant.Fields().ByName("role") fd_Participant_kyc_id = md_Participant.Fields().ByName("kyc_id") } @@ -511,9 +511,9 @@ func (x *fastReflection_Participant) Range(f func(protoreflect.FieldDescriptor, return } } - if x.NitroAddress != "" { - value := protoreflect.ValueOfString(x.NitroAddress) - if !f(fd_Participant_nitro_address, value) { + if len(x.PublicKey) != 0 { + value := protoreflect.ValueOfBytes(x.PublicKey) + if !f(fd_Participant_public_key, value) { return } } @@ -546,8 +546,8 @@ func (x *fastReflection_Participant) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "cerc.onboarding.v1.Participant.cosmos_address": return x.CosmosAddress != "" - case "cerc.onboarding.v1.Participant.nitro_address": - return x.NitroAddress != "" + case "cerc.onboarding.v1.Participant.public_key": + return len(x.PublicKey) != 0 case "cerc.onboarding.v1.Participant.role": return x.Role != "" case "cerc.onboarding.v1.Participant.kyc_id": @@ -570,8 +570,8 @@ func (x *fastReflection_Participant) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "cerc.onboarding.v1.Participant.cosmos_address": x.CosmosAddress = "" - case "cerc.onboarding.v1.Participant.nitro_address": - x.NitroAddress = "" + case "cerc.onboarding.v1.Participant.public_key": + x.PublicKey = nil case "cerc.onboarding.v1.Participant.role": x.Role = "" case "cerc.onboarding.v1.Participant.kyc_id": @@ -595,9 +595,9 @@ func (x *fastReflection_Participant) Get(descriptor protoreflect.FieldDescriptor case "cerc.onboarding.v1.Participant.cosmos_address": value := x.CosmosAddress return protoreflect.ValueOfString(value) - case "cerc.onboarding.v1.Participant.nitro_address": - value := x.NitroAddress - return protoreflect.ValueOfString(value) + case "cerc.onboarding.v1.Participant.public_key": + value := x.PublicKey + return protoreflect.ValueOfBytes(value) case "cerc.onboarding.v1.Participant.role": value := x.Role return protoreflect.ValueOfString(value) @@ -626,8 +626,8 @@ func (x *fastReflection_Participant) Set(fd protoreflect.FieldDescriptor, value switch fd.FullName() { case "cerc.onboarding.v1.Participant.cosmos_address": x.CosmosAddress = value.Interface().(string) - case "cerc.onboarding.v1.Participant.nitro_address": - x.NitroAddress = value.Interface().(string) + case "cerc.onboarding.v1.Participant.public_key": + x.PublicKey = value.Bytes() case "cerc.onboarding.v1.Participant.role": x.Role = value.Interface().(string) case "cerc.onboarding.v1.Participant.kyc_id": @@ -654,8 +654,8 @@ func (x *fastReflection_Participant) Mutable(fd protoreflect.FieldDescriptor) pr switch fd.FullName() { case "cerc.onboarding.v1.Participant.cosmos_address": panic(fmt.Errorf("field cosmos_address of message cerc.onboarding.v1.Participant is not mutable")) - case "cerc.onboarding.v1.Participant.nitro_address": - panic(fmt.Errorf("field nitro_address of message cerc.onboarding.v1.Participant is not mutable")) + case "cerc.onboarding.v1.Participant.public_key": + panic(fmt.Errorf("field public_key of message cerc.onboarding.v1.Participant is not mutable")) case "cerc.onboarding.v1.Participant.role": panic(fmt.Errorf("field role of message cerc.onboarding.v1.Participant is not mutable")) case "cerc.onboarding.v1.Participant.kyc_id": @@ -675,8 +675,8 @@ func (x *fastReflection_Participant) NewField(fd protoreflect.FieldDescriptor) p switch fd.FullName() { case "cerc.onboarding.v1.Participant.cosmos_address": return protoreflect.ValueOfString("") - case "cerc.onboarding.v1.Participant.nitro_address": - return protoreflect.ValueOfString("") + case "cerc.onboarding.v1.Participant.public_key": + return protoreflect.ValueOfBytes(nil) case "cerc.onboarding.v1.Participant.role": return protoreflect.ValueOfString("") case "cerc.onboarding.v1.Participant.kyc_id": @@ -754,7 +754,7 @@ func (x *fastReflection_Participant) ProtoMethods() *protoiface.Methods { if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.NitroAddress) + l = len(x.PublicKey) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -809,10 +809,10 @@ func (x *fastReflection_Participant) ProtoMethods() *protoiface.Methods { i-- dAtA[i] = 0x1a } - if len(x.NitroAddress) > 0 { - i -= len(x.NitroAddress) - copy(dAtA[i:], x.NitroAddress) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.NitroAddress))) + if len(x.PublicKey) > 0 { + i -= len(x.PublicKey) + copy(dAtA[i:], x.PublicKey) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.PublicKey))) i-- dAtA[i] = 0x12 } @@ -906,9 +906,9 @@ func (x *fastReflection_Participant) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 2: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NitroAddress", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -918,23 +918,25 @@ func (x *fastReflection_Participant) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.NitroAddress = string(dAtA[iNdEx:postIndex]) + x.PublicKey = append(x.PublicKey[:0], dAtA[iNdEx:postIndex]...) + if x.PublicKey == nil { + x.PublicKey = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { @@ -1577,8 +1579,8 @@ type Participant struct { // participant's cosmos (laconic) address CosmosAddress string `protobuf:"bytes,1,opt,name=cosmos_address,json=cosmosAddress,proto3" json:"cosmos_address,omitempty"` - // participant's Nitro address - NitroAddress string `protobuf:"bytes,2,opt,name=nitro_address,json=nitroAddress,proto3" json:"nitro_address,omitempty"` + // full public key used to derive participant's Nitro address + PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` // participant's role (participant | validator) Role string `protobuf:"bytes,3,opt,name=role,proto3" json:"role,omitempty"` // participant's KYC receipt ID @@ -1612,11 +1614,11 @@ func (x *Participant) GetCosmosAddress() string { return "" } -func (x *Participant) GetNitroAddress() string { +func (x *Participant) GetPublicKey() []byte { if x != nil { - return x.NitroAddress + return x.PublicKey } - return "" + return nil } func (x *Participant) GetRole() string { @@ -1692,46 +1694,43 @@ var file_cerc_onboarding_v1_onboarding_proto_rawDesc = []byte{ 0x6c, 0x65, 0x64, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x22, 0x52, 0x11, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, - 0x64, 0x22, 0xa2, 0x02, 0x0a, 0x0b, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, + 0x64, 0x22, 0xed, 0x01, 0x0a, 0x0b, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x56, 0x0a, 0x0e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2f, 0xf2, 0xde, 0x1f, 0x2b, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x52, 0x0d, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x52, 0x0a, 0x0d, 0x6e, 0x69, 0x74, - 0x72, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x2d, 0xf2, 0xde, 0x1f, 0x29, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6e, 0x69, 0x74, 0x72, - 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, - 0x22, 0x6e, 0x69, 0x74, 0x72, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x52, - 0x0c, 0x6e, 0x69, 0x74, 0x72, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x2f, 0x0a, - 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1b, 0xf2, 0xde, 0x1f, - 0x17, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x20, 0x79, 0x61, 0x6d, - 0x6c, 0x3a, 0x22, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x36, - 0x0a, 0x06, 0x6b, 0x79, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1f, - 0xf2, 0xde, 0x1f, 0x1b, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6b, 0x79, 0x63, 0x5f, 0x69, 0x64, - 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6b, 0x79, 0x63, 0x5f, 0x69, 0x64, 0x22, 0x52, - 0x05, 0x6b, 0x79, 0x63, 0x49, 0x64, 0x22, 0x76, 0x0a, 0x0a, 0x45, 0x74, 0x68, 0x50, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x3b, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, 0xf2, 0xde, 0x1f, 0x1d, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, - 0x22, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x12, 0x2b, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, - 0xf2, 0xde, 0x1f, 0x15, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6d, 0x73, 0x67, 0x22, 0x20, 0x79, - 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x73, 0x67, 0x22, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x42, 0xd4, - 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, 0x62, 0x6f, - 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0f, 0x4f, 0x6e, 0x62, 0x6f, 0x61, - 0x72, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3f, 0x67, 0x69, - 0x74, 0x2e, 0x76, 0x64, 0x62, 0x2e, 0x74, 0x6f, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2d, 0x69, 0x6f, - 0x2f, 0x6c, 0x61, 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x65, - 0x72, 0x63, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, - 0x3b, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, - 0x43, 0x4f, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, - 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x65, 0x72, 0x63, 0x5c, - 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, - 0x43, 0x65, 0x72, 0x63, 0x5c, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5c, - 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x14, 0x43, 0x65, 0x72, 0x63, 0x3a, 0x3a, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, - 0x67, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x73, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x2f, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1b, 0xf2, 0xde, 0x1f, 0x17, 0x6a, 0x73, 0x6f, 0x6e, + 0x3a, 0x22, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x72, 0x6f, + 0x6c, 0x65, 0x22, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x36, 0x0a, 0x06, 0x6b, 0x79, 0x63, + 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1f, 0xf2, 0xde, 0x1f, 0x1b, 0x6a, + 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6b, 0x79, 0x63, 0x5f, 0x69, 0x64, 0x22, 0x20, 0x79, 0x61, 0x6d, + 0x6c, 0x3a, 0x22, 0x6b, 0x79, 0x63, 0x5f, 0x69, 0x64, 0x22, 0x52, 0x05, 0x6b, 0x79, 0x63, 0x49, + 0x64, 0x22, 0x76, 0x0a, 0x0a, 0x45, 0x74, 0x68, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, + 0x3b, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x21, 0xf2, 0xde, 0x1f, 0x1d, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x22, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x2b, 0x0a, 0x03, + 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, 0xf2, 0xde, 0x1f, 0x15, 0x6a, + 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6d, 0x73, 0x67, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, + 0x6d, 0x73, 0x67, 0x22, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x42, 0xd4, 0x01, 0x0a, 0x16, 0x63, 0x6f, + 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, + 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0f, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x2e, 0x76, 0x64, 0x62, + 0x2e, 0x74, 0x6f, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2d, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x63, 0x6f, + 0x6e, 0x69, 0x63, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x6f, 0x6e, + 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x6f, 0x6e, 0x62, 0x6f, + 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4f, 0x58, 0xaa, 0x02, + 0x12, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, + 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x4f, 0x6e, 0x62, 0x6f, 0x61, + 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x65, 0x72, 0x63, 0x5c, + 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x65, 0x72, 0x63, + 0x3a, 0x3a, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/cerc/onboarding/v1/query.pulsar.go b/api/cerc/onboarding/v1/query.pulsar.go index c1a3bbaa..4d96c01e 100644 --- a/api/cerc/onboarding/v1/query.pulsar.go +++ b/api/cerc/onboarding/v1/query.pulsar.go @@ -3037,7 +3037,7 @@ var file_cerc_onboarding_v1_query_proto_rawDesc = []byte{ 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, - 0x61, 0x6e, 0x74, 0x32, 0xba, 0x04, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x95, 0x01, + 0x61, 0x6e, 0x74, 0x32, 0xc3, 0x04, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x95, 0x01, 0x0a, 0x0c, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x2c, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, @@ -3059,7 +3059,7 @@ var file_cerc_onboarding_v1_query_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x12, 0x2a, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x2f, 0x7b, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x7d, 0x12, 0xd5, 0x01, 0x0a, 0x1c, 0x47, 0x65, 0x74, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x7d, 0x12, 0xde, 0x01, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x42, 0x79, 0x4e, 0x69, 0x74, 0x72, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3c, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x51, @@ -3069,24 +3069,25 @@ var file_cerc_onboarding_v1_query_proto_rawDesc = []byte{ 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x42, 0x79, 0x4e, 0x69, 0x74, 0x72, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x38, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x32, 0x12, 0x30, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x41, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3b, 0x12, 0x39, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, - 0x2f, 0x7b, 0x6e, 0x69, 0x74, 0x72, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x7d, - 0x42, 0xcf, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, - 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x2e, 0x76, - 0x64, 0x62, 0x2e, 0x74, 0x6f, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2d, 0x69, 0x6f, 0x2f, 0x6c, 0x61, - 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, - 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x6f, 0x6e, - 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4f, 0x58, - 0xaa, 0x02, 0x12, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, - 0x6e, 0x67, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x4f, 0x6e, 0x62, - 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x65, 0x72, - 0x63, 0x5c, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x65, - 0x72, 0x63, 0x3a, 0x3a, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2d, 0x62, 0x79, 0x2d, 0x6e, 0x69, 0x74, 0x72, 0x6f, 0x2f, 0x7b, 0x6e, 0x69, 0x74, 0x72, 0x6f, + 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x7d, 0x42, 0xcf, 0x01, 0x0a, 0x16, 0x63, 0x6f, + 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, + 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x2e, 0x76, 0x64, 0x62, 0x2e, 0x74, 0x6f, 0x2f, 0x63, + 0x65, 0x72, 0x63, 0x2d, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x64, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, + 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, + 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4f, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x65, 0x72, 0x63, + 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x56, 0x31, 0xca, 0x02, + 0x12, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, + 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x4f, 0x6e, 0x62, 0x6f, 0x61, + 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x65, 0x72, 0x63, 0x3a, 0x3a, 0x4f, 0x6e, 0x62, + 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/api/cerc/onboarding/v1/query_grpc.pb.go b/api/cerc/onboarding/v1/query_grpc.pb.go index 8f8342d8..a3c90baf 100644 --- a/api/cerc/onboarding/v1/query_grpc.pb.go +++ b/api/cerc/onboarding/v1/query_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: cerc/onboarding/v1/query.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Query_Participants_FullMethodName = "/cerc.onboarding.v1.Query/Participants" @@ -27,6 +27,8 @@ const ( // QueryClient is the client API for Query service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Query defines the gRPC querier service for onboarding module type QueryClient interface { // Participants queries Participants list Participants(ctx context.Context, in *QueryParticipantsRequest, opts ...grpc.CallOption) (*QueryParticipantsResponse, error) @@ -45,8 +47,9 @@ func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { } func (c *queryClient) Participants(ctx context.Context, in *QueryParticipantsRequest, opts ...grpc.CallOption) (*QueryParticipantsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryParticipantsResponse) - err := c.cc.Invoke(ctx, Query_Participants_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Participants_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -54,8 +57,9 @@ func (c *queryClient) Participants(ctx context.Context, in *QueryParticipantsReq } func (c *queryClient) GetParticipantByAddress(ctx context.Context, in *QueryGetParticipantByAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByAddressResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetParticipantByAddressResponse) - err := c.cc.Invoke(ctx, Query_GetParticipantByAddress_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetParticipantByAddress_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -63,8 +67,9 @@ func (c *queryClient) GetParticipantByAddress(ctx context.Context, in *QueryGetP } func (c *queryClient) GetParticipantByNitroAddress(ctx context.Context, in *QueryGetParticipantByNitroAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByNitroAddressResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetParticipantByNitroAddressResponse) - err := c.cc.Invoke(ctx, Query_GetParticipantByNitroAddress_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetParticipantByNitroAddress_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -73,7 +78,9 @@ func (c *queryClient) GetParticipantByNitroAddress(ctx context.Context, in *Quer // QueryServer is the server API for Query service. // All implementations must embed UnimplementedQueryServer -// for forward compatibility +// for forward compatibility. +// +// Query defines the gRPC querier service for onboarding module type QueryServer interface { // Participants queries Participants list Participants(context.Context, *QueryParticipantsRequest) (*QueryParticipantsResponse, error) @@ -84,9 +91,12 @@ type QueryServer interface { mustEmbedUnimplementedQueryServer() } -// UnimplementedQueryServer must be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +// UnimplementedQueryServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedQueryServer struct{} func (UnimplementedQueryServer) Participants(context.Context, *QueryParticipantsRequest) (*QueryParticipantsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Participants not implemented") @@ -98,6 +108,7 @@ func (UnimplementedQueryServer) GetParticipantByNitroAddress(context.Context, *Q return nil, status.Errorf(codes.Unimplemented, "method GetParticipantByNitroAddress not implemented") } func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} +func (UnimplementedQueryServer) testEmbeddedByValue() {} // UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to QueryServer will @@ -107,6 +118,13 @@ type UnsafeQueryServer interface { } func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + // If the following call pancis, it indicates UnimplementedQueryServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Query_ServiceDesc, srv) } diff --git a/api/cerc/onboarding/v1/tx_grpc.pb.go b/api/cerc/onboarding/v1/tx_grpc.pb.go index 72d50ff0..c0cbd049 100644 --- a/api/cerc/onboarding/v1/tx_grpc.pb.go +++ b/api/cerc/onboarding/v1/tx_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: cerc/onboarding/v1/tx.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Msg_OnboardParticipant_FullMethodName = "/cerc.onboarding.v1.Msg/OnboardParticipant" @@ -25,6 +25,8 @@ const ( // MsgClient is the client API for Msg service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Msg defines the onboarding Msg service. type MsgClient interface { // OnboardParticipant defines a method for enrolling a new validator. OnboardParticipant(ctx context.Context, in *MsgOnboardParticipant, opts ...grpc.CallOption) (*MsgOnboardParticipantResponse, error) @@ -39,8 +41,9 @@ func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { } func (c *msgClient) OnboardParticipant(ctx context.Context, in *MsgOnboardParticipant, opts ...grpc.CallOption) (*MsgOnboardParticipantResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgOnboardParticipantResponse) - err := c.cc.Invoke(ctx, Msg_OnboardParticipant_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_OnboardParticipant_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -49,21 +52,27 @@ func (c *msgClient) OnboardParticipant(ctx context.Context, in *MsgOnboardPartic // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer -// for forward compatibility +// for forward compatibility. +// +// Msg defines the onboarding Msg service. type MsgServer interface { // OnboardParticipant defines a method for enrolling a new validator. OnboardParticipant(context.Context, *MsgOnboardParticipant) (*MsgOnboardParticipantResponse, error) mustEmbedUnimplementedMsgServer() } -// UnimplementedMsgServer must be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} +// UnimplementedMsgServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMsgServer struct{} func (UnimplementedMsgServer) OnboardParticipant(context.Context, *MsgOnboardParticipant) (*MsgOnboardParticipantResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OnboardParticipant not implemented") } func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} +func (UnimplementedMsgServer) testEmbeddedByValue() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to MsgServer will @@ -73,6 +82,13 @@ type UnsafeMsgServer interface { } func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { + // If the following call pancis, it indicates UnimplementedMsgServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Msg_ServiceDesc, srv) } diff --git a/api/cerc/registry/v1/query_grpc.pb.go b/api/cerc/registry/v1/query_grpc.pb.go index 59aa47e3..c1fbeac8 100644 --- a/api/cerc/registry/v1/query_grpc.pb.go +++ b/api/cerc/registry/v1/query_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: cerc/registry/v1/query.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Query_Params_FullMethodName = "/cerc.registry.v1.Query/Params" @@ -34,6 +34,8 @@ const ( // QueryClient is the client API for Query service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Query defines the gRPC querier service for registry module type QueryClient interface { // Params queries the registry module params. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) @@ -66,8 +68,9 @@ func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { } func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -75,8 +78,9 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . } func (c *queryClient) Records(ctx context.Context, in *QueryRecordsRequest, opts ...grpc.CallOption) (*QueryRecordsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryRecordsResponse) - err := c.cc.Invoke(ctx, Query_Records_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Records_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -84,8 +88,9 @@ func (c *queryClient) Records(ctx context.Context, in *QueryRecordsRequest, opts } func (c *queryClient) GetRecord(ctx context.Context, in *QueryGetRecordRequest, opts ...grpc.CallOption) (*QueryGetRecordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetRecordResponse) - err := c.cc.Invoke(ctx, Query_GetRecord_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetRecord_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -93,8 +98,9 @@ func (c *queryClient) GetRecord(ctx context.Context, in *QueryGetRecordRequest, } func (c *queryClient) GetRecordsByBondId(ctx context.Context, in *QueryGetRecordsByBondIdRequest, opts ...grpc.CallOption) (*QueryGetRecordsByBondIdResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetRecordsByBondIdResponse) - err := c.cc.Invoke(ctx, Query_GetRecordsByBondId_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetRecordsByBondId_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -102,8 +108,9 @@ func (c *queryClient) GetRecordsByBondId(ctx context.Context, in *QueryGetRecord } func (c *queryClient) NameRecords(ctx context.Context, in *QueryNameRecordsRequest, opts ...grpc.CallOption) (*QueryNameRecordsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryNameRecordsResponse) - err := c.cc.Invoke(ctx, Query_NameRecords_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_NameRecords_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -111,8 +118,9 @@ func (c *queryClient) NameRecords(ctx context.Context, in *QueryNameRecordsReque } func (c *queryClient) Whois(ctx context.Context, in *QueryWhoisRequest, opts ...grpc.CallOption) (*QueryWhoisResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryWhoisResponse) - err := c.cc.Invoke(ctx, Query_Whois_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Whois_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -120,8 +128,9 @@ func (c *queryClient) Whois(ctx context.Context, in *QueryWhoisRequest, opts ... } func (c *queryClient) LookupLrn(ctx context.Context, in *QueryLookupLrnRequest, opts ...grpc.CallOption) (*QueryLookupLrnResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryLookupLrnResponse) - err := c.cc.Invoke(ctx, Query_LookupLrn_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_LookupLrn_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -129,8 +138,9 @@ func (c *queryClient) LookupLrn(ctx context.Context, in *QueryLookupLrnRequest, } func (c *queryClient) ResolveLrn(ctx context.Context, in *QueryResolveLrnRequest, opts ...grpc.CallOption) (*QueryResolveLrnResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryResolveLrnResponse) - err := c.cc.Invoke(ctx, Query_ResolveLrn_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_ResolveLrn_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -138,8 +148,9 @@ func (c *queryClient) ResolveLrn(ctx context.Context, in *QueryResolveLrnRequest } func (c *queryClient) GetRegistryModuleBalance(ctx context.Context, in *QueryGetRegistryModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetRegistryModuleBalanceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryGetRegistryModuleBalanceResponse) - err := c.cc.Invoke(ctx, Query_GetRegistryModuleBalance_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_GetRegistryModuleBalance_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -147,8 +158,9 @@ func (c *queryClient) GetRegistryModuleBalance(ctx context.Context, in *QueryGet } func (c *queryClient) Authorities(ctx context.Context, in *QueryAuthoritiesRequest, opts ...grpc.CallOption) (*QueryAuthoritiesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryAuthoritiesResponse) - err := c.cc.Invoke(ctx, Query_Authorities_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Query_Authorities_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -157,7 +169,9 @@ func (c *queryClient) Authorities(ctx context.Context, in *QueryAuthoritiesReque // QueryServer is the server API for Query service. // All implementations must embed UnimplementedQueryServer -// for forward compatibility +// for forward compatibility. +// +// Query defines the gRPC querier service for registry module type QueryServer interface { // Params queries the registry module params. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) @@ -182,9 +196,12 @@ type QueryServer interface { mustEmbedUnimplementedQueryServer() } -// UnimplementedQueryServer must be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +// UnimplementedQueryServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedQueryServer struct{} func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") @@ -217,6 +234,7 @@ func (UnimplementedQueryServer) Authorities(context.Context, *QueryAuthoritiesRe return nil, status.Errorf(codes.Unimplemented, "method Authorities not implemented") } func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} +func (UnimplementedQueryServer) testEmbeddedByValue() {} // UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to QueryServer will @@ -226,6 +244,13 @@ type UnsafeQueryServer interface { } func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + // If the following call pancis, it indicates UnimplementedQueryServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Query_ServiceDesc, srv) } diff --git a/api/cerc/registry/v1/registry.pulsar.go b/api/cerc/registry/v1/registry.pulsar.go index af5ffe44..1fb3e977 100644 --- a/api/cerc/registry/v1/registry.pulsar.go +++ b/api/cerc/registry/v1/registry.pulsar.go @@ -1318,7 +1318,7 @@ var ( fd_Record_owners protoreflect.FieldDescriptor fd_Record_attributes protoreflect.FieldDescriptor fd_Record_names protoreflect.FieldDescriptor - fd_Record_type protoreflect.FieldDescriptor + fd_Record_types protoreflect.FieldDescriptor ) func init() { @@ -1332,7 +1332,7 @@ func init() { fd_Record_owners = md_Record.Fields().ByName("owners") fd_Record_attributes = md_Record.Fields().ByName("attributes") fd_Record_names = md_Record.Fields().ByName("names") - fd_Record_type = md_Record.Fields().ByName("type") + fd_Record_types = md_Record.Fields().ByName("types") } var _ protoreflect.Message = (*fastReflection_Record)(nil) @@ -1448,9 +1448,9 @@ func (x *fastReflection_Record) Range(f func(protoreflect.FieldDescriptor, proto return } } - if x.Type_ != "" { - value := protoreflect.ValueOfString(x.Type_) - if !f(fd_Record_type, value) { + if x.Types != "" { + value := protoreflect.ValueOfString(x.Types) + if !f(fd_Record_types, value) { return } } @@ -1485,8 +1485,8 @@ func (x *fastReflection_Record) Has(fd protoreflect.FieldDescriptor) bool { return len(x.Attributes) != 0 case "cerc.registry.v1.Record.names": return len(x.Names) != 0 - case "cerc.registry.v1.Record.type": - return x.Type_ != "" + case "cerc.registry.v1.Record.types": + return x.Types != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.v1.Record")) @@ -1519,8 +1519,8 @@ func (x *fastReflection_Record) Clear(fd protoreflect.FieldDescriptor) { x.Attributes = nil case "cerc.registry.v1.Record.names": x.Names = nil - case "cerc.registry.v1.Record.type": - x.Type_ = "" + case "cerc.registry.v1.Record.types": + x.Types = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.v1.Record")) @@ -1567,8 +1567,8 @@ func (x *fastReflection_Record) Get(descriptor protoreflect.FieldDescriptor) pro } listValue := &_Record_8_list{list: &x.Names} return protoreflect.ValueOfList(listValue) - case "cerc.registry.v1.Record.type": - value := x.Type_ + case "cerc.registry.v1.Record.types": + value := x.Types return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { @@ -1610,8 +1610,8 @@ func (x *fastReflection_Record) Set(fd protoreflect.FieldDescriptor, value proto lv := value.List() clv := lv.(*_Record_8_list) x.Names = *clv.list - case "cerc.registry.v1.Record.type": - x.Type_ = value.Interface().(string) + case "cerc.registry.v1.Record.types": + x.Types = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.v1.Record")) @@ -1656,8 +1656,8 @@ func (x *fastReflection_Record) Mutable(fd protoreflect.FieldDescriptor) protore panic(fmt.Errorf("field deleted of message cerc.registry.v1.Record is not mutable")) case "cerc.registry.v1.Record.attributes": panic(fmt.Errorf("field attributes of message cerc.registry.v1.Record is not mutable")) - case "cerc.registry.v1.Record.type": - panic(fmt.Errorf("field type of message cerc.registry.v1.Record is not mutable")) + case "cerc.registry.v1.Record.types": + panic(fmt.Errorf("field types of message cerc.registry.v1.Record is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.v1.Record")) @@ -1689,7 +1689,7 @@ func (x *fastReflection_Record) NewField(fd protoreflect.FieldDescriptor) protor case "cerc.registry.v1.Record.names": list := []string{} return protoreflect.ValueOfList(&_Record_8_list{list: &list}) - case "cerc.registry.v1.Record.type": + case "cerc.registry.v1.Record.types": return protoreflect.ValueOfString("") default: if fd.IsExtension() { @@ -1795,7 +1795,7 @@ func (x *fastReflection_Record) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } - l = len(x.Type_) + l = len(x.Types) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -1828,10 +1828,10 @@ func (x *fastReflection_Record) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.Type_) > 0 { - i -= len(x.Type_) - copy(dAtA[i:], x.Type_) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Type_))) + if len(x.Types) > 0 { + i -= len(x.Types) + copy(dAtA[i:], x.Types) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Types))) i-- dAtA[i] = 0x4a } @@ -2195,7 +2195,7 @@ func (x *fastReflection_Record) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 9: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Type_", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Types", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2223,7 +2223,7 @@ func (x *fastReflection_Record) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Type_ = string(dAtA[iNdEx:postIndex]) + x.Types = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -6753,7 +6753,7 @@ type Record struct { Owners []string `protobuf:"bytes,6,rep,name=owners,proto3" json:"owners,omitempty"` Attributes []byte `protobuf:"bytes,7,opt,name=attributes,proto3" json:"attributes,omitempty"` Names []string `protobuf:"bytes,8,rep,name=names,proto3" json:"names,omitempty"` - Type_ string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty"` + Types string `protobuf:"bytes,9,opt,name=types,proto3" json:"types,omitempty"` } func (x *Record) Reset() { @@ -6832,9 +6832,9 @@ func (x *Record) GetNames() []string { return nil } -func (x *Record) GetType_() string { +func (x *Record) GetTypes() string { if x != nil { - return x.Type_ + return x.Types } return "" } @@ -7352,7 +7352,7 @@ var file_cerc_registry_v1_registry_proto_rawDesc = []byte{ 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x62, 0x69, 0x64, 0x22, 0x52, 0x1a, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x41, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x4d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x42, 0x69, 0x64, 0x22, 0x89, 0x04, 0x0a, 0x06, 0x52, + 0x4d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x42, 0x69, 0x64, 0x22, 0x8b, 0x04, 0x0a, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x27, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x17, 0xf2, 0xde, 0x1f, 0x13, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x69, 0x64, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x69, 0x64, 0x22, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3a, @@ -7382,90 +7382,90 @@ var file_cerc_registry_v1_registry_proto_rawDesc = []byte{ 0x0a, 0x05, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x42, 0x1d, 0xf2, 0xde, 0x1f, 0x19, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x52, 0x05, 0x6e, 0x61, - 0x6d, 0x65, 0x73, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x1d, 0xf2, 0xde, 0x1f, 0x19, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, - 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x5b, 0x0a, 0x0e, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, - 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x05, - 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x65, - 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x4e, - 0x61, 0x6d, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x52, 0x05, 0x65, 0x6e, - 0x74, 0x72, 0x79, 0x22, 0xe6, 0x03, 0x0a, 0x0d, 0x4e, 0x61, 0x6d, 0x65, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x5d, 0x0a, 0x10, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x33, 0xf2, 0xde, 0x1f, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6f, 0x77, 0x6e, 0x65, 0x72, - 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x22, 0x20, 0x79, 0x61, 0x6d, - 0x6c, 0x3a, 0x22, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, - 0x6b, 0x65, 0x79, 0x22, 0x52, 0x0e, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x4b, 0x65, 0x79, 0x12, 0x52, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2d, 0xf2, 0xde, 0x1f, - 0x29, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6f, 0x77, 0x6e, 0x65, - 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x52, 0x0c, 0x6f, 0x77, 0x6e, 0x65, - 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, - 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x46, 0x0a, 0x0a, 0x61, 0x75, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0xf2, 0xde, - 0x1f, 0x23, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, - 0x69, 0x64, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x52, 0x09, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x12, 0x3a, 0x0a, 0x07, 0x62, 0x6f, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x21, 0xf2, 0xde, 0x1f, 0x1d, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x62, 0x6f, 0x6e, - 0x64, 0x5f, 0x69, 0x64, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x62, 0x6f, 0x6e, 0x64, - 0x5f, 0x69, 0x64, 0x22, 0x52, 0x06, 0x62, 0x6f, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x6e, 0x0a, 0x0b, - 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x31, 0xc8, - 0xde, 0x1f, 0x00, 0xf2, 0xde, 0x1f, 0x25, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x65, 0x78, 0x70, - 0x69, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, - 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x90, 0xdf, 0x1f, 0x01, - 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x53, 0x0a, 0x09, - 0x4e, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x32, 0x0a, - 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, - 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x2e, - 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, - 0x79, 0x22, 0x84, 0x01, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, - 0x12, 0x39, 0x0a, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x21, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x3b, 0x0a, 0x07, 0x68, - 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, - 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x2e, - 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x07, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x39, 0x0a, 0x0f, 0x4e, 0x61, 0x6d, 0x65, - 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x22, 0x74, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x12, 0x2b, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, 0xf2, - 0xde, 0x1f, 0x15, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x73, 0x69, 0x67, 0x22, 0x20, 0x79, 0x61, - 0x6d, 0x6c, 0x3a, 0x22, 0x73, 0x69, 0x67, 0x22, 0x52, 0x03, 0x73, 0x69, 0x67, 0x12, 0x3a, 0x0a, - 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, - 0xf2, 0xde, 0x1f, 0x1d, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, - 0x79, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, - 0x22, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x22, 0x33, 0x0a, 0x0b, 0x45, 0x78, 0x70, - 0x69, 0x72, 0x79, 0x51, 0x75, 0x65, 0x75, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x23, - 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x42, 0xc4, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x42, 0x0d, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3b, 0x67, - 0x69, 0x74, 0x2e, 0x76, 0x64, 0x62, 0x2e, 0x74, 0x6f, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2d, 0x69, - 0x6f, 0x2f, 0x6c, 0x61, 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, - 0x65, 0x72, 0x63, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x3b, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x52, 0x58, - 0xaa, 0x02, 0x10, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x56, 0x31, 0xca, 0x02, 0x10, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x43, 0x65, 0x72, 0x63, 0x3a, 0x3a, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6d, 0x65, 0x73, 0x12, 0x33, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x1d, 0xf2, 0xde, 0x1f, 0x19, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x74, 0x79, + 0x70, 0x65, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x22, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x5b, 0x0a, 0x0e, 0x41, 0x75, 0x74, 0x68, + 0x6f, 0x72, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x35, + 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, + 0x63, 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x52, 0x05, + 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xe6, 0x03, 0x0a, 0x0d, 0x4e, 0x61, 0x6d, 0x65, 0x41, 0x75, + 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x5d, 0x0a, 0x10, 0x6f, 0x77, 0x6e, 0x65, 0x72, + 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x33, 0xf2, 0xde, 0x1f, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6f, 0x77, 0x6e, + 0x65, 0x72, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x22, 0x20, 0x79, + 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x22, 0x52, 0x0e, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x50, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x52, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2d, 0xf2, + 0xde, 0x1f, 0x29, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x52, 0x0c, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x46, 0x0a, 0x0a, 0x61, 0x75, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, + 0xf2, 0xde, 0x1f, 0x23, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x75, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x52, 0x09, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x12, 0x3a, 0x0a, 0x07, 0x62, 0x6f, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x21, 0xf2, 0xde, 0x1f, 0x1d, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x62, + 0x6f, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x62, 0x6f, + 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x22, 0x52, 0x06, 0x62, 0x6f, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x6e, + 0x0a, 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, + 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xf2, 0xde, 0x1f, 0x25, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x65, + 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, + 0x3a, 0x22, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x90, 0xdf, + 0x1f, 0x01, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x53, + 0x0a, 0x09, 0x4e, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x32, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x05, 0x65, 0x6e, + 0x74, 0x72, 0x79, 0x22, 0x84, 0x01, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x12, 0x39, 0x0a, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x3b, 0x0a, + 0x07, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, + 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x07, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x39, 0x0a, 0x0f, 0x4e, 0x61, + 0x6d, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x74, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x12, 0x2b, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x19, 0xf2, 0xde, 0x1f, 0x15, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x73, 0x69, 0x67, 0x22, 0x20, + 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x73, 0x69, 0x67, 0x22, 0x52, 0x03, 0x73, 0x69, 0x67, 0x12, + 0x3a, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x21, 0xf2, 0xde, 0x1f, 0x1d, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x22, 0x70, 0x75, 0x62, 0x5f, + 0x6b, 0x65, 0x79, 0x22, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x70, 0x75, 0x62, 0x5f, 0x6b, + 0x65, 0x79, 0x22, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x22, 0x33, 0x0a, 0x0b, 0x45, + 0x78, 0x70, 0x69, 0x72, 0x79, 0x51, 0x75, 0x65, 0x75, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x22, 0x23, 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0xc4, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, + 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x42, 0x0d, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x3b, 0x67, 0x69, 0x74, 0x2e, 0x76, 0x64, 0x62, 0x2e, 0x74, 0x6f, 0x2f, 0x63, 0x65, 0x72, 0x63, + 0x2d, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x64, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, + 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, + 0x52, 0x58, 0xaa, 0x02, 0x10, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x10, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x43, 0x65, 0x72, 0x63, 0x5c, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x43, 0x65, 0x72, 0x63, 0x3a, 0x3a, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/cerc/registry/v1/tx_grpc.pb.go b/api/cerc/registry/v1/tx_grpc.pb.go index b2ca338b..c3adc3db 100644 --- a/api/cerc/registry/v1/tx_grpc.pb.go +++ b/api/cerc/registry/v1/tx_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: cerc/registry/v1/tx.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Msg_SetRecord_FullMethodName = "/cerc.registry.v1.Msg/SetRecord" @@ -35,6 +35,8 @@ const ( // MsgClient is the client API for Msg service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Msg is a service which exposes the registry functionality type MsgClient interface { // SetRecord records a new record with given payload and bond id SetRecord(ctx context.Context, in *MsgSetRecord, opts ...grpc.CallOption) (*MsgSetRecordResponse, error) @@ -70,8 +72,9 @@ func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { } func (c *msgClient) SetRecord(ctx context.Context, in *MsgSetRecord, opts ...grpc.CallOption) (*MsgSetRecordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgSetRecordResponse) - err := c.cc.Invoke(ctx, Msg_SetRecord_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_SetRecord_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -79,8 +82,9 @@ func (c *msgClient) SetRecord(ctx context.Context, in *MsgSetRecord, opts ...grp } func (c *msgClient) RenewRecord(ctx context.Context, in *MsgRenewRecord, opts ...grpc.CallOption) (*MsgRenewRecordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgRenewRecordResponse) - err := c.cc.Invoke(ctx, Msg_RenewRecord_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_RenewRecord_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -88,8 +92,9 @@ func (c *msgClient) RenewRecord(ctx context.Context, in *MsgRenewRecord, opts .. } func (c *msgClient) AssociateBond(ctx context.Context, in *MsgAssociateBond, opts ...grpc.CallOption) (*MsgAssociateBondResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgAssociateBondResponse) - err := c.cc.Invoke(ctx, Msg_AssociateBond_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_AssociateBond_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -97,8 +102,9 @@ func (c *msgClient) AssociateBond(ctx context.Context, in *MsgAssociateBond, opt } func (c *msgClient) DissociateBond(ctx context.Context, in *MsgDissociateBond, opts ...grpc.CallOption) (*MsgDissociateBondResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgDissociateBondResponse) - err := c.cc.Invoke(ctx, Msg_DissociateBond_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_DissociateBond_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -106,8 +112,9 @@ func (c *msgClient) DissociateBond(ctx context.Context, in *MsgDissociateBond, o } func (c *msgClient) DissociateRecords(ctx context.Context, in *MsgDissociateRecords, opts ...grpc.CallOption) (*MsgDissociateRecordsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgDissociateRecordsResponse) - err := c.cc.Invoke(ctx, Msg_DissociateRecords_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_DissociateRecords_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -115,8 +122,9 @@ func (c *msgClient) DissociateRecords(ctx context.Context, in *MsgDissociateReco } func (c *msgClient) ReassociateRecords(ctx context.Context, in *MsgReassociateRecords, opts ...grpc.CallOption) (*MsgReassociateRecordsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgReassociateRecordsResponse) - err := c.cc.Invoke(ctx, Msg_ReassociateRecords_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_ReassociateRecords_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -124,8 +132,9 @@ func (c *msgClient) ReassociateRecords(ctx context.Context, in *MsgReassociateRe } func (c *msgClient) SetName(ctx context.Context, in *MsgSetName, opts ...grpc.CallOption) (*MsgSetNameResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgSetNameResponse) - err := c.cc.Invoke(ctx, Msg_SetName_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_SetName_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -133,8 +142,9 @@ func (c *msgClient) SetName(ctx context.Context, in *MsgSetName, opts ...grpc.Ca } func (c *msgClient) DeleteName(ctx context.Context, in *MsgDeleteName, opts ...grpc.CallOption) (*MsgDeleteNameResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgDeleteNameResponse) - err := c.cc.Invoke(ctx, Msg_DeleteName_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_DeleteName_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -142,8 +152,9 @@ func (c *msgClient) DeleteName(ctx context.Context, in *MsgDeleteName, opts ...g } func (c *msgClient) ReserveAuthority(ctx context.Context, in *MsgReserveAuthority, opts ...grpc.CallOption) (*MsgReserveAuthorityResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgReserveAuthorityResponse) - err := c.cc.Invoke(ctx, Msg_ReserveAuthority_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_ReserveAuthority_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -151,8 +162,9 @@ func (c *msgClient) ReserveAuthority(ctx context.Context, in *MsgReserveAuthorit } func (c *msgClient) SetAuthorityBond(ctx context.Context, in *MsgSetAuthorityBond, opts ...grpc.CallOption) (*MsgSetAuthorityBondResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgSetAuthorityBondResponse) - err := c.cc.Invoke(ctx, Msg_SetAuthorityBond_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_SetAuthorityBond_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -160,8 +172,9 @@ func (c *msgClient) SetAuthorityBond(ctx context.Context, in *MsgSetAuthorityBon } func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -170,7 +183,9 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer -// for forward compatibility +// for forward compatibility. +// +// Msg is a service which exposes the registry functionality type MsgServer interface { // SetRecord records a new record with given payload and bond id SetRecord(context.Context, *MsgSetRecord) (*MsgSetRecordResponse, error) @@ -198,9 +213,12 @@ type MsgServer interface { mustEmbedUnimplementedMsgServer() } -// UnimplementedMsgServer must be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} +// UnimplementedMsgServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMsgServer struct{} func (UnimplementedMsgServer) SetRecord(context.Context, *MsgSetRecord) (*MsgSetRecordResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetRecord not implemented") @@ -236,6 +254,7 @@ func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (* return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} +func (UnimplementedMsgServer) testEmbeddedByValue() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to MsgServer will @@ -245,6 +264,13 @@ type UnsafeMsgServer interface { } func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { + // If the following call pancis, it indicates UnimplementedMsgServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Msg_ServiceDesc, srv) } diff --git a/app/abci.go b/app/abci.go new file mode 100644 index 00000000..51cc191a --- /dev/null +++ b/app/abci.go @@ -0,0 +1,180 @@ +package app + +import ( + "bytes" + "crypto/rand" + "encoding/gob" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + + "git.vdb.to/cerc-io/laconicd/server/distsig" +) + +type ( + // VoteExtensionHandler defines the vote extension handler for LaconicApp. + VoteExtensionHandler struct { + app *LaconicApp + } + + // VoteExtension defines the structure used to create a vote extension. + VoteExtension struct { + Hash []byte + Height int64 + Data []byte + } +) + +func NewVoteExtensionHandler() *VoteExtensionHandler { + return &VoteExtensionHandler{} +} + +func (app *LaconicApp) NewVoteExtensionHandler() *VoteExtensionHandler { + return &VoteExtensionHandler{app: app} +} + +func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { + if h.app != nil { + // Use the real laconic handlers when app is available + bApp.SetExtendVoteHandler(h.ExtendVoteWithLaconic()) + bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtensionWithLaconic()) + bApp.SetPrepareProposal(h.PrepareProposal()) + bApp.SetProcessProposal(h.ProcessProposal()) + } else { + // Use dummy handlers for testing + bApp.SetExtendVoteHandler(h.ExtendVote()) + bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension()) + } +} + +func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { + return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + buf := make([]byte, 1024) + + _, err := rand.Read(buf) + if err != nil { + return nil, fmt.Errorf("failed to generate random vote extension data: %w", err) + } + + ve := VoteExtension{ + Hash: req.Hash, + Height: req.Height, + Data: buf, + } + + bz, err := json.Marshal(ve) + if err != nil { + return nil, fmt.Errorf("failed to encode vote extension: %w", err) + } + + return &abci.ResponseExtendVote{VoteExtension: bz}, nil + } +} + +func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + var ve VoteExtension + + if err := json.Unmarshal(req.VoteExtension, &ve); err != nil { + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + switch { + case req.Height != ve.Height: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case !bytes.Equal(req.Hash, ve.Hash): + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case len(ve.Data) != 1024: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} + +// PrepareProposal is responsible for: +// - collecting Nitro state updates and applying them as inserted transactions in the block proposal +func (h *VoteExtensionHandler) PrepareProposal() sdk.PrepareProposalHandler { + return func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + + // paramsResp, err := h.app.ConsensusParamsKeeper.Params(ctx, &consensustypes.QueryParamsRequest{}) + // if err != nil { + // return nil, err + // } + + // var maxBlockGas uint64 + // if b := paramsResp.GetParams().Block; b != nil { + // maxBlockGas = uint64(b.MaxGas) + // } + + // Decode transactions from bytes + txs := make([]sdk.Tx, 0, len(req.Txs)) + for _, txBz := range req.Txs { + tx, err := h.app.txConfig.TxDecoder()(txBz) + if err != nil { + continue // Skip invalid transactions + } + txs = append(txs, tx) + } + + // For now, just return the transactions as-is + // TODO: Add custom transaction selection logic here + return &abci.ResponsePrepareProposal{Txs: req.Txs}, nil + } +} + +func (h *VoteExtensionHandler) ProcessProposal() sdk.ProcessProposalHandler { + return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + // For now, accept all proposals + // TODO: Add custom proposal validation logic here + return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + } +} + +// ExtendVoteWithLaconic implements the real Laconic-specific vote extension logic +// - renews distsig key (DKG) if validator set has changed +// - broadcasts prepared DKG and distsig messages +func (h *VoteExtensionHandler) ExtendVoteWithLaconic() sdk.ExtendVoteHandler { + return func(ctx sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + // Check if we have a distributed signature manager + // Since we can't access DistSigManager() directly in v1, we'll implement a simpler version + // TODO: Integrate with actual distributed signature manager when available + + // Check if we are a participant + if h.app.OnboardingKeeper != nil { + // For now, return empty vote extension + // TODO: Implement the full distsig logic here + return &abci.ResponseExtendVote{VoteExtension: []byte{}}, nil + } + + return &abci.ResponseExtendVote{VoteExtension: []byte{}}, nil + } +} + +// VerifyVoteExtensionWithLaconic implements the real Laconic-specific vote extension verification +func (h *VoteExtensionHandler) VerifyVoteExtensionWithLaconic() sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + if len(req.VoteExtension) == 0 { + // Empty vote extension is acceptable + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } + + // Decode and verify the vote extension + dec := gob.NewDecoder(bytes.NewReader(req.VoteExtension)) + var messages distsig.PeerMessages + if err := dec.Decode(&messages); err != nil { + // If we can't decode, reject + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + // TODO: Actually verify the messages with the distributed signature manager + // For now, just accept + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} diff --git a/app/app.go b/app/app.go index 47c1a1a5..5f641e14 100644 --- a/app/app.go +++ b/app/app.go @@ -3,22 +3,15 @@ package app import ( _ "embed" "io" - "os" - "path/filepath" dbm "github.com/cosmos/cosmos-db" - "cosmossdk.io/core/appconfig" + clienthelpers "cosmossdk.io/client/v2/helpers" "cosmossdk.io/depinject" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" evidencekeeper "cosmossdk.io/x/evidence/keeper" - auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper" - bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper" - onboardingkeeper "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper" - registrykeeper "git.vdb.to/cerc-io/laconicd/x/registry/keeper" - types "git.vdb.to/cerc-io/laconicd/x/types/v1" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -35,41 +28,40 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - "github.com/cosmos/cosmos-sdk/x/genutil" - genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/cosmos/cosmos-sdk/x/gov" - govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" + protocolpoolkeeper "github.com/cosmos/cosmos-sdk/x/protocolpool/keeper" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - _ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects - _ "cosmossdk.io/x/evidence" // import for side-effects + auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper" + bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper" + nitrokeeper "git.vdb.to/cerc-io/laconicd/x/nitro/keeper" + onboardingkeeper "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper" + registrykeeper "git.vdb.to/cerc-io/laconicd/x/registry/keeper" + types "git.vdb.to/cerc-io/laconicd/x/types/v1" + + _ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects + _ "cosmossdk.io/x/evidence" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/auth" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/bank" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/protocolpool" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects + _ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects + _ "git.vdb.to/cerc-io/laconicd/x/auction/module" // import for side-effects _ "git.vdb.to/cerc-io/laconicd/x/bond/module" // import for side-effects _ "git.vdb.to/cerc-io/laconicd/x/onboarding/module" // import for side-effects _ "git.vdb.to/cerc-io/laconicd/x/registry/module" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/auth" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/bank" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects - _ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects ) // DefaultNodeHome default home directories for the application daemon var DefaultNodeHome string -//go:embed app.yaml -var AppConfigYAML []byte - var ( _ runtime.AppI = (*LaconicApp)(nil) _ servertypes.Application = (*LaconicApp)(nil) @@ -85,52 +77,36 @@ type LaconicApp struct { txConfig client.TxConfig interfaceRegistry codectypes.InterfaceRegistry - // keepers + // essential keepers AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper + BankKeeper bankkeeper.BaseKeeper StakingKeeper *stakingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper DistrKeeper distrkeeper.Keeper GovKeeper *govkeeper.Keeper - CrisisKeeper *crisiskeeper.Keeper ConsensusParamsKeeper consensuskeeper.Keeper EvidenceKeeper evidencekeeper.Keeper + // supplementary keepers + ProtocolPoolKeeper protocolpoolkeeper.Keeper + // laconic keepers - AuctionKeeper *auctionkeeper.Keeper // (Use * as per ProvideModule implementation) + AuctionKeeper *auctionkeeper.Keeper BondKeeper *bondkeeper.Keeper RegistryKeeper registrykeeper.Keeper OnboardingKeeper *onboardingkeeper.Keeper + NitroKeeper nitrokeeper.Keeper // simulation manager sm *module.SimulationManager } func init() { - userHomeDir, err := os.UserHomeDir() + var err error + DefaultNodeHome, err = clienthelpers.GetNodeHomeDirectory(".laconicd") if err != nil { panic(err) } - - DefaultNodeHome = filepath.Join(userHomeDir, ".laconicd") -} - -// AppConfig returns the default app config. -func AppConfig() depinject.Config { - return depinject.Configs( - appconfig.LoadYAML(AppConfigYAML), - depinject.Supply( - // supply custom module basics - map[string]module.AppModuleBasic{ - genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - govtypes.ModuleName: gov.NewAppModuleBasic( - []govclient.ProposalHandler{ - paramsclient.ProposalHandler, - }, - ), - }, - ), - ) } // NewLaconicApp returns a reference to an initialized LaconicApp. @@ -145,16 +121,20 @@ func NewLaconicApp( var ( app = &LaconicApp{} appBuilder *runtime.AppBuilder - ) - if err := depinject.Inject( - depinject.Configs( - AppConfig(), + appConfig = depinject.Configs( + AppModuleConfig, depinject.Supply( logger, appOpts, ), - ), + ) + ) + + // if err := depinject.Inject(appConfig, + if err := depinject.InjectDebug( + depinject.FileLogger("/Users/roy/vulcanize/dump/laconic-debug/depinject_app.log"), + appConfig, &appBuilder, &app.appCodec, &app.legacyAmino, @@ -166,13 +146,14 @@ func NewLaconicApp( &app.SlashingKeeper, &app.DistrKeeper, &app.GovKeeper, - &app.CrisisKeeper, &app.ConsensusParamsKeeper, &app.EvidenceKeeper, + &app.ProtocolPoolKeeper, &app.AuctionKeeper, &app.BondKeeper, &app.RegistryKeeper, &app.OnboardingKeeper, + &app.NitroKeeper, ); err != nil { return nil, err } @@ -181,6 +162,13 @@ func NewLaconicApp( RegisterCustomInterfaces(app.interfaceRegistry) RegisterCustomLegacyAminoCodec(app.legacyAmino) + // create and set vote extension handler + voteExtOp := func(bApp *baseapp.BaseApp) { + voteExtHandler := app.NewVoteExtensionHandler() + voteExtHandler.SetHandlers(bApp) + } + baseAppOptions = append(baseAppOptions, voteExtOp, baseapp.SetOptimisticExecution()) + app.App = appBuilder.Build(db, traceStore, baseAppOptions...) // register streaming services @@ -190,15 +178,13 @@ func NewLaconicApp( /**** Module Options ****/ - app.ModuleManager.RegisterInvariants(app.CrisisKeeper) - // create the simulation manager and define the order of the modules for deterministic simulations // NOTE: this is not required apps that don't use the simulator for fuzz testing transactions app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, make(map[string]module.AppModuleSimulation, 0)) app.sm.RegisterStoreDecoders() - // set custom ante handlers - app.setCustomAnteHandler() + // set custom ante handler + app.setAnteHandler() if err := app.Load(loadLatest); err != nil { return nil, err @@ -207,12 +193,56 @@ func NewLaconicApp( return app, nil } +// setCustomAnteHandler overwrites default ante handlers with custom ante handlers +// Reference: https://github.com/cosmos/cosmos-sdk/blob/v0.50.10/x/auth/tx/config/config.go#L149 +func (app *LaconicApp) setAnteHandler() error { + anteHandler, err := ante.NewAnteHandler( + ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + SignModeHandler: app.txConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + TxFeeChecker: checkTxFeeWithValidatorMinGasPrices, + }, + ) + if err != nil { + return err + } + + // Set the AnteHandler for the app + app.SetAnteHandler(anteHandler) + return nil +} + // LegacyAmino returns LaconicApp's amino codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. func (app *LaconicApp) LegacyAmino() *codec.LegacyAmino { return app.legacyAmino } +// AppCodec returns LaconicApp's app codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. +func (app *LaconicApp) AppCodec() codec.Codec { + return app.appCodec +} + +// InterfaceRegistry returns LaconicApp's InterfaceRegistry. +func (app *LaconicApp) InterfaceRegistry() codectypes.InterfaceRegistry { + return app.interfaceRegistry +} + +// TxConfig returns LaconicApp's TxConfig +func (app *LaconicApp) TxConfig() client.TxConfig { + return app.txConfig +} + // GetKey returns the KVStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. func (app *LaconicApp) GetKey(storeKey string) *storetypes.KVStoreKey { sk := app.UnsafeFindStoreKey(storeKey) kvStoreKey, ok := sk.(*storetypes.KVStoreKey) diff --git a/app/app.yaml b/app/app.yaml index 7ec30bad..9cfdf869 100644 --- a/app/app.yaml +++ b/app/app.yaml @@ -6,14 +6,35 @@ modules: # During begin block slashing happens after distr.BeginBlocker so that # there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant. # NOTE: staking module is required if HistoricalEntries param > 0 - begin_blockers: [distribution, slashing, evidence, staking] - end_blockers: [crisis, gov, staking, auction, registry] + begin_blockers: [distribution, protocolpool, slashing, evidence, staking] + end_blockers: [gov, staking, protocolpool, auction, registry] # NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts. # NOTE: The genutils module must also occur after auth so that it can access the params from auth. - init_genesis: [auth, bank, distribution, staking, slashing, gov, crisis, genutil, evidence, auction, bond, registry, onboarding] + init_genesis: + - consensus + - auth + - bank + - distribution + - staking + - slashing + - gov + - genutil + - evidence + - protocolpool + - auction + - bond + - registry + - onboarding + - nitro override_store_keys: - module_name: auth kv_store_key: acc + skip_store_keys: + - tx + - validate + - genutil + - runtime + - vesting - name: auth config: "@type": cosmos.auth.module.v1.Module @@ -27,6 +48,8 @@ modules: permissions: [burner, staking] - account: gov permissions: [burner] + - account: protocolpool + - account: protocolpool_escrow - account: auction - account: auction_burn - account: bond @@ -34,11 +57,12 @@ modules: - account: record_rent - account: authority_rent - account: lps_lockup + enable_unordered_transactions: true - name: bank config: "@type": cosmos.bank.module.v1.Module blocked_module_accounts_override: - [auth, distribution, bonded_tokens_pool, not_bonded_tokens_pool] + [fee_collector, distribution, bonded_tokens_pool, not_bonded_tokens_pool] - name: staking config: "@type": cosmos.staking.module.v1.Module @@ -60,12 +84,12 @@ modules: - name: gov config: "@type": cosmos.gov.module.v1.Module - - name: crisis - config: - "@type": cosmos.crisis.module.v1.Module - name: evidence config: "@type": cosmos.evidence.module.v1.Module + - name: protocolpool + config: + "@type": cosmos.protocolpool.module.v1.Module - name: bond config: "@type": cerc.bond.module.v1.Module @@ -78,3 +102,6 @@ modules: - name: onboarding config: "@type": cerc.onboarding.module.v1.Module + - name: nitro + config: + "@type": cerc.nitro.module.v1.Module diff --git a/app/app_test.go b/app/app_test.go new file mode 100644 index 00000000..6755ef51 --- /dev/null +++ b/app/app_test.go @@ -0,0 +1,50 @@ +package app + +import ( + "fmt" + "testing" + + abci "github.com/cometbft/cometbft/abci/types" + dbm "github.com/cosmos/cosmos-db" + "github.com/stretchr/testify/require" + + "cosmossdk.io/log" + + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" +) + +func TestLaconicAppExportAndBlockedAccounts(t *testing.T) { + db := dbm.NewMemDB() + logger := log.NewTestLogger(t) + app := NewLaconicAppWithCustomOptions(t, false, SetupOptions{ + Logger: logger.With("instance", "first"), + DB: db, + AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), + }) + + // BlockedAddresses returns a map of addresses in app v1 and a map of modules name in app di. + for _, acc := range BlockedAccounts() { + addr := app.AccountKeeper.GetModuleAddress(acc) + + require.True( + t, + app.BankKeeper.BlockedAddr(addr), + fmt.Sprintf("ensure that blocked addresses are properly set in bank keeper: %s should be blocked", acc), + ) + } + + // finalize block so we have CheckTx state set + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: 1, + }) + require.NoError(t, err) + + _, err = app.Commit() + require.NoError(t, err) + + // Making a new app object with the db, so that initchain hasn't been called + app2, err := NewLaconicApp(logger.With("instance", "second"), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir())) + require.NoError(t, err) + _, err = app2.ExportAppStateAndValidators(false, []string{}, []string{}) + require.NoError(t, err, "ExportAppStateAndValidators should not have an error") +} diff --git a/app/config.go b/app/config.go new file mode 100644 index 00000000..906a0bc9 --- /dev/null +++ b/app/config.go @@ -0,0 +1,42 @@ +package app + +import ( + _ "embed" + + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/gov" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "git.vdb.to/cerc-io/laconicd/server" + "git.vdb.to/cerc-io/laconicd/utils" +) + +var ( + //go:embed app.yaml + AppModuleConfigYAML []byte + + // AppModuleConfig returns the default app config. + AppModuleConfig = depinject.Configs( + appconfig.LoadYAML(AppModuleConfigYAML), + depinject.Provide( + server.NewGasService, + ), + depinject.Supply( + utils.NewAddressCodec, + utils.NewValidatorAddressCodec, + utils.NewConsensusAddressCodec, + // supply custom module basics + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + govtypes.ModuleName: gov.NewAppModuleBasic( + []govclient.ProposalHandler{}, + ), + }, + ), + ) +) diff --git a/app/config/config.go b/app/config/config.go new file mode 100644 index 00000000..14c551d3 --- /dev/null +++ b/app/config/config.go @@ -0,0 +1,62 @@ +package config + +import ( + "fmt" + + serverconfig "github.com/cosmos/cosmos-sdk/server/config" + "github.com/pelletier/go-toml/v2" + + "git.vdb.to/cerc-io/laconicd/app/params" + "git.vdb.to/cerc-io/laconicd/server/nitro" + "git.vdb.to/cerc-io/laconicd/server/relay" +) + +type LaconicAppConfig struct { + serverconfig.Config `mapstructure:",squash"` + customConfigs `mapstructure:",squash"` +} + +// the custom parts of the full config, so we can encode them separately +type customConfigs struct { + Nitro nitro.Config `mapstructure:"nitro" toml:"nitro"` + Relay relay.Config `mapstructure:"relay" toml:"relay"` +} + +var DefaultConfigTemplate string + +func init() { + var err error + DefaultConfigTemplate, err = createConfigTemplate() + if err != nil { + panic(err) + } +} + +func DefaultConfig() LaconicAppConfig { + srvCfg := serverconfig.DefaultConfig() + // In laconicd, we set the min gas prices to 0. + srvCfg.MinGasPrices = "0" + params.CoinUnit + + // Now we set the custom config default values. + customAppConfig := LaconicAppConfig{ + *srvCfg, + customConfigs{ + Nitro: *nitro.DefaultConfig(), + Relay: *relay.DefaultConfig(), + }, + } + return customAppConfig +} + +func createConfigTemplate() (string, error) { + defaultCustomConfigs := customConfigs{ + Nitro: *nitro.DefaultConfig(), + Relay: *relay.DefaultConfig(), + } + b, err := toml.Marshal(defaultCustomConfigs) + if err != nil { + return "", err + } + + return fmt.Sprintf("%s\n%s", serverconfig.DefaultConfigTemplate, b), nil +} diff --git a/app/export.go b/app/export.go index 2ff81849..222d6f16 100644 --- a/app/export.go +++ b/app/export.go @@ -2,12 +2,13 @@ package app import ( "encoding/json" - "errors" "fmt" "log" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + storetypes "cosmossdk.io/store/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -15,14 +16,11 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) -// ExportAppStateAndValidators exports the state of the application for a genesis file. -func (app *LaconicApp) ExportAppStateAndValidators( - forZeroHeight bool, - jailAllowedAddrs []string, - modulesToExport []string, -) (servertypes.ExportedApp, error) { +// ExportAppStateAndValidators exports the state of the application for a genesis +// file. +func (app *LaconicApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, modulesToExport []string) (servertypes.ExportedApp, error) { // as if they could withdraw from the start of the next block - ctx := app.NewContextLegacy(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()}) // We export at last height + 1, because that's the height at which // CometBFT will start InitChain. @@ -32,9 +30,9 @@ func (app *LaconicApp) ExportAppStateAndValidators( app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) } - genState, err := app.ModuleManager.ExportGenesis(ctx, app.appCodec) + genState, err := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) if err != nil { - return servertypes.ExportedApp{}, fmt.Errorf("failed to export genesis state: %w", err) + return servertypes.ExportedApp{}, err } appState, err := json.MarshalIndent(genState, "", " ") @@ -47,19 +45,18 @@ func (app *LaconicApp) ExportAppStateAndValidators( AppState: appState, Validators: validators, Height: height, - ConsensusParams: app.BaseApp.GetConsensusParams(ctx), + ConsensusParams: app.GetConsensusParams(ctx), }, err } // prepare for fresh start at zero height -// NOTE zero height genesis is a temporary feature, which will be deprecated in favor of export at a block height +// NOTE zero height genesis is a temporary feature which will be deprecated +// +// in favor of export at a block height func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { - applyAllowedAddrs := false + applyAllowedAddrs := len(jailAllowedAddrs) > 0 // check if there is a allowed address list - if len(jailAllowedAddrs) > 0 { - applyAllowedAddrs = true - } allowedAddrsMap := make(map[string]bool) @@ -74,15 +71,17 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr /* Handle fee distribution state. */ // withdraw all validator commission - _ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) if err != nil { panic(err) } - _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz) return false }) + if err != nil { + panic(err) + } // withdraw all delegator rewards dels, err := app.StakingKeeper.GetAllDelegations(ctx) @@ -96,10 +95,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr panic(err) } - delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) - if err != nil { - panic(err) - } + delAddr := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) } @@ -115,23 +111,20 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr ctx = ctx.WithBlockHeight(0) // reinitialize all validators - _ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) if err != nil { panic(err) } - // donate any unwithdrawn outstanding reward fraction tokens to the community pool scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz) if err != nil { panic(err) } - feePool, err := app.DistrKeeper.FeePool.Get(ctx) if err != nil { panic(err) } - feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) if err := app.DistrKeeper.FeePool.Set(ctx, feePool); err != nil { panic(err) @@ -149,11 +142,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr if err != nil { panic(err) } - - delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress) - if err != nil { - panic(err) - } + delAddr := sdk.MustAccAddressFromBech32(del.DelegatorAddress) if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil { // never called as BeforeDelegationCreated always returns nil @@ -172,36 +161,45 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr /* Handle staking state. */ // iterate through redelegations, reset creation height - _ = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { + err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { for i := range red.Entries { red.Entries[i].CreationHeight = 0 } - _ = app.StakingKeeper.SetRedelegation(ctx, red) + err = app.StakingKeeper.SetRedelegation(ctx, red) + if err != nil { + panic(err) + } return false }) + if err != nil { + panic(fmt.Errorf("error while iterating redelegations: %w", err)) + } // iterate through unbonding delegations, reset creation height - _ = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { + err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { for i := range ubd.Entries { ubd.Entries[i].CreationHeight = 0 } - _ = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) + err = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) + if err != nil { + panic(err) + } return false }) + if err != nil { + panic(fmt.Errorf("error while iterating unbonding delegations: %w", err)) + } // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) - counter := int16(0) for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key())) validator, err := app.StakingKeeper.GetValidator(ctx, addr) - if errors.Is(err, stakingtypes.ErrNoValidatorFound) { + if err != nil { panic("expected validator, not found") - } else if err != nil { - panic(err) } validator.UnbondingHeight = 0 @@ -209,8 +207,10 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr validator.Jailed = true } - _ = app.StakingKeeper.SetValidator(ctx, validator) - counter++ + err = app.StakingKeeper.SetValidator(ctx, validator) + if err != nil { + panic(fmt.Errorf("unable to set validator: %w", err)) + } } if err := iter.Close(); err != nil { @@ -232,12 +232,12 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr info.StartHeight = 0 err = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) if err != nil { - log.Fatal(err) + panic("unable to set validator signing info") } return false }, ) if err != nil { - log.Fatal(err) + panic(fmt.Errorf("error while iterating validator signing info: %w", err)) } } diff --git a/app/params/config.go b/app/params/config.go index 6e728934..97fc10a7 100644 --- a/app/params/config.go +++ b/app/params/config.go @@ -39,6 +39,7 @@ var ( func init() { SetAddressPrefixes() RegisterDenoms() + sdk.DefaultBondDenom = CoinUnit } func RegisterDenoms() { diff --git a/cmd/laconicd/cmd/commands.go b/cmd/laconicd/cmd/commands.go index 96ec6765..9eafd01b 100644 --- a/cmd/laconicd/cmd/commands.go +++ b/cmd/laconicd/cmd/commands.go @@ -1,21 +1,18 @@ package cmd import ( - "context" "errors" "io" + "github.com/cometbft/cometbft/node" dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cobra" "github.com/spf13/viper" - "golang.org/x/sync/errgroup" "cosmossdk.io/log" confixcmd "cosmossdk.io/tools/confix/cmd" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/debug" - "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" @@ -25,37 +22,41 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" "git.vdb.to/cerc-io/laconicd/app" "git.vdb.to/cerc-io/laconicd/gql" + laconicserver "git.vdb.to/cerc-io/laconicd/server" + "git.vdb.to/cerc-io/laconicd/server/nitro" + "git.vdb.to/cerc-io/laconicd/server/relay" ) -func initRootCmd(rootCmd *cobra.Command, txConfig client.TxConfig, basicManager module.BasicManager) { +func initRootCmd( + rootCmd *cobra.Command, + txConfig client.TxConfig, + basicManager module.BasicManager, +) *laconicserver.ServerAux { cfg := sdk.GetConfig() cfg.Seal() rootCmd.AddCommand( genutilcli.InitCmd(basicManager, app.DefaultNodeHome), + NewTestnetCmd(basicManager, banktypes.GenesisBalancesIterator{}), debug.Cmd(), confixcmd.ConfigCommand(), pruning.Cmd(newApp, app.DefaultNodeHome), snapshot.Cmd(newApp), ) - server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, func(startCmd *cobra.Command) { - // Override start command to run the GQL server - newStartCmd := server.StartCmdWithOptions(newApp, app.DefaultNodeHome, server.StartCmdOptions{ - PostSetup: func(svrCtx *server.Context, clientCtx client.Context, ctx context.Context, g *errgroup.Group) error { - g.Go(func() error { - return gql.Server(ctx, clientCtx, svrCtx.Logger.With("module", "gql-server")) - }) - - return nil - }, - }) - - startCmd.RunE = newStartCmd.RunE + addStartComponents := func(startCmd *cobra.Command) { + laconicserver.SetRequiredComponents(startCmd, &gql.Server{}, &nitro.Server{}, &relay.Server{}) + } + var srv laconicserver.ServerAux + server.AddCommandsWithStartCmdOptions(rootCmd, app.DefaultNodeHome, newApp, appExport, server.StartCmdOptions{ + AddFlags: addStartComponents, + // reactors will be configured at start, after the command is fully initialized + CometNodeOptions: []node.Option{srv.AddReactors}, }) // Capture the genesis command from genutilcli and add new commands @@ -65,11 +66,60 @@ func initRootCmd(rootCmd *cobra.Command, txConfig client.TxConfig, basicManager // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( server.StatusCommand(), - genesisCmd, + genesisCommand(txConfig, basicManager), queryCommand(), txCommand(), keys.Commands(), ) + return &srv +} + +// initializes all server components needed by a command +func initComponents( + configMap laconicserver.ConfigMap, + clientCtx client.Context, + logger log.Logger, + needComponent func(string) bool, +) ([]laconicserver.ServerComponent, error) { + var ( + components []laconicserver.ServerComponent + gqlServer = &gql.Server{} + nitroServer = &nitro.Server{} + relayServer = &relay.Server{} + err error + ) + if needComponent(gqlServer.Name()) { + gqlServer, err = gql.New(clientCtx, configMap, logger.With("module", "gql-server")) + if err != nil { + return nil, err + } + components = append(components, gqlServer) + } + if needComponent(nitroServer.Name()) { + nitroServer, err = nitro.New(configMap, logger, clientCtx.Keyring) + if err != nil { + return nil, err + } + components = append(components, nitroServer) + } + if needComponent(relayServer.Name()) { + relayServer, err = relay.New(configMap, logger) + if err != nil { + return nil, err + } + components = append(components, relayServer) + } + return components, nil +} + +// genesisCommand builds genesis-related `laconicd genesis` command. Users may provide application specific commands as a parameter +func genesisCommand(txConfig client.TxConfig, basicManager module.BasicManager, cmds ...*cobra.Command) *cobra.Command { + cmd := genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome) + + for _, subCmd := range cmds { + cmd.AddCommand(subCmd) + } + return cmd } func queryCommand() *cobra.Command { @@ -83,7 +133,7 @@ func queryCommand() *cobra.Command { } cmd.AddCommand( - rpc.ValidatorCommand(), + rpc.WaitTxCmd(), server.QueryBlockCmd(), authcmd.QueryTxsByEventsCmd(), server.QueryBlocksCmd(), @@ -118,18 +168,26 @@ func txCommand() *cobra.Command { return cmd } -// newApp is an appCreator -func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { +// newApp creates the application +func newApp( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + appOpts servertypes.AppOptions, +) servertypes.Application { baseappOptions := server.DefaultBaseappOptions(appOpts) - app, err := app.NewLaconicApp(logger, db, traceStore, true, appOpts, baseappOptions...) + ret, err := app.NewLaconicApp( + logger, db, traceStore, true, + appOpts, + baseappOptions..., + ) if err != nil { panic(err) } - - return app + return ret } -// appExport creates a new app (optionally at a given height) and exports state. +// appExport creates a new laconicd (optionally at a given height) and exports state. func appExport( logger log.Logger, db dbm.DB, @@ -140,18 +198,6 @@ func appExport( appOpts servertypes.AppOptions, modulesToExport []string, ) (servertypes.ExportedApp, error) { - var ( - laconicApp *app.LaconicApp - err error - ) - - // this check is necessary as we use the flag in x/upgrade. - // we can exit more gracefully by checking the flag here. - homePath, ok := appOpts.Get(flags.FlagHome).(string) - if !ok || homePath == "" { - return servertypes.ExportedApp{}, errors.New("application home not set") - } - viperAppOpts, ok := appOpts.(*viper.Viper) if !ok { return servertypes.ExportedApp{}, errors.New("appOpts is not viper.Viper") @@ -161,18 +207,17 @@ func appExport( viperAppOpts.Set(server.FlagInvCheckPeriod, 1) appOpts = viperAppOpts + var laconicApp *app.LaconicApp + var err error if height != -1 { - laconicApp, err = app.NewLaconicApp(logger, db, traceStore, false, appOpts) - if err != nil { + if laconicApp, err = app.NewLaconicApp(logger, db, traceStore, false, appOpts); err != nil { return servertypes.ExportedApp{}, err } - - if err := laconicApp.LoadHeight(height); err != nil { + if err = laconicApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - laconicApp, err = app.NewLaconicApp(logger, db, traceStore, true, appOpts) - if err != nil { + if laconicApp, err = app.NewLaconicApp(logger, db, traceStore, true, appOpts); err != nil { return servertypes.ExportedApp{}, err } } diff --git a/cmd/laconicd/cmd/config.go b/cmd/laconicd/cmd/config.go new file mode 100644 index 00000000..975d1fe6 --- /dev/null +++ b/cmd/laconicd/cmd/config.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "time" + + cmtcfg "github.com/cometbft/cometbft/config" +) + +// initCometBFTConfig helps to override default CometBFT config values. +func initCometBFTConfig() *cmtcfg.Config { + cfg := cmtcfg.DefaultConfig() + + // display only warn logs by default for builtin modules except server, p2p, state + cfg.LogLevel = "*:warn,server:info,p2p:info,state:info" + cfg.LogLevel += ",auction:info,bond:info,registry:info,gql-server:info" + + // // TODO: understand full meaning of these settings + cfg.Consensus.TimeoutPropose = 5000 * time.Millisecond + // cfg.Consensus.TimeoutProposeDelta = 500 * time.Millisecond + // cfg.Consensus.TimeoutPrevote = 1000 * time.Millisecond + // cfg.Consensus.TimeoutPrevoteDelta = 500 * time.Millisecond + // cfg.Consensus.TimeoutPrecommit = 1000 * time.Millisecond + // cfg.Consensus.TimeoutPrecommitDelta = 500 * time.Millisecond + + // // start new block as soon as 2/3 precommits are received + // cfg.Consensus.TimeoutCommit = 0 * time.Second + + cfg.Consensus.CreateEmptyBlocks = false + + // overwrite default pprof listen address + cfg.RPC.PprofListenAddress = "localhost:6060" + // use previous db backend + cfg.DBBackend = "goleveldb" + + return cfg +} diff --git a/cmd/laconicd/cmd/log.go b/cmd/laconicd/cmd/log.go new file mode 100644 index 00000000..87fd3e8f --- /dev/null +++ b/cmd/laconicd/cmd/log.go @@ -0,0 +1,87 @@ +package cmd + +import ( + "fmt" + "io" + "log/slog" + "math" + "time" + + "cosmossdk.io/log" + sdk_slog "cosmossdk.io/log/slog" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/lmittmann/tint" + + "git.vdb.to/cerc-io/laconicd/server" +) + +func createSlogLogger(cfg server.ConfigMap, out io.Writer) (log.Logger, error) { + handler, err := createSlogHandler(cfg, out) + if err != nil { + return nil, err + } + return sdk_slog.NewCustomLogger(slog.New(handler)), nil +} + +func createSlogHandler(cfg server.ConfigMap, out io.Writer) (slog.Handler, error) { + var ( + format string + noColor bool + level string + ) + if v, ok := cfg[flags.FlagLogFormat]; ok { + format = v.(string) + } + if v, ok := cfg[flags.FlagLogNoColor]; ok { + noColor = v.(bool) + } + if v, ok := cfg[flags.FlagLogLevel]; ok { + level = v.(string) + } + + logLvl, err := parseSlogLevel(level) + if err != nil { + // If the log level is not a valid zerolog level, then we try to parse it as a key filter. + filterFunc, err := log.ParseLogLevelWithParser(level, parseSlogLevel) + if err != nil { + return nil, err + } + out = log.NewFilterWriter(out, filterFunc) + } + + var handler slog.Handler + // if json format is requested, ignore no_color + if format == flags.OutputFormatJSON { + handler = slog.NewJSONHandler(out, &slog.HandlerOptions{ + Level: logLvl, + }) + } else { + handler = tint.NewHandler(out, &tint.Options{ + Level: logLvl, + TimeFormat: time.RFC3339Nano, + NoColor: noColor, + }) + } + return handler, nil +} + +func parseSlogLevel(l string) (slog.Level, error) { + // Legal log level values are hardcoded into server/v2 command factory: + // (trace|debug|info|warn|error|fatal|panic|disabled or '*:,:') + // however, slog only has debug, info, warn, error + switch l { + case "debug", "trace": + return slog.LevelDebug, nil + case "info": + return slog.LevelInfo, nil + case "warn": + return slog.LevelWarn, nil + case "error": + return slog.LevelError, nil + case "fatal", "panic": + return slog.LevelError, nil + case "disabled": + return slog.Level(math.MaxInt), nil + } + return 0, fmt.Errorf("invalid log level: %s", l) +} diff --git a/cmd/laconicd/cmd/root.go b/cmd/laconicd/cmd/root.go index 6e91a710..e2739d22 100644 --- a/cmd/laconicd/cmd/root.go +++ b/cmd/laconicd/cmd/root.go @@ -1,26 +1,23 @@ package cmd import ( - "fmt" "os" - "time" - cmtcfg "github.com/cometbft/cometbft/config" "github.com/spf13/cobra" + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" "cosmossdk.io/client/v2/autocli" clientv2keyring "cosmossdk.io/client/v2/autocli/keyring" "cosmossdk.io/core/address" "cosmossdk.io/depinject" "cosmossdk.io/log" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/config" + clientconfig "github.com/cosmos/cosmos-sdk/client/config" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" - serverconfig "github.com/cosmos/cosmos-sdk/server/config" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" @@ -28,16 +25,19 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "git.vdb.to/cerc-io/laconicd/app" - "git.vdb.to/cerc-io/laconicd/app/params" - "git.vdb.to/cerc-io/laconicd/gql" - types "git.vdb.to/cerc-io/laconicd/x/types/v1" + appconfig "git.vdb.to/cerc-io/laconicd/app/config" ) -const EnvPrefix = "LACONIC" +const ( + // EnvPrefix is the environment variable prefix for the application + EnvPrefix = "LACONIC" -// NewRootCmd creates a new root command for laconicd. It is called once in the -// main function. -func NewRootCmd() *cobra.Command { + // DefaultNodeHome is the default data directory name for the application + DefaultNodeHome = ".laconicd" +) + +// NewRootCmd creates a new root command for laconicd. It is called once in the main function. +func NewRootCmd(args ...string) (*cobra.Command, error) { var ( txConfigOpts tx.ConfigOptions autoCliOpts autocli.AppOptions @@ -46,13 +46,12 @@ func NewRootCmd() *cobra.Command { ) if err := depinject.Inject( - depinject.Configs(app.AppConfig(), + depinject.Configs(app.AppModuleConfig, depinject.Supply( log.NewNopLogger(), ), depinject.Provide( ProvideClientContext, - ProvideKeyring, ), ), &txConfigOpts, @@ -60,68 +59,34 @@ func NewRootCmd() *cobra.Command { &moduleBasicManager, &clientCtx, ); err != nil { - panic(err) + return nil, err } rootCmd := &cobra.Command{ - Use: "laconicd", - Short: "Laconic Daemon", - PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { - // set the default command outputs - cmd.SetOut(cmd.OutOrStdout()) - cmd.SetErr(cmd.ErrOrStderr()) - - clientCtx = clientCtx.WithCmdContext(cmd.Context()).WithViper(EnvPrefix) - clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) - if err != nil { - return err - } - - clientCtx, err = config.ReadFromClientConfig(clientCtx) - if err != nil { - return err - } - - // sign mode textual is only available in online mode - if !clientCtx.Offline { - // This needs to go after ReadFromClientConfig, as that function ets the RPC client needed for SIGN_MODE_TEXTUAL. - txConfigOpts.EnabledSignModes = append(txConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) - txConfigOpts.TextualCoinMetadataQueryFn = txmodule.NewGRPCCoinMetadataQueryFn(clientCtx) - txConfigWithTextual, err := tx.NewTxConfigWithOptions(codec.NewProtoCodec(clientCtx.InterfaceRegistry), txConfigOpts) - if err != nil { - return err - } - - clientCtx = clientCtx.WithTxConfig(txConfigWithTextual) - } - - if err := client.SetCmdClientContextHandler(clientCtx, cmd); err != nil { - return err - } - - // overwrite the minimum gas price from the app configuration - srvCfg := serverconfig.DefaultConfig() - srvCfg.MinGasPrices = fmt.Sprintf("0%s", params.CoinUnit) - - // overwrite the block timeout - cmtCfg := cmtcfg.DefaultConfig() - cmtCfg.Consensus.TimeoutCommit = 3 * time.Second - cmtCfg.LogLevel = "*:error,p2p:info,state:info,auction:info,bond:info,registry:info,gql-server:info" // better default logging - - return server.InterceptConfigsPreRunHandler(cmd, serverconfig.DefaultConfigTemplate, srvCfg, cmtCfg) - }, + Use: "laconicd", + SilenceErrors: true, + SilenceUsage: true, // prevent usage printing on every error + PersistentPreRunE: RootCommandPersistentPreRun(clientCtx, txConfigOpts), } - initRootCmd(rootCmd, clientCtx.TxConfig, moduleBasicManager) + initCtx := initRootCmd(rootCmd, clientCtx.TxConfig, moduleBasicManager) + + nodeCmds := nodeservice.NewNodeCommands() + autoCliOpts.ModuleOptions = make(map[string]*autocliv1.ModuleOptions) + autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions() if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { - panic(err) + return nil, err } + rootCmd.SetArgs(args) - // Add flags for GQL server. - rootCmd = gql.AddGQLFlags(rootCmd) - - return rootCmd + // now enhance the subcommand + subCmd, _, err := rootCmd.Find(args) + if err != nil { + return nil, err + } + initCtx.AddComponents(subCmd, initComponents) + return rootCmd, nil } func ProvideClientContext( @@ -141,7 +106,7 @@ func ProvideClientContext( WithViper(EnvPrefix) // env variable prefix // Read the config again to overwrite the default values with the values from the config file - clientCtx, _ = config.ReadFromClientConfig(clientCtx) + clientCtx, _ = clientconfig.ReadFromClientConfig(clientCtx) // Workaround: Unset clientCtx.HomeDir and clientCtx.KeyringDir from depinject clientCtx as they are given precedence over // the CLI args (--home flag) in some commands @@ -149,9 +114,10 @@ func ProvideClientContext( clientCtx.HomeDir = "" clientCtx.KeyringDir = "" + // XXX TODO fix after rebase // Custom LockupAccount type needs to be registered - interfaceRegistry.RegisterImplementations((*types.LockupAccountI)(nil), &types.LockupAccount{}) - interfaceRegistry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &types.LockupAccount{}) + // interfaceRegistry.RegisterImplementations((*types.LockupAccountI)(nil), &types.LockupAccount{}) + // interfaceRegistry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &types.LockupAccount{}) return clientCtx } @@ -164,3 +130,61 @@ func ProvideKeyring(clientCtx client.Context, addressCodec address.Codec) (clien return keyring.NewAutoCLIKeyring(kb) } + +func RootCommandPersistentPreRun( + clientCtx client.Context, + txConfigOpts tx.ConfigOptions, +) func(*cobra.Command, []string) error { + return func(cmd *cobra.Command, _ []string) error { + // set the default command outputs + cmd.SetOut(cmd.OutOrStdout()) + cmd.SetErr(cmd.ErrOrStderr()) + + clientCtx = clientCtx.WithCmdContext(cmd.Context()).WithViper("") + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + clientCtx, err = clientconfig.ReadFromClientConfig(clientCtx) + if err != nil { + return err + } + + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode + // is only available if the client is online. + if !clientCtx.Offline { + txConfigOpts.EnabledSignModes = append(txConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts.TextualCoinMetadataQueryFn = txmodule.NewGRPCCoinMetadataQueryFn(clientCtx) + txConfigWithTextual, err := tx.NewTxConfigWithOptions(codec.NewProtoCodec(clientCtx.InterfaceRegistry), txConfigOpts) + if err != nil { + return err + } + + clientCtx = clientCtx.WithTxConfig(txConfigWithTextual) + } + + if err := client.SetCmdClientContextHandler(clientCtx, cmd); err != nil { + return err + } + + appConfig := appconfig.DefaultConfig() + cmtConfig := initCometBFTConfig() + + serverCtx, err := server.InterceptConfigsAndCreateContext( + cmd, appconfig.DefaultConfigTemplate, appConfig, cmtConfig, + ) + if err != nil { + return err + } + // use slog-based logger to combine with nitro logs + logger, err := createSlogLogger(serverCtx.Viper.AllSettings(), cmd.OutOrStdout()) + if err != nil { + return err + } + serverCtx.Logger = logger.With(log.ModuleKey, "server") + + return server.SetCmdServerContext(cmd, serverCtx) + } +} diff --git a/cmd/laconicd/cmd/root_test.go b/cmd/laconicd/cmd/root_test.go new file mode 100644 index 00000000..ed5fc6fa --- /dev/null +++ b/cmd/laconicd/cmd/root_test.go @@ -0,0 +1,67 @@ +package cmd_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/client/flags" + svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" + "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + + "git.vdb.to/cerc-io/laconicd/app" + "git.vdb.to/cerc-io/laconicd/cmd/laconicd/cmd" +) + +func TestInitCmd(t *testing.T) { + rootCmd, err := cmd.NewRootCmd() + require.NoError(t, err) + rootCmd.SetArgs([]string{ + "init", // Test the init cmd + "simapp-test", // Moniker + fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json, in case it already exists + }) + + require.NoError(t, svrcmd.Execute(rootCmd, "", app.DefaultNodeHome)) +} + +func TestHomeFlagRegistration(t *testing.T) { + homeDir := "/tmp/foo" + + rootCmd, err := cmd.NewRootCmd() + require.NoError(t, err) + rootCmd.SetArgs([]string{ + "query", + fmt.Sprintf("--%s", flags.FlagHome), + homeDir, + }) + + require.NoError(t, svrcmd.Execute(rootCmd, "", app.DefaultNodeHome)) + + result, err := rootCmd.Flags().GetString(flags.FlagHome) + require.NoError(t, err) + require.Equal(t, result, homeDir) +} + +func TestHelpRequested(t *testing.T) { + argz := [][]string{ + {"query", "--help"}, + {"query", "tx", "-h"}, + {"--help"}, + {"start", "-h"}, + } + + for _, args := range argz { + rootCmd, err := cmd.NewRootCmd(args...) + require.NoError(t, err) + + var out bytes.Buffer + rootCmd.SetArgs(args) + rootCmd.SetOut(&out) + require.NoError(t, rootCmd.Execute()) + require.Contains(t, out.String(), args[0]) + require.Contains(t, out.String(), "--help") + require.Contains(t, out.String(), "Usage:") + } +} diff --git a/cmd/laconicd/cmd/testnet.go b/cmd/laconicd/cmd/testnet.go new file mode 100644 index 00000000..df55e03d --- /dev/null +++ b/cmd/laconicd/cmd/testnet.go @@ -0,0 +1,598 @@ +package cmd + +import ( + "bufio" + "encoding/json" + "fmt" + "net" + "os" + "path/filepath" + "time" + + cmtcfg "github.com/cometbft/cometbft/config" + cmtconfig "github.com/cometbft/cometbft/config" + cmttime "github.com/cometbft/cometbft/types/time" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + + "cosmossdk.io/math" + "cosmossdk.io/math/unsafe" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/server" + srvconfig "github.com/cosmos/cosmos-sdk/server/config" + "github.com/cosmos/cosmos-sdk/testutil" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/version" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "git.vdb.to/cerc-io/laconicd/app" + appconfig "git.vdb.to/cerc-io/laconicd/app/config" +) + +var ( + flagNodeDirPrefix = "node-dir-prefix" + flagNumValidators = "validator-count" + flagOutputDir = "output-dir" + flagNodeDaemonHome = "node-daemon-home" + flagStartingIPAddress = "starting-ip-address" + flagListenIPAddress = "listen-ip-address" + flagEnableLogging = "enable-logging" + flagGRPCAddress = "grpc.address" + flagRPCAddress = "rpc.address" + flagAPIAddress = "api.address" + flagPrintMnemonic = "print-mnemonic" + flagStakingDenom = "staking-denom" + flagCommitTimeout = "commit-timeout" + flagSingleHost = "single-host" +) + +type initArgs struct { + algo string + chainID string + keyringBackend string + minGasPrices string + nodeDaemonHome string + nodeDirPrefix string + numValidators int + outputDir string + startingIPAddress string + listenIPAddress string + singleMachine bool + bondTokenDenom string +} + +type startArgs struct { + algo string + apiAddress string + chainID string + enableLogging bool + grpcAddress string + minGasPrices string + numValidators int + outputDir string + printMnemonic bool + rpcAddress string + timeoutCommit time.Duration +} + +func addTestnetFlagsToCmd(cmd *cobra.Command) { + cmd.Flags().IntP(flagNumValidators, "v", 4, "Number of validators to initialize the testnet with") + cmd.Flags().StringP(flagOutputDir, "o", "./.testnets", "Directory to store initialization data for the testnet") + cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") + cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") + cmd.Flags().String(flags.FlagKeyType, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for") + + // support old flags name for backwards compatibility + cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { + if name == flags.FlagKeyAlgorithm { + name = flags.FlagKeyType + } + + return pflag.NormalizedName(name) + }) +} + +// NewTestnetCmd creates a root testnet command with subcommands to run an in-process testnet or initialize +// validator configuration files for running a multi-validator testnet in a separate process +func NewTestnetCmd(mm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { + testnetCmd := &cobra.Command{ + Use: "testnet", + Short: "subcommands for starting or configuring local testnets", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + testnetCmd.AddCommand(testnetStartCmd()) + testnetCmd.AddCommand(testnetInitFilesCmd(mm, genBalIterator)) + + return testnetCmd +} + +// testnetInitFilesCmd returns a cmd to initialize all files for CometBFT testnet and application +func testnetInitFilesCmd(mm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { + cmd := &cobra.Command{ + Use: "init-files", + Short: "Initialize config directories & files for a multi-validator testnet running locally via separate processes (e.g. Docker Compose or similar)", + Long: fmt.Sprintf(`init-files will setup one directory per validator and populate each with +necessary files (private validator, genesis, config, etc.) for running validator nodes. + +Booting up a network with these validator folders is intended to be used with Docker Compose, +or a similar setup where each node has a manually configurable IP address. + +Note, strict routability for addresses is turned off in the config file. + +Example: + %s testnet init-files --validator-count 4 --output-dir ./.testnets --starting-ip-address 192.168.10.2 + `, version.AppName), + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + config := cmtcfg.DefaultConfig() + + args := initArgs{} + args.outputDir, _ = cmd.Flags().GetString(flagOutputDir) + args.keyringBackend, _ = cmd.Flags().GetString(flags.FlagKeyringBackend) + args.chainID, _ = cmd.Flags().GetString(flags.FlagChainID) + args.minGasPrices, _ = cmd.Flags().GetString(server.FlagMinGasPrices) + args.nodeDirPrefix, _ = cmd.Flags().GetString(flagNodeDirPrefix) + args.nodeDaemonHome, _ = cmd.Flags().GetString(flagNodeDaemonHome) + args.startingIPAddress, _ = cmd.Flags().GetString(flagStartingIPAddress) + args.listenIPAddress, _ = cmd.Flags().GetString(flagListenIPAddress) + args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators) + args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType) + args.bondTokenDenom, _ = cmd.Flags().GetString(flagStakingDenom) + args.singleMachine, _ = cmd.Flags().GetBool(flagSingleHost) + config.Consensus.TimeoutCommit, err = cmd.Flags().GetDuration(flagCommitTimeout) + if err != nil { + return err + } + + return initTestnetFiles(clientCtx, cmd, config, mm, genBalIterator, args) + }, + } + + addTestnetFlagsToCmd(cmd) + cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix for the name of per-validator subdirectories (to be number-suffixed like node0, node1, ...)") + cmd.Flags().String(flagNodeDaemonHome, "laconicd", "Home directory of the node's daemon configuration") + cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)") + cmd.Flags().String(flagListenIPAddress, "127.0.0.1", "TCP or UNIX socket IP address for the RPC server to listen on") + cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") + cmd.Flags().Duration(flagCommitTimeout, 5*time.Second, "Time to wait after a block commit before starting on the new height") + cmd.Flags().Bool(flagSingleHost, false, "Cluster runs on a single host machine with different ports") + cmd.Flags().String(flagStakingDenom, sdk.DefaultBondDenom, "Default staking token denominator") + + return cmd +} + +// testnetStartCmd returns a cmd to start multi validator in-process testnet +func testnetStartCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "start", + Short: "Launch an in-process multi-validator testnet", + Long: fmt.Sprintf(`testnet will launch an in-process multi-validator testnet, +and generate a directory for each validator populated with necessary +configuration files (private validator, genesis, config, etc.). + +Example: + %s testnet --validator-count 4 --output-dir ./.testnets + `, version.AppName), + RunE: func(cmd *cobra.Command, _ []string) (err error) { + args := startArgs{} + args.outputDir, _ = cmd.Flags().GetString(flagOutputDir) + args.chainID, _ = cmd.Flags().GetString(flags.FlagChainID) + args.minGasPrices, _ = cmd.Flags().GetString(server.FlagMinGasPrices) + args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators) + args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType) + args.enableLogging, _ = cmd.Flags().GetBool(flagEnableLogging) + args.rpcAddress, _ = cmd.Flags().GetString(flagRPCAddress) + args.apiAddress, _ = cmd.Flags().GetString(flagAPIAddress) + args.grpcAddress, _ = cmd.Flags().GetString(flagGRPCAddress) + args.printMnemonic, _ = cmd.Flags().GetBool(flagPrintMnemonic) + + return startTestnet(cmd, args) + }, + } + + addTestnetFlagsToCmd(cmd) + cmd.Flags().Bool(flagEnableLogging, false, "Enable INFO logging of CometBFT validator nodes") + cmd.Flags().String(flagRPCAddress, "tcp://0.0.0.0:26657", "the RPC address to listen on") + cmd.Flags().String(flagAPIAddress, "tcp://0.0.0.0:1317", "the address to listen on for REST API") + cmd.Flags().String(flagGRPCAddress, "0.0.0.0:9090", "the gRPC server address to listen on") + cmd.Flags().Bool(flagPrintMnemonic, true, "print mnemonic of first validator to stdout for manual testing") + return cmd +} + +const nodeDirPerm = 0o755 + +// initTestnetFiles initializes testnet files for a testnet to be run in a separate process +func initTestnetFiles( + clientCtx client.Context, + cmd *cobra.Command, + nodeConfig *cmtconfig.Config, + mm module.BasicManager, + genBalIterator banktypes.GenesisBalancesIterator, + args initArgs, +) error { + if args.chainID == "" { + args.chainID = "chain-" + unsafe.Str(6) + } + nodeIDs := make([]string, args.numValidators) + valPubKeys := make([]cryptotypes.PubKey, args.numValidators) + + appConfig := appconfig.DefaultConfig() + appConfig.MinGasPrices = args.minGasPrices + appConfig.API.Enable = true + appConfig.Telemetry.Enabled = true + appConfig.Telemetry.PrometheusRetentionTime = 60 + appConfig.Telemetry.EnableHostnameLabel = false + appConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}} + + var ( + genAccounts []authtypes.GenesisAccount + genBalances []banktypes.Balance + genFiles []string + ) + const ( + rpcPort = 26657 + apiPort = 1317 + grpcPort = 9090 + ) + p2pPortStart := 26656 + + inBuf := bufio.NewReader(cmd.InOrStdin()) + // generate private keys, node IDs, and initial transactions + for i := 0; i < args.numValidators; i++ { + var portOffset int + if args.singleMachine { + portOffset = i + p2pPortStart = 16656 // use different start point to not conflict with rpc port + nodeConfig.P2P.AddrBookStrict = false + nodeConfig.P2P.PexReactor = false + nodeConfig.P2P.AllowDuplicateIP = true + appConfig.API.Address = fmt.Sprintf("tcp://0.0.0.0:%d", apiPort+portOffset) + appConfig.GRPC.Address = fmt.Sprintf("0.0.0.0:%d", grpcPort+portOffset) + } + + nodeDirName := fmt.Sprintf("%s%d", args.nodeDirPrefix, i) + nodeDir := filepath.Join(args.outputDir, nodeDirName, args.nodeDaemonHome) + gentxsDir := filepath.Join(args.outputDir, "gentxs") + + nodeConfig.SetRoot(nodeDir) + nodeConfig.Moniker = nodeDirName + nodeConfig.RPC.ListenAddress = fmt.Sprintf("tcp://%s:%d", args.listenIPAddress, rpcPort+portOffset) + + if err := os.MkdirAll(filepath.Join(nodeDir, "config"), nodeDirPerm); err != nil { + _ = os.RemoveAll(args.outputDir) + return err + } + var ( + err error + ip string + ) + if args.singleMachine { + ip = "127.0.0.1" + } else { + ip, err = getIP(i, args.startingIPAddress) + if err != nil { + _ = os.RemoveAll(args.outputDir) + return err + } + } + + nodeIDs[i], valPubKeys[i], err = genutil.InitializeNodeValidatorFiles(nodeConfig) + if err != nil { + _ = os.RemoveAll(args.outputDir) + return err + } + + memo := fmt.Sprintf("%s@%s:%d", nodeIDs[i], ip, p2pPortStart+portOffset) + genFiles = append(genFiles, nodeConfig.GenesisFile()) + + kb, err := keyring.New(sdk.KeyringServiceName(), args.keyringBackend, nodeDir, inBuf, clientCtx.Codec) + if err != nil { + return err + } + + keyringAlgos, _ := kb.SupportedAlgorithms() + algo, err := keyring.NewSigningAlgoFromString(args.algo, keyringAlgos) + if err != nil { + return err + } + + addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo) + if err != nil { + _ = os.RemoveAll(args.outputDir) + return err + } + + info := map[string]string{"secret": secret} + + cliPrint, err := json.Marshal(info) + if err != nil { + return err + } + + // save private key seed words + if err := writeFile(fmt.Sprintf("%v.json", "key_seed"), nodeDir, cliPrint); err != nil { + return err + } + + accTokens := sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction) + accStakingTokens := sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction) + coins := sdk.Coins{ + sdk.NewCoin("testtoken", accTokens), + sdk.NewCoin(args.bondTokenDenom, accStakingTokens), + } + + genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()}) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) + + valAddr := sdk.ValAddress(addr) + valStr := valAddr.String() + valTokens := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction) + createValMsg, err := stakingtypes.NewMsgCreateValidator( + valStr, + valPubKeys[i], + sdk.NewCoin(args.bondTokenDenom, valTokens), + stakingtypes.NewDescription(nodeDirName, "", "", "", ""), + stakingtypes.NewCommissionRates(math.LegacyOneDec(), math.LegacyOneDec(), math.LegacyOneDec()), + math.OneInt(), + ) + if err != nil { + return err + } + + txBuilder := clientCtx.TxConfig.NewTxBuilder() + if err := txBuilder.SetMsgs(createValMsg); err != nil { + return err + } + + txBuilder.SetMemo(memo) + + txFactory := tx.Factory{} + txFactory = txFactory. + WithChainID(args.chainID). + WithMemo(memo). + WithKeybase(kb). + WithTxConfig(clientCtx.TxConfig) + + if err := tx.Sign(cmd.Context(), txFactory, nodeDirName, txBuilder, true); err != nil { + return err + } + + txBz, err := clientCtx.TxConfig.TxJSONEncoder()(txBuilder.GetTx()) + if err != nil { + return err + } + + if err := writeFile(fmt.Sprintf("%v.json", nodeDirName), gentxsDir, txBz); err != nil { + return err + } + + srvconfig.SetConfigTemplate(appconfig.DefaultConfigTemplate) + srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config", "app.toml"), appConfig) + } + + if err := initGenFiles(clientCtx, mm, args.chainID, genAccounts, genBalances, genFiles, args.numValidators); err != nil { + return err + } + + err := collectGenFiles( + clientCtx, nodeConfig, args.chainID, nodeIDs, valPubKeys, args.numValidators, + args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome, genBalIterator, + rpcPort, p2pPortStart, args.singleMachine, + ) + if err != nil { + return err + } + + server.GetServerContextFromCmd(cmd).Viper.Set(flags.FlagHome, nodeConfig.RootDir) + + cmd.PrintErrf("Successfully initialized %d node directories\n", args.numValidators) + return nil +} + +func initGenFiles( + clientCtx client.Context, mm module.BasicManager, chainID string, + genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, + genFiles []string, numValidators int, +) error { + appGenState := mm.DefaultGenesis(clientCtx.Codec) + + // set the accounts in the genesis state + var authGenState authtypes.GenesisState + clientCtx.Codec.MustUnmarshalJSON(appGenState[authtypes.ModuleName], &authGenState) + + accounts, err := authtypes.PackAccounts(genAccounts) + if err != nil { + return err + } + + authGenState.Accounts = accounts + appGenState[authtypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&authGenState) + + // set the balances in the genesis state + var bankGenState banktypes.GenesisState + clientCtx.Codec.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState) + + bankGenState.Balances = banktypes.SanitizeGenesisBalances(genBalances) + + for _, bal := range bankGenState.Balances { + bankGenState.Supply = bankGenState.Supply.Add(bal.Coins...) + } + appGenState[banktypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&bankGenState) + + appGenStateJSON, err := json.MarshalIndent(appGenState, "", " ") + if err != nil { + return err + } + + appGenesis := genutiltypes.NewAppGenesisWithVersion(chainID, appGenStateJSON) + // generate empty genesis files for each validator and save + for i := 0; i < numValidators; i++ { + if err := appGenesis.SaveAs(genFiles[i]); err != nil { + return err + } + } + return nil +} + +func collectGenFiles( + clientCtx client.Context, nodeConfig *cmtconfig.Config, chainID string, + nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, + outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, + rpcPortStart, p2pPortStart int, + singleMachine bool, +) error { + var appState json.RawMessage + genTime := cmttime.Now() + + for i := 0; i < numValidators; i++ { + if singleMachine { + portOffset := i + nodeConfig.RPC.ListenAddress = fmt.Sprintf("tcp://127.0.0.1:%d", rpcPortStart+portOffset) + nodeConfig.P2P.ListenAddress = fmt.Sprintf("tcp://127.0.0.1:%d", p2pPortStart+portOffset) + } + + nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i) + nodeDir := filepath.Join(outputDir, nodeDirName, nodeDaemonHome) + gentxsDir := filepath.Join(outputDir, "gentxs") + nodeConfig.Moniker = nodeDirName + + nodeConfig.SetRoot(nodeDir) + + nodeID, valPubKey := nodeIDs[i], valPubKeys[i] + initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, nodeID, valPubKey) + + appGenesis, err := genutiltypes.AppGenesisFromFile(nodeConfig.GenesisFile()) + if err != nil { + return err + } + + nodeAppState, err := genutil.GenAppStateFromConfig( + clientCtx.Codec, + clientCtx.TxConfig, + nodeConfig, + initCfg, + appGenesis, + genBalIterator, + genutiltypes.DefaultMessageValidator, + clientCtx.TxConfig.SigningContext().ValidatorAddressCodec(), + ) + if err != nil { + return err + } + + if appState == nil { + // set the canonical application state (they should not differ) + appState = nodeAppState + } + + genFile := nodeConfig.GenesisFile() + + // overwrite each validator's genesis file to have a canonical genesis time + if err := genutil.ExportGenesisFileWithTime(genFile, chainID, nil, appState, genTime); err != nil { + return err + } + } + + return nil +} + +func getIP(i int, startingIPAddr string) (ip string, err error) { + if len(startingIPAddr) == 0 { + ip, err = server.ExternalIP() + if err != nil { + return "", err + } + return ip, nil + } + return calculateIP(startingIPAddr, i) +} + +func calculateIP(ip string, i int) (string, error) { + ipv4 := net.ParseIP(ip).To4() + if ipv4 == nil { + return "", fmt.Errorf("%v: non ipv4 address", ip) + } + + for j := 0; j < i; j++ { + ipv4[3]++ + } + + return ipv4.String(), nil +} + +func writeFile(name, dir string, contents []byte) error { + file := filepath.Join(dir, name) + + if err := os.MkdirAll(dir, 0o755); err != nil { + return fmt.Errorf("could not create directory %q: %w", dir, err) + } + + if err := os.WriteFile(file, contents, 0o600); err != nil { + return err + } + + return nil +} + +// startTestnet starts an in-process testnet +func startTestnet(cmd *cobra.Command, args startArgs) error { + networkConfig := network.DefaultConfig(app.NewTestNetworkFixture) + + // Default networkConfig.ChainID is random, and we should only override it if chainID provided + // is non-empty + if args.chainID != "" { + networkConfig.ChainID = args.chainID + } + networkConfig.SigningAlgo = args.algo + networkConfig.MinGasPrices = args.minGasPrices + networkConfig.NumValidators = args.numValidators + networkConfig.EnableLogging = args.enableLogging + networkConfig.RPCAddress = args.rpcAddress + networkConfig.APIAddress = args.apiAddress + networkConfig.GRPCAddress = args.grpcAddress + networkConfig.PrintMnemonic = args.printMnemonic + networkConfig.TimeoutCommit = args.timeoutCommit + networkLogger := network.NewCLILogger(cmd) + + baseDir := fmt.Sprintf("%s/%s", args.outputDir, networkConfig.ChainID) + if _, err := os.Stat(baseDir); !os.IsNotExist(err) { + return fmt.Errorf( + "testnests directory already exists for chain-id '%s': %s, please remove or select a new --chain-id", + networkConfig.ChainID, baseDir) + } + + testnet, err := network.New(networkLogger, baseDir, networkConfig) + if err != nil { + return err + } + + if _, err := testnet.WaitForHeight(1); err != nil { + return err + } + cmd.Println("press the Enter Key to terminate") + if _, err := fmt.Scanln(); err != nil { // wait for Enter Key + return err + } + testnet.Cleanup() + + return nil +} diff --git a/cmd/laconicd/cmd/testnet_test.go b/cmd/laconicd/cmd/testnet_test.go new file mode 100644 index 00000000..d4a18469 --- /dev/null +++ b/cmd/laconicd/cmd/testnet_test.go @@ -0,0 +1,72 @@ +package cmd + +import ( + "context" + "fmt" + "testing" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + + "cosmossdk.io/log" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/types/module" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/bank" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/consensus" + "github.com/cosmos/cosmos-sdk/x/distribution" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/staking" +) + +func Test_TestnetCmd(t *testing.T) { + moduleBasic := module.NewBasicManager( + auth.AppModuleBasic{}, + genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + bank.AppModuleBasic{}, + staking.AppModuleBasic{}, + distribution.AppModuleBasic{}, + consensus.AppModuleBasic{}, + ) + + home := t.TempDir() + encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}, staking.AppModuleBasic{}) + logger := log.NewNopLogger() + cfg, err := genutiltest.CreateDefaultCometConfig(home) + require.NoError(t, err) + + err = genutiltest.ExecInitCmd(moduleBasic, home, encodingConfig.Codec) + require.NoError(t, err) + + serverCtx := server.NewContext(viper.New(), cfg, logger) + clientCtx := client.Context{}. + WithCodec(encodingConfig.Codec). + WithHomeDir(home). + WithTxConfig(encodingConfig.TxConfig) + + ctx := context.Background() + ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx) + ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) + cmd := testnetInitFilesCmd(moduleBasic, banktypes.GenesisBalancesIterator{}) + cmd.SetArgs([]string{ + fmt.Sprintf("--%s=test", flags.FlagKeyringBackend, keyring.BackendTest), + fmt.Sprintf("--output-dir=%s", home), + }) + err = cmd.ExecuteContext(ctx) + require.NoError(t, err) + + genFile := cfg.GenesisFile() + appState, _, err := genutiltypes.GenesisStateFromGenFile(genFile) + require.NoError(t, err) + + bankGenState := banktypes.GetGenesisStateFromAppState(encodingConfig.Codec, appState) + require.NotEmpty(t, bankGenState.Supply.String()) +} diff --git a/cmd/laconicd/cmd_test.go b/cmd/laconicd/cmd_test.go deleted file mode 100644 index 9279cb1b..00000000 --- a/cmd/laconicd/cmd_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package main_test - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/client/flags" - svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" - - "git.vdb.to/cerc-io/laconicd/app" - "git.vdb.to/cerc-io/laconicd/cmd/laconicd/cmd" -) - -func TestInitCmd(t *testing.T) { - rootCmd := cmd.NewRootCmd() - rootCmd.SetArgs([]string{ - "init", // Test the init cmd - "localtestnet", // Moniker - fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json, in case it already exists - fmt.Sprintf("--%s=%s", flags.FlagChainID, "laconic_9000-1"), - }) - - err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome) - require.NoError(t, err) -} diff --git a/cmd/laconicd/main.go b/cmd/laconicd/main.go index 0e41416b..c1750e16 100644 --- a/cmd/laconicd/main.go +++ b/cmd/laconicd/main.go @@ -1,22 +1,32 @@ package main import ( + "errors" "fmt" "os" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "git.vdb.to/cerc-io/laconicd/app" - "git.vdb.to/cerc-io/laconicd/app/params" + _ "git.vdb.to/cerc-io/laconicd/app/params" // import for side-effects "git.vdb.to/cerc-io/laconicd/cmd/laconicd/cmd" ) func main() { - params.SetAddressPrefixes() - - rootCmd := cmd.NewRootCmd() - if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { - fmt.Fprintln(rootCmd.OutOrStderr(), err) + // reproduce default cobra behavior so that eager parsing of flags is possible. + // see: https://github.com/spf13/cobra/blob/e94f6d0dd9a5e5738dca6bce03c4b1207ffbc0ec/command.go#L1082 + args := os.Args[1:] + rootCmd, err := cmd.NewRootCmd(args...) + if err != nil { + if _, pErr := fmt.Fprintln(os.Stderr, err); pErr != nil { + panic(errors.Join(err, pErr)) + } + os.Exit(1) + } + if err := svrcmd.Execute(rootCmd, cmd.EnvPrefix, app.DefaultNodeHome); err != nil { + if _, pErr := fmt.Fprintln(rootCmd.OutOrStderr(), err); pErr != nil { + panic(errors.Join(err, pErr)) + } os.Exit(1) } } diff --git a/go.mod b/go.mod index d1c5352d..c5724cc9 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module git.vdb.to/cerc-io/laconicd -go 1.21 +go 1.23.5 -toolchain go1.21.0 +toolchain go1.23.6 replace ( // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. @@ -12,138 +12,192 @@ replace ( github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) +// DEV +replace ( + cosmossdk.io/client/v2 => ../mod/cosmos-sdk/client/v2 + cosmossdk.io/log => ../mod/cosmos-sdk/log + cosmossdk.io/systemtests => ../mod/cosmos-sdk/systemtests + cosmossdk.io/tools/confix => ../mod/cosmos-sdk/tools/confix + github.com/cometbft/cometbft => ../mod/cometbft + // github.com/cometbft/cometbft/api => ../mod/cometbft/api + github.com/cosmos/cosmos-sdk => ../mod/cosmos-sdk +) + +// DEV - nitro deps +replace ( + // github.com/ethereum/go-ethereum => ../mod/go-ethereum + git.vdb.to/cerc-io/chainsig => ../mod/chainsig + github.com/statechannels/go-nitro => ../mod/go-nitro + go.dedis.ch/kyber/v3 => ../mod/kyber + +// go.dedis.ch/kyber/v3 => github.com/cerc-io/kyber/v3 v3.0.0-20250728035006-f80208a7f291 // branch dev-3.x +) + require ( - cosmossdk.io/api v0.7.5 - cosmossdk.io/client/v2 v2.0.0-beta.1 - cosmossdk.io/collections v0.4.0 - cosmossdk.io/core v0.11.1 - cosmossdk.io/depinject v1.0.0 - cosmossdk.io/errors v1.0.1 - cosmossdk.io/log v1.4.1 - cosmossdk.io/math v1.3.0 - cosmossdk.io/store v1.1.1 - cosmossdk.io/tools/confix v0.1.0 - cosmossdk.io/x/evidence v0.1.1 + cosmossdk.io/api v0.9.2 + cosmossdk.io/client/v2 v2.0.0-00010101000000-000000000000 + cosmossdk.io/collections v1.3.1 + cosmossdk.io/core v0.11.3 + cosmossdk.io/depinject v1.2.1 + cosmossdk.io/errors v1.0.2 + cosmossdk.io/log v1.6.0 + cosmossdk.io/math v1.5.3 + cosmossdk.io/store v1.1.2 + cosmossdk.io/systemtests v1.2.1 + cosmossdk.io/tools/confix v0.1.2 + cosmossdk.io/x/evidence v0.2.0 + git.vdb.to/cerc-io/chain-signatures v0.1.0 github.com/99designs/gqlgen v0.17.22 - github.com/cometbft/cometbft v0.38.12 - github.com/cosmos/cosmos-db v1.0.2 + github.com/cometbft/cometbft v0.38.17 + github.com/cosmos/cosmos-db v1.1.3 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.50.10 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogoproto v1.7.0 github.com/deckarep/golang-set v1.8.0 - github.com/ethereum/go-ethereum v1.14.5 + github.com/ethereum/go-ethereum v1.16.1 github.com/gibson042/canonicaljson-go v1.0.3 - github.com/go-chi/chi/v5 v5.0.8 + github.com/go-chi/chi/v5 v5.2.2 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/ipfs/go-cid v0.4.1 + github.com/ipfs/go-cid v0.5.0 github.com/ipld/go-ipld-prime v0.21.0 + github.com/lmittmann/tint v1.1.2 + github.com/mitchellh/mapstructure v1.5.0 + github.com/pelletier/go-toml/v2 v2.2.4 github.com/rs/cors v1.11.1 - github.com/spf13/cobra v1.8.1 - github.com/spf13/viper v1.19.0 - github.com/statechannels/go-nitro v0.1.2 - github.com/stretchr/testify v1.9.0 - github.com/vektah/gqlparser/v2 v2.5.11 - golang.org/x/sync v0.8.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 - google.golang.org/grpc v1.64.1 - google.golang.org/protobuf v1.34.2 + github.com/spf13/cobra v1.9.1 + github.com/spf13/pflag v1.0.7 + github.com/spf13/viper v1.20.1 + github.com/statechannels/go-nitro v0.0.0-00010101000000-000000000000 + github.com/stretchr/testify v1.10.0 + github.com/tidwall/gjson v1.18.0 + github.com/tidwall/sjson v1.2.5 + github.com/vektah/gqlparser/v2 v2.5.30 + go.dedis.ch/kyber/v3 v3.1.0 + golang.org/x/time v0.10.0 + google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a + google.golang.org/grpc v1.72.2 + google.golang.org/protobuf v1.36.6 gopkg.in/yaml.v3 v3.0.1 ) require ( - cosmossdk.io/x/tx v0.13.5 // indirect - filippo.io/edwards25519 v1.0.0 // indirect + cosmossdk.io/schema v1.1.0 // indirect + cosmossdk.io/x/tx v0.14.0 // indirect + filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect - github.com/99designs/keyring v1.2.1 // indirect + github.com/99designs/keyring v1.2.2 // indirect github.com/DataDog/datadog-go v3.2.0+incompatible // indirect - github.com/DataDog/zstd v1.5.5 // indirect - github.com/agnivade/levenshtein v1.1.1 // indirect + github.com/DataDog/zstd v1.5.7 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect + github.com/VictoriaMetrics/fastcache v1.12.2 // indirect + github.com/agnivade/levenshtein v1.2.1 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect - github.com/bits-and-blooms/bitset v1.10.0 // indirect + github.com/bgentry/speakeasy v0.2.0 // indirect + github.com/bits-and-blooms/bitset v1.22.0 // indirect + github.com/btcsuite/btcd v0.22.0-beta // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect - github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect - github.com/cenkalti/backoff/v4 v4.1.3 // indirect - github.com/cespare/xxhash v1.1.0 // indirect + github.com/bytedance/sonic v1.13.2 // indirect + github.com/bytedance/sonic/loader v0.2.4 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect + github.com/cloudwego/base64x v0.1.5 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/cockroachdb/errors v1.11.3 // indirect - github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v1.1.1 // indirect - github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/errors v1.12.0 // indirect + github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect + github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect + github.com/cockroachdb/pebble v1.1.5 // indirect + github.com/cockroachdb/redact v1.1.6 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/cometbft/cometbft-db v0.11.0 // indirect + github.com/cometbft/cometbft-db v0.14.1 // indirect + github.com/consensys/gnark-crypto v0.18.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.2 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect - github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect - github.com/creachadair/atomicfile v0.3.1 // indirect - github.com/creachadair/tomledit v0.0.24 // indirect + github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect + github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect + github.com/creachadair/atomicfile v0.3.7 // indirect + github.com/creachadair/tomledit v0.0.27 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgraph-io/badger/v2 v2.2007.4 // indirect + github.com/dgraph-io/badger/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect - github.com/emicklei/dot v1.6.1 // indirect - github.com/fatih/color v1.16.0 // indirect + github.com/emicklei/dot v1.6.2 // indirect + github.com/ethereum/c-kzg-4844/v2 v2.1.0 // indirect + github.com/ethereum/go-verkle v0.2.2 // indirect + github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/getsentry/sentry-go v0.27.0 // indirect - github.com/go-kit/kit v0.12.0 // indirect + github.com/ferranbt/fastssz v0.1.2 // indirect + github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/getsentry/sentry-go v0.33.0 // indirect + github.com/go-kit/kit v0.13.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect + github.com/go-viper/mapstructure/v2 v2.3.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect + github.com/gofrs/flock v0.12.1 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.0 // indirect - github.com/golang/mock v1.6.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/golang/glog v1.2.4 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect - github.com/google/btree v1.1.2 // indirect - github.com/google/go-cmp v0.6.0 // indirect + github.com/google/btree v1.1.3 // indirect + github.com/google/flatbuffers v2.0.8+incompatible // indirect + github.com/google/go-cmp v0.7.0 // indirect github.com/google/orderedcode v0.0.1 // indirect - github.com/gorilla/handlers v1.5.1 // indirect - github.com/gorilla/mux v1.8.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/gorilla/handlers v1.5.2 // indirect + github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-bexpr v0.1.10 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-metrics v0.5.3 // indirect - github.com/hashicorp/go-plugin v1.5.2 // indirect + github.com/hashicorp/go-metrics v0.5.4 // indirect + github.com/hashicorp/go-plugin v1.6.3 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/yamux v0.1.1 // indirect - github.com/hdevalence/ed25519consensus v0.1.0 // indirect - github.com/holiman/uint256 v1.2.4 // indirect - github.com/huandu/skiplist v1.2.0 // indirect + github.com/hashicorp/yamux v0.1.2 // indirect + github.com/hdevalence/ed25519consensus v0.2.0 // indirect + github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect + github.com/holiman/bloomfilter/v2 v2.0.3 // indirect + github.com/holiman/uint256 v1.3.2 // indirect + github.com/huandu/skiplist v1.2.1 // indirect + github.com/huin/goupnp v1.3.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jmhodges/levigo v1.0.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/klauspost/compress v1.18.0 // indirect + github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/lib/pq v1.10.7 // indirect - github.com/linxGnu/grocksdb v1.8.14 // indirect - github.com/magiconair/properties v1.8.7 // indirect + github.com/lib/pq v1.10.9 // indirect + github.com/linxGnu/grocksdb v1.9.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/minio/highwayhash v1.0.2 // indirect + github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/mdp/qrterminal/v3 v3.2.1 // indirect + github.com/minio/highwayhash v1.0.3 // indirect github.com/minio/sha256-simd v1.0.1 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mitchellh/pointerstructure v1.2.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect @@ -154,49 +208,75 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect + github.com/pion/dtls/v2 v2.2.12 // indirect + github.com/pion/logging v0.2.2 // indirect + github.com/pion/stun/v2 v2.0.0 // indirect + github.com/pion/transport/v2 v2.2.10 // indirect + github.com/pion/transport/v3 v3.0.7 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/polydawn/refmt v0.89.0 // indirect - github.com/prometheus/client_golang v1.20.1 // indirect + github.com/prometheus/client_golang v1.22.0 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/common v0.63.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/rs/zerolog v1.33.0 // indirect - github.com/sagikazarmark/locafero v0.4.0 // indirect - github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sasha-s/go-deadlock v0.3.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect + github.com/rivo/uniseg v0.2.0 // indirect + github.com/rogpeppe/go-internal v1.14.1 // indirect + github.com/rs/zerolog v1.34.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/sagikazarmark/locafero v0.7.0 // indirect + github.com/sasha-s/go-deadlock v0.3.5 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/cast v1.6.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/afero v1.12.0 // indirect + github.com/spf13/cast v1.9.2 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/supranational/blst v0.3.14 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect + github.com/tidwall/buntdb v1.2.10 // indirect + github.com/tidwall/grect v0.1.4 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.1 // indirect + github.com/tidwall/rtred v0.1.2 // indirect + github.com/tidwall/tinyqueue v0.1.1 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/urfave/cli/v2 v2.27.7 // indirect + github.com/wlynxg/anet v0.0.5 // indirect + github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect - go.etcd.io/bbolt v1.3.10 // indirect + go.dedis.ch/fixbuf v1.0.3 // indirect + go.dedis.ch/protobuf v1.0.11 // indirect + go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect + go.opencensus.io v0.24.0 // indirect + go.uber.org/mock v0.5.2 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.26.0 // indirect - golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.17.0 // indirect - google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gotest.tools/v3 v3.5.1 // indirect - lukechampine.com/blake3 v1.2.1 // indirect + go.yaml.in/yaml/v2 v2.4.2 // indirect + golang.org/x/arch v0.15.0 // indirect + golang.org/x/crypto v0.39.0 // indirect + golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect + golang.org/x/net v0.41.0 // indirect + golang.org/x/sync v0.15.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/term v0.32.0 // indirect + golang.org/x/text v0.26.0 // indirect + google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gotest.tools/v3 v3.5.2 // indirect + lukechampine.com/blake3 v1.3.0 // indirect nhooyr.io/websocket v1.8.6 // indirect - pgregory.net/rapid v1.1.0 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect + pgregory.net/rapid v1.2.0 // indirect + rsc.io/qr v0.2.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect ) - -replace github.com/statechannels/go-nitro v0.1.2 => github.com/cerc-io/go-nitro v0.1.3-ts-port-0.1.10 diff --git a/go.sum b/go.sum index a572e5a6..eda21cec 100644 --- a/go.sum +++ b/go.sum @@ -1,38 +1,36 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= -cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= -cosmossdk.io/client/v2 v2.0.0-beta.1 h1:XkHh1lhrLYIT9zKl7cIOXUXg2hdhtjTPBUfqERNA1/Q= -cosmossdk.io/client/v2 v2.0.0-beta.1/go.mod h1:JEUSu9moNZQ4kU3ir1DKD5eU4bllmAexrGWjmb9k8qU= -cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= -cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= -cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA= -cosmossdk.io/core v0.11.1/go.mod h1:OJzxcdC+RPrgGF8NJZR2uoQr56tc7gfBKhiKeDO7hH0= -cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= -cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= -cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= -cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= -cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= -cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU= -cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= -cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= -cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y= -cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= -cosmossdk.io/tools/confix v0.1.0 h1:2OOZTtQsDT5e7P3FM5xqM0bPfluAxZlAwxqaDmYBE+E= -cosmossdk.io/tools/confix v0.1.0/go.mod h1:TdXKVYs4gEayav5wM+JHT+kTU2J7fozFNqoVaN+8CdY= -cosmossdk.io/x/evidence v0.1.1 h1:Ks+BLTa3uftFpElLTDp9L76t2b58htjVbSZ86aoK/E4= -cosmossdk.io/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc= -cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= -cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +cosmossdk.io/api v0.9.2 h1:9i9ptOBdmoIEVEVWLtYYHjxZonlF/aOVODLFaxpmNtg= +cosmossdk.io/api v0.9.2/go.mod h1:CWt31nVohvoPMTlPv+mMNCtC0a7BqRdESjCsstHcTkU= +cosmossdk.io/collections v1.3.1 h1:09e+DUId2brWsNOQ4nrk+bprVmMUaDH9xvtZkeqIjVw= +cosmossdk.io/collections v1.3.1/go.mod h1:ynvkP0r5ruAjbmedE+vQ07MT6OtJ0ZIDKrtJHK7Q/4c= +cosmossdk.io/core v0.11.3 h1:mei+MVDJOwIjIniaKelE3jPDqShCc/F4LkNNHh+4yfo= +cosmossdk.io/core v0.11.3/go.mod h1:9rL4RE1uDt5AJ4Tg55sYyHWXA16VmpHgbe0PbJc6N2Y= +cosmossdk.io/depinject v1.2.1 h1:eD6FxkIjlVaNZT+dXTQuwQTKZrFZ4UrfCq1RKgzyhMw= +cosmossdk.io/depinject v1.2.1/go.mod h1:lqQEycz0H2JXqvOgVwTsjEdMI0plswI7p6KX+MVqFOM= +cosmossdk.io/errors v1.0.2 h1:wcYiJz08HThbWxd/L4jObeLaLySopyyuUFB5w4AGpCo= +cosmossdk.io/errors v1.0.2/go.mod h1:0rjgiHkftRYPj//3DrD6y8hcm40HcPv/dR4R/4efr0k= +cosmossdk.io/math v1.5.3 h1:WH6tu6Z3AUCeHbeOSHg2mt9rnoiUWVWaQ2t6Gkll96U= +cosmossdk.io/math v1.5.3/go.mod h1:uqcZv7vexnhMFJF+6zh9EWdm/+Ylyln34IvPnBauPCQ= +cosmossdk.io/schema v1.1.0 h1:mmpuz3dzouCoyjjcMcA/xHBEmMChN+EHh8EHxHRHhzE= +cosmossdk.io/schema v1.1.0/go.mod h1:Gb7pqO+tpR+jLW5qDcNOSv0KtppYs7881kfzakguhhI= +cosmossdk.io/store v1.1.2 h1:3HOZG8+CuThREKv6cn3WSohAc6yccxO3hLzwK6rBC7o= +cosmossdk.io/store v1.1.2/go.mod h1:60rAGzTHevGm592kFhiUVkNC9w7gooSEn5iUBPzHQ6A= +cosmossdk.io/x/evidence v0.2.0 h1:o72zbmgCM7U0v7z7b0XnMB+NqX0tFamqb1HHkQbhrZ0= +cosmossdk.io/x/evidence v0.2.0/go.mod h1:zx/Xqy+hnGVzkqVuVuvmP9KsO6YCl4SfbAetYi+k+sE= +cosmossdk.io/x/tx v0.14.0 h1:hB3O25kIcyDW/7kMTLMaO8Ripj3yqs5imceVd6c/heA= +cosmossdk.io/x/tx v0.14.0/go.mod h1:Tn30rSRA1PRfdGB3Yz55W4Sn6EIutr9xtMKSHij+9PM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= -filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +git.vdb.to/cerc-io/chain-signatures v0.1.0 h1:gePU2R/KNODm1Z3qKTER4Nq9YkH2vr7ihZF9xFd2Lck= +git.vdb.to/cerc-io/chain-signatures v0.1.0/go.mod h1:IiIv4Eb6gY19zoGzWehzJLtQrvoq0lbAbeVCU7V9VEQ= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/99designs/gqlgen v0.17.22 h1:TOcrF8t0T3I0za9JD3CB6ehq7dDEMjR9Onikf8Lc/04= github.com/99designs/gqlgen v0.17.22/go.mod h1:BMhYIhe4bp7OlCo5I2PnowSK/Wimpv/YlxfNkqZGwLo= -github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o= -github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= +github.com/99designs/keyring v1.2.2 h1:pZd3neh/EmUzWONb35LxQfvuY7kiSXAq3HQd97+XBn0= +github.com/99designs/keyring v1.2.2/go.mod h1:wes/FrByc8j7lFOAGLGSNEg8f/PaI3cgTBqhFkHUrPk= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -40,30 +38,36 @@ github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= -github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/DataDog/zstd v1.5.7 h1:ybO8RBeh29qrxIhCA9E8gKY6xfONU9T6G6aP9DTKfLE= +github.com/DataDog/zstd v1.5.7/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -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 v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= 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= -github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= +github.com/adlio/schema v1.3.6 h1:k1/zc2jNfeiZBA5aFTRy37jlBIuCkXCm0XmvpzCKI9I= +github.com/adlio/schema v1.3.6/go.mod h1:qkxwLgPBd1FgLRHYVCmQT/rrBr3JH38J9LjmVzWNudg= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= -github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= +github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM= +github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +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/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -72,44 +76,61 @@ github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= +github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= -github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= -github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= +github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.22.0 h1:Tquv9S8+SGaS3EhyA+up3FXzmkhxPGjQQCkcs2uw7w4= +github.com/bits-and-blooms/bitset v1.22.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= +github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= -github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= +github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw= +github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c= +github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= +github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY= +github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cerc-io/go-nitro v0.1.3-ts-port-0.1.10 h1:lJg2a5Zi0kXxG89B1Fhq3VqnKmicK4AcUtruZUZQkDc= -github.com/cerc-io/go-nitro v0.1.3-ts-port-0.1.10/go.mod h1:x7xAzfyhRoVQ1hvuowH6LLEU/mmwpz1tQYLNi6F2ohI= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= +github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -125,6 +146,9 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= +github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= @@ -137,39 +161,39 @@ github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOG github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= -github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= -github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= -github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= -github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/errors v1.12.0 h1:d7oCs6vuIMUQRVbi6jWWWEJZahLCfJpnJSVobd1/sUo= +github.com/cockroachdb/errors v1.12.0/go.mod h1:SvzfYNNBshAVbZ8wzNc/UPK3w1vf0dKDUP41ucAIf7g= +github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 h1:pU88SPhIFid6/k0egdR5V6eALQYq2qbSmukrkgIh/0A= +github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 h1:ASDL+UJcILMqgNeV5jiqR4j+sTuvQNHdf2chuKj1M5k= +github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506/go.mod h1:Mw7HqKr2kdtu6aYGn3tPmAftiP3QPX63LdK/zcariIo= +github.com/cockroachdb/pebble v1.1.5 h1:5AAWCBWbat0uE0blr8qzufZP5tBjkRyy/jWe1QWLnvw= +github.com/cockroachdb/pebble v1.1.5/go.mod h1:17wO9el1YEigxkP/YtV8NtCivQDgoCyBg5c4VR/eOWo= +github.com/cockroachdb/redact v1.1.6 h1:zXJBwDZ84xJNlHl1rMyCojqyIxv+7YUpQiJLQ7n4314= +github.com/cockroachdb/redact v1.1.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/cometbft/cometbft v0.38.12 h1:OWsLZN2KcSSFe8bet9xCn07VwhBnavPea3VyPnNq1bg= -github.com/cometbft/cometbft v0.38.12/go.mod h1:GPHp3/pehPqgX1930HmK1BpBLZPxB75v/dZg8Viwy+o= -github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEyf7jej8= -github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc= +github.com/cometbft/cometbft-db v0.14.1 h1:SxoamPghqICBAIcGpleHbmoPqy+crij/++eZz3DlerQ= +github.com/cometbft/cometbft-db v0.14.1/go.mod h1:KHP1YghilyGV/xjD5DP3+2hyigWx0WTp9X+0Gnx0RxQ= +github.com/consensys/gnark-crypto v0.18.0 h1:vIye/FqI50VeAr0B3dx+YjeIvmc3LWz4yEfbWBpTUf0= +github.com/consensys/gnark-crypto v0.18.0/go.mod h1:L3mXGFTe1ZN+RSJ+CLjUt9x7PNdx8ubaYfDROyp2Z8c= +github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= +github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 h1:u9SHYsPQNyt5tgDm3YN7+9dYrpK96E5wFilTFWIDZOM= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= -github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAKs= -github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= +github.com/cosmos/cosmos-db v1.1.3 h1:7QNT77+vkefostcKkhrzDK9uoIEryzFrU9eoMeaQOPY= +github.com/cosmos/cosmos-db v1.1.3/go.mod h1:kN+wGsnwUJZYn8Sy5Q2O0vCYA99MJllkKASbs6Unb9U= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/cosmos-sdk v0.50.10 h1:zXfeu/z653tWZARr/jESzAEiCUYjgJwwG4ytnYWMoDM= -github.com/cosmos/cosmos-sdk v0.50.10/go.mod h1:6Eesrx3ZE7vxBZWpK++30H+Uc7Q4ahQWCL7JKU/LEdU= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -177,47 +201,62 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro= github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.2 h1:qHhKW3I70w+04g5KdsdVSHRbFLgt3yY3qTMd4Xa4rC8= +github.com/cosmos/iavl v1.2.2/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= -github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= -github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cosmos/ledger-cosmos-go v0.14.0 h1:WfCHricT3rPbkPSVKRH+L4fQGKYHuGOK9Edpel8TYpE= +github.com/cosmos/ledger-cosmos-go v0.14.0/go.mod h1:E07xCWSBl3mTGofZ2QnL4cIUzMbbGVyik84QYKbX3RA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= -github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= -github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= -github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= +github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/crate-crypto/go-eth-kzg v1.3.0 h1:05GrhASN9kDAidaFJOda6A4BEvgvuXbazXg/0E3OOdI= +github.com/crate-crypto/go-eth-kzg v1.3.0/go.mod h1:J9/u5sWfznSObptgfa92Jq8rTswn6ahQWEuiLHOjCUI= +github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a h1:W8mUrRp6NOVl3J+MYp5kPMoUZPp7aOYHtaua31lwRHg= +github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a/go.mod h1:sTwzHBvIzm2RfVCGNEBZgRyjwK40bVoun3ZnGOCafNM= +github.com/creachadair/atomicfile v0.3.7 h1:wdg8+Isz07NDMi2yZQAoI1EKB9SxuDhvo5MUii/ZqlM= +github.com/creachadair/atomicfile v0.3.7/go.mod h1:lUrZrE/XjMA7rJY/n8dF7/sSpy6KjtPaxPbrDambthA= +github.com/creachadair/mds v0.22.1 h1:Wink9jeYR7brBbOkOTVZVrd6vyb5W4ZBRhlZd96TSgU= +github.com/creachadair/mds v0.22.1/go.mod h1:ArfS0vPHoLV/SzuIzoqTEZfoYmac7n9Cj8XPANHocvw= +github.com/creachadair/tomledit v0.0.27 h1:6xOpEnkKmcpT/gmKhabN0JXrqNX065lyje1/mXTSSIE= +github.com/creachadair/tomledit v0.0.27/go.mod h1:v1EWpgCisD3ct1kO8Gq4o4pdgX5JXD0rBI2PJ4UnPoA= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU= +github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= -github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= -github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8= +github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +github.com/deepmap/oapi-codegen v1.6.0 h1:w/d1ntwh91XI0b/8ja7+u5SvA4IFfM0UNNLmiDR1gg0= +github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= -github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= -github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= -github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= +github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= +github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo= +github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -232,8 +271,10 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/emicklei/dot v1.6.1 h1:ujpDlBkkwgWUY+qPId5IwapRW/xEoligRSYjioR6DFI= -github.com/emicklei/dot v1.6.1/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= +github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/uo= +github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= +github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A= +github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -242,27 +283,38 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.14.5 h1:szuFzO1MhJmweXjoM5nSAeDvjNUH3vIQoMzzQnfvjpw= -github.com/ethereum/go-ethereum v1.14.5/go.mod h1:VEDGGhSxY7IEjn98hJRFXl/uFvpRgbIIf2PpXiyGGgc= +github.com/ethereum/c-kzg-4844/v2 v2.1.0 h1:gQropX9YFBhl3g4HYhwE70zq3IHFRgbbNPw0Shwzf5w= +github.com/ethereum/c-kzg-4844/v2 v2.1.0/go.mod h1:TC48kOKjJKPbN7C++qIgt0TJzZ70QznYR7Ob+WXl57E= +github.com/ethereum/go-ethereum v1.16.1 h1:7684NfKCb1+IChudzdKyZJ12l1Tq4ybPZOITiCDXqCk= +github.com/ethereum/go-ethereum v1.16.1/go.mod h1:ngYIvmMAYdo4sGW9cGzLvSsPGhDOOzL0jK5S5iXpj0g= +github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8= +github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= -github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/ferranbt/fastssz v0.1.2 h1:Dky6dXlngF6Qjc+EfDipAkE83N5I5DE68bY6O0VLNPk= +github.com/ferranbt/fastssz v0.1.2/go.mod h1:X5UPrE2u1UJjxHA8X54u04SBwdAQjG2sFtWs39YxyWs= +github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg= +github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= +github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= -github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= +github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/getsentry/sentry-go v0.33.0 h1:YWyDii0KGVov3xOaamOnF0mjOrqSjBqwv48UEzn7QFg= +github.com/getsentry/sentry-go v0.33.0/go.mod h1:C55omcY9ChRQIUcVcGcs+Zdy4ZpQGvNJ7JYHIoSWOtE= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI= github.com/gibson042/canonicaljson-go v1.0.3/go.mod h1:DsLpJTThXyGNO+KZlI85C1/KDcImpP67k/RKVjcaEqo= @@ -270,16 +322,16 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= -github.com/go-chi/chi/v5 v5.0.8 h1:lD+NLqFcAi1ovnVZpsnObHGW4xb4J8lNmoYVfECH1Y0= -github.com/go-chi/chi/v5 v5.0.8/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618= +github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= +github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= @@ -288,18 +340,26 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/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.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= -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-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= +github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk= +github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= 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= @@ -310,6 +370,10 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E 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/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= 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= @@ -320,11 +384,18 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= -github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.4 h1:CNNw5U8lSiiBk7druxtSHHTsRWcxKoac6kZKm2peBBc= +github.com/golang/glog v1.2.4/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= @@ -347,47 +418,57 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= -github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= +github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/flatbuffers v2.0.8+incompatible h1:ivUb1cGomAB101ZM1T0nOiWz9pSrTMoa9+EiY7igmkM= +github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= +github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= +github.com/google/pprof v0.0.0-20241017200806-017d972448fc h1:NGyrhhFhwvRAZg02jnYVg3GBQy0qGBKmFQJwaPmpmxs= +github.com/google/pprof v0.0.0-20241017200806-017d972448fc/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/graph-gophers/graphql-go v1.3.0 h1:Eb9x/q6MFpCLz7jBCiP/WTxjSDrYLR1QY41SORZyNJ0= +github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= @@ -401,19 +482,25 @@ github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NM github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE= -github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= +github.com/hashicorp/go-metrics v0.5.4 h1:8mmPiIJkTPPEbAiV97IxdAGNdRdaWwVap1BU6elejKY= +github.com/hashicorp/go-metrics v0.5.4/go.mod h1:CG5yz4NZ/AI/aQt9Ucm/vdBnbh7fvmv4lxZ350i+QQI= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y= -github.com/hashicorp/go-plugin v1.5.2/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-plugin v1.6.3 h1:xgHB+ZUSYeuJi96WtxEjzi23uh7YQpznjGh0U0UUrwg= +github.com/hashicorp/go-plugin v1.6.3/go.mod h1:MRobyh+Wc/nYy1V4KAXUiYfzxoYhs7V1mlH1Z7iY2h0= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= @@ -430,24 +517,28 @@ github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iP github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= -github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU= -github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= -github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= -github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8= +github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns= +github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= +github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA= +github.com/holiman/uint256 v1.3.2/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= -github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= -github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= +github.com/huandu/skiplist v1.2.1 h1:dTi93MgjwErA/8idWTzIw4Y1kZsMWx35fmI2c8Rij7w= +github.com/huandu/skiplist v1.2.1/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= @@ -455,23 +546,47 @@ github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPt github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/influxdata/influxdb-client-go/v2 v2.4.0 h1:HGBfZYStlx3Kqvsv1h2pJixbCl/jhnFtxpKFAv9Tu5k= +github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= -github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= +github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c h1:qSHzRbhzK8RdXOsAdfDgO49TtqC1oZ+acxPrkfTxcCs= +github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 h1:W9WBk7wlPfJLvMCdtV4zPulc4uCPrlywQOmbFOhgQNU= +github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= +github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= +github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= +github.com/ipfs/go-cid v0.5.0 h1:goEKKhaGm0ul11IHA7I6p1GmKz8kEYniqFopaB5Otwg= +github.com/ipfs/go-cid v0.5.0/go.mod h1:0L7vmeNXpQpUS9vt+yEARkJ8rOg43DF3iPgn4GIN0mk= +github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= +github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= +github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= +github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= +github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= +github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E= github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ= -github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= -github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= +github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= +github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= +github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94= +github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -483,15 +598,19 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= +github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= +github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -502,28 +621,59 @@ 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/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4= +github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= 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= -github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= -github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= +github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= +github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c= +github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic= +github.com/libp2p/go-flow-metrics v0.2.0 h1:EIZzjmeOE6c8Dav0sNv35vhZxATIXWZg6j/C08XmmDw= +github.com/libp2p/go-flow-metrics v0.2.0/go.mod h1:st3qqfu8+pMfh+9Mzqb2GTiwrAGjIPszEjZmtksN8Jc= +github.com/libp2p/go-libp2p v0.37.0 h1:8K3mcZgwTldydMCNOiNi/ZJrOB9BY+GlI3UxYzxBi9A= +github.com/libp2p/go-libp2p v0.37.0/go.mod h1:GOKmSN99scDuYGTwaTbQPR8Nt6dxrK3ue7OjW2NGDg4= +github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= +github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= +github.com/libp2p/go-libp2p-kad-dht v0.24.2 h1:zd7myKBKCmtZBhI3I0zm8xBkb28v3gmSEtQfBdAdFwc= +github.com/libp2p/go-libp2p-kad-dht v0.24.2/go.mod h1:BShPzRbK6+fN3hk8a0WGAYKpb8m4k+DtchkqouGTrSg= +github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= +github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= +github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= +github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk= +github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= +github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= +github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= +github.com/libp2p/go-nat v0.2.0/go.mod h1:3MJr+GRpRkyT65EpVPBstXLvOlAPzUVlG6Pwg9ohLJk= +github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= +github.com/libp2p/go-netroute v0.2.1/go.mod h1:hraioZr0fhBjG0ZRXJJ6Zj2IVEVNx6tDTFQfSmcq7mQ= +github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQscQm2s= +github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU= +github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ= +github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= -github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= +github.com/linxGnu/grocksdb v1.9.7 h1:Bp2r1Yti/IXxEobZZnDooXAui/Q+5gVqgQMenLWyDUw= +github.com/linxGnu/grocksdb v1.9.7/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= +github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w= +github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= -github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= +github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= +github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= +github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU= github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= @@ -533,24 +683,37 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 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.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mdp/qrterminal/v3 v3.2.1 h1:6+yQjiiOsSuXT5n9/m60E54vdgFsw0zhADHhHLrFet4= +github.com/mdp/qrterminal/v3 v3.2.1/go.mod h1:jOTmXvnBsMy5xqLniO0R++Jmjs2sTm9dFSuQ5kpz/SU= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= -github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= +github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= +github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= +github.com/miguelmota/go-ethereum-hdwallet v0.1.1 h1:zdXGlHao7idpCBjEGTXThVAtMKs+IxAgivZ75xqkWK0= +github.com/miguelmota/go-ethereum-hdwallet v0.1.1/go.mod h1:f9m9uXokAHA6WNoYOPjj4AqjJS5pquQRiYYj/XSyPYc= +github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= +github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU= +github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc= +github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s= +github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= +github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= -github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -566,12 +729,20 @@ github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aG github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= +github.com/multiformats/go-multiaddr v0.13.0 h1:BCBzs61E3AGHcYYTv8dqRH43ZfyrqM8RXVPT8t13tLQ= +github.com/multiformats/go-multiaddr v0.13.0/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII= +github.com/multiformats/go-multiaddr-dns v0.4.0 h1:P76EJ3qzBXpUXZ3twdCDx/kvagMsNo0LMFXpyms/zgU= +github.com/multiformats/go-multiaddr-dns v0.4.0/go.mod h1:7hfthtB4E4pQwirrz+J0CcDUfbWzTqEzVyYKKIKpgkc= +github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= +github.com/multiformats/go-multiaddr-fmt v0.1.0/go.mod h1:hGtDIW4PU4BqJ50gW2quDuPVjyWNZxToGUh/HwTZYJo= github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= +github.com/multiformats/go-multistream v0.5.0 h1:5htLSLl7lvJk3xx3qT/8Zm9J4K8vEOf/QGkvOGQAyiE= +github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dydlEqV3l6N3/GBsX6ILA= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= @@ -581,16 +752,26 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76/go.mod h1:x5OoJHDHqxHS801UIuhqGl6QdSAEJvtausosHSdazIo= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2 h1:+RB5hMpXUUA2dfxuhBTEkMOrYmM+gKIZYS1KjSostMI= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/jwt/v2 v2.3.0 h1:z2mA1a7tIf5ShggOFlR1oBPgd6hGqcDYsISxZByUzdI= +github.com/nats-io/jwt/v2 v2.3.0/go.mod h1:0tqz9Hlu6bCBFLWAASKhE5vUA4c24L9KPUUgvwumE/k= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats-server/v2 v2.9.11 h1:4y5SwWvWI59V5mcqtuoqKq6L9NDUydOP3Ekwuwl8cZI= +github.com/nats-io/nats-server/v2 v2.9.11/go.mod h1:b0oVuxSlkvS3ZjMkncFeACGyZohbO4XhSqW1Lt7iRRY= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nats.go v1.23.0 h1:lR28r7IX44WjYgdiKz9GmUeW0uh/m33uD3yEjLZ2cOE= +github.com/nats-io/nats.go v1.23.0/go.mod h1:ki/Scsa23edbh8IRZbCuNXR9TDcbvfaSijKtaqQgw+Q= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8= +github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= +github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= +github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q= github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= @@ -598,11 +779,16 @@ 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= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= +github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -613,12 +799,16 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= -github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= -github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= +github.com/opencontainers/runc v1.1.12 h1:BOIssBaW1La0/qbNZHXOOa71dZfZEQOzW7dqQf3phss= +github.com/opencontainers/runc v1.1.12/go.mod h1:S+lQwSfncpBha7XTy/5lBwWgm5+y5Ma/O44Ekby9FK8= +github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= +github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= @@ -629,18 +819,60 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= +github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= -github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 h1:jik8PHtAIsPlCRJjJzl4udgEf7hawInF9texMeO2jrU= -github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM= +github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pion/datachannel v1.5.9 h1:LpIWAOYPyDrXtU+BW7X0Yt/vGtYxtXQ8ql7dFfYUVZA= +github.com/pion/datachannel v1.5.9/go.mod h1:kDUuk4CU4Uxp82NH4LQZbISULkX/HtzKa4P7ldf9izE= +github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= +github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk= +github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE= +github.com/pion/ice/v2 v2.3.36 h1:SopeXiVbbcooUg2EIR8sq4b13RQ8gzrkkldOVg+bBsc= +github.com/pion/ice/v2 v2.3.36/go.mod h1:mBF7lnigdqgtB+YHkaY/Y6s6tsyRyo4u4rPGRuOjUBQ= +github.com/pion/interceptor v0.1.37 h1:aRA8Zpab/wE7/c0O3fh1PqY0AJI3fCSEM5lRWJVorwI= +github.com/pion/interceptor v0.1.37/go.mod h1:JzxbJ4umVTlZAf+/utHzNesY8tmRkM2lVmkS82TTj8Y= +github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= +github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= +github.com/pion/mdns v0.0.12 h1:CiMYlY+O0azojWDmxdNr7ADGrnZ+V6Ilfner+6mSVK8= +github.com/pion/mdns v0.0.12/go.mod h1:VExJjv8to/6Wqm1FXK+Ii/Z9tsVk/F5sD/N70cnYFbk= +github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= +github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= +github.com/pion/rtcp v1.2.14 h1:KCkGV3vJ+4DAJmvP0vaQShsb0xkRfWkO540Gy102KyE= +github.com/pion/rtcp v1.2.14/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4= +github.com/pion/rtp v1.8.9 h1:E2HX740TZKaqdcPmf4pw6ZZuG8u5RlMMt+l3dxeu6Wk= +github.com/pion/rtp v1.8.9/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU= +github.com/pion/sctp v1.8.33 h1:dSE4wX6uTJBcNm8+YlMg7lw1wqyKHggsP5uKbdj+NZw= +github.com/pion/sctp v1.8.33/go.mod h1:beTnqSzewI53KWoG3nqB282oDMGrhNxBdb+JZnkCwRM= +github.com/pion/sdp/v3 v3.0.9 h1:pX++dCHoHUwq43kuwf3PyJfHlwIj4hXA7Vrifiq0IJY= +github.com/pion/sdp/v3 v3.0.9/go.mod h1:B5xmvENq5IXJimIO4zfp6LAe1fD9N+kFv+V/1lOdz8M= +github.com/pion/srtp/v2 v2.0.20 h1:HNNny4s+OUmG280ETrCdgFndp4ufx3/uy85EawYEhTk= +github.com/pion/srtp/v2 v2.0.20/go.mod h1:0KJQjA99A6/a0DOVTu1PhDSw0CXF2jTkqOoMg3ODqdA= +github.com/pion/stun v0.6.1 h1:8lp6YejULeHBF8NmV8e2787BogQhduZugh5PdhDyyN4= +github.com/pion/stun v0.6.1/go.mod h1:/hO7APkX4hZKu/D0f2lHzNyvdkTGtIy3NDmLR7kSz/8= +github.com/pion/stun/v2 v2.0.0 h1:A5+wXKLAypxQri59+tmQKVs7+l6mMM+3d+eER9ifRU0= +github.com/pion/stun/v2 v2.0.0/go.mod h1:22qRSh08fSEttYUmJZGlriq9+03jtVmXNODgLccj8GQ= +github.com/pion/transport/v2 v2.2.1/go.mod h1:cXXWavvCnFF6McHTft3DWS9iic2Mftcz1Aq29pGcU5g= +github.com/pion/transport/v2 v2.2.4/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= +github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQpw6Q= +github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E= +github.com/pion/transport/v3 v3.0.1/go.mod h1:UY7kiITrlMv7/IKgd5eTUcaahZx5oUN3l9SzK5f5xE0= +github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0= +github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo= +github.com/pion/turn/v2 v2.1.6 h1:Xr2niVsiPTB0FPtt+yAWKFUkU1eotQbGgpTIld4x1Gc= +github.com/pion/turn/v2 v2.1.6/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY= +github.com/pion/webrtc/v3 v3.3.4 h1:v2heQVnXTSqNRXcaFQVOhIOYkLMxOu1iJG8uy1djvkk= +github.com/pion/webrtc/v3 v3.3.4/go.mod h1:liNa+E1iwyzyXqNUwvoMRNQ10x8h8FOeJKL8RkIbamE= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -659,8 +891,9 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= -github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q= +github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -675,46 +908,60 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k= +github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220714111606-acbb2962fb48 h1:cSo6/vk8YpvkLbk9v3FO97cakNmUoxwi2KMP8hd5WIw= +github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220714111606-acbb2962fb48/go.mod h1:4pWaT30XoEx1j8KNJf3TV+E3mQkaufn7mf+jRNb/Fuk= +github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= +github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= +github.com/quic-go/quic-go v0.48.1 h1:y/8xmfWI9qmGTc+lBr4jKRUWLGSlSigv847ULJ4hYXA= +github.com/quic-go/quic-go v0.48.1/go.mod h1:yBgs3rWBOADpga7F+jJsb6Ybg1LSYiQvwWlLX+/6HMs= +github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66 h1:4WFk6u3sOT6pLa1kQ50ZVdm8BQFgJNA117cepZxtLIg= +github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66/go.mod h1:Vp72IJajgeOL6ddqrAhmp7IM9zbTcgkQxD/YdxrVwMw= +github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= +github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= 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/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= -github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= +github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= +github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= -github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= -github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= -github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= +github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo= +github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -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/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= +github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= +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= @@ -732,27 +979,22 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= -github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= -github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs= +github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4= +github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE= +github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= +github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= -github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M= +github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4= +github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= @@ -771,59 +1013,125 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/supranational/blst v0.3.14 h1:xNMoHRJOTwMn63ip6qoWJ2Ymgvj7E2b9jY2FAwY+qRo= +github.com/supranational/blst v0.3.14/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tidwall/assert v0.1.0 h1:aWcKyRBUAdLoVebxo95N7+YZVTFF/ASTr7BN4sLP6XI= +github.com/tidwall/assert v0.1.0/go.mod h1:QLYtGyeqse53vuELQheYl9dngGCJQ+mTtlxcktb+Kj8= 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/tidwall/buntdb v1.2.10 h1:U/ebfkmYPBnyiNZIirUiWFcxA/mgzjbKlyPynFsPtyM= +github.com/tidwall/buntdb v1.2.10/go.mod h1:lZZrZUWzlyDJKlLQ6DKAy53LnG7m5kHyrEHvvcDmBpU= +github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/grect v0.1.4 h1:dA3oIgNgWdSspFzn1kS4S/RDpZFLrIxAZOdJKjYapOg= +github.com/tidwall/grect v0.1.4/go.mod h1:9FBsaYRaR0Tcy4UwefBX/UDcDcDy9V5jUcxHzv2jd5Q= +github.com/tidwall/lotsa v1.0.2 h1:dNVBH5MErdaQ/xd9s769R31/n2dXavsQ0Yf4TMEHHw8= +github.com/tidwall/lotsa v1.0.2/go.mod h1:X6NiU+4yHA3fE3Puvpnn1XMDrFZrE9JO2/w+UMuqgR8= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/rtred v0.1.2 h1:exmoQtOLvDoO8ud++6LwVsAMTu0KPzLTUrMln8u1yu8= +github.com/tidwall/rtred v0.1.2/go.mod h1:hd69WNXQ5RP9vHd7dqekAz+RIdtfBogmglkZSRxCHFQ= +github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= +github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= +github.com/tidwall/tinyqueue v0.1.1 h1:SpNEvEggbpyN5DIReaJ2/1ndroY8iyEGxPYxoSaymYE= +github.com/tidwall/tinyqueue v0.1.1/go.mod h1:O/QNHwrnjqr6IHItYrzoHAKYhBkLI67Q096fQP5zMYw= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= 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/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= -github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY= +github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU= +github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4= github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs= -github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8= -github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +github.com/vektah/gqlparser/v2 v2.5.30 h1:EqLwGAFLIzt1wpx1IPpY67DwUujF1OfzgEyDsLrN6kE= +github.com/vektah/gqlparser/v2 v2.5.30/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= +github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= +github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc= +github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= +github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU= +github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= +go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs= +go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw= +go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo= +go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= -go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= +go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6ejyAJc760RwW4SnVDiTYTzwnXuxo= +go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= +go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= +go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= +go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= +go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/dig v1.18.0 h1:imUL1UiY0Mg4bqbFfsRQO5G4CGRBec/ZujWTvSVp3pw= +go.uber.org/dig v1.18.0/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= +go.uber.org/fx v1.23.0 h1:lIr/gYWQGfTwGcSXWXu4vP5Ws6iqnNEIY+F/aFzCKTg= +go.uber.org/fx v1.23.0/go.mod h1:o/D9n+2mLP6v1EG+qsdT1O8wKopYAsqZasju97SDFCU= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko= +go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -833,23 +1141,37 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= +go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= +go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE= +go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI= +golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw= +golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -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/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= +golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= 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-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8= -golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= +golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw= +golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -863,9 +1185,12 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= +golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -889,14 +1214,20 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -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/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= 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-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -907,10 +1238,12 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= +golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -919,17 +1252,16 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -948,9 +1280,11 @@ golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -963,19 +1297,30 @@ golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.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.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 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.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= +golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -983,10 +1328,16 @@ 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.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4= +golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1006,13 +1357,17 @@ golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= 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= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.15.1 h1:FNy7N6OUZVUaWG9pTiD+jlhdQ3lMP+/LcTpJ6+a8sQ0= +gonum.org/v1/gonum v0.15.1/go.mod h1:eZTZuRFrzu5pcyjN5wJhcIhnUdNijYxX1T2IcrOGY0o= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1028,12 +1383,12 @@ google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= -google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= -google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 h1:ToEetK57OidYuqD4Q5w+vfEnPvPpuTwedCNVohYJfNk= +google.golang.org/genproto v0.0.0-20241118233622-e639e219e697/go.mod h1:JJrvXBWRZaFMxBufik1a4RpFw4HhgVtBBWQeQgUj2cc= +google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a h1:SGktgSolFCo75dnHJF2yMvnns6jCmHFJ0vE4Vn2JKvQ= +google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a/go.mod h1:a77HrdMjoeKbnd2jmgcWdaS++ZLZAEq3orIOAEIKiVw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a h1:v2PbRU4K3llS09c7zodFpNePeamkAwG3mPrAery9VeE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1048,11 +1403,12 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= -google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= +google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8= +google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1068,8 +1424,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1081,8 +1437,8 @@ gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -1101,19 +1457,22 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= -gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= +gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= +gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= -lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= +lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= -pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= +pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= +pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= +rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= +rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= -sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/gql/README.md b/gql/README.md index d2f10b1c..b610293e 100644 --- a/gql/README.md +++ b/gql/README.md @@ -29,7 +29,7 @@ On having some change in the GQL schema (for example: adding a new query) update ## Start server ```shell -laconicd start --gql-playground --gql-server +laconicd start --gql.playground --gql.server ``` Basic node status: diff --git a/gql/config.go b/gql/config.go new file mode 100644 index 00000000..98d29134 --- /dev/null +++ b/gql/config.go @@ -0,0 +1,19 @@ +package gql + +func DefaultConfig() *Config { + return &Config{ + Enable: false, + Playground: false, + PlaygroundAPIBase: "", + Port: 9473, + // LogFile: "", + } +} + +type Config struct { + Enable bool `mapstructure:"enable" toml:"enable" comment:"Enable the GraphQL server."` + Playground bool `mapstructure:"playground" toml:"playground" comment:"Enable the GraphQL playground."` + PlaygroundAPIBase string `mapstructure:"playground-api-base" toml:"playground-api-base" comment:"GraphQL API base path to use in the playground."` + Port uint `mapstructure:"port" toml:"port" comment:"Port to use for the GraphQL server."` + // LogFile string `mapstructure:"log-file" toml:"log-file" comment:"File to tail for the 'getLogs' API."` +} diff --git a/gql/flags.go b/gql/flags.go index 9c86137e..763e656f 100644 --- a/gql/flags.go +++ b/gql/flags.go @@ -1,15 +1,24 @@ package gql -import "github.com/spf13/cobra" +import "github.com/spf13/pflag" -// AddGQLFlags adds gql flags for -func AddGQLFlags(cmd *cobra.Command) *cobra.Command { - // Add flags for GQL server. - cmd.PersistentFlags().Bool("gql-server", false, "Start GQL server.") - cmd.PersistentFlags().Bool("gql-playground", false, "Enable GQL playground.") - cmd.PersistentFlags().String("gql-playground-api-base", "", "GQL API base path to use in GQL playground.") - cmd.PersistentFlags().String("gql-port", "9473", "Port to use for the GQL server.") - cmd.PersistentFlags().String("log-file", "", "File to tail for GQL 'getLogs' API.") +var ( + FlagEnable = prefix("enable") + FlagPlayground = prefix("playground") + FlagPlaygroundAPIBase = prefix("playground-api-base") + FlagPort = prefix("port") + //FlagLogFile = prefix("log-file") +) - return cmd +// AddGQLFlags adds flags for the GraphQL server. +func AddGQLFlags(flags *pflag.FlagSet) { + flags.Bool(FlagEnable, false, "Enable the GraphQL server") + flags.Bool(FlagPlayground, false, "Enable the GraphQL playground") + flags.String(FlagPlaygroundAPIBase, "", "GraphQL API base path to use in the playground") + flags.String(FlagPort, "9473", "Port to use for the GraphQL server.") + // cmd.PersistentFlags().String(FlagLogFile, "", "File to tail for GraphQL 'getLogs' API") +} + +func prefix(f string) string { + return ServerName + "." + f } diff --git a/gql/gqlgen.yml b/gql/gqlgen.yml index 7e857210..66c48bee 100644 --- a/gql/gqlgen.yml +++ b/gql/gqlgen.yml @@ -4,9 +4,9 @@ schema: - cerc-io/laconicd/*.graphql exec: - filename: generated.go + filename: schema/generated.go model: - filename: models_gen.go + filename: schema/models_gen.go resolver: filename: resolver.go type: Resolver @@ -14,4 +14,4 @@ resolver: models: Link: model: - - git.vdb.to/cerc-io/laconicd/gql.Link + - git.vdb.to/cerc-io/laconicd/gql/schema.Link diff --git a/gql/resolver.go b/gql/resolver.go index f5aaf055..56ffcee4 100644 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -12,6 +12,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "git.vdb.to/cerc-io/laconicd/gql/schema" + "git.vdb.to/cerc-io/laconicd/utils" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" bondtypes "git.vdb.to/cerc-io/laconicd/x/bond" onboardingTypes "git.vdb.to/cerc-io/laconicd/x/onboarding" @@ -33,13 +35,13 @@ type Resolver struct { } // Query is the entry point to query execution. -func (r *Resolver) Query() QueryResolver { +func (r *Resolver) Query() schema.QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } -func (q queryResolver) GetAuthorities(ctx context.Context, owner *string) ([]*Authority, error) { +func (q queryResolver) GetAuthorities(ctx context.Context, owner *string) ([]*schema.Authority, error) { nsQueryClient := registrytypes.NewQueryClient(q.ctx) auctionQueryClient := auctiontypes.NewQueryClient(q.ctx) @@ -53,14 +55,14 @@ func (q queryResolver) GetAuthorities(ctx context.Context, owner *string) ([]*Au return nil, err } - authorities := make([]*Authority, len(authoritiesResp.GetAuthorities())) + authorities := make([]*schema.Authority, len(authoritiesResp.GetAuthorities())) for i, a := range authoritiesResp.Authorities { entry, err := getAuthorityRecord(*a.Entry, auctionQueryClient) if err != nil { return nil, err } - authorities[i] = &Authority{ + authorities[i] = &schema.Authority{ Name: a.Name, Entry: entry, } @@ -69,10 +71,10 @@ func (q queryResolver) GetAuthorities(ctx context.Context, owner *string) ([]*Au return authorities, nil } -func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error) { +func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([]*schema.AuthorityRecord, error) { nsQueryClient := registrytypes.NewQueryClient(q.ctx) auctionQueryClient := auctiontypes.NewQueryClient(q.ctx) - gqlResponse := []*AuthorityRecord{} + gqlResponse := []*schema.AuthorityRecord{} for _, name := range names { res, err := nsQueryClient.Whois(context.Background(), ®istrytypes.QueryWhoisRequest{Name: name}) @@ -97,9 +99,9 @@ func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([ return gqlResponse, nil } -func (q queryResolver) ResolveNames(ctx context.Context, names []string) ([]*Record, error) { +func (q queryResolver) ResolveNames(ctx context.Context, names []string) ([]*schema.Record, error) { nsQueryClient := registrytypes.NewQueryClient(q.ctx) - var gqlResponse []*Record + var gqlResponse []*schema.Record for _, name := range names { res, err := nsQueryClient.ResolveLrn(context.Background(), ®istrytypes.QueryResolveLrnRequest{Lrn: name}) if err != nil { @@ -118,9 +120,9 @@ func (q queryResolver) ResolveNames(ctx context.Context, names []string) ([]*Rec return gqlResponse, nil } -func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*NameRecord, error) { +func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*schema.NameRecord, error) { nsQueryClient := registrytypes.NewQueryClient(q.ctx) - var gqlResponse []*NameRecord + var gqlResponse []*schema.NameRecord for _, name := range names { res, err := nsQueryClient.LookupLrn(context.Background(), ®istrytypes.QueryLookupLrnRequest{Lrn: name}) @@ -140,7 +142,7 @@ func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*Name return gqlResponse, nil } -func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool, limit *int, offset *int) ([]*Record, error) { +func (q queryResolver) QueryRecords(ctx context.Context, attributes []*schema.KeyValueInput, all *bool, limit *int, offset *int) ([]*schema.Record, error) { nsQueryClient := registrytypes.NewQueryClient(q.ctx) var pagination *query.PageRequest @@ -175,7 +177,7 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI } records := res.GetRecords() - gqlResponse := make([]*Record, len(records)) + gqlResponse := make([]*schema.Record, len(records)) for i, record := range records { gqlRecord, err := getGQLRecord(context.Background(), q, record) @@ -188,9 +190,9 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI return gqlResponse, nil } -func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error) { +func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*schema.Record, error) { nsQueryClient := registrytypes.NewQueryClient(q.ctx) - gqlResponse := make([]*Record, len(ids)) + gqlResponse := make([]*schema.Record, len(ids)) for i, id := range ids { res, err := nsQueryClient.GetRecord(context.Background(), ®istrytypes.QueryGetRecordRequest{Id: id}) @@ -209,7 +211,7 @@ func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Re return gqlResponse, nil } -func (q queryResolver) GetStatus(ctx context.Context) (*Status, error) { +func (q queryResolver) GetStatus(ctx context.Context) (*schema.Status, error) { nodeInfo, syncInfo, validatorInfo, err := getStatusInfo(q.ctx) if err != nil { return nil, err @@ -230,7 +232,7 @@ func (q queryResolver) GetStatus(ctx context.Context) (*Status, error) { return nil, err } - return &Status{ + return &schema.Status{ Version: RegistryVersion, Node: nodeInfo, Sync: syncInfo, @@ -242,8 +244,8 @@ func (q queryResolver) GetStatus(ctx context.Context) (*Status, error) { }, nil } -func (q queryResolver) GetAccounts(ctx context.Context, addresses []string) ([]*Account, error) { - accounts := make([]*Account, len(addresses)) +func (q queryResolver) GetAccounts(ctx context.Context, addresses []string) ([]*schema.Account, error) { + accounts := make([]*schema.Account, len(addresses)) for index, address := range addresses { account, err := q.GetAccount(ctx, address) if err != nil { @@ -254,7 +256,7 @@ func (q queryResolver) GetAccounts(ctx context.Context, addresses []string) ([]* return accounts, nil } -func (q queryResolver) GetAccount(ctx context.Context, address string) (*Account, error) { +func (q queryResolver) GetAccount(ctx context.Context, address string) (*schema.Account, error) { authQueryClient := authtypes.NewQueryClient(q.ctx) accountResponse, err := authQueryClient.Account(ctx, &authtypes.QueryAccountRequest{Address: address}) if err != nil { @@ -280,7 +282,7 @@ func (q queryResolver) GetAccount(ctx context.Context, address string) (*Account accNum := strconv.FormatUint(account.GetAccountNumber(), 10) seq := strconv.FormatUint(account.GetSequence(), 10) - return &Account{ + return &schema.Account{ Address: address, Number: accNum, Sequence: seq, @@ -289,8 +291,8 @@ func (q queryResolver) GetAccount(ctx context.Context, address string) (*Account }, nil } -func (q queryResolver) GetBondsByIds(ctx context.Context, ids []string) ([]*Bond, error) { - bonds := make([]*Bond, len(ids)) +func (q queryResolver) GetBondsByIds(ctx context.Context, ids []string) ([]*schema.Bond, error) { + bonds := make([]*schema.Bond, len(ids)) for index, id := range ids { bondObj, err := q.GetBond(ctx, id) if err != nil { @@ -302,7 +304,7 @@ func (q queryResolver) GetBondsByIds(ctx context.Context, ids []string) ([]*Bond return bonds, nil } -func (q *queryResolver) GetBond(ctx context.Context, id string) (*Bond, error) { +func (q *queryResolver) GetBond(ctx context.Context, id string) (*schema.Bond, error) { bondQueryClient := bondtypes.NewQueryClient(q.ctx) bondResp, err := bondQueryClient.GetBondById(context.Background(), &bondtypes.QueryGetBondByIdRequest{Id: id}) if err != nil { @@ -320,14 +322,14 @@ func (q *queryResolver) GetBond(ctx context.Context, id string) (*Bond, error) { return getGQLBond(bondResp.GetBond()) } -func (q queryResolver) QueryBonds(ctx context.Context) ([]*Bond, error) { +func (q queryResolver) QueryBonds(ctx context.Context) ([]*schema.Bond, error) { bondQueryClient := bondtypes.NewQueryClient(q.ctx) bonds, err := bondQueryClient.Bonds(context.Background(), &bondtypes.QueryBondsRequest{}) if err != nil { return nil, err } - gqlResponse := make([]*Bond, len(bonds.GetBonds())) + gqlResponse := make([]*schema.Bond, len(bonds.GetBonds())) for i, bondObj := range bonds.GetBonds() { gqlBond, err := getGQLBond(bondObj) if err != nil { @@ -340,8 +342,8 @@ func (q queryResolver) QueryBonds(ctx context.Context) ([]*Bond, error) { } // QueryBondsByOwner will return bonds by owner -func (q queryResolver) QueryBondsByOwner(ctx context.Context, ownerAddresses []string) ([]*OwnerBonds, error) { - ownerBonds := make([]*OwnerBonds, len(ownerAddresses)) +func (q queryResolver) QueryBondsByOwner(ctx context.Context, ownerAddresses []string) ([]*schema.OwnerBonds, error) { + ownerBonds := make([]*schema.OwnerBonds, len(ownerAddresses)) for index, ownerAddress := range ownerAddresses { bondsObj, err := q.GetBondsByOwner(ctx, ownerAddress) if err != nil { @@ -353,14 +355,14 @@ func (q queryResolver) QueryBondsByOwner(ctx context.Context, ownerAddresses []s return ownerBonds, nil } -func (q queryResolver) GetBondsByOwner(ctx context.Context, address string) (*OwnerBonds, error) { +func (q queryResolver) GetBondsByOwner(ctx context.Context, address string) (*schema.OwnerBonds, error) { bondQueryClient := bondtypes.NewQueryClient(q.ctx) bondResp, err := bondQueryClient.GetBondsByOwner(context.Background(), &bondtypes.QueryGetBondsByOwnerRequest{Owner: address}) if err != nil { return nil, err } - ownerBonds := make([]*Bond, len(bondResp.GetBonds())) + ownerBonds := make([]*schema.Bond, len(bondResp.GetBonds())) for i, bond := range bondResp.GetBonds() { // #nosec G601 bondObj, err := getGQLBond(&bond) //nolint: all @@ -370,12 +372,12 @@ func (q queryResolver) GetBondsByOwner(ctx context.Context, address string) (*Ow ownerBonds[i] = bondObj } - return &OwnerBonds{Bonds: ownerBonds, Owner: address}, nil + return &schema.OwnerBonds{Bonds: ownerBonds, Owner: address}, nil } -func (q queryResolver) GetAuctionsByIds(ctx context.Context, ids []string) ([]*Auction, error) { +func (q queryResolver) GetAuctionsByIds(ctx context.Context, ids []string) ([]*schema.Auction, error) { auctionQueryClient := auctiontypes.NewQueryClient(q.ctx) - gqlAuctionResponse := make([]*Auction, len(ids)) + gqlAuctionResponse := make([]*schema.Auction, len(ids)) for i, id := range ids { auctionObj, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.QueryGetAuctionRequest{Id: id}) if err != nil { @@ -397,18 +399,22 @@ func (q queryResolver) GetAuctionsByIds(ctx context.Context, ids []string) ([]*A return gqlAuctionResponse, nil } -func (q queryResolver) GetParticipants(ctx context.Context) ([]*Participant, error) { +func (q queryResolver) GetParticipants(ctx context.Context) ([]*schema.Participant, error) { onboardingQueryClient := onboardingTypes.NewQueryClient(q.ctx) participantResp, err := onboardingQueryClient.Participants(context.Background(), &onboardingTypes.QueryParticipantsRequest{}) if err != nil { return nil, err } - participants := make([]*Participant, len(participantResp.GetParticipants())) + participants := make([]*schema.Participant, len(participantResp.GetParticipants())) for i, p := range participantResp.Participants { - participants[i] = &Participant{ + nitroAddress, err := utils.EthAddressFromPubKey(p.PublicKey) + if err != nil { + return nil, err + } + participants[i] = &schema.Participant{ CosmosAddress: p.CosmosAddress, - NitroAddress: p.NitroAddress, + NitroAddress: nitroAddress.String(), Role: p.Role, KycID: p.KycId, } @@ -417,7 +423,7 @@ func (q queryResolver) GetParticipants(ctx context.Context) ([]*Participant, err return participants, nil } -func (q queryResolver) GetParticipantByAddress(ctx context.Context, address string) (*Participant, error) { +func (q queryResolver) GetParticipantByAddress(ctx context.Context, address string) (*schema.Participant, error) { onboardingQueryClient := onboardingTypes.NewQueryClient(q.ctx) participantResp, err := onboardingQueryClient.GetParticipantByAddress(ctx, &onboardingTypes.QueryGetParticipantByAddressRequest{Address: address}) if err != nil { @@ -425,9 +431,13 @@ func (q queryResolver) GetParticipantByAddress(ctx context.Context, address stri } p := participantResp.Participant - participant := &Participant{ + nitroAddress, err := utils.EthAddressFromPubKey(p.PublicKey) + if err != nil { + return nil, err + } + participant := &schema.Participant{ CosmosAddress: p.CosmosAddress, - NitroAddress: p.NitroAddress, + NitroAddress: nitroAddress.String(), Role: p.Role, KycID: p.KycId, } @@ -435,7 +445,7 @@ func (q queryResolver) GetParticipantByAddress(ctx context.Context, address stri return participant, nil } -func (q queryResolver) GetParticipantByNitroAddress(ctx context.Context, nitroAddress string) (*Participant, error) { +func (q queryResolver) GetParticipantByNitroAddress(ctx context.Context, nitroAddress string) (*schema.Participant, error) { onboardingQueryClient := onboardingTypes.NewQueryClient(q.ctx) participantResp, err := onboardingQueryClient.GetParticipantByNitroAddress( ctx, @@ -448,9 +458,9 @@ func (q queryResolver) GetParticipantByNitroAddress(ctx context.Context, nitroAd } p := participantResp.Participant - participant := &Participant{ + participant := &schema.Participant{ CosmosAddress: p.CosmosAddress, - NitroAddress: p.NitroAddress, + NitroAddress: nitroAddress, Role: p.Role, KycID: p.KycId, } diff --git a/gql/generated.go b/gql/schema/generated.go similarity index 95% rename from gql/generated.go rename to gql/schema/generated.go index 81225cfb..1633967b 100644 --- a/gql/generated.go +++ b/gql/schema/generated.go @@ -1,11 +1,10 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package gql +package schema import ( "bytes" "context" - "embed" "errors" "fmt" "strconv" @@ -1136,19 +1135,296 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } -//go:embed "cerc-io/laconicd/schema.graphql" -var sourcesFS embed.FS +var sources = []*ast.Source{ + {Name: "../cerc-io/laconicd/schema.graphql", Input: `# Reference to another record. +scalar Link -func sourceData(filename string) string { - data, err := sourcesFS.ReadFile(filename) - if err != nil { - panic(fmt.Sprintf("codegen problem: %s not available", filename)) - } - return string(data) +# Bonds contain funds that are used to pay rent on record registration and renewal. +type Bond { + id: String! # Primary key, auto-generated by the server. + owner: String! # Bond owner cosmos-sdk address. + balance: [Coin!] # Current balance for each coin type. } -var sources = []*ast.Source{ - {Name: "cerc-io/laconicd/schema.graphql", Input: sourceData("cerc-io/laconicd/schema.graphql"), BuiltIn: false}, +# OwnerBonds contains the bonds related the owner +type OwnerBonds { + owner: String! + bonds: [Bond!] +} + +# Mutations require payment in coins (e.g. 100wire). +# Used by the wallet to get the account balance for display and mutations. +type Coin { + type: String! # e.g. 'WIRE' + quantity: String! # e.g. 1000000 +} +# Represents an account on the blockchain. +# Mutations have to be signed by a particular account. +type Account { + address: String! # Blockchain address. + pubKey: String # Public key. + number: String! # Account number. + sequence: String! # Sequence number used to prevent replays. + balance: [Coin!] # Current balance for each coin type. +} + +type Participant { + cosmosAddress: String! # Cosmos address of the participant who will be registered. + nitroAddress: String! # Nitro addresss of the participant who will be registered. + role: String! # Participant's role + kycId: String! # Participant's KYC receipt ID +} + +# Value describes a DAG-JSON compatible value. +union Value = + BooleanValue + | IntValue + | FloatValue + | StringValue + | BytesValue + | LinkValue + | ArrayValue + | MapValue + +type BooleanValue { + value: Boolean! +} + +type IntValue { + value: Int! +} + +type FloatValue { + value: Float! +} + +type StringValue { + value: String! +} + +type BytesValue { + value: String! +} + +type ArrayValue { + value: [Value]! +} + +type LinkValue { + value: Link! +} + +type MapValue { + value: [Attribute!]! +} + +# Key/value pair. +type Attribute { + key: String! + value: Value +} + +# Value of a given type used as input to queries. +# Note: GQL doesn't allow union input types. +input ValueInput { + int: Int + float: Float + string: String + boolean: Boolean + link: Link + array: [ValueInput] + map: [KeyValueInput!] +} + +# Key/value pair for inputs. +input KeyValueInput { + key: String! + value: ValueInput +} + +# Status information about a node (https://docs.tendermint.com/master/rpc/#/Info/status). +type NodeInfo { + id: String! # Tendermint Node ID. + network: String! # Name of the network/blockchain. + moniker: String! # Name of the node. +} + +# Node sync status. +type SyncInfo { + latestBlockHash: String! + latestBlockHeight: String! + latestBlockTime: String! + catchingUp: Boolean! +} + +# Validator set info (https://docs.tendermint.com/master/rpc/#/Info/validators). +type ValidatorInfo { + address: String! + votingPower: String! + proposerPriority: String +} + +# Network/peer info (https://docs.tendermint.com/master/rpc/#/Info/net_info). +type PeerInfo { + node: NodeInfo! + isOutbound: Boolean! + remoteIp: String! +} + +# Vulcanize laconic status. +type Status { + version: String! + node: NodeInfo! + sync: SyncInfo! + validator: ValidatorInfo + validators: [ValidatorInfo]! + numPeers: String! + peers: [PeerInfo] + diskUsage: String! +} + +# An auction bid. +type AuctionBid { + bidderAddress: String! + status: String! + commitHash: String! + commitTime: String! + commitFee: Coin! + revealTime: String! + revealFee: Coin! + bidAmount: Coin! +} + +# A sealed-bid, 2nd price auction. +type Auction { + id: String! # Auction ID. + status: String! # Auction status (commit, reveal, expired). + ownerAddress: String! # Auction owner time. + createTime: String! # Create time. + commitsEndTime: String! # Commit phase end time. + revealsEndTime: String! # Reveal phase end time. + commitFee: Coin! # Fee required to bid/participate in the auction. + revealFee: Coin! # Reveal fee (paid back to bidders only if they unseal/reveal the bid). + minimumBid: Coin! # Minimum bid amount. + winnerAddresses: [String!]! # Winner address. + winnerBids: [Coin!]! # The winning bid amount. + winnerPrice: Coin! # The price that the winner actually pays (2nd highest bid). + maxPrice: Coin! # Max bid amount for service provider auction. + kind: String! # Auction kind. + numProviders: Int # Number of service providers + fundsReleased: Boolean! # Whether funds have been released to providers + bids: [AuctionBid!]! # Bids made in the auction. +} + +# Record defines the basic properties of an entity in the graph database. +type Record { + id: String! # Computed attribute: Multibase encoded content hash (https://github.com/multiformats/multibase). + names: [String!] # Names pointing to this CID (reverse lookup). + bondId: String! # Associated bond ID. + createTime: String! # Record create time. + expiryTime: String! # Record expiry time. + owners: [String!] # Addresses of record owners. + attributes: [Attribute!] # Record attributes. + references: [Record] # Record references. +} + +# Name authority record. +type AuthorityRecord { + ownerAddress: String! # Owner address. + ownerPublicKey: String! # Owner public key. + height: String! # Height at which record was created. + status: String! # Status (active, auction, expired). + bondId: String! # Associated bond ID. + expiryTime: String! # Authority expiry time. + auction: Auction # Authority auction. +} + +type Authority { + name: String! + entry: AuthorityRecord! +} + +# Name record entry, created at a particular height. +type NameRecordEntry { + id: String! # Target record ID. + height: String! # Height at which record was created. +} + +# Name record stores the latest and historical name -> record ID mappings. +type NameRecord { + latest: NameRecordEntry! # Latest mame record entry. + history: [NameRecordEntry] # Historical name record entries. +} + +type Query { + # + # Status API. + # + getStatus: Status! + + # Get blockchain accounts. + getAccounts(addresses: [String!]): [Account] + + # Get bonds by IDs. + getBondsByIds(ids: [String!]): [Bond] + + # Query bonds. + queryBonds: [Bond] + + # Query bonds by owner. + queryBondsByOwner(ownerAddresses: [String!]): [OwnerBonds] + + # + # GraphDB API. + # + + # Get records by IDs. + getRecordsByIds(ids: [String!]): [Record] + + # Query records. + queryRecords( + # Multiple attribute conditions are in a logical AND. + attributes: [KeyValueInput!] + + # Whether to query all records, not just named ones (false by default). + all: Boolean + + # Pagination limit + limit: Int + + # Pagination offset + offset: Int + ): [Record] + + # + # Naming API. + # + + # Get authorities list. + getAuthorities(owner: String): [Authority]! + + # Lookup authority information. + lookupAuthorities(names: [String!]): [AuthorityRecord]! + + # Lookup name to record mapping information. + lookupNames(names: [String!]): [NameRecord]! + + # Resolve names to records. + resolveNames(names: [String!]): [Record]! + + # + # Auctions API. + # + + # Get auctions by IDs. + getAuctionsByIds(ids: [String!]): [Auction] + + # Query participants. + getParticipants: [Participant]! + getParticipantByAddress(address: String!): Participant! + getParticipantByNitroAddress(nitroAddress: String!): Participant! +} +`, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) @@ -1327,7 +1603,7 @@ func (ec *executionContext) field_Query_queryRecords_args(ctx context.Context, r var arg0 []*KeyValueInput if tmp, ok := rawArgs["attributes"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("attributes")) - arg0, err = ec.unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐKeyValueInputᚄ(ctx, tmp) + arg0, err = ec.unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐKeyValueInputᚄ(ctx, tmp) if err != nil { return nil, err } @@ -1614,7 +1890,7 @@ func (ec *executionContext) _Account_balance(ctx context.Context, field graphql. } res := resTmp.([]*Coin) fc.Result = res - return ec.marshalOCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoinᚄ(ctx, field.Selections, res) + return ec.marshalOCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoinᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Account_balance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -1664,7 +1940,7 @@ func (ec *executionContext) _ArrayValue_value(ctx context.Context, field graphql } res := resTmp.([]Value) fc.Result = res - return ec.marshalNValue2ᚕgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValue(ctx, field.Selections, res) + return ec.marshalNValue2ᚕgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValue(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_ArrayValue_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -1749,7 +2025,7 @@ func (ec *executionContext) _Attribute_value(ctx context.Context, field graphql. } res := resTmp.(Value) fc.Result = res - return ec.marshalOValue2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValue(ctx, field.Selections, res) + return ec.marshalOValue2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValue(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Attribute_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2057,7 +2333,7 @@ func (ec *executionContext) _Auction_commitFee(ctx context.Context, field graphq } res := resTmp.(*Coin) fc.Result = res - return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res) + return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Auction_commitFee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2107,7 +2383,7 @@ func (ec *executionContext) _Auction_revealFee(ctx context.Context, field graphq } res := resTmp.(*Coin) fc.Result = res - return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res) + return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Auction_revealFee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2157,7 +2433,7 @@ func (ec *executionContext) _Auction_minimumBid(ctx context.Context, field graph } res := resTmp.(*Coin) fc.Result = res - return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res) + return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Auction_minimumBid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2251,7 +2527,7 @@ func (ec *executionContext) _Auction_winnerBids(ctx context.Context, field graph } res := resTmp.([]*Coin) fc.Result = res - return ec.marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoinᚄ(ctx, field.Selections, res) + return ec.marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoinᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Auction_winnerBids(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2301,7 +2577,7 @@ func (ec *executionContext) _Auction_winnerPrice(ctx context.Context, field grap } res := resTmp.(*Coin) fc.Result = res - return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res) + return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Auction_winnerPrice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2351,7 +2627,7 @@ func (ec *executionContext) _Auction_maxPrice(ctx context.Context, field graphql } res := resTmp.(*Coin) fc.Result = res - return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res) + return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Auction_maxPrice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2530,7 +2806,7 @@ func (ec *executionContext) _Auction_bids(ctx context.Context, field graphql.Col } res := resTmp.([]*AuctionBid) fc.Result = res - return ec.marshalNAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBidᚄ(ctx, field.Selections, res) + return ec.marshalNAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuctionBidᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Auction_bids(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2768,7 +3044,7 @@ func (ec *executionContext) _AuctionBid_commitFee(ctx context.Context, field gra } res := resTmp.(*Coin) fc.Result = res - return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res) + return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_AuctionBid_commitFee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2862,7 +3138,7 @@ func (ec *executionContext) _AuctionBid_revealFee(ctx context.Context, field gra } res := resTmp.(*Coin) fc.Result = res - return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res) + return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_AuctionBid_revealFee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2912,7 +3188,7 @@ func (ec *executionContext) _AuctionBid_bidAmount(ctx context.Context, field gra } res := resTmp.(*Coin) fc.Result = res - return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, field.Selections, res) + return ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_AuctionBid_bidAmount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3006,7 +3282,7 @@ func (ec *executionContext) _Authority_entry(ctx context.Context, field graphql. } res := resTmp.(*AuthorityRecord) fc.Result = res - return ec.marshalNAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx, field.Selections, res) + return ec.marshalNAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthorityRecord(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Authority_entry(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3327,7 +3603,7 @@ func (ec *executionContext) _AuthorityRecord_auction(ctx context.Context, field } res := resTmp.(*Auction) fc.Result = res - return ec.marshalOAuction2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuction(ctx, field.Selections, res) + return ec.marshalOAuction2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuction(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_AuthorityRecord_auction(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3492,7 +3768,7 @@ func (ec *executionContext) _Bond_balance(ctx context.Context, field graphql.Col } res := resTmp.([]*Coin) fc.Result = res - return ec.marshalOCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoinᚄ(ctx, field.Selections, res) + return ec.marshalOCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoinᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Bond_balance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3806,7 +4082,7 @@ func (ec *executionContext) _LinkValue_value(ctx context.Context, field graphql. } res := resTmp.(Link) fc.Result = res - return ec.marshalNLink2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐLink(ctx, field.Selections, res) + return ec.marshalNLink2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐLink(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_LinkValue_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3850,7 +4126,7 @@ func (ec *executionContext) _MapValue_value(ctx context.Context, field graphql.C } res := resTmp.([]*Attribute) fc.Result = res - return ec.marshalNAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAttributeᚄ(ctx, field.Selections, res) + return ec.marshalNAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAttributeᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_MapValue_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3900,7 +4176,7 @@ func (ec *executionContext) _NameRecord_latest(ctx context.Context, field graphq } res := resTmp.(*NameRecordEntry) fc.Result = res - return ec.marshalNNameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecordEntry(ctx, field.Selections, res) + return ec.marshalNNameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecordEntry(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_NameRecord_latest(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3947,7 +4223,7 @@ func (ec *executionContext) _NameRecord_history(ctx context.Context, field graph } res := resTmp.([]*NameRecordEntry) fc.Result = res - return ec.marshalONameRecordEntry2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecordEntry(ctx, field.Selections, res) + return ec.marshalONameRecordEntry2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecordEntry(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_NameRecord_history(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4258,7 +4534,7 @@ func (ec *executionContext) _OwnerBonds_bonds(ctx context.Context, field graphql } res := resTmp.([]*Bond) fc.Result = res - return ec.marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBondᚄ(ctx, field.Selections, res) + return ec.marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBondᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OwnerBonds_bonds(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4486,7 +4762,7 @@ func (ec *executionContext) _PeerInfo_node(ctx context.Context, field graphql.Co } res := resTmp.(*NodeInfo) fc.Result = res - return ec.marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNodeInfo(ctx, field.Selections, res) + return ec.marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNodeInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_PeerInfo_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4626,7 +4902,7 @@ func (ec *executionContext) _Query_getStatus(ctx context.Context, field graphql. } res := resTmp.(*Status) fc.Result = res - return ec.marshalNStatus2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐStatus(ctx, field.Selections, res) + return ec.marshalNStatus2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐStatus(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getStatus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4685,7 +4961,7 @@ func (ec *executionContext) _Query_getAccounts(ctx context.Context, field graphq } res := resTmp.([]*Account) fc.Result = res - return ec.marshalOAccount2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAccount(ctx, field.Selections, res) + return ec.marshalOAccount2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAccount(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4749,7 +5025,7 @@ func (ec *executionContext) _Query_getBondsByIds(ctx context.Context, field grap } res := resTmp.([]*Bond) fc.Result = res - return ec.marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBond(ctx, field.Selections, res) + return ec.marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBond(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getBondsByIds(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4809,7 +5085,7 @@ func (ec *executionContext) _Query_queryBonds(ctx context.Context, field graphql } res := resTmp.([]*Bond) fc.Result = res - return ec.marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBond(ctx, field.Selections, res) + return ec.marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBond(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_queryBonds(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4858,7 +5134,7 @@ func (ec *executionContext) _Query_queryBondsByOwner(ctx context.Context, field } res := resTmp.([]*OwnerBonds) fc.Result = res - return ec.marshalOOwnerBonds2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐOwnerBonds(ctx, field.Selections, res) + return ec.marshalOOwnerBonds2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐOwnerBonds(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_queryBondsByOwner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4916,7 +5192,7 @@ func (ec *executionContext) _Query_getRecordsByIds(ctx context.Context, field gr } res := resTmp.([]*Record) fc.Result = res - return ec.marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx, field.Selections, res) + return ec.marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getRecordsByIds(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4986,7 +5262,7 @@ func (ec *executionContext) _Query_queryRecords(ctx context.Context, field graph } res := resTmp.([]*Record) fc.Result = res - return ec.marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx, field.Selections, res) + return ec.marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_queryRecords(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5059,7 +5335,7 @@ func (ec *executionContext) _Query_getAuthorities(ctx context.Context, field gra } res := resTmp.([]*Authority) fc.Result = res - return ec.marshalNAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx, field.Selections, res) + return ec.marshalNAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthority(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getAuthorities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5120,7 +5396,7 @@ func (ec *executionContext) _Query_lookupAuthorities(ctx context.Context, field } res := resTmp.([]*AuthorityRecord) fc.Result = res - return ec.marshalNAuthorityRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx, field.Selections, res) + return ec.marshalNAuthorityRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthorityRecord(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_lookupAuthorities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5191,7 +5467,7 @@ func (ec *executionContext) _Query_lookupNames(ctx context.Context, field graphq } res := resTmp.([]*NameRecord) fc.Result = res - return ec.marshalNNameRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecord(ctx, field.Selections, res) + return ec.marshalNNameRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecord(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_lookupNames(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5252,7 +5528,7 @@ func (ec *executionContext) _Query_resolveNames(ctx context.Context, field graph } res := resTmp.([]*Record) fc.Result = res - return ec.marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx, field.Selections, res) + return ec.marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_resolveNames(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5322,7 +5598,7 @@ func (ec *executionContext) _Query_getAuctionsByIds(ctx context.Context, field g } res := resTmp.([]*Auction) fc.Result = res - return ec.marshalOAuction2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuction(ctx, field.Selections, res) + return ec.marshalOAuction2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuction(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getAuctionsByIds(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5413,7 +5689,7 @@ func (ec *executionContext) _Query_getParticipants(ctx context.Context, field gr } res := resTmp.([]*Participant) fc.Result = res - return ec.marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx, field.Selections, res) + return ec.marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐParticipant(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getParticipants(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5467,7 +5743,7 @@ func (ec *executionContext) _Query_getParticipantByAddress(ctx context.Context, } res := resTmp.(*Participant) fc.Result = res - return ec.marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx, field.Selections, res) + return ec.marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐParticipant(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getParticipantByAddress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5532,7 +5808,7 @@ func (ec *executionContext) _Query_getParticipantByNitroAddress(ctx context.Cont } res := resTmp.(*Participant) fc.Result = res - return ec.marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx, field.Selections, res) + return ec.marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐParticipant(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getParticipantByNitroAddress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5981,7 +6257,7 @@ func (ec *executionContext) _Record_attributes(ctx context.Context, field graphq } res := resTmp.([]*Attribute) fc.Result = res - return ec.marshalOAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAttributeᚄ(ctx, field.Selections, res) + return ec.marshalOAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAttributeᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Record_attributes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6028,7 +6304,7 @@ func (ec *executionContext) _Record_references(ctx context.Context, field graphq } res := resTmp.([]*Record) fc.Result = res - return ec.marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx, field.Selections, res) + return ec.marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Record_references(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6134,7 +6410,7 @@ func (ec *executionContext) _Status_node(ctx context.Context, field graphql.Coll } res := resTmp.(*NodeInfo) fc.Result = res - return ec.marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNodeInfo(ctx, field.Selections, res) + return ec.marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNodeInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Status_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6186,7 +6462,7 @@ func (ec *executionContext) _Status_sync(ctx context.Context, field graphql.Coll } res := resTmp.(*SyncInfo) fc.Result = res - return ec.marshalNSyncInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐSyncInfo(ctx, field.Selections, res) + return ec.marshalNSyncInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐSyncInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Status_sync(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6237,7 +6513,7 @@ func (ec *executionContext) _Status_validator(ctx context.Context, field graphql } res := resTmp.(*ValidatorInfo) fc.Result = res - return ec.marshalOValidatorInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValidatorInfo(ctx, field.Selections, res) + return ec.marshalOValidatorInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValidatorInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Status_validator(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6289,7 +6565,7 @@ func (ec *executionContext) _Status_validators(ctx context.Context, field graphq } res := resTmp.([]*ValidatorInfo) fc.Result = res - return ec.marshalNValidatorInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValidatorInfo(ctx, field.Selections, res) + return ec.marshalNValidatorInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValidatorInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Status_validators(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6382,7 +6658,7 @@ func (ec *executionContext) _Status_peers(ctx context.Context, field graphql.Col } res := resTmp.([]*PeerInfo) fc.Result = res - return ec.marshalOPeerInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐPeerInfo(ctx, field.Selections, res) + return ec.marshalOPeerInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐPeerInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Status_peers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -8598,7 +8874,7 @@ func (ec *executionContext) unmarshalInputKeyValueInput(ctx context.Context, obj var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) - it.Value, err = ec.unmarshalOValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValueInput(ctx, v) + it.Value, err = ec.unmarshalOValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValueInput(ctx, v) if err != nil { return it, err } @@ -8658,7 +8934,7 @@ func (ec *executionContext) unmarshalInputValueInput(ctx context.Context, obj in var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) - it.Link, err = ec.unmarshalOLink2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐLink(ctx, v) + it.Link, err = ec.unmarshalOLink2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐLink(ctx, v) if err != nil { return it, err } @@ -8666,7 +8942,7 @@ func (ec *executionContext) unmarshalInputValueInput(ctx context.Context, obj in var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("array")) - it.Array, err = ec.unmarshalOValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValueInput(ctx, v) + it.Array, err = ec.unmarshalOValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValueInput(ctx, v) if err != nil { return it, err } @@ -8674,7 +8950,7 @@ func (ec *executionContext) unmarshalInputValueInput(ctx context.Context, obj in var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) - it.Map, err = ec.unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐKeyValueInputᚄ(ctx, v) + it.Map, err = ec.unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐKeyValueInputᚄ(ctx, v) if err != nil { return it, err } @@ -10593,7 +10869,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) marshalNAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAttributeᚄ(ctx context.Context, sel ast.SelectionSet, v []*Attribute) graphql.Marshaler { +func (ec *executionContext) marshalNAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAttributeᚄ(ctx context.Context, sel ast.SelectionSet, v []*Attribute) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -10617,7 +10893,7 @@ func (ec *executionContext) marshalNAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAttribute(ctx, sel, v[i]) + ret[i] = ec.marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAttribute(ctx, sel, v[i]) } if isLen1 { f(i) @@ -10637,7 +10913,7 @@ func (ec *executionContext) marshalNAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio return ret } -func (ec *executionContext) marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAttribute(ctx context.Context, sel ast.SelectionSet, v *Attribute) graphql.Marshaler { +func (ec *executionContext) marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAttribute(ctx context.Context, sel ast.SelectionSet, v *Attribute) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -10647,7 +10923,7 @@ func (ec *executionContext) marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋla return ec._Attribute(ctx, sel, v) } -func (ec *executionContext) marshalNAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBidᚄ(ctx context.Context, sel ast.SelectionSet, v []*AuctionBid) graphql.Marshaler { +func (ec *executionContext) marshalNAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuctionBidᚄ(ctx context.Context, sel ast.SelectionSet, v []*AuctionBid) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -10671,7 +10947,7 @@ func (ec *executionContext) marshalNAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBid(ctx, sel, v[i]) + ret[i] = ec.marshalNAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuctionBid(ctx, sel, v[i]) } if isLen1 { f(i) @@ -10691,7 +10967,7 @@ func (ec *executionContext) marshalNAuctionBid2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio return ret } -func (ec *executionContext) marshalNAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuctionBid(ctx context.Context, sel ast.SelectionSet, v *AuctionBid) graphql.Marshaler { +func (ec *executionContext) marshalNAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuctionBid(ctx context.Context, sel ast.SelectionSet, v *AuctionBid) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -10701,7 +10977,7 @@ func (ec *executionContext) marshalNAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋl return ec._AuctionBid(ctx, sel, v) } -func (ec *executionContext) marshalNAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx context.Context, sel ast.SelectionSet, v []*Authority) graphql.Marshaler { +func (ec *executionContext) marshalNAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthority(ctx context.Context, sel ast.SelectionSet, v []*Authority) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -10725,7 +11001,7 @@ func (ec *executionContext) marshalNAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOAuthority2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx, sel, v[i]) + ret[i] = ec.marshalOAuthority2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthority(ctx, sel, v[i]) } if isLen1 { f(i) @@ -10739,7 +11015,7 @@ func (ec *executionContext) marshalNAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio return ret } -func (ec *executionContext) marshalNAuthorityRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx context.Context, sel ast.SelectionSet, v []*AuthorityRecord) graphql.Marshaler { +func (ec *executionContext) marshalNAuthorityRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthorityRecord(ctx context.Context, sel ast.SelectionSet, v []*AuthorityRecord) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -10763,7 +11039,7 @@ func (ec *executionContext) marshalNAuthorityRecord2ᚕᚖgitᚗvdbᚗtoᚋcerc if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx, sel, v[i]) + ret[i] = ec.marshalOAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthorityRecord(ctx, sel, v[i]) } if isLen1 { f(i) @@ -10777,7 +11053,7 @@ func (ec *executionContext) marshalNAuthorityRecord2ᚕᚖgitᚗvdbᚗtoᚋcerc return ret } -func (ec *executionContext) marshalNAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx context.Context, sel ast.SelectionSet, v *AuthorityRecord) graphql.Marshaler { +func (ec *executionContext) marshalNAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthorityRecord(ctx context.Context, sel ast.SelectionSet, v *AuthorityRecord) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -10787,7 +11063,7 @@ func (ec *executionContext) marshalNAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑi return ec._AuthorityRecord(ctx, sel, v) } -func (ec *executionContext) marshalNBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBond(ctx context.Context, sel ast.SelectionSet, v *Bond) graphql.Marshaler { +func (ec *executionContext) marshalNBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBond(ctx context.Context, sel ast.SelectionSet, v *Bond) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -10812,7 +11088,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } -func (ec *executionContext) marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoinᚄ(ctx context.Context, sel ast.SelectionSet, v []*Coin) graphql.Marshaler { +func (ec *executionContext) marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoinᚄ(ctx context.Context, sel ast.SelectionSet, v []*Coin) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -10836,7 +11112,7 @@ func (ec *executionContext) marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, sel, v[i]) + ret[i] = ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, sel, v[i]) } if isLen1 { f(i) @@ -10856,7 +11132,7 @@ func (ec *executionContext) marshalNCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco return ret } -func (ec *executionContext) marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx context.Context, sel ast.SelectionSet, v *Coin) graphql.Marshaler { +func (ec *executionContext) marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx context.Context, sel ast.SelectionSet, v *Coin) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -10896,22 +11172,22 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } -func (ec *executionContext) unmarshalNKeyValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐKeyValueInput(ctx context.Context, v interface{}) (*KeyValueInput, error) { +func (ec *executionContext) unmarshalNKeyValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐKeyValueInput(ctx context.Context, v interface{}) (*KeyValueInput, error) { res, err := ec.unmarshalInputKeyValueInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNLink2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐLink(ctx context.Context, v interface{}) (Link, error) { +func (ec *executionContext) unmarshalNLink2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐLink(ctx context.Context, v interface{}) (Link, error) { var res Link err := res.UnmarshalGQLContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNLink2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐLink(ctx context.Context, sel ast.SelectionSet, v Link) graphql.Marshaler { +func (ec *executionContext) marshalNLink2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐLink(ctx context.Context, sel ast.SelectionSet, v Link) graphql.Marshaler { return graphql.WrapContextMarshaler(ctx, v) } -func (ec *executionContext) marshalNNameRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecord(ctx context.Context, sel ast.SelectionSet, v []*NameRecord) graphql.Marshaler { +func (ec *executionContext) marshalNNameRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecord(ctx context.Context, sel ast.SelectionSet, v []*NameRecord) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -10935,7 +11211,7 @@ func (ec *executionContext) marshalNNameRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalONameRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecord(ctx, sel, v[i]) + ret[i] = ec.marshalONameRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecord(ctx, sel, v[i]) } if isLen1 { f(i) @@ -10949,7 +11225,7 @@ func (ec *executionContext) marshalNNameRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio return ret } -func (ec *executionContext) marshalNNameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecordEntry(ctx context.Context, sel ast.SelectionSet, v *NameRecordEntry) graphql.Marshaler { +func (ec *executionContext) marshalNNameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecordEntry(ctx context.Context, sel ast.SelectionSet, v *NameRecordEntry) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -10959,7 +11235,7 @@ func (ec *executionContext) marshalNNameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑi return ec._NameRecordEntry(ctx, sel, v) } -func (ec *executionContext) marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNodeInfo(ctx context.Context, sel ast.SelectionSet, v *NodeInfo) graphql.Marshaler { +func (ec *executionContext) marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNodeInfo(ctx context.Context, sel ast.SelectionSet, v *NodeInfo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -10969,11 +11245,11 @@ func (ec *executionContext) marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlac return ec._NodeInfo(ctx, sel, v) } -func (ec *executionContext) marshalNParticipant2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v Participant) graphql.Marshaler { +func (ec *executionContext) marshalNParticipant2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐParticipant(ctx context.Context, sel ast.SelectionSet, v Participant) graphql.Marshaler { return ec._Participant(ctx, sel, &v) } -func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v []*Participant) graphql.Marshaler { +func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐParticipant(ctx context.Context, sel ast.SelectionSet, v []*Participant) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -10997,7 +11273,7 @@ func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx, sel, v[i]) + ret[i] = ec.marshalOParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐParticipant(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11011,7 +11287,7 @@ func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio return ret } -func (ec *executionContext) marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v *Participant) graphql.Marshaler { +func (ec *executionContext) marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐParticipant(ctx context.Context, sel ast.SelectionSet, v *Participant) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -11021,7 +11297,7 @@ func (ec *executionContext) marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋ return ec._Participant(ctx, sel, v) } -func (ec *executionContext) marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx context.Context, sel ast.SelectionSet, v []*Record) graphql.Marshaler { +func (ec *executionContext) marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx context.Context, sel ast.SelectionSet, v []*Record) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -11045,7 +11321,7 @@ func (ec *executionContext) marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋla if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalORecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx, sel, v[i]) + ret[i] = ec.marshalORecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11059,11 +11335,11 @@ func (ec *executionContext) marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋla return ret } -func (ec *executionContext) marshalNStatus2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐStatus(ctx context.Context, sel ast.SelectionSet, v Status) graphql.Marshaler { +func (ec *executionContext) marshalNStatus2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐStatus(ctx context.Context, sel ast.SelectionSet, v Status) graphql.Marshaler { return ec._Status(ctx, sel, &v) } -func (ec *executionContext) marshalNStatus2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐStatus(ctx context.Context, sel ast.SelectionSet, v *Status) graphql.Marshaler { +func (ec *executionContext) marshalNStatus2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐStatus(ctx context.Context, sel ast.SelectionSet, v *Status) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -11120,7 +11396,7 @@ func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel return ret } -func (ec *executionContext) marshalNSyncInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐSyncInfo(ctx context.Context, sel ast.SelectionSet, v *SyncInfo) graphql.Marshaler { +func (ec *executionContext) marshalNSyncInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐSyncInfo(ctx context.Context, sel ast.SelectionSet, v *SyncInfo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -11130,7 +11406,7 @@ func (ec *executionContext) marshalNSyncInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlac return ec._SyncInfo(ctx, sel, v) } -func (ec *executionContext) marshalNValidatorInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValidatorInfo(ctx context.Context, sel ast.SelectionSet, v []*ValidatorInfo) graphql.Marshaler { +func (ec *executionContext) marshalNValidatorInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValidatorInfo(ctx context.Context, sel ast.SelectionSet, v []*ValidatorInfo) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -11154,7 +11430,7 @@ func (ec *executionContext) marshalNValidatorInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑ if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOValidatorInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValidatorInfo(ctx, sel, v[i]) + ret[i] = ec.marshalOValidatorInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValidatorInfo(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11168,7 +11444,7 @@ func (ec *executionContext) marshalNValidatorInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑ return ret } -func (ec *executionContext) marshalNValue2ᚕgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValue(ctx context.Context, sel ast.SelectionSet, v []Value) graphql.Marshaler { +func (ec *executionContext) marshalNValue2ᚕgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValue(ctx context.Context, sel ast.SelectionSet, v []Value) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -11192,7 +11468,7 @@ func (ec *executionContext) marshalNValue2ᚕgitᚗvdbᚗtoᚋcercᚑioᚋlaconi if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOValue2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValue(ctx, sel, v[i]) + ret[i] = ec.marshalOValue2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11459,7 +11735,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return res } -func (ec *executionContext) marshalOAccount2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAccount(ctx context.Context, sel ast.SelectionSet, v []*Account) graphql.Marshaler { +func (ec *executionContext) marshalOAccount2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAccount(ctx context.Context, sel ast.SelectionSet, v []*Account) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11486,7 +11762,7 @@ func (ec *executionContext) marshalOAccount2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋl if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOAccount2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAccount(ctx, sel, v[i]) + ret[i] = ec.marshalOAccount2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAccount(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11500,14 +11776,14 @@ func (ec *executionContext) marshalOAccount2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋl return ret } -func (ec *executionContext) marshalOAccount2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAccount(ctx context.Context, sel ast.SelectionSet, v *Account) graphql.Marshaler { +func (ec *executionContext) marshalOAccount2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAccount(ctx context.Context, sel ast.SelectionSet, v *Account) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Account(ctx, sel, v) } -func (ec *executionContext) marshalOAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAttributeᚄ(ctx context.Context, sel ast.SelectionSet, v []*Attribute) graphql.Marshaler { +func (ec *executionContext) marshalOAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAttributeᚄ(ctx context.Context, sel ast.SelectionSet, v []*Attribute) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11534,7 +11810,7 @@ func (ec *executionContext) marshalOAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAttribute(ctx, sel, v[i]) + ret[i] = ec.marshalNAttribute2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAttribute(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11554,7 +11830,7 @@ func (ec *executionContext) marshalOAttribute2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio return ret } -func (ec *executionContext) marshalOAuction2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuction(ctx context.Context, sel ast.SelectionSet, v []*Auction) graphql.Marshaler { +func (ec *executionContext) marshalOAuction2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuction(ctx context.Context, sel ast.SelectionSet, v []*Auction) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11581,7 +11857,7 @@ func (ec *executionContext) marshalOAuction2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋl if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOAuction2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuction(ctx, sel, v[i]) + ret[i] = ec.marshalOAuction2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuction(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11595,28 +11871,28 @@ func (ec *executionContext) marshalOAuction2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋl return ret } -func (ec *executionContext) marshalOAuction2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuction(ctx context.Context, sel ast.SelectionSet, v *Auction) graphql.Marshaler { +func (ec *executionContext) marshalOAuction2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuction(ctx context.Context, sel ast.SelectionSet, v *Auction) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Auction(ctx, sel, v) } -func (ec *executionContext) marshalOAuthority2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx context.Context, sel ast.SelectionSet, v *Authority) graphql.Marshaler { +func (ec *executionContext) marshalOAuthority2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthority(ctx context.Context, sel ast.SelectionSet, v *Authority) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Authority(ctx, sel, v) } -func (ec *executionContext) marshalOAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx context.Context, sel ast.SelectionSet, v *AuthorityRecord) graphql.Marshaler { +func (ec *executionContext) marshalOAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐAuthorityRecord(ctx context.Context, sel ast.SelectionSet, v *AuthorityRecord) graphql.Marshaler { if v == nil { return graphql.Null } return ec._AuthorityRecord(ctx, sel, v) } -func (ec *executionContext) marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBond(ctx context.Context, sel ast.SelectionSet, v []*Bond) graphql.Marshaler { +func (ec *executionContext) marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBond(ctx context.Context, sel ast.SelectionSet, v []*Bond) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11643,7 +11919,7 @@ func (ec *executionContext) marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBond(ctx, sel, v[i]) + ret[i] = ec.marshalOBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBond(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11657,7 +11933,7 @@ func (ec *executionContext) marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco return ret } -func (ec *executionContext) marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBondᚄ(ctx context.Context, sel ast.SelectionSet, v []*Bond) graphql.Marshaler { +func (ec *executionContext) marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBondᚄ(ctx context.Context, sel ast.SelectionSet, v []*Bond) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11684,7 +11960,7 @@ func (ec *executionContext) marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBond(ctx, sel, v[i]) + ret[i] = ec.marshalNBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBond(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11704,7 +11980,7 @@ func (ec *executionContext) marshalOBond2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco return ret } -func (ec *executionContext) marshalOBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBond(ctx context.Context, sel ast.SelectionSet, v *Bond) graphql.Marshaler { +func (ec *executionContext) marshalOBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐBond(ctx context.Context, sel ast.SelectionSet, v *Bond) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11737,7 +12013,7 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } -func (ec *executionContext) marshalOCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoinᚄ(ctx context.Context, sel ast.SelectionSet, v []*Coin) graphql.Marshaler { +func (ec *executionContext) marshalOCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoinᚄ(ctx context.Context, sel ast.SelectionSet, v []*Coin) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11764,7 +12040,7 @@ func (ec *executionContext) marshalOCoin2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaco if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐCoin(ctx, sel, v[i]) + ret[i] = ec.marshalNCoin2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐCoin(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11816,7 +12092,7 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return res } -func (ec *executionContext) unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐKeyValueInputᚄ(ctx context.Context, v interface{}) ([]*KeyValueInput, error) { +func (ec *executionContext) unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐKeyValueInputᚄ(ctx context.Context, v interface{}) ([]*KeyValueInput, error) { if v == nil { return nil, nil } @@ -11828,7 +12104,7 @@ func (ec *executionContext) unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcerc res := make([]*KeyValueInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNKeyValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐKeyValueInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalNKeyValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐKeyValueInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -11836,7 +12112,7 @@ func (ec *executionContext) unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcerc return res, nil } -func (ec *executionContext) unmarshalOLink2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐLink(ctx context.Context, v interface{}) (*Link, error) { +func (ec *executionContext) unmarshalOLink2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐLink(ctx context.Context, v interface{}) (*Link, error) { if v == nil { return nil, nil } @@ -11845,21 +12121,21 @@ func (ec *executionContext) unmarshalOLink2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlacon return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalOLink2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐLink(ctx context.Context, sel ast.SelectionSet, v *Link) graphql.Marshaler { +func (ec *executionContext) marshalOLink2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐLink(ctx context.Context, sel ast.SelectionSet, v *Link) graphql.Marshaler { if v == nil { return graphql.Null } return graphql.WrapContextMarshaler(ctx, v) } -func (ec *executionContext) marshalONameRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecord(ctx context.Context, sel ast.SelectionSet, v *NameRecord) graphql.Marshaler { +func (ec *executionContext) marshalONameRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecord(ctx context.Context, sel ast.SelectionSet, v *NameRecord) graphql.Marshaler { if v == nil { return graphql.Null } return ec._NameRecord(ctx, sel, v) } -func (ec *executionContext) marshalONameRecordEntry2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecordEntry(ctx context.Context, sel ast.SelectionSet, v []*NameRecordEntry) graphql.Marshaler { +func (ec *executionContext) marshalONameRecordEntry2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecordEntry(ctx context.Context, sel ast.SelectionSet, v []*NameRecordEntry) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11886,7 +12162,7 @@ func (ec *executionContext) marshalONameRecordEntry2ᚕᚖgitᚗvdbᚗtoᚋcerc if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalONameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecordEntry(ctx, sel, v[i]) + ret[i] = ec.marshalONameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecordEntry(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11900,14 +12176,14 @@ func (ec *executionContext) marshalONameRecordEntry2ᚕᚖgitᚗvdbᚗtoᚋcerc return ret } -func (ec *executionContext) marshalONameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐNameRecordEntry(ctx context.Context, sel ast.SelectionSet, v *NameRecordEntry) graphql.Marshaler { +func (ec *executionContext) marshalONameRecordEntry2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐNameRecordEntry(ctx context.Context, sel ast.SelectionSet, v *NameRecordEntry) graphql.Marshaler { if v == nil { return graphql.Null } return ec._NameRecordEntry(ctx, sel, v) } -func (ec *executionContext) marshalOOwnerBonds2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐOwnerBonds(ctx context.Context, sel ast.SelectionSet, v []*OwnerBonds) graphql.Marshaler { +func (ec *executionContext) marshalOOwnerBonds2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐOwnerBonds(ctx context.Context, sel ast.SelectionSet, v []*OwnerBonds) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11934,7 +12210,7 @@ func (ec *executionContext) marshalOOwnerBonds2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOOwnerBonds2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐOwnerBonds(ctx, sel, v[i]) + ret[i] = ec.marshalOOwnerBonds2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐOwnerBonds(ctx, sel, v[i]) } if isLen1 { f(i) @@ -11948,21 +12224,21 @@ func (ec *executionContext) marshalOOwnerBonds2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio return ret } -func (ec *executionContext) marshalOOwnerBonds2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐOwnerBonds(ctx context.Context, sel ast.SelectionSet, v *OwnerBonds) graphql.Marshaler { +func (ec *executionContext) marshalOOwnerBonds2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐOwnerBonds(ctx context.Context, sel ast.SelectionSet, v *OwnerBonds) graphql.Marshaler { if v == nil { return graphql.Null } return ec._OwnerBonds(ctx, sel, v) } -func (ec *executionContext) marshalOParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v *Participant) graphql.Marshaler { +func (ec *executionContext) marshalOParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐParticipant(ctx context.Context, sel ast.SelectionSet, v *Participant) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Participant(ctx, sel, v) } -func (ec *executionContext) marshalOPeerInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐPeerInfo(ctx context.Context, sel ast.SelectionSet, v []*PeerInfo) graphql.Marshaler { +func (ec *executionContext) marshalOPeerInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐPeerInfo(ctx context.Context, sel ast.SelectionSet, v []*PeerInfo) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11989,7 +12265,7 @@ func (ec *executionContext) marshalOPeerInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋ if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOPeerInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐPeerInfo(ctx, sel, v[i]) + ret[i] = ec.marshalOPeerInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐPeerInfo(ctx, sel, v[i]) } if isLen1 { f(i) @@ -12003,14 +12279,14 @@ func (ec *executionContext) marshalOPeerInfo2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋ return ret } -func (ec *executionContext) marshalOPeerInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐPeerInfo(ctx context.Context, sel ast.SelectionSet, v *PeerInfo) graphql.Marshaler { +func (ec *executionContext) marshalOPeerInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐPeerInfo(ctx context.Context, sel ast.SelectionSet, v *PeerInfo) graphql.Marshaler { if v == nil { return graphql.Null } return ec._PeerInfo(ctx, sel, v) } -func (ec *executionContext) marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx context.Context, sel ast.SelectionSet, v []*Record) graphql.Marshaler { +func (ec *executionContext) marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx context.Context, sel ast.SelectionSet, v []*Record) graphql.Marshaler { if v == nil { return graphql.Null } @@ -12037,7 +12313,7 @@ func (ec *executionContext) marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋla if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalORecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx, sel, v[i]) + ret[i] = ec.marshalORecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx, sel, v[i]) } if isLen1 { f(i) @@ -12051,7 +12327,7 @@ func (ec *executionContext) marshalORecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋla return ret } -func (ec *executionContext) marshalORecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx context.Context, sel ast.SelectionSet, v *Record) graphql.Marshaler { +func (ec *executionContext) marshalORecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐRecord(ctx context.Context, sel ast.SelectionSet, v *Record) graphql.Marshaler { if v == nil { return graphql.Null } @@ -12112,21 +12388,21 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return res } -func (ec *executionContext) marshalOValidatorInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValidatorInfo(ctx context.Context, sel ast.SelectionSet, v *ValidatorInfo) graphql.Marshaler { +func (ec *executionContext) marshalOValidatorInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValidatorInfo(ctx context.Context, sel ast.SelectionSet, v *ValidatorInfo) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ValidatorInfo(ctx, sel, v) } -func (ec *executionContext) marshalOValue2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValue(ctx context.Context, sel ast.SelectionSet, v Value) graphql.Marshaler { +func (ec *executionContext) marshalOValue2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValue(ctx context.Context, sel ast.SelectionSet, v Value) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Value(ctx, sel, v) } -func (ec *executionContext) unmarshalOValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValueInput(ctx context.Context, v interface{}) ([]*ValueInput, error) { +func (ec *executionContext) unmarshalOValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValueInput(ctx context.Context, v interface{}) ([]*ValueInput, error) { if v == nil { return nil, nil } @@ -12138,7 +12414,7 @@ func (ec *executionContext) unmarshalOValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑi res := make([]*ValueInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalOValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValueInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalOValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValueInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -12146,7 +12422,7 @@ func (ec *executionContext) unmarshalOValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑi return res, nil } -func (ec *executionContext) unmarshalOValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐValueInput(ctx context.Context, v interface{}) (*ValueInput, error) { +func (ec *executionContext) unmarshalOValueInput2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚋschemaᚐValueInput(ctx context.Context, v interface{}) (*ValueInput, error) { if v == nil { return nil, nil } diff --git a/gql/scalar.go b/gql/schema/link.go similarity index 97% rename from gql/scalar.go rename to gql/schema/link.go index c53b4149..cfa9034a 100644 --- a/gql/scalar.go +++ b/gql/schema/link.go @@ -1,4 +1,4 @@ -package gql +package schema import ( "context" diff --git a/gql/models_gen.go b/gql/schema/models_gen.go similarity index 99% rename from gql/models_gen.go rename to gql/schema/models_gen.go index 5afebccd..6494d9f0 100644 --- a/gql/models_gen.go +++ b/gql/schema/models_gen.go @@ -1,6 +1,6 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package gql +package schema type Value interface { IsValue() diff --git a/gql/server.go b/gql/server.go index fbf95a48..ae999142 100644 --- a/gql/server.go +++ b/gql/server.go @@ -2,74 +2,117 @@ package gql import ( "context" + "errors" "fmt" "net/http" "time" "cosmossdk.io/log" "github.com/99designs/gqlgen/graphql/handler" + "github.com/cosmos/cosmos-sdk/client" "github.com/go-chi/chi/v5" "github.com/rs/cors" - "github.com/spf13/viper" + "github.com/spf13/pflag" - "github.com/cosmos/cosmos-sdk/client" + "git.vdb.to/cerc-io/laconicd/gql/schema" + "git.vdb.to/cerc-io/laconicd/server" ) -// Server configures and starts the GQL server. -func Server(ctx context.Context, clientCtx client.Context, logger log.Logger) error { - if !viper.GetBool("gql-server") { - return nil +const ( + ServerName = "gql" +) + +type Server struct { + logger log.Logger + router chi.Router + config *Config + httpServer *http.Server +} + +// func New(logger log.Logger, cfg server.ConfigMap, clientCtx client.Context) (*Server, error) { +func New(clientCtx client.Context, cfg server.ConfigMap, logger log.Logger) (*Server, error) { + s := &Server{ + logger: logger.With(log.ModuleKey, ServerName), + router: chi.NewRouter(), } - router := chi.NewRouter() + s.config = s.Config().(*Config) + if len(cfg) > 0 { + if err := server.UnmarshalSubConfig(cfg, s.Name(), &s.config); err != nil { + return nil, fmt.Errorf("failed to unmarshal config: %w", err) + } + } // Add CORS middleware around every request // See https://github.com/rs/cors for full option listing - router.Use(cors.New(cors.Options{ + s.router.Use(cors.New(cors.Options{ AllowedOrigins: []string{"*"}, Debug: false, }).Handler) - logFile := viper.GetString("log-file") - - port := viper.GetString("gql-port") - - srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{ - ctx: clientCtx, - logFile: logFile, + srv := handler.NewDefaultServer(schema.NewExecutableSchema(schema.Config{Resolvers: &Resolver{ + ctx: clientCtx, + // logFile: logFile, }})) - router.Handle("/", PlaygroundHandler("/api")) + s.router.Handle("/", PlaygroundHandler("/api")) - if viper.GetBool("gql-playground") { - apiBase := viper.GetString("gql-playground-api-base") - - router.Handle("/webui", PlaygroundHandler(apiBase+"/api")) - router.Handle("/console", PlaygroundHandler(apiBase+"/graphql")) + if s.config.Playground { + apiBase := s.config.PlaygroundAPIBase + s.router.Handle("/webui", PlaygroundHandler(apiBase+"/api")) + s.router.Handle("/console", PlaygroundHandler(apiBase+"/graphql")) } - router.Handle("/api", srv) - router.Handle("/graphql", srv) + s.router.Handle("/api", srv) + s.router.Handle("/graphql", srv) + return s, nil +} - errCh := make(chan error) +func (s *Server) Name() string { + return ServerName +} - go func() { - logger.Info(fmt.Sprintf("Connect to GraphQL playground url: http://localhost:%s", port)) - server := &http.Server{ - Addr: ":" + port, - Handler: router, - ReadHeaderTimeout: 3 * time.Second, - } - errCh <- server.ListenAndServe() - }() - - select { - case <-ctx.Done(): - // Gracefully stop the GQL server. - logger.Info("Stopping GQL server...") +// Server configures and starts the GQL server. +func (s *Server) Start(ctx context.Context) error { + if !s.config.Enable { + s.logger.Info(fmt.Sprintf("%s server is disabled via config", s.Name())) return nil - case err := <-errCh: - logger.Error(fmt.Sprintf("Failed to start GQL server: %s", err)) + } + + if s.config.Playground { + s.logger.Info(fmt.Sprintf("Connect to GraphQL playground URL at http://localhost:%d", s.config.Port)) + } + s.httpServer = &http.Server{ + Addr: fmt.Sprintf(":%d", s.config.Port), + Handler: s.router, + ReadHeaderTimeout: 3 * time.Second, + } + if err := s.httpServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { + s.logger.Error("Failed to start GraphQL server", "error", err) return err } + return nil +} + +func (s *Server) Stop(ctx context.Context) error { + if !s.config.Enable { + return nil + } + + s.logger.Info("stopping GraphQL server") + return s.httpServer.Shutdown(ctx) + +} + +func (s *Server) Config() any { + if s.config == nil { + return DefaultConfig() + } + return s.config +} + +func (s *Server) StartCmdFlags() *pflag.FlagSet { + flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError) + AddGQLFlags(flags) + return flags } diff --git a/gql/status.go b/gql/status.go index 955dc949..eda840e2 100644 --- a/gql/status.go +++ b/gql/status.go @@ -7,13 +7,14 @@ import ( "strconv" "strings" + "git.vdb.to/cerc-io/laconicd/gql/schema" "github.com/cosmos/cosmos-sdk/client" ) // NodeDataPath is the path to the laconicd data folder. var NodeDataPath = os.ExpandEnv("$HOME/.laconicd/data") -func getStatusInfo(client client.Context) (*NodeInfo, *SyncInfo, *ValidatorInfo, error) { +func getStatusInfo(client client.Context) (*schema.NodeInfo, *schema.SyncInfo, *schema.ValidatorInfo, error) { nodeClient, err := client.GetNode() if err != nil { return nil, nil, nil, err @@ -23,16 +24,16 @@ func getStatusInfo(client client.Context) (*NodeInfo, *SyncInfo, *ValidatorInfo, return nil, nil, nil, err } - return &NodeInfo{ + return &schema.NodeInfo{ ID: string(nodeStatus.NodeInfo.ID()), Network: nodeStatus.NodeInfo.Network, Moniker: nodeStatus.NodeInfo.Moniker, - }, &SyncInfo{ + }, &schema.SyncInfo{ LatestBlockHash: nodeStatus.SyncInfo.LatestBlockHash.String(), LatestBlockHeight: strconv.FormatInt(nodeStatus.SyncInfo.LatestBlockHeight, 10), LatestBlockTime: nodeStatus.SyncInfo.LatestBlockTime.String(), CatchingUp: nodeStatus.SyncInfo.CatchingUp, - }, &ValidatorInfo{ + }, &schema.ValidatorInfo{ Address: nodeStatus.ValidatorInfo.Address.String(), VotingPower: strconv.FormatInt(nodeStatus.ValidatorInfo.VotingPower, 10), ProposerPriority: nil, @@ -40,7 +41,7 @@ func getStatusInfo(client client.Context) (*NodeInfo, *SyncInfo, *ValidatorInfo, } // nolint: all -func getNetInfo(_ client.Context) (string, []*PeerInfo, error) { +func getNetInfo(_ client.Context) (string, []*schema.PeerInfo, error) { // TODO: Implement // nodeClient, err := client.GetNode() @@ -68,10 +69,10 @@ func getNetInfo(_ client.Context) (string, []*PeerInfo, error) { // return strconv.FormatInt(int64(netInfo.NPeers), 10), peersInfo, nil - return strconv.FormatInt(int64(0), 10), []*PeerInfo{}, nil + return strconv.FormatInt(int64(0), 10), []*schema.PeerInfo{}, nil } -func getValidatorSet(client client.Context) ([]*ValidatorInfo, error) { +func getValidatorSet(client client.Context) ([]*schema.ValidatorInfo, error) { nodeClient, err := client.GetNode() if err != nil { return nil, err @@ -81,10 +82,10 @@ func getValidatorSet(client client.Context) ([]*ValidatorInfo, error) { return nil, err } - validatorSet := make([]*ValidatorInfo, len(res.Validators)) + validatorSet := make([]*schema.ValidatorInfo, len(res.Validators)) for index, validator := range res.Validators { proposerPriority := strconv.FormatInt(validator.ProposerPriority, 10) - validatorSet[index] = &ValidatorInfo{ + validatorSet[index] = &schema.ValidatorInfo{ Address: validator.Address.String(), VotingPower: strconv.FormatInt(validator.VotingPower, 10), ProposerPriority: &proposerPriority, diff --git a/gql/util.go b/gql/util.go index c8c70f09..745352bf 100644 --- a/gql/util.go +++ b/gql/util.go @@ -9,6 +9,7 @@ import ( "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/codec/dagjson" + "git.vdb.to/cerc-io/laconicd/gql/schema" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" bondtypes "git.vdb.to/cerc-io/laconicd/x/bond" registrytypes "git.vdb.to/cerc-io/laconicd/x/registry" @@ -23,8 +24,8 @@ const BondIDAttributeName = "bondId" // ExpiryTimeAttributeName denotes the record expiry time. const ExpiryTimeAttributeName = "expiryTime" -func getGQLCoin(coin sdk.Coin) *Coin { - gqlCoin := Coin{ +func getGQLCoin(coin sdk.Coin) *schema.Coin { + gqlCoin := schema.Coin{ Type: coin.Denom, Quantity: coin.Amount.BigInt().String(), } @@ -32,8 +33,8 @@ func getGQLCoin(coin sdk.Coin) *Coin { return &gqlCoin } -func getGQLCoins(coins sdk.Coins) []*Coin { - gqlCoins := make([]*Coin, len(coins)) +func getGQLCoins(coins sdk.Coins) []*schema.Coin { + gqlCoins := make([]*schema.Coin, len(coins)) for index, coin := range coins { gqlCoins[index] = getGQLCoin(coin) } @@ -41,12 +42,12 @@ func getGQLCoins(coins sdk.Coins) []*Coin { return gqlCoins } -func GetGQLNameAuthorityRecord(record *registrytypes.NameAuthority) (*AuthorityRecord, error) { +func GetGQLNameAuthorityRecord(record *registrytypes.NameAuthority) (*schema.AuthorityRecord, error) { if record == nil { return nil, nil } - return &AuthorityRecord{ + return &schema.AuthorityRecord{ OwnerAddress: record.OwnerAddress, OwnerPublicKey: record.OwnerPublicKey, Height: strconv.FormatUint(record.Height, 10), @@ -56,7 +57,7 @@ func GetGQLNameAuthorityRecord(record *registrytypes.NameAuthority) (*AuthorityR }, nil } -func getGQLRecord(ctx context.Context, resolver QueryResolver, record registrytypes.Record) (*Record, error) { +func getGQLRecord(ctx context.Context, resolver schema.QueryResolver, record registrytypes.Record) (*schema.Record, error) { // Nil record. if record.Deleted { return nil, nil @@ -81,22 +82,22 @@ func getGQLRecord(ctx context.Context, resolver QueryResolver, record registryty return nil, err } - return &Record{ + return &schema.Record{ ID: record.Id, BondID: record.GetBondId(), CreateTime: record.GetCreateTime(), ExpiryTime: record.GetExpiryTime(), Owners: record.GetOwners(), Names: record.GetNames(), - Attributes: attributes.(MapValue).Value, + Attributes: attributes.(schema.MapValue).Value, References: references, }, nil } -func resolveIPLDNode(node ipld.Node, links *[]string) (Value, error) { +func resolveIPLDNode(node ipld.Node, links *[]string) (schema.Value, error) { switch node.Kind() { case ipld.Kind_Map: - var entries []*Attribute + var entries []*schema.Attribute for itr := node.MapIterator(); !itr.Done(); { k, v, err := itr.Next() if err != nil { @@ -113,14 +114,14 @@ func resolveIPLDNode(node ipld.Node, links *[]string) (Value, error) { if err != nil { return nil, err } - entries = append(entries, &Attribute{ + entries = append(entries, &schema.Attribute{ Key: s, Value: val, }) } - return MapValue{entries}, nil + return schema.MapValue{entries}, nil case ipld.Kind_List: - var values []Value + var values []schema.Value for itr := node.ListIterator(); !itr.Done(); { _, v, err := itr.Next() if err != nil { @@ -132,7 +133,7 @@ func resolveIPLDNode(node ipld.Node, links *[]string) (Value, error) { } values = append(values, val) } - return ArrayValue{values}, nil + return schema.ArrayValue{values}, nil case ipld.Kind_Null: return nil, nil case ipld.Kind_Bool: @@ -140,82 +141,82 @@ func resolveIPLDNode(node ipld.Node, links *[]string) (Value, error) { if err != nil { return nil, err } - return BooleanValue{val}, nil + return schema.BooleanValue{val}, nil case ipld.Kind_Int: val, err := node.AsInt() if err != nil { return nil, err } // TODO: handle bigger ints - return IntValue{int(val)}, nil + return schema.IntValue{int(val)}, nil case ipld.Kind_Float: val, err := node.AsFloat() if err != nil { return nil, err } - return FloatValue{val}, nil + return schema.FloatValue{val}, nil case ipld.Kind_String: val, err := node.AsString() if err != nil { return nil, err } - return StringValue{val}, nil + return schema.StringValue{val}, nil case ipld.Kind_Bytes: val, err := node.AsBytes() if err != nil { return nil, err } - return BytesValue{string(val)}, nil + return schema.BytesValue{string(val)}, nil case ipld.Kind_Link: val, err := node.AsLink() if err != nil { return nil, err } *links = append(*links, val.String()) - return LinkValue{Link(val.String())}, nil + return schema.LinkValue{schema.Link(val.String())}, nil default: return nil, fmt.Errorf("invalid node kind") } } -func getGQLNameRecord(record *registrytypes.NameRecord) (*NameRecord, error) { +func getGQLNameRecord(record *registrytypes.NameRecord) (*schema.NameRecord, error) { if record == nil { return nil, fmt.Errorf("got nil record") } - records := make([]*NameRecordEntry, len(record.History)) + records := make([]*schema.NameRecordEntry, len(record.History)) for index, entry := range record.History { records[index] = getNameRecordEntry(entry) } - return &NameRecord{ + return &schema.NameRecord{ Latest: getNameRecordEntry(record.Latest), History: records, }, nil } -func getNameRecordEntry(record *registrytypes.NameRecordEntry) *NameRecordEntry { - return &NameRecordEntry{ +func getNameRecordEntry(record *registrytypes.NameRecordEntry) *schema.NameRecordEntry { + return &schema.NameRecordEntry{ ID: record.Id, Height: strconv.FormatUint(record.Height, 10), } } -func getGQLBond(bondObj *bondtypes.Bond) (*Bond, error) { +func getGQLBond(bondObj *bondtypes.Bond) (*schema.Bond, error) { // Nil record. if bondObj == nil { return nil, nil } - return &Bond{ + return &schema.Bond{ ID: bondObj.Id, Owner: bondObj.Owner, Balance: getGQLCoins(bondObj.Balance), }, nil } -func getAuctionBid(bid *auctiontypes.Bid) *AuctionBid { - return &AuctionBid{ +func getAuctionBid(bid *auctiontypes.Bid) *schema.AuctionBid { + return &schema.AuctionBid{ BidderAddress: bid.BidderAddress, Status: bid.Status, CommitHash: bid.CommitHash, @@ -227,14 +228,14 @@ func getAuctionBid(bid *auctiontypes.Bid) *AuctionBid { } } -func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Auction, error) { +func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*schema.Auction, error) { if auction == nil { return nil, nil } numProviders := int(auction.NumProviders) - gqlAuction := Auction{ + gqlAuction := schema.Auction{ ID: auction.Id, Status: auction.Status, OwnerAddress: auction.OwnerAddress, @@ -253,7 +254,7 @@ func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Au FundsReleased: auction.FundsReleased, } - auctionBids := make([]*AuctionBid, len(bids)) + auctionBids := make([]*schema.AuctionBid, len(bids)) for index, entry := range bids { auctionBids[index] = getAuctionBid(entry) } @@ -263,7 +264,7 @@ func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Au return &gqlAuction, nil } -func toRPCValue(value *ValueInput) *registrytypes.QueryRecordsRequest_ValueInput { +func toRPCValue(value *schema.ValueInput) *registrytypes.QueryRecordsRequest_ValueInput { var rpcval registrytypes.QueryRecordsRequest_ValueInput switch { @@ -295,7 +296,7 @@ func toRPCValue(value *ValueInput) *registrytypes.QueryRecordsRequest_ValueInput return &rpcval } -func toRPCAttributes(attrs []*KeyValueInput) []*registrytypes.QueryRecordsRequest_KeyValueInput { +func toRPCAttributes(attrs []*schema.KeyValueInput) []*registrytypes.QueryRecordsRequest_KeyValueInput { kvPairs := []*registrytypes.QueryRecordsRequest_KeyValueInput{} for _, value := range attrs { @@ -310,7 +311,7 @@ func toRPCAttributes(attrs []*KeyValueInput) []*registrytypes.QueryRecordsReques return kvPairs } -func getAuthorityRecord(nameAuthority registrytypes.NameAuthority, auctionQueryClient auctiontypes.QueryClient) (*AuthorityRecord, error) { +func getAuthorityRecord(nameAuthority registrytypes.NameAuthority, auctionQueryClient auctiontypes.QueryClient) (*schema.AuthorityRecord, error) { gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority) if err != nil { return nil, err diff --git a/proto/buf.yaml b/proto/buf.yaml index 202f3f2e..ac492faf 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -4,6 +4,7 @@ deps: - buf.build/cosmos/cosmos-proto - buf.build/cosmos/gogo-proto - buf.build/googleapis/googleapis + - buf.build/protocolbuffers/wellknowntypes lint: use: - DEFAULT diff --git a/proto/cerc/nitro/module/v1/module.proto b/proto/cerc/nitro/module/v1/module.proto new file mode 100644 index 00000000..851c7770 --- /dev/null +++ b/proto/cerc/nitro/module/v1/module.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package cerc.nitro.module.v1; + +import "cosmos/app/v1alpha1/module.proto"; + +// Module is the app config object of the module. +// Learn more: https://docs.cosmos.network/main/building-modules/depinject +message Module { + option (cosmos.app.v1alpha1.module) = { + go_import : "git.vdb.to/cerc-io/laconicd/x/nitro" + }; + + // authority defines the custom module authority. If not set, defaults to the + // governance module. + string authority = 2; + + // TODO LNT address here? + string token_address = 3; +} diff --git a/proto/cerc/nitro/v1/nitro.proto b/proto/cerc/nitro/v1/nitro.proto new file mode 100644 index 00000000..db6442d7 --- /dev/null +++ b/proto/cerc/nitro/v1/nitro.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package cerc.nitro.v1; + +import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1"; + +// Params defines the parameters of the nitro module. +message Params { + bytes nitro_adjudicator_address = 1; + bytes virtual_payment_app_address = 2; + bytes consensus_app_address = 3; +} + +message PaymentChannel { + string channel_id = 1; + // TODO +} + +message Fund { + option (gogoproto.equal) = true; + + string token_address = 1; + string amount = 2 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/cerc/nitro/v1/p2p.proto b/proto/cerc/nitro/v1/p2p.proto new file mode 100644 index 00000000..33cf7b5b --- /dev/null +++ b/proto/cerc/nitro/v1/p2p.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package cerc.nitro.v1; + +option go_package = "git.vdb.to/cerc-io/laconicd/server/nitro"; + +// P2PMessage wraps a json-encoded Nitro protocols.Message +// TODO: proper proto message? +message P2PMessage { + string content = 1; +} diff --git a/proto/cerc/nitro/v1/query.proto b/proto/cerc/nitro/v1/query.proto new file mode 100644 index 00000000..be7d91d4 --- /dev/null +++ b/proto/cerc/nitro/v1/query.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package cerc.nitro.v1; + +import "google/api/annotations.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/msg/v1/msg.proto"; + +option go_package = "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1"; + +service Query { + +} diff --git a/proto/cerc/nitro/v1/tx.proto b/proto/cerc/nitro/v1/tx.proto new file mode 100644 index 00000000..740e7b9f --- /dev/null +++ b/proto/cerc/nitro/v1/tx.proto @@ -0,0 +1,139 @@ +syntax = "proto3"; + +package cerc.nitro.v1; + +import "google/api/annotations.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/msg/v1/msg.proto"; + +option go_package = "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1"; + +// 1. user submits OpenChannel tx (from local relay node) +// +// 2. tx is not processed; instead first block proposer to pick up tx triggers Nitro +// CreateLedgerChannel call (or client makes the call and the tx indicates it was made, then +// proposer pushes an event to Nitro?) +// +// 3. objective is cranked among Nitro nodes over comet p2p +// +// 4. once complete, block proposer includes actual tx; client can detect update via Event api + +service Msg { + option (cosmos.msg.v1.service) = true; + + // TODO: OpenLedgerChannel? + rpc OpenChannel(MsgOpenChannel) returns (MsgOpenChannelResponse) { + option (google.api.http).post = "/cerc/nitro/v1/open_channel"; + } + + rpc CloseChannel(MsgCloseChannel) returns (MsgCloseChannelResponse) { + option (google.api.http).post = "/cerc/nitro/v1/close_channel"; + } + + rpc CreatePaymentChannel(MsgCreatePaymentChannel) returns (MsgCreatePaymentChannelResponse) { + option (google.api.http).post = "/cerc/nitro/v1/create_payment_channel"; + } + + rpc ClosePaymentChannel(MsgClosePaymentChannel) returns (MsgClosePaymentChannelResponse) { + option (google.api.http).post = "/cerc/nitro/v1/close_payment_channel"; + } + + rpc Pay(MsgPay) returns (MsgPayResponse) { + option (google.api.http).post = "/cerc/nitro/v1/pay"; + } +} + +message MsgOpenChannel { + option (cosmos.msg.v1.signer) = "signer"; + + // Nitro address of proposing party + string nitro_address = 1; + + // Nitro address of counterparty + string counterparty = 2; + + // Simplified outcome just includes the funding amount from payer + // TODO: review use of coins to represent ETH/ERC20 + repeated cosmos.base.v1beta1.Coin funds = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + + // Nitro channel ID + string channel_id = 4; + + // Tx signer address is independent of proposer ETH address + string signer = 5; +} +message MsgOpenChannelResponse {} + +message MsgCloseChannel { + option (cosmos.msg.v1.signer) = "signer"; + + // Nitro channel ID to close + string channel_id = 1; + + // Whether to close via challenge (dispute resolution) or cooperative closure + bool is_challenge = 2; + + // Laconic address of proposing party + string signer = 3; +} +message MsgCloseChannelResponse {} + +message MsgCreatePaymentChannel { + option (cosmos.msg.v1.signer) = "signer"; + + // Nitro address of proposing party + string nitro_address = 1; + + // Nitro address of counterparty + string counterparty = 2; + + // Nitro addresses of intermediaries + repeated string intermediaries = 3; + + // Challenge duration for the channel + uint32 challenge_duration = 4; + + // Funding amount for the payment channel + repeated cosmos.base.v1beta1.Coin funds = 5 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + + // Nitro channel ID + string channel_id = 6; + + // Laconic address of proposing party + string signer = 7; +} +message MsgCreatePaymentChannelResponse {} + +message MsgClosePaymentChannel { + option (cosmos.msg.v1.signer) = "signer"; + + // Nitro channel ID to close + string channel_id = 1; + + // Laconic address of proposing party + string signer = 2; +} +message MsgClosePaymentChannelResponse {} + +message MsgPay { + option (cosmos.msg.v1.signer) = "signer"; + + // Nitro channel ID through which to send payment + string channel_id = 1; + + // Amount to pay + cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false + ]; + + // Laconic address of the payer + string signer = 3; +} +message MsgPayResponse {} diff --git a/proto/cerc/onboarding/v1/onboarding.proto b/proto/cerc/onboarding/v1/onboarding.proto index 002dc6ae..2b59155b 100644 --- a/proto/cerc/onboarding/v1/onboarding.proto +++ b/proto/cerc/onboarding/v1/onboarding.proto @@ -21,10 +21,8 @@ message Participant { [ (gogoproto.moretags) = "json:\"cosmos_address\" yaml:\"cosmos_address\"" ]; - // participant's Nitro address - string nitro_address = 2 - [ (gogoproto.moretags) = - "json:\"nitro_address\" yaml:\"nitro_address\"" ]; + // full public key used to derive participant's Nitro address + bytes public_key = 2; // participant's role (participant | validator) string role = 3 [ (gogoproto.moretags) = "json:\"role\" yaml:\"role\"" ]; diff --git a/proto/cerc/onboarding/v1/query.proto b/proto/cerc/onboarding/v1/query.proto index f340d999..2a7bb8c8 100644 --- a/proto/cerc/onboarding/v1/query.proto +++ b/proto/cerc/onboarding/v1/query.proto @@ -27,7 +27,7 @@ service Query { rpc GetParticipantByNitroAddress(QueryGetParticipantByNitroAddressRequest) returns (QueryGetParticipantByNitroAddressResponse) { option (google.api.http).get = - "/cerc/onboarding/v1/participants/{nitro_address}"; + "/cerc/onboarding/v1/participants-by-nitro/{nitro_address}"; } } diff --git a/proto/cerc/registry/v1/registry.proto b/proto/cerc/registry/v1/registry.proto index 35cf8993..6d0b94fc 100644 --- a/proto/cerc/registry/v1/registry.proto +++ b/proto/cerc/registry/v1/registry.proto @@ -96,7 +96,7 @@ message Record { [ (gogoproto.moretags) = "json:\"attributes\" yaml:\"attributes\"" ]; repeated string names = 8 [ (gogoproto.moretags) = "json:\"names\" yaml:\"names\"" ]; - string type = 9 [ (gogoproto.moretags) = "json:\"types\" yaml:\"types\"" ]; + string types = 9 [ (gogoproto.moretags) = "json:\"types\" yaml:\"types\"" ]; } // AuthorityEntry defines a registry authority diff --git a/scripts/init.sh b/scripts/init.sh index 30db16d9..1a56a93a 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -1,153 +1,105 @@ #!/bin/bash -set -e +if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then + set -x +fi -KEY="alice" +LACONIC_BIN=${LACONIC_BIN:-laconicd} +LACONIC_HOME="${LACONIC_HOME:-$HOME/.laconicd}" + +KEYNAME="node_key" CHAINID=${CHAINID:-"laconic_9000-1"} MONIKER=${MONIKER:-"localtestnet"} KEYRING=${KEYRING:-"test"} DENOM=${DENOM:-"alnt"} -BALANCE=${BALANCE:-"1000000000000000000000000000000"} # 10^32 alnt STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"} # 10^15 alnt -MIN_GAS_PRICE=${MIN_GAS_PRICE:-"0.001"} +ALLOCATION_AMOUNT=1000000000000000000000000000000 # 10^30 alnt | 10^12 lnt LOGLEVEL=${LOGLEVEL:-"info"} +P2P_EXTERNAL_PORT=${P2P_EXTERNAL_PORT:-26656} + input_genesis_file=${GENESIS_FILE} +import_private_key=${PRIVATE_KEY} -if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data" ]; then - # validate dependencies are installed - command -v jq > /dev/null 2>&1 || { - echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/" - exit 1 - } +laconicd="$LACONIC_BIN --home=$LACONIC_HOME --log_level=$LOGLEVEL" - # remove existing daemon and client - rm -rf $HOME/.laconicd/* +set -e - if [ -n "`which make`" ]; then - make install +if [ "$1" == "clean" ]; then + echo "Clearing existing data directory in $LACONIC_HOME" + rm -rf "$LACONIC_HOME" +else + echo "Using existing database at $LACONIC_HOME. To replace, run '$(basename $0) clean'" +fi + +# Create a new home dir if needed +if [[ ! -d "$LACONIC_HOME/data/application.db" ]]; then + # Import the node key if passed, or generate one + if [[ -n "$import_private_key" ]]; then + $laconicd keys import-hex $KEYNAME 'b0b0000000000000000000000000000000000000000000000000000000000000' + else + printf "y\n" | $laconicd keys add $KEYNAME --keyring-backend $KEYRING --no-backup fi - laconicd config set client chain-id $CHAINID - laconicd config set client keyring-backend $KEYRING + # Set moniker and chain-id (Moniker can be anything, chain-id must be an integer) + $laconicd init $MONIKER --chain-id $CHAINID --default-denom $DENOM +else + KEYNAME=$($laconicd keys list --list-names --keyring-backend $KEYRING | head -1) +fi - # if $KEY exists it should be deleted - laconicd keys add $KEY --keyring-backend $KEYRING - - # Set moniker and chain-id - laconicd init $MONIKER --chain-id $CHAINID --default-denom $DENOM +if [[ ! -d "$db_path" ]]; then + $laconicd config set client chain-id $CHAINID + $laconicd config set client keyring-backend $KEYRING if [[ -f ${input_genesis_file} ]]; then # Use provided genesis config - cp $input_genesis_file $HOME/.laconicd/config/genesis.json + cp $input_genesis_file $LACONIC_HOME/config/genesis.json fi - update_genesis() { - jq "$1" $HOME/.laconicd/config/genesis.json > $HOME/.laconicd/config/tmp_genesis.json && - mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json + $laconicd genesis validate + + update_comet_config() { # comet config is not supported by confix cli + local file="$LACONIC_HOME/config/config.toml" + cp -f "$file" "${file}.bak" && tomlq --toml-output ".$1 = $2" "${file}.bak" > "$file" } - if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then - echo "Setting timers for expiry tests." + # disable empty blocks + update_comet_config consensus.create_empty_blocks 'false' - update_genesis '.app_state["registry"]["params"]["record_rent_duration"]="60s"' - update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="60s"' - update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' - fi + # Allow requests from any origin + update_comet_config rpc.cors_allowed_origins '["*"]' - if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then - echo "Enabling auction and setting timers." - - update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true' - update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' - update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="300s"' - update_genesis '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"' - update_genesis '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"' - fi - - if [[ "$ONBOARDING_ENABLED" == "true" ]]; then - echo "Enabling onboarding." - - update_genesis '.app_state["onboarding"]["params"]["onboarding_enabled"]=true' - fi - - if [[ "$AUTHORITY_AUCTION_ENABLED" == "true" ]]; then - echo "Enabling authority auctions." - update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true' - fi - - if [[ -n $AUTHORITY_AUCTION_COMMITS_DURATION ]]; then - echo "Setting authority_auction_commits_duration to $AUTHORITY_AUCTION_COMMITS_DURATION seconds." - update_genesis ".app_state[\"registry\"][\"params\"][\"authority_auction_commits_duration\"]=\"${AUTHORITY_AUCTION_COMMITS_DURATION}s\"" - fi - - if [[ -n $AUTHORITY_AUCTION_REVEALS_DURATION ]]; then - echo "Setting authority_auction_reveals_duration to $AUTHORITY_AUCTION_REVEALS_DURATION seconds." - update_genesis ".app_state[\"registry\"][\"params\"][\"authority_auction_reveals_duration\"]=\"${AUTHORITY_AUCTION_REVEALS_DURATION}s\"" - fi - - if [[ -n $AUTHORITY_GRACE_PERIOD ]]; then - echo "Setting authority_grace_period to $AUTHORITY_GRACE_PERIOD seconds." - update_genesis ".app_state[\"registry\"][\"params\"][\"authority_grace_period\"]=\"${AUTHORITY_GRACE_PERIOD}s\"" - fi - - # increase block time (?) - update_genesis '.consensus["params"]["block"]["time_iota_ms"]="1000"' - - # Set gas limit in genesis - update_genesis '.consensus["params"]["block"]["max_gas"]="10000000"' - - # Set distribution community tax to 1 for disabling staking rewards - update_genesis '.app_state["distribution"]["params"]["community_tax"]="1.000000000000000000"' - - echo "Setting high threshold for accepting governance proposal" - update_genesis '.app_state["gov"]["params"]["quorum"]="1.000000000000000000"' - # Set expedited threshold to 100% - update_genesis '.app_state["gov"]["params"]["expedited_threshold"]="1.000000000000000000"' - # Set normal threshold to 99% since it needs to be lesser than expedited threshold - update_genesis '.app_state["gov"]["params"]["threshold"]="0.990000000000000000"' - - # disable produce empty block - if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml - else - sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml - fi - - # Run this to allow requests from any origin - sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $HOME/.laconicd/config/config.toml + # Set persistent peers + update_comet_config p2p.seeds "\"$P2P_PEERS\"" + update_comet_config p2p.persistent_peers "\"$P2P_PEERS\"" + update_comet_config p2p.external_address "\"tcp://127.0.0.1:${P2P_EXTERNAL_PORT}\"" + update_comet_config p2p.addr_book_strict false # Enable telemetry (prometheus metrics: http://localhost:1317/metrics?format=prometheus) - if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml - sed -i '' 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $HOME/.laconicd/config/app.toml - sed -i '' 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml - else - sed -i 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml - sed -i 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $HOME/.laconicd/config/app.toml - sed -i 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml - fi + $laconicd config set app telemetry.enable true + $laconicd config set app telemetry.prometheus-retention-time 60 + update_comet_config instrumentation.prometheus true - # Allocate genesis accounts (cosmos formatted addresses) - laconicd genesis add-genesis-account $KEY ${BALANCE}${DENOM} --keyring-backend $KEYRING + # Enable validator distsig + $laconicd config set app distsig.enable true + $laconicd config set app distsig.longterm-key "$KEYNAME" - # Sign genesis transaction - laconicd genesis gentx $KEY $STAKING_AMOUNT$DENOM --keyring-backend $KEYRING --chain-id $CHAINID - - # Collect genesis tx - laconicd genesis collect-gentxs - - # Run this to ensure everything worked and that the genesis file is setup correctly - laconicd genesis validate + # Nitro config, WIP + # $laconicd config set app nitro.use-distsig true # TODO + $laconicd config set app nitro.eth-key "$KEYNAME" + $laconicd config set app nitro.eth-url "$NITRO_ETH_URL" + $laconicd config set app nitro.eth-start-block "$NITRO_ETH_START_BLOCK" + $laconicd config set app nitro.eth-na-address "'$NITRO_ADJUDICATOR_ADDRESS'" + $laconicd config set app nitro.eth-vpa-address "'$VIRTUAL_PAYMENT_APP_ADDRESS'" + $laconicd config set app nitro.eth-ca-address "'$CONSENSUS_APP_ADDRESS'" else - echo "Using existing database at $HOME/.laconicd. To replace, run '`basename $0` clean'" + echo "Using existing database at $LACONIC_HOME." fi # Start the node (remove the --pruning=nothing flag if historical queries are not needed) -laconicd start \ - --pruning=nothing \ - --log_level $LOGLEVEL \ - --minimum-gas-prices=$MIN_GAS_PRICE$DENOM \ - --api.enable \ +# TODO new pruning config +$laconicd start \ + --server.minimum-gas-prices="1$DENOM" \ --rpc.laddr="tcp://0.0.0.0:26657" \ - --gql-server --gql-playground + --grpc.address="127.0.0.1:9091" \ + --gql.enable --gql.playground diff --git a/server/components.go b/server/components.go new file mode 100644 index 00000000..13a59744 --- /dev/null +++ b/server/components.go @@ -0,0 +1,120 @@ +package server + +import ( + "context" + "errors" + "fmt" + + "cosmossdk.io/log" + "github.com/cometbft/cometbft/node" + "github.com/cometbft/cometbft/p2p" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/server" + "github.com/spf13/cobra" +) + +// HasContextKey is implemented by servers that have a dedicated key under which they should be +// associated with a context. +type HasContextKey interface { + ContextKey() string +} + +type HasP2PReactors interface { + P2PReactors() map[string]p2p.Reactor +} + +// maps commands to server components they require +var cmdRequirements = map[*cobra.Command][]ServerComponent{} + +// SetRequiredComponents sets required server components for a command +func SetRequiredComponents(cmd *cobra.Command, components ...ServerComponent) { + for _, c := range components { + cmdRequirements[cmd] = append(cmdRequirements[cmd], c) + if startmod, ok := c.(HasStartFlags); ok { + cmd.Flags().AddFlagSet(startmod.StartCmdFlags()) + } + } +} + +func RequiresComponent(cmd *cobra.Command, c string) bool { + components, ok := cmdRequirements[cmd] + if !ok { + return false + } + for _, mod := range components { + if mod.Name() == c { + return true + } + } + return false +} + +type ComponentsCreator func(ConfigMap, client.Context, log.Logger, func(string) bool) ([]ServerComponent, error) + +type ServerAux struct { + components []ServerComponent +} + +// AddComponents adds hooks to create, start and stop the components returned from the passed +// constructor, and ensures they are available on the command context. +// It returns a node.Option to additionally configure the CometBFT node. +func (s *ServerAux) AddComponents(cmd *cobra.Command, initComponents ComponentsCreator) { + needsComponent := func(name string) bool { + return RequiresComponent(cmd, name) + } + + // manage component lifecycle + cmd.PreRunE = func(cmd *cobra.Command, args []string) error { + serverCtx := server.GetServerContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + s.components, err = initComponents( + serverCtx.Viper.AllSettings(), clientCtx, serverCtx.Logger, needsComponent, + ) + // add available context keys + for _, mod := range s.components { + if ckeymod, ok := mod.(HasContextKey); ok { + cmdCtx := cmd.Context() + if cmdCtx == nil { + cmdCtx = context.Background() + } + cmd.SetContext(context.WithValue(cmdCtx, ckeymod.ContextKey(), mod)) + } + } + + for _, mod := range s.components { + if err := mod.Start(cmd.Context()); err != nil { + return fmt.Errorf("failed to start server %s: %w", mod.Name(), err) + } + } + return nil + } + + startFn := cmd.RunE + cmd.RunE = func(cmd *cobra.Command, args []string) error { + // if we do this in PostRunE, it won't be called if RunE errors + defer func() { + var err error + for _, mod := range s.components { + err = errors.Join(err, mod.Stop(cmd.Context())) + } + if err != nil { + cmd.PrintErrln("failed to stop servers:", err) + } + }() + return startFn(cmd, args) + } +} + +// AddReactors adds p2p Reactors for all configured components to a CometBFT node. +// When passed to StartCmdOptions this will be run in start(), after components are initialized in PreRun. +func (s *ServerAux) AddReactors(cmt *node.Node) { + for _, mod := range s.components { + if reactormod, ok := mod.(HasP2PReactors); ok { + opt := node.CustomReactors(reactormod.P2PReactors()) + opt(cmt) + } + } +} diff --git a/server/config.go b/server/config.go new file mode 100644 index 00000000..3fa59796 --- /dev/null +++ b/server/config.go @@ -0,0 +1,65 @@ +package server + +// The utilities in this file are copied from cosmos-sdk server/v2 + +import ( + "fmt" + + "github.com/mitchellh/mapstructure" + "github.com/spf13/viper" +) + +type ConfigMap map[string]any + +// ReadConfig returns a viper instance of the config file +func ReadConfig(configPath string) (*viper.Viper, error) { + v := viper.New() + v.SetConfigType("toml") + v.SetConfigName("config") + v.AddConfigPath(configPath) + if err := v.ReadInConfig(); err != nil { + return nil, fmt.Errorf("failed to read config: %s: %w", configPath, err) + } + + v.SetConfigName("app") + if err := v.MergeInConfig(); err != nil { + return nil, fmt.Errorf("failed to merge configuration: %w", err) + } + + v.WatchConfig() + + return v, nil +} + +// UnmarshalSubConfig unmarshals the given (sub) config from the main config (given as a map) into the target. +// If subName is empty, the main config is unmarshaled into the target. +func UnmarshalSubConfig(cfg map[string]any, subName string, target any) error { + var sub any + if subName != "" { + if val, ok := cfg[subName]; ok { + sub = val + } + } else { + sub = cfg + } + + // Create a new decoder with custom decoding options + decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ + DecodeHook: mapstructure.ComposeDecodeHookFunc( + mapstructure.StringToTimeDurationHookFunc(), + mapstructure.StringToSliceHookFunc(","), + ), + Result: target, + WeaklyTypedInput: true, + }) + if err != nil { + return fmt.Errorf("failed to create decoder: %w", err) + } + + // Decode the sub-configuration + if err := decoder.Decode(sub); err != nil { + return fmt.Errorf("failed to decode sub-configuration: %w", err) + } + + return nil +} diff --git a/server/distsig/config.go b/server/distsig/config.go new file mode 100644 index 00000000..324dcf79 --- /dev/null +++ b/server/distsig/config.go @@ -0,0 +1,29 @@ +package distsig + +import ( + "fmt" + + "git.vdb.to/cerc-io/laconicd/server" +) + +type Config struct { + Enable bool `mapstructure:"enable" toml:"enable" comment:"Enable distributed Schnorr signatures"` + LongtermKey string `mapstructure:"longterm-key" toml:"longterm-key" comment:"The long-term key used in distributed signatures"` + // TODO: set this in genesis + ThresholdRatio float64 `mapstructure:"threshold-ratio" toml:"threshold-ratio" comment:"The ratio of signers required to sign a message"` +} + +func DefaultConfig() *Config { + return &Config{ + Enable: false, + ThresholdRatio: 4. / 7, + } +} + +func UnmarshalConfig(cfg map[string]any) (*Config, error) { + config := DefaultConfig() + if err := server.UnmarshalSubConfig(cfg, componentName, config); err != nil { + return nil, fmt.Errorf("failed to unmarshal %T: %w", config, err) + } + return config, nil +} diff --git a/server/distsig/distsig_test.go b/server/distsig/distsig_test.go new file mode 100644 index 00000000..2ecaf73e --- /dev/null +++ b/server/distsig/distsig_test.go @@ -0,0 +1,175 @@ +package distsig + +import ( + "errors" + "math/big" + "testing" + + "cosmossdk.io/log" + "git.vdb.to/cerc-io/chain-signatures/ethschnorr" + sdktestutil "github.com/cosmos/cosmos-sdk/testutil" + "github.com/stretchr/testify/require" + + "git.vdb.to/cerc-io/laconicd/testutil" +) + +func NewTestManager(t *testing.T) (*Manager, Point) { + logger := log.NewTestLogger(t) + kr := testutil.NewKeyring() + accounts := sdktestutil.CreateKeyringAccounts(t, kr, 1) + cfg := DefaultConfig() + cfg.LongtermKey = accounts[0].Name + + dsm, err := New(logger, cfg, kr) + require.NoError(t, err) + + longterm, err := kr.Key(cfg.LongtermKey) + require.NoError(t, err) + longtermPoint, err := KeyRecordToPoint(longterm) + require.NoError(t, err) + + return dsm, longtermPoint +} + +type round struct { + name string + verify func(*Manager) error + tweak func([]PeerMessages) +} + +var ( + dkgRounds = []round{ + { + name: "deal", + }, + { + name: "response", + verify: func(m *Manager) error { + if !m.currentDkg().Certified() { + return errors.New("not certified") + } + return nil + }, + }, + { + name: "commit", + verify: func(m *Manager) error { + if !m.currentDkg().Finished() { + return errors.New("run not finished") + } + if m.currentDkg().share == nil { + return errors.New("dist key share is absent") + } + return nil + }, + }, + } + dssRounds = []round{ + { + name: "sign", + verify: func(m *Manager) error { + dss := m.sigs[m.completeSigs[0]] + if dss.sig == nil { + return errors.New("signature is nil") + } + dkg, err := m.getDkg(dss.dkgID) + if err != nil { + return err + } + return ethschnorr.Verify(dkg.share.Public(), dss.Message(), dss.sig) + }, + }, + } +) + +func runRound(t *testing.T, r round, members []*Manager) { + buf := make([]PeerMessages, len(members)) + for i := range members { + buf[i] = members[i].FlushMessages() + } + if r.tweak != nil { + r.tweak(buf) + } + for i := range members { + for j := range members { + if i == j { + continue + } + require.NoError(t, members[i].ProcessMessages(&buf[j]), + "round=%s, i=%d, j=%d", r.name, i, j) + } + } + if r.verify != nil { + for i, m := range members { + require.NoError(t, r.verify(m), "round=%s, i=%d", r.name, i) + } + } +} + +func TestDkgBasic(t *testing.T) { + numMembers := 2 + blockHeight := int64(1) + + members := make([]*Manager, numMembers) + pubkeys := make([]Point, numMembers) + for i := range members { + members[i], pubkeys[i] = NewTestManager(t) + } + t.Logf("DKG with %d members", numMembers) + + for i, m := range members { + require.NoError(t, m.StartDKG(blockHeight, pubkeys), "i=%d", i) + } + for _, r := range dkgRounds { + runRound(t, r, members) + } + + require.False(t, members[0].NeedDKG(pubkeys)) + require.Error(t, members[0].StartDKG(blockHeight, pubkeys)) + + // add participants and refresh DKG + for len(members) < 7 { + blockHeight++ + + m, pub := NewTestManager(t) + members = append(members, m) + pubkeys = append(pubkeys, pub) + t.Logf("DKG with %d members", len(members)) + + for i, m := range members { + require.True(t, m.NeedDKG(pubkeys), "i=%d", i) + require.NoError(t, m.StartDKG(blockHeight, pubkeys), "i=%d", i) + } + for _, r := range dkgRounds { + runRound(t, r, members) + } + } +} + +func TestSignatureBasic(t *testing.T) { + numMembers := 7 + + members := make([]*Manager, numMembers) + pubkeys := make([]Point, numMembers) + for i := range members { + members[i], pubkeys[i] = NewTestManager(t) + } + + for _, m := range members { + require.NoError(t, m.StartDKG(1, pubkeys)) + } + for _, r := range dkgRounds { + runRound(t, r, members) + } + + msg := big.NewInt(42) + for _, m := range members { + require.NoError(t, m.StartSignature(m.currentDkgID, msg)) + } + runRound(t, dssRounds[0], members) + + require.Error(t, members[0].StartSignature(0, msg)) + + require.NoError(t, members[0].StartDKG(2, pubkeys[:3])) + require.Error(t, members[0].StartSignature(2, msg)) +} diff --git a/server/distsig/flags.go b/server/distsig/flags.go new file mode 100644 index 00000000..4fe60720 --- /dev/null +++ b/server/distsig/flags.go @@ -0,0 +1,19 @@ +package distsig + +import ( + "fmt" + + "github.com/spf13/pflag" +) + +func prefix(f string) string { + return fmt.Sprintf("%s.%s", componentName, f) +} + +var ( + FlagLongtermKey = prefix("longterm-key") +) + +func AddNitroFlags(flags *pflag.FlagSet) { + flags.String(FlagLongtermKey, "", "The long-term key used in distributed signatures") +} diff --git a/server/distsig/keygen.go b/server/distsig/keygen.go new file mode 100644 index 00000000..86c3fe68 --- /dev/null +++ b/server/distsig/keygen.go @@ -0,0 +1,224 @@ +package distsig + +import ( + "fmt" + + dkg "go.dedis.ch/kyber/v3/share/dkg/rabin" +) + +// DkgMessages collects local DKG messages that are pending broadcast. +type DkgMessages struct { + runID DkgRunID + messages []dkgMessage +} + +// DKG steps (actions) that are executed by the DKG protocol +type dkgStep int + +const ( + dkg_deal dkgStep = iota + dkg_certify + dkg_commit + dkg_finish + dkg_done +) + +type dkgRun struct { + *dkg.DistKeyGenerator + // runID RunID + msgBuffer []dkgMessage + step dkgStep + share *dkg.DistKeyShare +} + +type dkgMessage interface { + send(*dkgRun) (dkgMessage, error) + from() uint32 + target() uint32 +} + +// prepareMessages produces DKG state transitions that don't rely on peer inputs, i.e. the deal or +// commit steps. This is called during ExtendVote by all validators. +func (d *dkgRun) prepareMessages() error { + out, err := d.handleMessage(nil) + if err != nil { + return err + } + if out != nil { + d.msgBuffer = append(d.msgBuffer, out...) + } + return nil +} + +func (d *dkgRun) flushMessages() []dkgMessage { + buf := d.msgBuffer + d.msgBuffer = nil + return buf +} + +// processMessages processes incoming DKG messages and produces outgoing messages. This is called +// during VerifyVoteExtension by all validators (TODO: verify). +func (d *dkgRun) processMessages(in []dkgMessage) error { + for _, msg := range in { + out, err := d.handleMessage(msg) + if err != nil { + return err + } + if out != nil { + d.msgBuffer = append(d.msgBuffer, out...) + } + } + return nil +} + +func (d *dkgRun) handleMessage(in dkgMessage) ([]dkgMessage, error) { + // fmt.Printf("[%d, %7s] handle: %T", d.index, d.step, in) + // if in != nil { + // fmt.Printf(" (from %d to %+v)", in.from(), in.target()) + // } + // fmt.Println() + + // nil input means we try to execute a step requiring no peer input + if in == nil { + var out []dkgMessage + switch d.step { + case dkg_deal: + deals, err := d.Deals() + if err != nil { + return nil, err + } + for index, deal := range deals { + out = append(out, msgDeal{index: uint32(index), msg: deal}) + } + case dkg_commit: + sc, err := d.SecretCommits() + if err != nil { + return nil, err + } + out = []dkgMessage{msgSecretCommits{msg: sc}} + case dkg_done: + dks, err := d.DistKeyShare() + if err != nil { + return nil, err + } + d.share = dks + default: + return nil, fmt.Errorf("unexpected stage: %v", d.step) + } + d.step = nextStep(d.step) + return out, nil + } + + var out []dkgMessage + if msg, err := in.send(d); err != nil { + return nil, err + } else if msg != nil { + out = []dkgMessage{msg} + } + if (d.step == dkg_certify && d.Certified()) || + (d.step == dkg_finish && d.Finished()) { + d.step = nextStep(d.step) + msgs, err := d.handleMessage(nil) + if err != nil { + return nil, err + } + out = append(out, msgs...) + } + return out, nil +} + +func nextStep(step dkgStep) dkgStep { + if step == dkg_done { + return dkg_done + } + return step + 1 +} + +type ( + msgDeal struct { + msg *dkg.Deal + index uint32 // recipient index + } + msgResponse struct{ msg *dkg.Response } + msgJustification struct{ msg *dkg.Justification } + msgSecretCommits struct{ msg *dkg.SecretCommits } + msgComplaintCommits struct{ msg *dkg.ComplaintCommits } + msgReconstructCommits struct{ msg *dkg.ReconstructCommits } +) + +func (m msgDeal) send(d *dkgRun) (dkgMessage, error) { + if m.index != uint32(d.Index()) { + return nil, nil + } + out, err := d.ProcessDeal(m.msg) + if err != nil { + return nil, err + } + return msgResponse{out}, nil +} + +func (m msgResponse) send(d *dkgRun) (dkgMessage, error) { + if out, err := d.ProcessResponse(m.msg); err != nil { + return nil, err + } else if out != nil { + return msgJustification{out}, nil + } + return nil, nil +} + +func (m msgJustification) send(d *dkgRun) (dkgMessage, error) { + return nil, d.ProcessJustification(m.msg) +} + +func (m msgSecretCommits) send(d *dkgRun) (dkgMessage, error) { + if out, err := d.ProcessSecretCommits(m.msg); err != nil { + return nil, err + } else if out != nil { + return msgComplaintCommits{out}, nil + } + return nil, nil +} + +func (m msgComplaintCommits) send(d *dkgRun) (dkgMessage, error) { + out, err := d.ProcessComplaintCommits(m.msg) + if err != nil { + return nil, err + } + return msgReconstructCommits{out}, nil +} + +func (m msgReconstructCommits) send(d *dkgRun) (dkgMessage, error) { + return nil, d.ProcessReconstructCommits(m.msg) +} + +func (d dkgStep) String() string { + switch d { + case dkg_deal: + return "deal" + case dkg_certify: + return "certify" + case dkg_commit: + return "commit" + case dkg_finish: + return "finish" + case dkg_done: + return "done" + default: + return "unknown" + } +} + +// for debugging +func (m msgDeal) from() uint32 { return m.msg.Index } +func (m msgResponse) from() uint32 { return m.msg.Response.Index } +func (m msgJustification) from() uint32 { return m.msg.Justification.Index } +func (m msgSecretCommits) from() uint32 { return m.msg.Index } +func (m msgComplaintCommits) from() uint32 { return m.msg.Index } +func (m msgReconstructCommits) from() uint32 { return m.msg.Index } + +func (m msgDeal) target() uint32 { return m.index } +func (m msgResponse) target() uint32 { return m.msg.Index } +func (m msgJustification) target() uint32 { return m.msg.Index } +func (m msgSecretCommits) target() uint32 { return 0 } +func (m msgComplaintCommits) target() uint32 { return m.msg.DealerIndex } +func (m msgReconstructCommits) target() uint32 { return m.msg.DealerIndex } diff --git a/server/distsig/manager.go b/server/distsig/manager.go new file mode 100644 index 00000000..cbf29dcc --- /dev/null +++ b/server/distsig/manager.go @@ -0,0 +1,268 @@ +package distsig + +import ( + "context" + "fmt" + "math" + "math/big" + + cmtcrypto "github.com/cometbft/cometbft/crypto" + "github.com/ethereum/go-ethereum/common" + dkg "go.dedis.ch/kyber/v3/share/dkg/rabin" + + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + + clientdss "git.vdb.to/cerc-io/chain-signatures/ethdss" + "git.vdb.to/cerc-io/chain-signatures/ethschnorr" + "git.vdb.to/cerc-io/laconicd/server" + "git.vdb.to/cerc-io/laconicd/utils" +) + +type ( + DealMap = map[int]*dkg.Deal + + DkgRunID int64 + SigRunID string +) + +const ( + componentName = "distsig" +) + +type Manager struct { + config *Config + logger log.Logger + keyring keyring.Keyring + + longtermKey Scalar // only initialized after Start() + longtermPubKey cmtcrypto.PubKey + + dkgs map[DkgRunID]*dkgRun + currentDkgID DkgRunID // zero indicates no current run + sigs map[SigRunID]*sigRun + completeSigs []SigRunID +} + +type PeerMessages struct { + dkg *DkgMessages + dss []SigMessages +} + +func New(logger log.Logger, globalConfig server.ConfigMap, kr keyring.Keyring) (*Manager, error) { + config, err := UnmarshalConfig(globalConfig) + if err != nil { + return nil, err + } + m := &Manager{ + config: config, + keyring: kr, + dkgs: make(map[DkgRunID]*dkgRun), + sigs: make(map[SigRunID]*sigRun), + } + m.logger = logger.With(log.ModuleKey, m.Name()) + return m, nil +} + +func (*Manager) Name() string { return componentName } + +func (m *Manager) Start(ctx context.Context) error { + if !m.config.Enable { + m.logger.Info(fmt.Sprintf("%s server is disabled via config", m.Name())) + return nil + } + if m.config.LongtermKey == "" { + return fmt.Errorf("missing longterm key") + } + longtermPrivKey, err := utils.ExtractPrivateKeyByUid(m.keyring, m.config.LongtermKey) + if err != nil { + return fmt.Errorf("failed to extract longterm key: %w", err) + } + m.longtermKey = suite.Scalar().SetBytes(longtermPrivKey.Bytes()) + m.longtermPubKey = longtermPrivKey.PubKey() + return nil +} + +func (*Manager) Stop(context.Context) error { return nil } + +func (m *Manager) Config() any { + if m.config == nil { + return DefaultConfig() + } + return m.config +} + +func (m *Manager) getDkg(runid DkgRunID) (*dkgRun, error) { + if runid == 0 { + // runid = m.currentDkg + return nil, fmt.Errorf("invalid run ID") + } + if run, ok := m.dkgs[runid]; ok { + return run, nil + } + return nil, fmt.Errorf("DKG not initialized for run: %v", runid) +} + +func (m *Manager) currentDkg() *dkgRun { + run, err := m.getDkg(m.currentDkgID) + if err != nil { + panic(err) + } + return run +} + +func (m *Manager) LongtermPublicKey() cmtcrypto.PubKey { + return m.longtermPubKey +} + +func (m *Manager) LongtermEthAddress() common.Address { + pubkey, err := SuitePublicKeyFromBytes(m.LongtermPublicKey().Bytes()) + if err != nil { + panic(fmt.Errorf("failed to parse longterm pubkey: %w", err)) + } + return pubkey.Address() +} + +func thresholdForRatio(m int, tr float64) int { + return int(math.Ceil(float64(m) * tr)) +} + +func (m *Manager) initDKG(members []Point) (*dkgRun, error) { + t := thresholdForRatio(len(members), m.config.ThresholdRatio) + keygen, err := dkg.NewDistKeyGenerator(suite.(dkg.Suite), m.longtermKey, members, t) + if err != nil { + return nil, err + } + return &dkgRun{DistKeyGenerator: keygen}, nil +} + +// NeedDKG returns true if DKG needs to be run for the given participants. +func (m *Manager) NeedDKG(pubkeys []Point) bool { + return m.currentDkgID == 0 || !equalPoints(m.currentDkg().Participants(), pubkeys) +} + +// StartDKG begins a new DKG run including the given participants. +func (m *Manager) StartDKG(block int64, pubkeys []Point) error { + // TODO: generate runid from block height and hash of pubkeys? + runid := DkgRunID(block) + if _, ok := m.dkgs[runid]; ok { + return fmt.Errorf("DKG run %v already exists", runid) + } + if len(pubkeys) < 2 { + m.currentDkgID = 0 + m.logger.Debug("Too few participants for distributed signature") + return nil + } + run, err := m.initDKG(pubkeys) + if err != nil { + return err + } + m.dkgs[runid] = run + m.currentDkgID = runid + return run.prepareMessages() +} + +func (m *Manager) initDSS(dkgid DkgRunID, msg *big.Int) (*sigRun, error) { + run, err := m.getDkg(dkgid) + if err != nil { + return nil, err + } + if !run.Finished() { + return nil, fmt.Errorf("DKG run has not finished: %v", dkgid) + } + random, err := run.DistKeyShare() + if err != nil { + return nil, err + } + dss, err := clientdss.NewDSS(clientdss.DSSArgs{ + Secret: m.longtermKey, + Participants: run.Participants(), + Long: run.share, + Random: random, + Msg: msg, + T: run.Threshold(), + // Qualified: run.QUAL(), + }) + if err != nil { + return nil, err + } + return &sigRun{DSS: dss, dkgID: dkgid}, nil +} + +// StartSignature begins a DSS run for the given message and DKG state. +func (m *Manager) StartSignature(msg *big.Int) error { + if m.currentDkgID == 0 { + return fmt.Errorf("no distributed key prepared") + } + run, err := m.initDSS(m.currentDkgID, msg) + if err != nil { + return err + } + sigid := run.SigRunID() + m.sigs[sigid] = run + return run.prepareMessages() +} + +func (m *Manager) CompletedSignatures() map[SigRunID]ethschnorr.Signature { + var ret map[SigRunID]ethschnorr.Signature + for _, id := range m.completeSigs { + run, ok := m.sigs[id] + if !ok { + panic(fmt.Errorf("DSS run not found: %v", id)) + } + if run.sig == nil { + panic(fmt.Errorf("DSS signature not completed: %v", id)) + } + // Deterministically pick a participant responsible for submitting the signature + session := new(big.Int).SetBytes(run.SessionID()[:8]) + submitterIdx := session.Uint64() % uint64(len(run.Participants())) + if run.Index() == int(submitterIdx) { + ret[id] = run.sig + } + } + return ret +} + +// FlushMessages flushes the message buffers for any active DKG and DSS runs. +func (m *Manager) FlushMessages() PeerMessages { + var ret PeerMessages + if buf := m.currentDkg().flushMessages(); len(buf) != 0 { + ret.dkg = &DkgMessages{runID: m.currentDkgID, messages: buf} + } + for id, run := range m.sigs { + if buf := run.flushMessages(); buf != nil { + ret.dss = append(ret.dss, SigMessages{id, buf}) + } + } + return ret +} + +// ProcessMessages processes DKG and DSS peer messages. +func (m *Manager) ProcessMessages(dm *PeerMessages) error { + if dkg := dm.dkg; dkg != nil { + run, err := m.getDkg(dkg.runID) + if err != nil { + return err + } + if err := run.processMessages(dkg.messages); err != nil { + return err + } + } + for _, dss := range dm.dss { + run, ok := m.sigs[dss.runID] + if !ok { + return fmt.Errorf("DSS not initialized for run: %v", dss.runID) + } + if err := run.processMessage(dss.messages); err != nil { + return err + } + if run.sig != nil { + m.completeSigs = append(m.completeSigs, dss.runID) + } + } + return nil +} + +func (pm PeerMessages) Empty() bool { + return pm.dkg == nil && len(pm.dss) == 0 +} diff --git a/server/distsig/signature.go b/server/distsig/signature.go new file mode 100644 index 00000000..c2fb6d10 --- /dev/null +++ b/server/distsig/signature.go @@ -0,0 +1,61 @@ +package distsig + +import ( + "fmt" + + clientdss "git.vdb.to/cerc-io/chain-signatures/ethdss" + "git.vdb.to/cerc-io/chain-signatures/ethschnorr" +) + +type SigMessages struct { + runID SigRunID + messages sigMessage +} + +type sigStep int + +const ( + sig_partial sigStep = iota + sig_complete +) + +type sigRun struct { + *clientdss.DSS + msgBuffer sigMessage + + dkgID DkgRunID + step sigStep + + sig ethschnorr.Signature +} + +type sigMessage = *clientdss.PartialSig + +func (d *sigRun) SigRunID() SigRunID { + return SigRunID(fmt.Sprintf("%020d-%x", d.dkgID, d.SessionID()[:8])) +} + +func (d *sigRun) prepareMessages() error { + var err error + d.msgBuffer, err = d.PartialSig() + return err +} + +func (d *sigRun) flushMessages() sigMessage { + buf := d.msgBuffer + d.msgBuffer = nil + return buf +} + +func (d *sigRun) processMessage(in sigMessage) error { + err := d.ProcessPartialSig(in) + if err != nil { + return err + } + // return d.EnoughPartialSig(), nil + if d.EnoughPartialSig() { + d.sig, err = d.Signature() + return err + } + return nil +} diff --git a/server/distsig/suite.go b/server/distsig/suite.go new file mode 100644 index 00000000..50dfa55a --- /dev/null +++ b/server/distsig/suite.go @@ -0,0 +1,39 @@ +package distsig + +import ( + "fmt" + + "git.vdb.to/cerc-io/chain-signatures/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "go.dedis.ch/kyber/v3" + "go.dedis.ch/kyber/v3/suites" +) + +type ( + Scalar = kyber.Scalar + Point = kyber.Point + + PublicKey = secp256k1.PublicKey +) + +var ( + suite suites.Suite = secp256k1.NewBlakeKeccackSecp256k1() + NewScalar = suite.Scalar + NewPoint = suite.Point + + // Note: the compressed encoding of pubkeys used by Cosmos SDK and our library (based on chainlink) + // are the same. See gitlab.com/yawning/secp256k1-voi/secec + SuitePublicKeyFromBytes = secp256k1.NewPublicKeyFromBytes +) + +func KeyRecordToPoint(longterm *keyring.Record) (kyber.Point, error) { + pubkey, err := longterm.GetPubKey() + if err != nil { + return nil, fmt.Errorf("failed to access public key: %w", err) + } + suitePubkey, err := SuitePublicKeyFromBytes(pubkey.Bytes()) + if err != nil { + return nil, fmt.Errorf("failed to decode public key: %w", err) + } + return suitePubkey.Point() +} diff --git a/server/distsig/utils.go b/server/distsig/utils.go new file mode 100644 index 00000000..8ef80366 --- /dev/null +++ b/server/distsig/utils.go @@ -0,0 +1,13 @@ +package distsig + +func equalPoints(a, b []Point) bool { + if len(a) != len(b) { + return false + } + for i, p := range a { + if !p.Equal(b[i]) { + return false + } + } + return true +} diff --git a/server/gas.go b/server/gas.go new file mode 100644 index 00000000..caa32f5d --- /dev/null +++ b/server/gas.go @@ -0,0 +1,36 @@ +package server + +import ( + "context" + + "cosmossdk.io/core/gas" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ gas.Service = gasService{} + +// Placeholder gas service, in anticipation of future use +// https://github.com/cosmos/cosmos-sdk/pull/16310 +type gasService struct{} + +func NewGasService() gas.Service { return gasService{} } + +func (gasService) GetGasMeter(ctx context.Context) gas.Meter { + c := sdk.UnwrapSDKContext(ctx) + return c.GasMeter() +} + +func (gasService) WithGasMeter(ctx context.Context, meter gas.Meter) context.Context { + c := sdk.UnwrapSDKContext(ctx) + return c.WithGasMeter(meter) +} + +// deprecated https://github.com/cosmos/cosmos-sdk/issues/19793 +func (gasService) GetBlockGasMeter(context.Context) gas.Meter { + return nil +} + +// deprecated https://github.com/cosmos/cosmos-sdk/issues/19793 +func (gasService) WithBlockGasMeter(ctx context.Context, meter gas.Meter) context.Context { + return ctx +} diff --git a/server/nitro/command_utils.go b/server/nitro/command_utils.go new file mode 100644 index 00000000..6feeaa0e --- /dev/null +++ b/server/nitro/command_utils.go @@ -0,0 +1,230 @@ +package nitro + +import ( + "fmt" + "math/big" + "runtime" + "strings" + "time" + + "github.com/cometbft/cometbft/p2p" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/spf13/cobra" + "github.com/statechannels/go-nitro/protocols" + nitrotypes "github.com/statechannels/go-nitro/types" + + "git.vdb.to/cerc-io/laconicd/server/relay" + "git.vdb.to/cerc-io/laconicd/utils" +) + +const txTimeoutDuration = 5 * time.Second + +func GetServerFromCmd(cmd *cobra.Command) (*Server, error) { + s, err := utils.GetFromContext[Server](cmd.Context(), ServerContextKey) + if err != nil { + return nil, err + } + for !s.Ready() { + runtime.Gosched() + } + return s, nil +} + +func delayAfterUpdate() { + // HACK: delay so remote server status is synced before we return + // TODO: correct solution is passing messages with consistency guarantees, + // i.e. using txs to pass nitro messages and integrating state into chain storage + time.Sleep(500 * time.Millisecond) +} + +// waitForObjective waits for an objective to complete or fail using select pattern +func waitForObjective[Info any]( + failedChan <-chan protocols.ObjectiveId, + objective protocols.ObjectiveId, + updateChan <-chan Info, + statusCheck func(Info) bool, +) error { + for { + select { + case update := <-updateChan: + if statusCheck(update) { + delayAfterUpdate() + return nil + } + case failedObjective := <-failedChan: + if failedObjective == objective { + return fmt.Errorf("objective failed for unspecified reason: %s", objective) + } + } + } +} + +func submitNitroTx( + clientCtx client.Context, + cmd *cobra.Command, + msg MsgWrapper, + unordered bool, +) error { + if msg.SignerField != nil { + ac := utils.NewAddressCodec() + var err error + *msg.SignerField, err = ac.BytesToString(clientCtx.FromAddress) + if err != nil { + return err + } + } + factory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + if unordered { + deadline := time.Now().Add(txTimeoutDuration) + factory = factory.WithUnordered(true).WithTimeoutTimestamp(deadline) + } + if err := tx.GenerateOrBroadcastTxWithFactory(clientCtx, factory, msg.Msg); err != nil { + return err + } + return nil +} + +// setupNitroCommand sets up common infrastructure for nitro commands +func setupNitroCommand(cmd *cobra.Command) (*client.Context, *Server, func() error, error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return nil, nil, nil, err + } + + s, err := GetServerFromCmd(cmd) + if err != nil { + return nil, nil, nil, err + } + + relayServer, err := relay.GetServerFromCmd(cmd) + if err != nil { + return nil, nil, nil, err + } + + sw, err := connectAsPeer(clientCtx, relayServer, s.P2PReactors()) + if err != nil { + return nil, nil, nil, err + } + + return &clientCtx, s, sw.Stop, nil +} + +// setupNitroQueryCommand sets up infrastructure for nitro query commands (no tx context needed) +func setupNitroQueryCommand(cmd *cobra.Command, needp2p bool) (*Server, func() error, error) { + s, err := GetServerFromCmd(cmd) + if err != nil { + return nil, nil, err + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return nil, nil, err + } + + if !needp2p { + return s, func() error { return nil }, nil + } + + relayServer, err := relay.GetServerFromCmd(cmd) + if err != nil { + return nil, nil, err + } + + sw, err := connectAsPeer(clientCtx, relayServer, s.P2PReactors()) + if err != nil { + return nil, nil, err + } + + return s, sw.Stop, nil +} + +// resolveTokens resolves amount and asset address to Nitro funds +func resolveTokens(s *Server, amountStr, assetAddr string) (nitrotypes.Funds, error) { + var amount *big.Int + var asset common.Address + + if assetAddr != "" { + // Parse asset address + if !common.IsHexAddress(assetAddr) { + return nitrotypes.Funds{}, fmt.Errorf("invalid asset address: %s", assetAddr) + } + asset = common.HexToAddress(assetAddr) + + // A token specified by address must have an integer amount + amount = new(big.Int) + if _, ok := amount.SetString(amountStr, 10); !ok { + return nitrotypes.Funds{}, fmt.Errorf("invalid amount for token %s: %s", assetAddr, amountStr) + } + if amount.Sign() <= 0 { + return nitrotypes.Funds{}, fmt.Errorf("amount must be positive for token %s: %s", assetAddr, amountStr) + } + } else { + // Parse as (known) coins and convert + coins, err := sdk.ParseCoinsNormalized(amountStr) + if err != nil { + return nitrotypes.Funds{}, fmt.Errorf("failed to parse coins: %w", err) + } + if len(coins) != 1 { + return nitrotypes.Funds{}, fmt.Errorf("only one asset is supported") + } + + // Convert denomination to token address + asset, err = denomToToken(coins[0].Denom) + if err != nil { + return nitrotypes.Funds{}, err + } + amount = coins[0].Amount.BigInt() + } + + return nitrotypes.Funds{asset: amount}, nil +} + +// map denoms to token addresses +// TODO nitro should control this mapping, and resolution should happen in the module logic +func denomToToken(denom string) (common.Address, error) { + _tokens := map[string]common.Address{ + "eth": {}, + } + token, ok := _tokens[strings.ToLower(denom)] + if !ok { + return common.Address{}, fmt.Errorf("unknown token %s", denom) + } + return token, nil +} + +// connects as a peer to the relay server, initializing the P2P switch +func connectAsPeer( + clientCtx client.Context, relayServer *relay.Server, reactors map[string]p2p.Reactor, +) (*relay.Switch, error) { + // initialize the switch using the target's node info + status, err := clientCtx.Client.Status(clientCtx.CmdContext) + if err != nil { + return nil, err + } + nodeInfo := status.NodeInfo + sw, err := relayServer.GetSwitch(clientCtx.ChainID, nodeInfo.ProtocolVersion.Block) + if err != nil { + return nil, fmt.Errorf("error creating switch: %w", err) + } + for name, reactor := range reactors { + if err := sw.AddReactor(name, reactor); err != nil { + return nil, fmt.Errorf("error adding reactor: %w", err) + } + } + if err := sw.Start(); err != nil { + return nil, fmt.Errorf("error starting switch: %w", err) + } + + peerAddr := p2p.IDAddressString(nodeInfo.ID(), nodeInfo.ListenAddr) + // s.logger.Debug("dialing peer", "peer", peerAddr) + if err := sw.Dial(peerAddr); err != nil { + return nil, fmt.Errorf("error dialing peer: %w", err) + } + return sw, nil +} diff --git a/server/nitro/config.go b/server/nitro/config.go new file mode 100644 index 00000000..6d8041cb --- /dev/null +++ b/server/nitro/config.go @@ -0,0 +1,80 @@ +package nitro + +import ( + "errors" + "fmt" + + "git.vdb.to/cerc-io/laconicd/server" +) + +type Config struct { + Enable bool `mapstructure:"enable" toml:"enable" comment:"Enable Nitro state channel functionality"` + + EthKey string `mapstructure:"eth-key" toml:"eth-key" comment:"The private key used when interacting with the Ethereum chain and for our identity as a participant in the Nitro protocol."` + // UseDistsig bool `mapstructure:"use-distsig" toml:"use-distsig" comment:"Whether to use distributed signatures to authenticate Nitro actions."` + + // EthChainID string + EthURL string `mapstructure:"eth-url" toml:"eth-url" comment:"The URL of the Ethereum node to connect to."` + EthAuthToken string `mapstructure:"eth-auth-token" toml:"eth-auth-token" comment:"The bearer token used for auth in requests to the Ethereum chain's RPC endpoint."` + EthStartBlock uint64 `mapstructure:"eth-start-block" toml:"eth-start-block" comment:"Ethereum block number to start listening for Nitro Adjudicator events."` + + // TODO: move to module params? + EthNaAddress string `mapstructure:"eth-na-address" toml:"eth-na-address" comment:"Ethereum address of the Nitro Adjudicator contract."` + EthVpaAddress string `mapstructure:"eth-vpa-address" toml:"eth-vpa-address" comment:"Ethereum address of the Virtual Payment App contract."` + EthCaAddress string `mapstructure:"eth-ca-address" toml:"eth-ca-address" comment:"Ethereum address of the Consensus App contract."` + + // P2P Rate Limiting + P2PRateLimitEnable bool `mapstructure:"p2p-rate-limit-enable" toml:"p2p-rate-limit-enable" comment:"Enable send-side rate limiting for P2P messages."` + P2PRateLimitRate float64 `mapstructure:"p2p-rate-limit-rate" toml:"p2p-rate-limit-rate" comment:"Maximum number of P2P messages per second (e.g., 10.0 for 10 messages/second)."` + P2PRateLimitBurst int `mapstructure:"p2p-rate-limit-burst" toml:"p2p-rate-limit-burst" comment:"Maximum burst size for P2P rate limiter."` +} + +func DefaultConfig() *Config { + return &Config{ + Enable: true, + // UseDistsig: false, + // EthURL: "ws://127.0.0.1:8545", + + // Default rate limiting: 10 messages/second with burst of 20 + P2PRateLimitEnable: true, + P2PRateLimitRate: 10.0, + P2PRateLimitBurst: 20, + } +} + +func (c Config) Validate() error { + if !c.Enable { + return nil + } + if c.EthKey == "" { + return errors.New("nitro.eth-key must be set") + } + // TODO With distsig enabled, eth-key will be a mutually exclusive setting, and authentication + // for signing groups will be done using longterm key + // + // if c.UseDistsig && c.EthKey != "" { + // return errors.New("nitro.eth-key should not be set when distsig is enabled") + // } + + // Validate rate limiting config + if c.P2PRateLimitEnable { + if c.P2PRateLimitRate <= 0 { + return errors.New("nitro.p2p-rate-limit-rate must be positive when rate limiting is enabled") + } + if c.P2PRateLimitBurst <= 0 { + return errors.New("nitro.p2p-rate-limit-burst must be positive when rate limiting is enabled") + } + } + + return nil +} + +func UnmarshalConfig(cfg map[string]any) (*Config, error) { + config := DefaultConfig() + if len(cfg) > 0 { + if err := server.UnmarshalSubConfig(cfg, serverName, config); err != nil { + return nil, fmt.Errorf("failed to unmarshal %T: %w", config, err) + } + } + return config, nil +} diff --git a/server/nitro/config_test.go b/server/nitro/config_test.go new file mode 100644 index 00000000..b11d2de6 --- /dev/null +++ b/server/nitro/config_test.go @@ -0,0 +1,71 @@ +package nitro + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestConfigValidation(t *testing.T) { + tests := []struct { + name string + config Config + expectErr bool + }{ + { + name: "valid config with rate limiting", + config: Config{ + Enable: true, + EthKey: "test-eth-key", + P2PRateLimitEnable: true, + P2PRateLimitRate: 10.0, + P2PRateLimitBurst: 20, + }, + expectErr: false, + }, + { + name: "invalid rate - zero", + config: Config{ + Enable: true, + EthKey: "test-eth-key", + P2PRateLimitEnable: true, + P2PRateLimitRate: 0, + P2PRateLimitBurst: 20, + }, + expectErr: true, + }, + { + name: "invalid burst - zero", + config: Config{ + Enable: true, + EthKey: "test-eth-key", + P2PRateLimitEnable: true, + P2PRateLimitRate: 10.0, + P2PRateLimitBurst: 0, + }, + expectErr: true, + }, + { + name: "rate limiting disabled - no validation needed", + config: Config{ + Enable: true, + EthKey: "test-eth-key", + P2PRateLimitEnable: false, + P2PRateLimitRate: 0, // Invalid but should be ignored + P2PRateLimitBurst: 0, // Invalid but should be ignored + }, + expectErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.config.Validate() + if tt.expectErr { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + }) + } +} diff --git a/server/nitro/flags.go b/server/nitro/flags.go new file mode 100644 index 00000000..93f35b6a --- /dev/null +++ b/server/nitro/flags.go @@ -0,0 +1,30 @@ +package nitro + +import ( + "fmt" + + "github.com/spf13/pflag" +) + +// start flags are prefixed with the server name +func prefix(f string) string { + return fmt.Sprintf("%s.%s", serverName, f) +} + +var ( + FlagEthKey = prefix("eth-key") + FlagEthURL = prefix("eth-url") + FlagEthStartBlock = prefix("eth-start-block") + FlagEthAuthToken = prefix("eth-auth-token") + + // FlagEthNaAddress = prefix("eth-na-address") + // FlagEthVpaAddress = prefix("eth-vpa-address") + // FlagEthCaAddress = prefix("eth-ca-address") +) + +func AddFlags(f *pflag.FlagSet) { + f.String(FlagEthKey, "", "name of private key to use when interacting with the Ethereum chain") + f.String(FlagEthURL, "ws://127.0.0.1:8545", "URL of the Ethereum node to connect to") + f.String(FlagEthAuthToken, "", "bearer token used for auth in requests to the Ethereum chain's RPC endpoint") + f.Uint64(FlagEthStartBlock, 0, "Ethereum block number to start listening for Nitro Adjudicator events") +} diff --git a/server/nitro/p2p.go b/server/nitro/p2p.go new file mode 100644 index 00000000..596207ed --- /dev/null +++ b/server/nitro/p2p.go @@ -0,0 +1,286 @@ +package nitro + +import ( + "context" + "errors" + "fmt" + "sync" + "time" + + "cosmossdk.io/log" + "github.com/cometbft/cometbft/p2p" + "github.com/cosmos/gogoproto/proto" + nitrop2p "github.com/statechannels/go-nitro/node/engine/messageservice" + "github.com/statechannels/go-nitro/protocols" + nitrotypes "github.com/statechannels/go-nitro/types" + "golang.org/x/time/rate" +) + +const ( + P2PMessageChannel = byte(0x80) + // SigRequestChannel = byte(0x81) + + maxMsgSize = 1024 * 1024 + msgBufSize = 1000 + limiterTimeout = 5 * time.Second +) + +var ( + _ p2p.Reactor = (*p2pReactor)(nil) + _ nitrop2p.MessageService = (*p2pMsgService)(nil) +) + +// p2pReactor handles Nitro P2P messages via CometBFT +type p2pReactor struct { + p2p.BaseReactor + incoming chan nitrop2p.Message + outgoing map[p2p.ID]chan nitrop2p.Message + sendQueue chan nitrop2p.Message + rateLimiter *rate.Limiter + config *Config + logger log.Logger + mtx sync.RWMutex + wg sync.WaitGroup +} + +type p2pMsgService struct { + id string + logger log.Logger + reactor *p2pReactor // one reactor per msg service +} + +type streamDesc struct { + id byte + msgType proto.Message +} + +func (sd streamDesc) StreamID() byte { return sd.id } + +// TODO: convert Message to protobuf +func (sd streamDesc) MessageType() proto.Message { return sd.msgType } + +// Reactor + +func newReactor(config *Config, logger log.Logger) *p2pReactor { + var rateLimiter *rate.Limiter + if config.P2PRateLimitEnable { + rateLimiter = rate.NewLimiter(rate.Limit(config.P2PRateLimitRate), config.P2PRateLimitBurst) + } + + ret := &p2pReactor{ + incoming: make(chan nitrop2p.Message, msgBufSize), + outgoing: make(map[p2p.ID]chan nitrop2p.Message), + sendQueue: make(chan nitrop2p.Message, msgBufSize), + rateLimiter: rateLimiter, + config: config, + logger: logger, + } + ret.BaseReactor = *p2p.NewBaseReactor("nitro-reactor", ret) + return ret +} + +// StreamDescriptors returns the stream descriptor for Nitro messages. +func (r *p2pReactor) GetChannels() []*p2p.ChannelDescriptor { + return []*p2p.ChannelDescriptor{ + { + ID: P2PMessageChannel, + Priority: 5, + SendQueueCapacity: 100, + RecvBufferCapacity: 1000, + RecvMessageCapacity: maxMsgSize, + MessageType: &P2PMessage{}, + }, + // TODO Nitro peer info channel + } +} + +// AddPeer begins sending messages to a peer. +func (r *p2pReactor) AddPeer(peer p2p.Peer) { + if !r.IsRunning() { + return + } + + peerCh := make(chan nitrop2p.Message, msgBufSize) + r.mtx.Lock() + r.outgoing[peer.ID()] = peerCh + r.mtx.Unlock() + + // Start goroutine to handle sending to this specific peer + go r.handlePeer(peer, peerCh) +} + +func (r *p2pReactor) handlePeer(peer p2p.Peer, peerCh chan nitrop2p.Message) { + logger := r.logger.With("peer", peer) + + defer func() { + r.mtx.Lock() + defer r.mtx.Unlock() + if _, ok := r.outgoing[peer.ID()]; ok { + close(peerCh) + delete(r.outgoing, peer.ID()) + } + }() + + for { + if !peer.IsRunning() || !r.IsRunning() { + return + } + inner_loop: + for { + select { + case msg := <-peerCh: + encoded, err := msg.Serialize() + if err != nil { + logger.Error("Failed to serialize message", "msg", msg, "err", err) + continue inner_loop + } + sent := peer.Send(p2p.Envelope{ + Message: &P2PMessage{Content: encoded}, + ChannelID: P2PMessageChannel, + }) + if !sent { + logger.Error("Failed to send message", "msg", msg) + return + } + default: + break inner_loop + } + } + } +} + +// Receive handles an envelope received from any connected peer on any registered channel. +func (r *p2pReactor) Receive(e p2p.Envelope) { + if !r.IsRunning() { + r.Logger.Debug("Receive", "src", e.Src, "chId", e.ChannelID) + return + } + switch e.ChannelID { + case P2PMessageChannel: + switch msg := e.Message.(type) { + case *P2PMessage: + nitroMsg, err := protocols.DeserializeMessage(msg.Content) + if err != nil { + r.Logger.Error("Failed to deserialize message", "err", err) + r.Switch.StopPeerForError(e.Src, err) + return + } + r.incoming <- nitroMsg + default: + r.Logger.Error(fmt.Sprintf("Unknown message type: %T", e.Message)) + } + default: + r.Logger.Error(fmt.Sprintf("Unknown channel ID: %X", e.ChannelID)) + } +} + +func (r *p2pReactor) OnStart() error { + // Start the single sending goroutine + r.wg.Add(1) + go r.sendLoop() + return nil +} + +func (r *p2pReactor) OnStop() { r.close() } + +func (r *p2pReactor) close() { + close(r.incoming) + close(r.sendQueue) + r.wg.Wait() // Wait for sending goroutine to finish + + r.mtx.Lock() + defer r.mtx.Unlock() + for id, ch := range r.outgoing { + close(ch) + delete(r.outgoing, id) + } +} + +// sendLoop runs in a single goroutine and handles all outgoing messages with rate limiting +func (r *p2pReactor) sendLoop() { + defer r.wg.Done() + + for msg := range r.sendQueue { + // Apply rate limiting if enabled + if r.rateLimiter != nil { + ctx, cancel := context.WithTimeout(context.Background(), limiterTimeout) + if err := r.rateLimiter.Wait(ctx); err != nil { + r.logger.Error("Rate limit exceeded, dropping message", "error", err) + cancel() + continue + } + cancel() + } + + // Send to all connected peers + r.mtx.RLock() + for peerID, ch := range r.outgoing { + select { + case ch <- msg: + // Message sent successfully + default: + // Channel is full, log warning but don't block + r.logger.Warn("Peer channel full, dropping message", "peer", peerID) + } + } + r.mtx.RUnlock() + } +} + +func (r *p2pReactor) send(msg nitrop2p.Message) { + select { + case r.sendQueue <- msg: + // Message queued successfully + default: + // Send queue is full, log error + r.logger.Error("Send queue full, dropping message") + } +} + +// GetRateLimitStats returns current rate limiting statistics +func (r *p2pReactor) GetRateLimitStats() (enabled bool, limit float64, burst int, tokens float64) { + if r.rateLimiter == nil { + return false, 0, 0, 0 + } + return true, float64(r.rateLimiter.Limit()), r.rateLimiter.Burst(), r.rateLimiter.Tokens() +} + +// UpdateRateLimit updates the rate limiting parameters at runtime +func (r *p2pReactor) UpdateRateLimit(newRate float64, newBurst int) { + if r.rateLimiter != nil { + r.rateLimiter.SetLimit(rate.Limit(newRate)) + r.rateLimiter.SetBurst(newBurst) + } +} + +// MessageService + +func newMessageService(id string, r *p2pReactor /* , logger log.Logger */) *p2pMsgService { + return &p2pMsgService{ + id: id, + reactor: r, + // logger: logger, + } +} + +func (ms *p2pMsgService) P2PMessages() <-chan nitrop2p.Message { + return ms.reactor.incoming +} + +func (ms *p2pMsgService) Send(p nitrotypes.Participant, m nitrop2p.Message) error { + if !ms.reactor.IsRunning() { + return errors.New("reactor not running") + } + + ms.reactor.send(m) + return nil +} + +func (ms *p2pMsgService) Close() error { + // the lifecycle of the reactor is managed by cometbft + return nil +} + +func (ms *p2pMsgService) Id() string { + return ms.id +} diff --git a/server/nitro/p2p.pb.go b/server/nitro/p2p.pb.go new file mode 100644 index 00000000..357357fd --- /dev/null +++ b/server/nitro/p2p.pb.go @@ -0,0 +1,317 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cerc/nitro/v1/p2p.proto + +package nitro + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// P2PMessage wraps a json-encoded Nitro protocols.Message +// TODO: proper proto message? +type P2PMessage struct { + Content string `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"` +} + +func (m *P2PMessage) Reset() { *m = P2PMessage{} } +func (m *P2PMessage) String() string { return proto.CompactTextString(m) } +func (*P2PMessage) ProtoMessage() {} +func (*P2PMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_97350824263b9206, []int{0} +} +func (m *P2PMessage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *P2PMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_P2PMessage.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *P2PMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_P2PMessage.Merge(m, src) +} +func (m *P2PMessage) XXX_Size() int { + return m.Size() +} +func (m *P2PMessage) XXX_DiscardUnknown() { + xxx_messageInfo_P2PMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_P2PMessage proto.InternalMessageInfo + +func (m *P2PMessage) GetContent() string { + if m != nil { + return m.Content + } + return "" +} + +func init() { + proto.RegisterType((*P2PMessage)(nil), "cerc.nitro.v1.P2PMessage") +} + +func init() { proto.RegisterFile("cerc/nitro/v1/p2p.proto", fileDescriptor_97350824263b9206) } + +var fileDescriptor_97350824263b9206 = []byte{ + // 162 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0x4e, 0x2d, 0x4a, + 0xd6, 0xcf, 0xcb, 0x2c, 0x29, 0xca, 0xd7, 0x2f, 0x33, 0xd4, 0x2f, 0x30, 0x2a, 0xd0, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x49, 0xe8, 0x81, 0x25, 0xf4, 0xca, 0x0c, 0x95, 0xd4, 0xb8, + 0xb8, 0x02, 0x8c, 0x02, 0x7c, 0x53, 0x8b, 0x8b, 0x13, 0xd3, 0x53, 0x85, 0x24, 0xb8, 0xd8, 0x93, + 0xf3, 0xf3, 0x4a, 0x52, 0xf3, 0x4a, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x27, + 0xa7, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, + 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x48, 0xcf, 0x2c, 0xd1, + 0x2b, 0x4b, 0x49, 0xd2, 0x2b, 0xc9, 0xd7, 0x07, 0x99, 0xad, 0x9b, 0x99, 0xaf, 0x9f, 0x93, 0x98, + 0x9c, 0x9f, 0x97, 0x99, 0x9c, 0xa2, 0x5f, 0x9c, 0x5a, 0x54, 0x96, 0x5a, 0x04, 0x71, 0x47, 0x12, + 0x1b, 0xd8, 0x05, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x79, 0x5d, 0x6d, 0x7c, 0x9c, 0x00, + 0x00, 0x00, +} + +func (m *P2PMessage) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *P2PMessage) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *P2PMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Content) > 0 { + i -= len(m.Content) + copy(dAtA[i:], m.Content) + i = encodeVarintP2P(dAtA, i, uint64(len(m.Content))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintP2P(dAtA []byte, offset int, v uint64) int { + offset -= sovP2P(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *P2PMessage) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Content) + if l > 0 { + n += 1 + l + sovP2P(uint64(l)) + } + return n +} + +func sovP2P(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozP2P(x uint64) (n int) { + return sovP2P(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *P2PMessage) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowP2P + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: P2PMessage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: P2PMessage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowP2P + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthP2P + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthP2P + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Content = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipP2P(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthP2P + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipP2P(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowP2P + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowP2P + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowP2P + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthP2P + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupP2P + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthP2P + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthP2P = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowP2P = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupP2P = fmt.Errorf("proto: unexpected end of group") +) diff --git a/server/nitro/p2p_ratelimit_test.go b/server/nitro/p2p_ratelimit_test.go new file mode 100644 index 00000000..3a295db9 --- /dev/null +++ b/server/nitro/p2p_ratelimit_test.go @@ -0,0 +1,74 @@ +package nitro + +import ( + "testing" + + "cosmossdk.io/log" + nitrop2p "github.com/statechannels/go-nitro/node/engine/messageservice" + nitrotypes "github.com/statechannels/go-nitro/types" + "github.com/stretchr/testify/assert" +) + +func TestP2PRateLimit(t *testing.T) { + // Test with rate limiting enabled + config := &Config{ + P2PRateLimitEnable: true, + P2PRateLimitRate: 2.0, // 2 messages per second + P2PRateLimitBurst: 2, // burst of 2 + } + + reactor := newReactor(config, log.NewNopLogger()) + + // Check rate limit stats + enabled, limit, burst, tokens := reactor.GetRateLimitStats() + assert.True(t, enabled, "Rate limiting should be enabled") + assert.Equal(t, 2.0, limit, "Rate limit should be 2.0") + assert.Equal(t, 2, burst, "Burst should be 2") + assert.Equal(t, float64(2), tokens, "Initial tokens should equal burst size") + + // Test that UpdateRateLimit works + reactor.UpdateRateLimit(5.0, 10) + enabled, limit, burst, _ = reactor.GetRateLimitStats() + assert.True(t, enabled) + assert.Equal(t, 5.0, limit) + assert.Equal(t, 10, burst) +} + +func TestP2PRateLimitDisabled(t *testing.T) { + // Test with rate limiting disabled + config := &Config{ + P2PRateLimitEnable: false, + } + + reactor := newReactor(config, log.NewNopLogger()) + + // Check rate limit stats + enabled, limit, burst, tokens := reactor.GetRateLimitStats() + assert.False(t, enabled, "Rate limiting should be disabled") + assert.Equal(t, 0.0, limit) + assert.Equal(t, 0, burst) + assert.Equal(t, 0.0, tokens) +} + +func TestP2PRateLimitSendBehavior(t *testing.T) { + // Test actual send behavior with rate limiting + config := &Config{ + P2PRateLimitEnable: true, + P2PRateLimitRate: 1000.0, // High rate for testing + P2PRateLimitBurst: 1, // Small burst + } + + reactor := newReactor(config, log.NewNopLogger()) + msgService := newMessageService("test", reactor) + + // Create a dummy participant and message + participant, _ := nitrotypes.ParseParticipant("0x0000000000000000000000000000000000000001") + message := nitrop2p.Message{} + + // This should return an error because reactor is not running + err := msgService.Send(participant, message) + + // We expect an error because reactor is not running + assert.Error(t, err) + assert.Contains(t, err.Error(), "reactor not running") +} diff --git a/server/nitro/protocol.go b/server/nitro/protocol.go new file mode 100644 index 00000000..d3315737 --- /dev/null +++ b/server/nitro/protocol.go @@ -0,0 +1,166 @@ +package nitro + +import ( + "errors" + "fmt" + "math/big" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/statechannels/go-nitro/channel/state/outcome" + "github.com/statechannels/go-nitro/protocols" + nitrotypes "github.com/statechannels/go-nitro/types" + + "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1" +) + +type MsgWrapper struct { + Msg sdk.Msg + Objective protocols.ObjectiveId + SignerField *string +} + +func (s *Server) OpenLedgerChannel(funds nitrotypes.Funds, counterparty nitrotypes.Participant) (*MsgWrapper, error) { + // TODO: handle multiple assets + if len(funds) != 1 { + return nil, errors.New("only one asset is supported") + } + fund, exit := makeOutcome(s.ethAddress, counterparty, funds) + + r, err := s.node.CreateLedgerChannel(counterparty, 0, exit) + if err != nil { + return nil, err + } + s.logger.Info("Initiated objective", "id", r.Id) + + // Convert nitrotypes.Funds back to sdk.Coins for the message + // Use "token" as a default denomination for now + // TODO: nitro will store a mapping of denoms to token addresses + // an entry will be added for new denominations upon confirmation of ledger deposit + coins := sdk.Coins{sdk.NewCoin("token", math.NewIntFromBigInt(fund.Amount))} + + msg := &v1.MsgOpenChannel{ + Funds: coins, + NitroAddress: s.ethAddress.String(), + Counterparty: counterparty.String(), + ChannelId: r.ChannelId.String(), + } + return &MsgWrapper{msg, r.Id, &msg.Signer}, nil +} + +func (s *Server) CloseLedgerChannel(channelId nitrotypes.ChannelID, isChallenge bool) (*MsgWrapper, error) { + objective, err := s.node.CloseLedgerChannel(channelId, isChallenge) + if err != nil { + return nil, err + } + s.logger.Info("Initiated objective", "id", objective) + + msg := &v1.MsgCloseChannel{ + ChannelId: channelId.String(), + IsChallenge: isChallenge, + } + return &MsgWrapper{msg, objective, &msg.Signer}, nil +} + +func (s *Server) CreatePaymentChannel(intermediaries []string, counterpartyString string, challengeDuration uint32, funds nitrotypes.Funds) (*MsgWrapper, error) { + // Parse intermediaries + var intermediaryParticipants []nitrotypes.Participant + for _, addr := range intermediaries { + participant, err := nitrotypes.ParseParticipant(addr) + if err != nil { + return nil, fmt.Errorf("failed to parse intermediary %s: %w", addr, err) + } + intermediaryParticipants = append(intermediaryParticipants, participant) + } + + // Parse counterparty + counterparty, err := nitrotypes.ParseParticipant(counterpartyString) + if err != nil { + return nil, fmt.Errorf("failed to parse counterparty: %w", err) + } + + // TODO: handle multiple assets + if len(funds) != 1 { + return nil, errors.New("only one asset is supported") + } + if len(funds) != 1 { + return nil, errors.New("only one asset is supported") + } + fund, exit := makeOutcome(s.ethAddress, counterparty, funds) + + // Create payment channel + r, err := s.node.CreatePaymentChannel(intermediaryParticipants, counterparty, challengeDuration, exit) + if err != nil { + return nil, err + } + s.logger.Info("Initiated payment channel objective", "id", r.Id) + + // Convert nitrotypes.Funds back to sdk.Coins for the message + coins := sdk.Coins{sdk.NewCoin("token", math.NewIntFromBigInt(fund.Amount))} + + msg := &v1.MsgCreatePaymentChannel{ + NitroAddress: s.ethAddress.String(), + Counterparty: counterpartyString, + Intermediaries: intermediaries, + ChallengeDuration: challengeDuration, + Funds: coins, + ChannelId: r.ChannelId.String(), + } + return &MsgWrapper{msg, r.Id, &msg.Signer}, nil +} + +func (s *Server) ClosePaymentChannel(channelId nitrotypes.ChannelID) (*MsgWrapper, error) { + objective, err := s.node.ClosePaymentChannel(channelId) + if err != nil { + return nil, err + } + s.logger.Info("Initiated payment channel close objective", "id", objective) + + msg := &v1.MsgClosePaymentChannel{ + ChannelId: channelId.String(), + } + return &MsgWrapper{msg, objective, &msg.Signer}, nil +} + +func (s *Server) Pay(channelId nitrotypes.ChannelID, amount sdk.Coin) (*MsgWrapper, error) { + err := s.node.Pay(channelId, amount.Amount.BigInt()) + if err != nil { + return nil, err + } + + nodeAddrStr, err := s.addressCodec.BytesToString(s.nodeAddress()) + if err != nil { + return nil, err + } + + msg := &v1.MsgPay{ + ChannelId: channelId.String(), + Amount: amount, + Signer: nodeAddrStr, + } + return &MsgWrapper{msg, "", &msg.Signer}, nil +} + +func makeOutcome(ethAddress, counterparty nitrotypes.Participant, funds nitrotypes.Funds) (nitrotypes.Fund, outcome.Exit) { + var fund nitrotypes.Fund + for asset, amount := range funds { + fund = nitrotypes.Fund{asset, amount} + } + + exit := outcome.Exit{ + outcome.SingleAssetExit{ + Asset: fund.Asset, + Allocations: []outcome.Allocation{ + { + Destination: ethAddress.ToDestination(), + Amount: fund.Amount, + }, + { + Destination: counterparty.ToDestination(), + Amount: big.NewInt(0), + }, + }, + }, + } + return fund, exit +} diff --git a/server/nitro/query.go b/server/nitro/query.go new file mode 100644 index 00000000..c38d97a2 --- /dev/null +++ b/server/nitro/query.go @@ -0,0 +1,194 @@ +package nitro + +import ( + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + nitrotypes "github.com/statechannels/go-nitro/types" + + "git.vdb.to/cerc-io/laconicd/server" + "git.vdb.to/cerc-io/laconicd/server/relay" +) + +func GetChannelCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-channel ", + Short: "Get information about a channel", + Args: cobra.ExactArgs(1), + Long: "Retrieves detailed information about a specific ledger or payment channel.", + RunE: func(cmd *cobra.Command, args []string) error { + channelId, err := nitrotypes.ParseChannelID(args[0]) + if err != nil { + return fmt.Errorf("failed to parse channel ID: %w", err) + } + + ledger, _ := cmd.Flags().GetBool("ledger") + payment, _ := cmd.Flags().GetBool("payment") + local, _ := cmd.Flags().GetBool("local") + + if !ledger && !payment { + ledger = true + } + if ledger && payment { + return fmt.Errorf("cannot specify both --ledger and --payment flags") + } + + s, done, err := setupNitroQueryCommand(cmd, !local) + if err != nil { + return err + } + defer done() + + var output []byte + if ledger { + info, err := s.node.GetLedgerChannel(channelId) + if err != nil { + return fmt.Errorf("failed to get ledger channel: %w", err) + } + output, err = json.MarshalIndent(info, "", " ") + if err != nil { + return fmt.Errorf("failed to marshal response: %w", err) + } + } else { + info, err := s.node.GetPaymentChannel(channelId) + if err != nil { + return fmt.Errorf("failed to get payment channel: %w", err) + } + output, err = json.MarshalIndent(info, "", " ") + if err != nil { + return fmt.Errorf("failed to marshal response: %w", err) + } + } + + fmt.Println(string(output)) + return nil + }, + } + + cmd.Flags().Bool("ledger", false, "Get ledger channel information") + cmd.Flags().Bool("payment", false, "Get payment channel information") + cmd.Flags().Bool("local", false, "Query local data only (no P2P connection)") + flags.AddQueryFlagsToCmd(cmd) + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} + +func ListChannelsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-channels", + Short: "List all ledger channels", + Args: cobra.NoArgs, + Long: "Retrieves information about all ledger channels.", + RunE: func(cmd *cobra.Command, args []string) error { + local, _ := cmd.Flags().GetBool("local") + + s, done, err := setupNitroQueryCommand(cmd, !local) + if err != nil { + return err + } + defer done() + + channels, err := s.node.GetAllLedgerChannels() + if err != nil { + return fmt.Errorf("failed to get all ledger channels: %w", err) + } + + output, err := json.MarshalIndent(channels, "", " ") + if err != nil { + return fmt.Errorf("failed to marshal response: %w", err) + } + + fmt.Println(string(output)) + return nil + }, + } + + cmd.Flags().Bool("local", false, "Query local data only (no P2P connection)") + flags.AddQueryFlagsToCmd(cmd) + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} + +func ListPaymentChannelsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-payment-channels ", + Short: "List all payment channels for a ledger channel", + Args: cobra.ExactArgs(1), + Long: "Retrieves all active payment channels associated with a specific ledger channel.", + RunE: func(cmd *cobra.Command, args []string) error { + ledgerChannelId, err := nitrotypes.ParseChannelID(args[0]) + if err != nil { + return fmt.Errorf("failed to parse ledger channel ID: %w", err) + } + + local, _ := cmd.Flags().GetBool("local") + + s, done, err := setupNitroQueryCommand(cmd, !local) + if err != nil { + return err + } + defer done() + + channels, err := s.node.GetPaymentChannelsByLedger(ledgerChannelId) + if err != nil { + return fmt.Errorf("failed to get payment channels: %w", err) + } + + output, err := json.MarshalIndent(channels, "", " ") + if err != nil { + return fmt.Errorf("failed to marshal response: %w", err) + } + + fmt.Println(string(output)) + return nil + }, + } + + cmd.Flags().Bool("local", false, "Query local data only (no P2P connection)") + flags.AddQueryFlagsToCmd(cmd) + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} + +func IdentityCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "identity", + Short: "Get the node identity", + Args: cobra.NoArgs, + Long: "Retrieves the node's identity. Use --participant for principal ID (default) or --network for network address.", + RunE: func(cmd *cobra.Command, args []string) error { + participant, _ := cmd.Flags().GetBool("participant") + network, _ := cmd.Flags().GetBool("network") + + if !participant && !network { + participant = true + } + if participant && network { + return fmt.Errorf("cannot specify both --participant and --network flags") + } + + s, done, err := setupNitroQueryCommand(cmd, false) + if err != nil { + return err + } + defer done() + + if participant { + identity := s.node.PrincipalID() + fmt.Println(identity.String()) + } else { + identity := s.node.NetworkID() + fmt.Println(identity.String()) + } + return nil + }, + } + + cmd.Flags().Bool("participant", false, "Get the principal ID (default)") + cmd.Flags().Bool("network", false, "Get the network address") + flags.AddQueryFlagsToCmd(cmd) + server.SetRequiredComponents(cmd, &Server{}) + return cmd +} diff --git a/server/nitro/server.go b/server/nitro/server.go new file mode 100644 index 00000000..46de5e39 --- /dev/null +++ b/server/nitro/server.go @@ -0,0 +1,210 @@ +package nitro + +import ( + "context" + "encoding/hex" + "fmt" + "log/slog" + "path/filepath" + "sync/atomic" + + cmtcrypto "github.com/cometbft/cometbft/crypto" + "github.com/cometbft/cometbft/p2p" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/spf13/pflag" + nitrocrypto "github.com/statechannels/go-nitro/crypto" + "github.com/statechannels/go-nitro/node" + "github.com/statechannels/go-nitro/node/engine" + "github.com/statechannels/go-nitro/node/engine/chainservice" + chainutils "github.com/statechannels/go-nitro/node/engine/chainservice/utils" + "github.com/statechannels/go-nitro/node/engine/store" + nitrotypes "github.com/statechannels/go-nitro/types" + + "cosmossdk.io/core/address" + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" + + "git.vdb.to/cerc-io/laconicd/server" + "git.vdb.to/cerc-io/laconicd/utils" +) + +const ( + serverName = "nitro" + + ServerContextKey = "server." + serverName +) + +// TODO +// 1. implement participation as a signing group member: +// 1.1. initialize group delegate credentials, with distsig over ABCI +// 1.2. bind custodian contract for chain/adjudicator actions +// 2. operation to update DKG group members +// 3. integrate with onboarding module + +// Server wraps and configures a go-nitro Node. +type Server struct { + logger log.Logger + config *Config + node *node.Node + storeDir string // path to Nitro store directory + reactor *p2pReactor + keyring keyring.Keyring + addressCodec address.Codec + ethAddress nitrotypes.Address + nodeKey cmtcrypto.PrivKey + // participantID nitrotypes.Participant + ready atomic.Bool +} + +func New(globalConfig server.ConfigMap, logger log.Logger, kr keyring.Keyring) (*Server, error) { + home, _ := globalConfig[flags.FlagHome].(string) + cfg, err := UnmarshalConfig(globalConfig) + if err != nil { + return nil, err + } + if err := cfg.Validate(); err != nil { + return nil, err + } + s := &Server{ + config: cfg, + storeDir: filepath.Join(home, "nitro"), + reactor: newReactor(cfg, logger.With(log.ModuleKey, serverName, "component", "p2p-reactor")), + keyring: kr, + logger: logger.With(log.ModuleKey, serverName), + addressCodec: utils.NewAddressCodec(), + } + return s, nil +} + +func (*Server) Name() string { + return serverName +} + +func (s *Server) Start(ctx context.Context) error { + if !s.config.Enable { + s.logger.Info(fmt.Sprintf("%s server is disabled via config", s.Name())) + return nil + } + // TODO: pass keyring through context? + if err := s.init(s.keyring); err != nil { + return err + } + s.logger.Info("starting Nitro server") + s.ready.Store(true) + return nil +} + +func (s *Server) Stop(context.Context) error { + s.logger.Info("stopping Nitro server") + s.ready.Store(false) + if s.node != nil { + return s.node.Close() + } + return nil +} + +func (s *Server) init(kr keyring.Keyring) error { + var ( + ethkey cmtcrypto.PrivKey + err error + c = s.config + ) + if c.EthKey != "" { + ethkey, err = utils.ExtractPrivateKeyByUid(kr, c.EthKey) + if err != nil { + return err + } + } else { + return fmt.Errorf("eth-key is not set") // should already be caught by Config.Validate + } + s.nodeKey = ethkey + + storeOpts := store.StoreOpts{ + UseDurableStore: true, + DurableStoreDir: s.storeDir, + } + chainOpts := chainservice.ChainOpts{ + ChainUrl: c.EthURL, + StartBlockNum: c.EthStartBlock, + ChainAuthToken: c.EthAuthToken, + ChainPk: hex.EncodeToString(ethkey.Bytes()), + } + // inject SDK logger into slog, which Nitro uses + loggerImpl, ok := s.logger.Impl().(*slog.Logger) + if ok { + slog.SetDefault(loggerImpl) + } else { + s.logger.Warn("Logger backend is not slog, cannot set as Nitro logger") + } + + store, err := store.NewStore(storeOpts) + if err != nil { + return err + } + // Compare chainOpts.ChainStartBlock to lastBlockNum seen in store. The larger of the two + // gets passed as an argument when creating NewEthChainService + storeBlockNum, err := store.GetLastBlockNumSeen() + if err != nil { + return err + } + chainOpts.StartBlockNum = max(storeBlockNum, chainOpts.StartBlockNum) + + contractAddresses := node.ContractAddresses{ + NaAddress: common.HexToAddress(c.EthNaAddress), + VpaAddress: common.HexToAddress(c.EthVpaAddress), + CaAddress: common.HexToAddress(c.EthCaAddress), + } + chainOpts.CreateAdjudicator = chainutils.AdjudicatorCreator(contractAddresses.NaAddress) + chain, err := chainservice.NewL1ChainService(chainOpts) + if err != nil { + return err + } + // note: utils.EthAddressFromPubKey expects uncompressed keys + ethPubkey, err := crypto.DecompressPubkey(ethkey.PubKey().Bytes()) + if err != nil { + return err + } + s.ethAddress = nitrotypes.Address(crypto.PubkeyToAddress(*ethPubkey)) + + s.node = node.New( + newMessageService("laconicd-p2p-"+s.ethAddress.String(), s.reactor), + chain, + store, + &engine.PermissivePolicy{}, + nitrocrypto.NewSimpleCredential(ethkey.Bytes()), + contractAddresses, + ) + return nil +} + +func (s *Server) Config() any { + if s.config == nil { + return DefaultConfig() + } + return s.config +} + +func (s *Server) StartCmdFlags() *pflag.FlagSet { + flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError) + AddFlags(flags) + return flags +} + +func (s *Server) Ready() bool { + return s.ready.Load() +} + +func (s *Server) ContextKey() string { + return ServerContextKey +} + +func (s *Server) P2PReactors() map[string]p2p.Reactor { + return map[string]p2p.Reactor{"NITRO": s.reactor} +} + +func (s *Server) nodeAddress() sdk.AccAddress { + return sdk.AccAddress(s.nodeKey.PubKey().Address()) +} diff --git a/server/nitro/tx.go b/server/nitro/tx.go new file mode 100644 index 00000000..8d3636fa --- /dev/null +++ b/server/nitro/tx.go @@ -0,0 +1,326 @@ +package nitro + +import ( + "encoding/json" + "fmt" + "math/big" + + "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + "github.com/statechannels/go-nitro/node/query" + nitrotypes "github.com/statechannels/go-nitro/types" + + "git.vdb.to/cerc-io/laconicd/server" + "git.vdb.to/cerc-io/laconicd/server/relay" +) + +func OpenChannelCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "open-channel ", + Short: "Open a ledger channel with the given counterparty", + Args: cobra.ExactArgs(2), + Long: "Creates a ledger channel with the specified counterparty and funding amount.", + RunE: func(cmd *cobra.Command, args []string) error { + counterparty, err := nitrotypes.ParseParticipant(args[0]) + if err != nil { + return fmt.Errorf("failed to parse counterparty: %w", err) + } + + clientCtx, s, done, err := setupNitroCommand(cmd) + if err != nil { + return err + } + defer done() + + assetAddr, _ := cmd.Flags().GetString("asset") + funds, err := resolveTokens(s, args[1], assetAddr) + if err != nil { + return err + } + + m, err := s.OpenLedgerChannel(funds, counterparty) + if err != nil { + return err + } + + if err = waitForObjective( + s.node.FailedObjectives(), + m.Objective, + s.node.LedgerUpdatedChan(m.Objective.ChannelID()), + func(info query.LedgerChannelInfo) bool { return info.Status == query.Open }, + ); err != nil { + return err + } + + return submitNitroTx(*clientCtx, cmd, *m, false) + }, + } + + cmd.Flags().String("asset", "", "Ethereum token address (if specified, amount is parsed as decimal without denomination)") + AddFlags(cmd.Flags()) + flags.AddTxFlagsToCmd(cmd) + + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} + +func CloseChannelCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "close-channel ", + Short: "Close a ledger channel", + Args: cobra.ExactArgs(1), + Long: "Close a ledger channel. Use --challenge flag for dispute resolution when cooperation fails.", + RunE: func(cmd *cobra.Command, args []string) error { + channelId, err := nitrotypes.ParseChannelID(args[0]) + if err != nil { + return fmt.Errorf("failed to parse channel ID: %w", err) + } + + isChallenge, err := cmd.Flags().GetBool("challenge") + if err != nil { + return err + } + + clientCtx, s, done, err := setupNitroCommand(cmd) + if err != nil { + return err + } + defer done() + + m, err := s.CloseLedgerChannel(channelId, isChallenge) + if err != nil { + return err + } + + if err = waitForObjective( + s.node.FailedObjectives(), + m.Objective, + s.node.LedgerUpdatedChan(channelId), + func(info query.LedgerChannelInfo) bool { return info.Status == query.Complete }, + ); err != nil { + return err + } + + return submitNitroTx(*clientCtx, cmd, *m, false) + }, + } + + cmd.Flags().Bool("challenge", false, "Close via challenge (dispute resolution) instead of cooperative closure") + AddFlags(cmd.Flags()) + flags.AddTxFlagsToCmd(cmd) + + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} + +func OpenPaymentChannelCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "open-payment-channel [intermediaries...]", + Short: "Open a virtual payment channel", + Args: cobra.MinimumNArgs(2), + Long: "Creates a virtual payment channel with the specified counterparty and optional intermediaries.", + RunE: func(cmd *cobra.Command, args []string) error { + counterparty := args[0] + + challengeDuration, err := cmd.Flags().GetUint32("challenge-duration") + if err != nil { + return err + } + + var intermediaries []string + if len(args) > 2 { + intermediaries = args[2:] + } + + clientCtx, s, done, err := setupNitroCommand(cmd) + if err != nil { + return err + } + defer done() + + assetAddr, _ := cmd.Flags().GetString("asset") + funds, err := resolveTokens(s, args[1], assetAddr) + if err != nil { + return err + } + + m, err := s.CreatePaymentChannel(intermediaries, counterparty, challengeDuration, funds) + if err != nil { + return err + } + + if err = waitForObjective( + s.node.FailedObjectives(), + m.Objective, + s.node.PaymentChannelUpdatedChan(m.Objective.ChannelID()), + func(info query.PaymentChannelInfo) bool { return info.Status == query.Open }, + ); err != nil { + return err + } + + return submitNitroTx(*clientCtx, cmd, *m, false) + }, + } + + cmd.Flags().String("asset", "", "Ethereum token address (if specified, amount is parsed as decimal without denomination)") + cmd.Flags().Uint32("challenge-duration", 0, "Challenge duration for the channel") + AddFlags(cmd.Flags()) + flags.AddTxFlagsToCmd(cmd) + + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} + +func ClosePaymentChannelCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "close-payment-channel ", + Short: "Close a virtual payment channel", + Args: cobra.ExactArgs(1), + Long: "Close a virtual payment channel with the given channel ID.", + RunE: func(cmd *cobra.Command, args []string) error { + channelId, err := nitrotypes.ParseChannelID(args[0]) + if err != nil { + return fmt.Errorf("failed to parse channel ID: %w", err) + } + + clientCtx, s, done, err := setupNitroCommand(cmd) + if err != nil { + return err + } + defer done() + + m, err := s.ClosePaymentChannel(channelId) + if err != nil { + return err + } + + if err = waitForObjective( + s.node.FailedObjectives(), + m.Objective, + s.node.PaymentChannelUpdatedChan(channelId), + func(info query.PaymentChannelInfo) bool { return info.Status == query.Complete }, + ); err != nil { + return err + } + + return submitNitroTx(*clientCtx, cmd, *m, false) + }, + } + + AddFlags(cmd.Flags()) + flags.AddTxFlagsToCmd(cmd) + + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} + +func PayCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "pay ", + Short: "Send a payment through a payment channel", + Args: cobra.ExactArgs(2), + Long: "Creates and sends a payment voucher through the specified payment channel.", + RunE: func(cmd *cobra.Command, args []string) error { + channelId, err := nitrotypes.ParseChannelID(args[0]) + if err != nil { + return fmt.Errorf("failed to parse channel ID: %w", err) + } + + coins, err := sdk.ParseCoinsNormalized(args[1]) + if err != nil { + return fmt.Errorf("failed to parse amount: %w", err) + } + if len(coins) != 1 { + return fmt.Errorf("exactly one coin denomination required") + } + + clientCtx, s, done, err := setupNitroCommand(cmd) + if err != nil { + return err + } + defer done() + + info, err := s.node.GetPaymentChannel(channelId) + if err != nil { + return err + } + paidSoFar := info.Balance.PaidSoFar.ToInt() + expectedAmount := new(big.Int).Add(paidSoFar, coins[0].Amount.BigInt()) + updateChan := s.node.PaymentChannelUpdatedChan(channelId) + + m, err := s.Pay(channelId, coins[0]) + if err != nil { + return fmt.Errorf("failed to send payment: %w", err) + } + + // TODO: unordered tx for payments: this could break if tx is sent before opening the + // channel; think through wrt. state integration + if err = submitNitroTx(*clientCtx, cmd, *m, true); err != nil { + return err + } + + for info := range updateChan { + if expectedAmount.Cmp(info.Balance.PaidSoFar.ToInt()) <= 0 { + break + } + } + delayAfterUpdate() + return nil + }, + } + + AddFlags(cmd.Flags()) + flags.AddTxFlagsToCmd(cmd) + + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} + +func CreateVoucherCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-voucher ", + Short: "Create a payment voucher for a payment channel", + Args: cobra.ExactArgs(2), + Long: "Creates a signed payment voucher that can be used to redeem payments from the specified channel.", + RunE: func(cmd *cobra.Command, args []string) error { + channelId, err := nitrotypes.ParseChannelID(args[0]) + if err != nil { + return fmt.Errorf("failed to parse channel ID: %w", err) + } + + coins, err := sdk.ParseCoinsNormalized(args[1]) + if err != nil { + return fmt.Errorf("failed to parse amount: %w", err) + } + + if len(coins) != 1 { + return fmt.Errorf("exactly one coin denomination required") + } + amount := coins[0].Amount.BigInt() + + s, done, err := setupNitroQueryCommand(cmd, false) + if err != nil { + return err + } + defer done() + + voucher, err := s.node.CreateVoucher(channelId, amount) + if err != nil { + return fmt.Errorf("failed to create voucher: %w", err) + } + + output, err := json.MarshalIndent(voucher, "", " ") + if err != nil { + return fmt.Errorf("failed to marshal voucher: %w", err) + } + + fmt.Println(string(output)) + return nil + }, + } + + flags.AddQueryFlagsToCmd(cmd) + server.SetRequiredComponents(cmd, &Server{}, &relay.Server{}) + return cmd +} diff --git a/server/relay/config.go b/server/relay/config.go new file mode 100644 index 00000000..cc0899ca --- /dev/null +++ b/server/relay/config.go @@ -0,0 +1,23 @@ +package relay + +import ( + "fmt" + + "git.vdb.to/cerc-io/laconicd/server" +) + +type Config struct { + // Target string `mapstructure:"target" toml:"target" comment:"The target peer to relay messages to"` +} + +func DefaultConfig() *Config { + return &Config{} +} + +func UnmarshalConfig(cfg map[string]any) (*Config, error) { + config := DefaultConfig() + if err := server.UnmarshalSubConfig(cfg, serverName, config); err != nil { + return nil, fmt.Errorf("failed to unmarshal %T: %w", config, err) + } + return config, nil +} diff --git a/server/relay/server.go b/server/relay/server.go new file mode 100644 index 00000000..2dd4714e --- /dev/null +++ b/server/relay/server.go @@ -0,0 +1,199 @@ +package relay + +import ( + "context" + "errors" + "fmt" + "strings" + "sync/atomic" + + "cosmossdk.io/log" + cmtcfg "github.com/cometbft/cometbft/config" + "github.com/cometbft/cometbft/p2p" + "github.com/cometbft/cometbft/p2p/pex" + "github.com/cometbft/cometbft/version" + cmtversion "github.com/cometbft/cometbft/version" + + "git.vdb.to/cerc-io/laconicd/server" +) + +const ( + serverName = "relay" + + ServerContextKey = "server." + serverName +) + +// Server is a server component with CometBFT p2p capabilities +type Server struct { + logger log.Logger + config *Config + cometConfig *cmtcfg.Config + nodeKey *p2p.NodeKey + ready atomic.Bool +} + +type Switch struct { + *p2p.Switch + transport *p2p.MultiplexTransport +} + +func New(cfg server.ConfigMap, logger log.Logger) (*Server, error) { + c, err := UnmarshalConfig(cfg) + if err != nil { + return nil, err + } + cometConfig := cmtcfg.DefaultConfig() + if err := server.UnmarshalSubConfig(cfg, "", &cometConfig); err != nil { + return nil, err + } + return &Server{ + config: c, + cometConfig: cometConfig, + logger: logger.With(log.ModuleKey, serverName), + }, nil +} + +func (*Server) Name() string { + return serverName +} + +func (s *Server) Start(ctx context.Context) error { + var err error + s.nodeKey, err = p2p.LoadOrGenNodeKey(s.cometConfig.NodeKeyFile()) + if err != nil { + return err + } + + s.ready.Store(true) + return nil +} + +func (s *Server) Stop(ctx context.Context) error { + s.ready.Store(false) + return nil +} + +func (s *Server) Config() any { + if s.config == nil { + return DefaultConfig() + } + return s.config +} + +func (s *Server) Ready() bool { + return s.ready.Load() +} + +func (s *Server) ContextKey() string { + return ServerContextKey +} + +func (s *Server) GetSwitch(chainID string, blockVersion uint64) (*Switch, error) { + nodeInfo, err := makeNodeInfo(s.cometConfig, s.nodeKey, chainID, blockVersion) + if err != nil { + return nil, err + } + transport := createTransport(s.cometConfig, nodeInfo, s.nodeKey) + sw := p2p.NewSwitch(s.cometConfig.P2P, transport, p2p.SwitchPeerFilters()) + sw.SetNodeInfo(nodeInfo) + sw.SetNodeKey(s.nodeKey) + return &Switch{sw, transport}, nil +} + +func (s *Switch) AddReactor(name string, reactor p2p.Reactor) error { + s.Switch.AddReactor(name, reactor) + // register the new channels to the nodeInfo + ni, ok := s.NodeInfo().(p2p.DefaultNodeInfo) + if !ok { + return errors.New("Node info is not of type DefaultNodeInfo") + } + for _, chDesc := range reactor.GetChannels() { + if !ni.HasChannel(chDesc.ID) { + ni.Channels = append(ni.Channels, chDesc.ID) + s.transport.AddChannel(chDesc.ID) + } + } + s.SetNodeInfo(ni) + return nil +} + +func (s *Switch) Dial(peerAddr string) error { + addr, err := p2p.NewNetAddressString(peerAddr) + if err != nil { + return fmt.Errorf("error resolving net address: %w", err) + } + err = s.AddPersistentPeers([]string{addr.String()}) + if err != nil { + return fmt.Errorf("error adding persistent peer: %w", err) + } + return s.DialPeerWithAddress(addr) +} + +func makeNodeInfo( + config *cmtcfg.Config, + nodeKey *p2p.NodeKey, + chainID string, + blockVersion uint64, +) (p2p.DefaultNodeInfo, error) { + nodeInfo := p2p.DefaultNodeInfo{ + ProtocolVersion: p2p.NewProtocolVersion( + cmtversion.P2PProtocol, + blockVersion, + 0, + ), + DefaultNodeID: nodeKey.ID(), + Network: chainID, + Version: version.TMCoreSemVer, + Channels: nil, // updated in AddReactor + Moniker: config.Moniker, + Other: p2p.DefaultNodeInfoOther{ + RPCAddress: config.RPC.ListenAddress, + }, + } + + if config.P2P.PexReactor { + nodeInfo.Channels = append(nodeInfo.Channels, pex.PexChannel) + } + + lAddr := config.P2P.ExternalAddress + + if lAddr == "" { + lAddr = config.P2P.ListenAddress + } + + nodeInfo.ListenAddr = lAddr + + // err := nodeInfo.Validate() + return nodeInfo, nil +} + +func createTransport( + config *cmtcfg.Config, + nodeInfo p2p.NodeInfo, + nodeKey *p2p.NodeKey, +) *p2p.MultiplexTransport { + var ( + mConnConfig = p2p.MConnConfig(config.P2P) + transport = p2p.NewMultiplexTransport(nodeInfo, *nodeKey, mConnConfig) + connFilters = []p2p.ConnFilterFunc{} + ) + + if !config.P2P.AllowDuplicateIP { + connFilters = append(connFilters, p2p.ConnDuplicateIPFilter()) + } + + p2p.MultiplexTransportConnFilters(connFilters...)(transport) + + // Limit the number of incoming connections. + max := config.P2P.MaxNumInboundPeers + p2p.MultiplexTransportMaxIncomingConnections(max)(transport) + + return transport +} + +func removeProtocolIfDefined(addr string) string { + if strings.Contains(addr, "://") { + return strings.Split(addr, "://")[1] + } + return addr +} diff --git a/server/relay/util.go b/server/relay/util.go new file mode 100644 index 00000000..0570357e --- /dev/null +++ b/server/relay/util.go @@ -0,0 +1,20 @@ +package relay + +import ( + "runtime" + + "git.vdb.to/cerc-io/laconicd/utils" + "github.com/spf13/cobra" +) + +func GetServerFromCmd(cmd *cobra.Command) (*Server, error) { + s, err := utils.GetFromContext[Server](cmd.Context(), ServerContextKey) + if err != nil { + return nil, err + } + for !s.Ready() { + s.logger.Debug("waiting for relay server") + runtime.Gosched() + } + return s, nil +} diff --git a/server/server.go b/server/server.go new file mode 100644 index 00000000..4a8498f7 --- /dev/null +++ b/server/server.go @@ -0,0 +1,29 @@ +package server + +// The utilities in this file are copied from cosmos-sdk server/v2 + +import ( + "context" + + "github.com/spf13/pflag" +) + +// ServerComponent is a server component that can be started and stopped. +type ServerComponent interface { + // Name returns the name of the server component. + Name() string + + // Start starts the server component. + Start(context.Context) error + // Stop stops the server component. + // Once Stop has been called on a server component, it may not be reused. + Stop(context.Context) error +} + +// HasStartFlags is a server component that has start flags. +type HasStartFlags interface { + // StartCmdFlags returns server start flags. + // Those flags should be prefixed with the server name. + // They are then merged with the server config in one viper instance. + StartCmdFlags() *pflag.FlagSet +} diff --git a/tests/integration/auction/keeper/common_test.go b/tests/integration/auction/keeper/common_test.go index 5f2378bf..cd7dbae9 100644 --- a/tests/integration/auction/keeper/common_test.go +++ b/tests/integration/auction/keeper/common_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration" @@ -19,7 +18,7 @@ type KeeperTestSuite struct { func (kts *KeeperTestSuite) SetupTest() { err := kts.TestFixture.Setup() - assert.Nil(kts.T(), err) + kts.Require().NoError(err) qr := kts.App.QueryHelper() kts.queryClient = types.NewQueryClient(qr) diff --git a/tests/integration/auction/keeper/query_server_test.go b/tests/integration/auction/keeper/query_server_test.go index d6821943..ed59516a 100644 --- a/tests/integration/auction/keeper/query_server_test.go +++ b/tests/integration/auction/keeper/query_server_test.go @@ -30,7 +30,7 @@ func (kts *KeeperTestSuite) TestGrpcQueryParams() { for _, test := range testCases { kts.Run(fmt.Sprintf("Case %s", test.msg), func() { resp, err := kts.queryClient.Params(context.Background(), test.req) - kts.Require().Nil(err) + kts.Require().NoError(err) kts.Require().Equal(*(resp.Params), types.DefaultParams()) }) } @@ -59,14 +59,14 @@ func (kts *KeeperTestSuite) TestGrpcGetAuction() { var expectedAuction types.Auction if test.createAuction { auction, _, err := kts.createAuctionAndCommitBid(false) - kts.Require().Nil(err) + kts.Require().NoError(err) test.req.Id = auction.Id expectedAuction = *auction } resp, err := kts.queryClient.GetAuction(context.Background(), test.req) if test.createAuction { - kts.Require().Nil(err) + kts.Require().NoError(err) kts.Require().NotNil(resp.GetAuction()) kts.Require().EqualExportedValues(expectedAuction, *(resp.GetAuction())) } else { @@ -103,7 +103,7 @@ func (kts *KeeperTestSuite) TestGrpcGetAllAuctions() { kts.Run(fmt.Sprintf("Case %s", test.msg), func() { if test.createAuctions { _, _, err := kts.createAuctionAndCommitBid(false) - kts.Require().Nil(err) + kts.Require().NoError(err) } resp, _ := kts.queryClient.Auctions(context.Background(), test.req) @@ -153,7 +153,7 @@ func (kts *KeeperTestSuite) TestGrpcGetBids() { resp, err := kts.queryClient.GetBids(context.Background(), test.req) if test.createAuction { - kts.Require().Nil(err) + kts.Require().NoError(err) kts.Require().Equal(test.bidCount, len(resp.GetBids())) } else { kts.Require().NotNil(err) diff --git a/tests/integration/bond/keeper/common_test.go b/tests/integration/bond/keeper/common_test.go index b76e20a7..c6e14c62 100644 --- a/tests/integration/bond/keeper/common_test.go +++ b/tests/integration/bond/keeper/common_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration" @@ -19,7 +18,7 @@ type KeeperTestSuite struct { func (kts *KeeperTestSuite) SetupTest() { err := kts.TestFixture.Setup() - assert.Nil(kts.T(), err) + kts.Require().NoError(err) qr := kts.App.QueryHelper() kts.queryClient = types.NewQueryClient(qr) diff --git a/tests/integration/bond/keeper/query_server_test.go b/tests/integration/bond/keeper/query_server_test.go index aed846ba..e18be682 100644 --- a/tests/integration/bond/keeper/query_server_test.go +++ b/tests/integration/bond/keeper/query_server_test.go @@ -26,7 +26,7 @@ func (kts *KeeperTestSuite) TestGrpcQueryParams() { for _, test := range testCases { kts.Run(fmt.Sprintf("Case %s", test.msg), func() { resp, err := kts.queryClient.Params(context.Background(), test.req) - kts.Require().Nil(err) + kts.Require().NoError(err) kts.Require().Equal(*(resp.Params), types.DefaultParams()) }) } @@ -101,7 +101,7 @@ func (kts *KeeperTestSuite) TestGrpcQueryBondByBondId() { } resp, err := kts.queryClient.GetBondById(context.Background(), test.req) if !test.errResponse { - kts.Require().Nil(err) + kts.Require().NoError(err) kts.Require().NotNil(resp.GetBond()) kts.Require().Equal(test.req.Id, resp.GetBond().GetId()) } else { @@ -148,7 +148,7 @@ func (kts *KeeperTestSuite) TestGrpcGetBondsByOwner() { } resp, err := kts.queryClient.GetBondsByOwner(context.Background(), test.req) if !test.errResponse { - kts.Require().Nil(err) + kts.Require().NoError(err) kts.Require().NotNil(resp.GetBonds()) kts.Require().Equal(test.noOfBonds, len(resp.GetBonds())) } else { @@ -184,7 +184,7 @@ func (kts *KeeperTestSuite) TestGrpcGetModuleBalance() { } resp, err := kts.queryClient.GetBondModuleBalance(context.Background(), test.req) if !test.errResponse { - kts.Require().Nil(err) + kts.Require().NoError(err) kts.Require().NotNil(resp.GetBalance()) kts.Require().Equal(resp.GetBalance(), sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(10)))) } else { diff --git a/tests/integration/common.go b/tests/integration/common.go index 15aa3947..99553ba2 100644 --- a/tests/integration/common.go +++ b/tests/integration/common.go @@ -3,17 +3,20 @@ package integration_test import ( "context" + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + "cosmossdk.io/core/appconfig" "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" cmtprototypes "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/codec" - addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/auth" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" @@ -21,16 +24,22 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + auctionmodulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/auction/module/v1" + bondmodulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/bond/module/v1" + registrymodulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/registry/module/v1" "git.vdb.to/cerc-io/laconicd/app/params" - auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction" + "git.vdb.to/cerc-io/laconicd/server" + "git.vdb.to/cerc-io/laconicd/utils" + auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper" auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module" - bondTypes "git.vdb.to/cerc-io/laconicd/x/bond" + bondtypes "git.vdb.to/cerc-io/laconicd/x/bond" bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper" bondmodule "git.vdb.to/cerc-io/laconicd/x/bond/module" - registryTypes "git.vdb.to/cerc-io/laconicd/x/registry" + registrytypes "git.vdb.to/cerc-io/laconicd/x/registry" registrykeeper "git.vdb.to/cerc-io/laconicd/x/registry/keeper" registrymodule "git.vdb.to/cerc-io/laconicd/x/registry/module" ) @@ -51,108 +60,136 @@ type TestFixture struct { } func (tf *TestFixture) Setup() error { - keys := storetypes.NewKVStoreKeys( - authtypes.StoreKey, banktypes.StoreKey, auctionTypes.StoreKey, bondTypes.StoreKey, registryTypes.StoreKey, + logger := log.NewNopLogger() + authority := authtypes.NewModuleAddress(govtypes.ModuleName) + + moduleAccPerms := []*authmodulev1.ModuleAccountPermission{ + {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, + {Account: auctiontypes.ModuleName}, + {Account: auctiontypes.AuctionBurnModuleAccountName}, + {Account: bondtypes.ModuleName}, + {Account: registrytypes.ModuleName}, + {Account: registrytypes.RecordRentModuleAccountName}, + {Account: registrytypes.AuthorityRentModuleAccountName}, + } + + moduleConfigs := []*appv1alpha1.ModuleConfig{ + { + Name: runtime.ModuleName, + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "TestApp", + BeginBlockers: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + auctiontypes.ModuleName, + bondtypes.ModuleName, + registrytypes.ModuleName, + }, + EndBlockers: []string{ + auctiontypes.ModuleName, + bondtypes.ModuleName, + registrytypes.ModuleName, + banktypes.ModuleName, + authtypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + auctiontypes.ModuleName, + bondtypes.ModuleName, + registrytypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: params.Bech32PrefixAccAddr, + ModuleAccountPermissions: moduleAccPerms, + EnableUnorderedTransactions: true, + }), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: auctiontypes.ModuleName, + Config: appconfig.WrapAny(&auctionmodulev1.Module{}), + }, + { + Name: bondtypes.ModuleName, + Config: appconfig.WrapAny(&bondmodulev1.Module{}), + }, + { + Name: registrytypes.ModuleName, + Config: appconfig.WrapAny(®istrymodulev1.Module{}), + }, + } + + storeKeys := StoreKeyExtractor{} + appConfig := depinject.Configs( + appconfig.Compose(&appv1alpha1.Config{ + Modules: moduleConfigs, + }), + depinject.Supply( + logger, + authority, + utils.NewAddressCodec(), + ), + depinject.Provide( + server.NewGasService, + ), + storeKeys.config(), ) - cdc := moduletestutil.MakeTestEncodingConfig( - auth.AppModuleBasic{}, - auctionmodule.AppModule{}, - bondmodule.AppModule{}, - registrymodule.AppModule{}, - ).Codec - - logger := log.NewNopLogger() // Use log.NewTestLogger(kts.T()) for help with debugging - cms := integration.CreateMultiStore(keys, logger) + var ( + appBuilder *runtime.AppBuilder + cdc codec.Codec + accountKeeper authkeeper.AccountKeeper + bankKeeper bankkeeper.Keeper + auctionKeeper *auctionkeeper.Keeper + bondKeeper *bondkeeper.Keeper + registryKeeper registrykeeper.Keeper + ) + if err := depinject.Inject( + appConfig, + &appBuilder, + &cdc, + &accountKeeper, + &bankKeeper, + &auctionKeeper, + &bondKeeper, + ®istryKeeper, + ); err != nil { + return err + } + cms := integration.CreateMultiStore(storeKeys, logger) newCtx := sdk.NewContext(cms, cmtprototypes.Header{}, true, logger) - authority := authtypes.NewModuleAddress("gov") - - maccPerms := map[string][]string{ - minttypes.ModuleName: {authtypes.Minter}, - auctionTypes.ModuleName: {}, - auctionTypes.AuctionBurnModuleAccountName: {}, - bondTypes.ModuleName: {}, - registryTypes.ModuleName: {}, - registryTypes.RecordRentModuleAccountName: {}, - registryTypes.AuthorityRentModuleAccountName: {}, + modules := map[string]appmodule.AppModule{ + authtypes.ModuleName: auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil), + banktypes.ModuleName: bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil), + auctiontypes.ModuleName: auctionmodule.NewAppModule(cdc, auctionKeeper), + bondtypes.ModuleName: bondmodule.NewAppModule(cdc, bondKeeper), + registrytypes.ModuleName: registrymodule.NewAppModule(cdc, registryKeeper), } - accountKeeper := authkeeper.NewAccountKeeper( - cdc, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), - authtypes.ProtoBaseAccount, - maccPerms, - addresscodec.NewBech32Codec(params.Bech32PrefixAccAddr), - params.Bech32PrefixAccAddr, - authority.String(), - ) - - blockedAddresses := map[string]bool{ - accountKeeper.GetAuthority(): false, - } - bankKeeper := bankkeeper.NewBaseKeeper( - cdc, - runtime.NewKVStoreService(keys[banktypes.StoreKey]), - accountKeeper, - blockedAddresses, - authority.String(), - log.NewNopLogger(), - ) - - auctionKeeper := auctionkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[auctionTypes.StoreKey]), accountKeeper, bankKeeper, authority.String()) - - bondKeeper := bondkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[bondTypes.StoreKey]), accountKeeper, bankKeeper, authority.String()) - - registryKeeper := registrykeeper.NewKeeper( - cdc, - runtime.NewKVStoreService(keys[registryTypes.StoreKey]), - accountKeeper, - bankKeeper, - bondKeeper, - auctionKeeper, - authority.String(), - ) - - authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil) - bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil) - auctionModule := auctionmodule.NewAppModule(cdc, auctionKeeper) - bondModule := bondmodule.NewAppModule(cdc, bondKeeper) - registryModule := registrymodule.NewAppModule(cdc, registryKeeper) - - integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ - authtypes.ModuleName: authModule, - banktypes.ModuleName: bankModule, - auctionTypes.ModuleName: auctionModule, - bondTypes.ModuleName: bondModule, - registryTypes.ModuleName: registryModule, - }) - + integrationApp := integration.NewIntegrationApp(newCtx, logger, storeKeys, cdc, modules) sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context()) - // Register MsgServer and QueryServer - auctionTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), auctionkeeper.NewMsgServerImpl(auctionKeeper)) - auctionTypes.RegisterQueryServer(integrationApp.QueryHelper(), auctionkeeper.NewQueryServerImpl(auctionKeeper)) + auctiontypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), auctionkeeper.NewMsgServerImpl(auctionKeeper)) + auctiontypes.RegisterQueryServer(integrationApp.QueryHelper(), auctionkeeper.NewQueryServerImpl(auctionKeeper)) + bondtypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), bondkeeper.NewMsgServerImpl(bondKeeper)) + bondtypes.RegisterQueryServer(integrationApp.QueryHelper(), bondkeeper.NewQueryServerImpl(bondKeeper)) + registrytypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), registrykeeper.NewMsgServerImpl(registryKeeper)) + registrytypes.RegisterQueryServer(integrationApp.QueryHelper(), registrykeeper.NewQueryServerImpl(registryKeeper)) - bondTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), bondkeeper.NewMsgServerImpl(bondKeeper)) - bondTypes.RegisterQueryServer(integrationApp.QueryHelper(), bondkeeper.NewQueryServerImpl(bondKeeper)) + auctionKeeper.Params.Set(sdkCtx, auctiontypes.DefaultParams()) + bondKeeper.Params.Set(sdkCtx, bondtypes.DefaultParams()) + registryKeeper.Params.Set(sdkCtx, registrytypes.DefaultParams()) - registryTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), registrykeeper.NewMsgServerImpl(registryKeeper)) - registryTypes.RegisterQueryServer(integrationApp.QueryHelper(), registrykeeper.NewQueryServerImpl(registryKeeper)) - - // set default params - if err := auctionKeeper.Params.Set(sdkCtx, auctionTypes.DefaultParams()); err != nil { - return err - } - if err := bondKeeper.Params.Set(sdkCtx, bondTypes.DefaultParams()); err != nil { - return err - } - if err := registryKeeper.Params.Set(sdkCtx, registryTypes.DefaultParams()); err != nil { - return err - } - - tf.App = integrationApp - tf.SdkCtx, tf.cdc, tf.keys = sdkCtx, cdc, keys + tf.App, tf.SdkCtx, tf.cdc, tf.keys = integrationApp, sdkCtx, cdc, storeKeys tf.AccountKeeper, tf.BankKeeper = accountKeeper, bankKeeper tf.AuctionKeeper, tf.BondKeeper, tf.RegistryKeeper = auctionKeeper, bondKeeper, registryKeeper @@ -164,3 +201,20 @@ type BondDenomProvider struct{} func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) { return params.CoinUnit, nil } + +type StoreKeyExtractor map[string]*storetypes.KVStoreKey + +func (ske *StoreKeyExtractor) ExtractKey(mkey depinject.ModuleKey, storeKey *storetypes.KVStoreKey) { + (*ske)[mkey.Name()] = storeKey +} + +func (ske *StoreKeyExtractor) config() depinject.Config { + return depinject.Configs( + depinject.Supply(ske), + depinject.InvokeInModule(banktypes.ModuleName, (*StoreKeyExtractor).ExtractKey), + depinject.InvokeInModule(authtypes.ModuleName, (*StoreKeyExtractor).ExtractKey), + depinject.InvokeInModule(bondtypes.ModuleName, (*StoreKeyExtractor).ExtractKey), + depinject.InvokeInModule(auctiontypes.ModuleName, (*StoreKeyExtractor).ExtractKey), + depinject.InvokeInModule(registrytypes.ModuleName, (*StoreKeyExtractor).ExtractKey), + ) +} diff --git a/tests/integration/registry/keeper/common_test.go b/tests/integration/registry/keeper/common_test.go index 1c171dc7..b4ce8432 100644 --- a/tests/integration/registry/keeper/common_test.go +++ b/tests/integration/registry/keeper/common_test.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/math" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "git.vdb.to/cerc-io/laconicd/app/params" @@ -27,18 +26,18 @@ type KeeperTestSuite struct { func (kts *KeeperTestSuite) SetupTest() { err := kts.TestFixture.Setup() - assert.Nil(kts.T(), err) + kts.Require().NoError(err) // set default params err = kts.RegistryKeeper.Params.Set(kts.SdkCtx, types.DefaultParams()) - assert.Nil(kts.T(), err) + kts.Require().NoError(err) qr := kts.App.QueryHelper() kts.queryClient = types.NewQueryClient(qr) // Create a bond bond, err := kts.createBond() - assert.Nil(kts.T(), err) + kts.Require().NoError(err) kts.bond = *bond } diff --git a/tests/system/auction_grpc_test.go b/tests/system/auction_grpc_test.go new file mode 100644 index 00000000..9caaa4a5 --- /dev/null +++ b/tests/system/auction_grpc_test.go @@ -0,0 +1,260 @@ +package system + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/testutil" + "github.com/tidwall/gjson" + + "git.vdb.to/cerc-io/laconicd/x/auction" +) + +const ( + randomAuctionId = "randomAuctionId" + randomBidderAddress = "randomBidderAddress" + randomOwnerAddress = "randomOwnerAddress" +) + +func (s *auctionSuite) TestGRPCQueryParams() { + reqURL := s.endpointURL("auction/v1/params") + + s.Run("valid request to get auction params", func() { + require := s.Require() + + resp, err := testutil.GetRequest(reqURL) + require.NoError(err) + + var params auction.QueryParamsResponse + require.NoError(s.codec.UnmarshalJSON(resp, ¶ms), string(resp)) + require.Equal(auction.DefaultParams(), *params.GetParams()) + }) +} + +func (s *auctionSuite) TestGRPCGetAllAuctions() { + reqURL := s.endpointURL("auction/v1/auctions") + + s.createAuction() + + testCases := []struct { + name string + url string + errmsg string + }{ + { + "invalid request", + reqURL + "-asdasd", + "Not Implemented", + }, + { + "valid request", + reqURL, + "", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var auctions auction.QueryAuctionsResponse + require.NoError(s.codec.UnmarshalJSON(resp, &auctions), string(resp)) + require.NotEmpty(auctions.Auctions.Auctions) + } + }) + } +} + +func (s *auctionSuite) TestGRPCGetAuction() { + reqURL := s.endpointURL("auction/v1/auctions/%s") + + auctionId := s.createAuction() + s.createBid(auctionId) + + testCases := []struct { + name string + url string + exists bool + }{ + { + "nonexistent auction", + fmt.Sprintf(reqURL, randomAuctionId), + false, + }, + { + "valid request", + fmt.Sprintf(reqURL, auctionId), + true, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + if tc.exists { + var auction auction.QueryGetAuctionResponse + require.NoError(s.codec.UnmarshalJSON(resp, &auction), string(resp)) + require.Equal(auctionId, auction.Auction.Id) + } else { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, "not found", tc.url) + } + }) + } +} + +func (s *auctionSuite) TestGRPCGetBids() { + reqURL := s.endpointURL("auction/v1/bids/%s") + + auctionId := s.createAuction() + s.createBid(auctionId) + + testCases := []struct { + name string + url string + exists bool + }{ + { + "nonexistent auction", + fmt.Sprintf(reqURL, randomAuctionId), + false, + }, + { + "valid request", + fmt.Sprintf(reqURL, auctionId), + true, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + var bids auction.QueryGetBidsResponse + require.NoError(s.codec.UnmarshalJSON(resp, &bids), string(resp)) + if tc.exists { + require.Equal(auctionId, bids.Bids[0].AuctionId) + } else { + require.Empty(bids.Bids) + } + }) + } +} + +func (s *auctionSuite) TestGRPCGetBid() { + reqURL := s.endpointURL("auction/v1/bids/%s/%s") + bidderAddress := s.cli().GetKeyAddr(s.bidderAccount) + + auctionId := s.createAuction() + s.createBid(auctionId) + + testCases := []struct { + name string + url string + exists bool + }{ + { + "nonexistent auction", + fmt.Sprintf(reqURL, randomAuctionId, bidderAddress), + false, + }, + { + "nonexistent bidder", + fmt.Sprintf(reqURL, auctionId, randomBidderAddress), + false, + }, + { + "valid request", + fmt.Sprintf(reqURL, auctionId, bidderAddress), + true, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + if tc.exists { + var bid auction.QueryGetBidResponse + require.NoError(s.codec.UnmarshalJSON(resp, &bid), string(resp)) + require.Equal(auctionId, bid.Bid.AuctionId) + } else { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, "not found", tc.url) + } + }) + } +} + +func (s *auctionSuite) TestGRPCGetAuctionsByOwner() { + reqURL := s.endpointURL("auction/v1/by-owner/%s") + ownerAddress := s.cli().GetKeyAddr(s.ownerAccount) + + auctionId := s.createAuction() + s.createBid(auctionId) + + testCases := []struct { + name string + url string + exists bool + }{ + { + "nonexistent owner", + fmt.Sprintf(reqURL, randomOwnerAddress), + false, + }, + { + "valid request", + fmt.Sprintf(reqURL, ownerAddress), + true, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + var auctions auction.QueryAuctionsResponse + require.NoError(s.codec.UnmarshalJSON(resp, &auctions), string(resp)) + if tc.exists { + require.Equal(auctionId, auctions.Auctions.Auctions[0].Id) + } else { + require.Empty(auctions.Auctions.Auctions) + } + }) + } +} + +func (s *auctionSuite) TestGRPCQueryBalance() { + reqURL := s.endpointURL("auction/v1/balance") + + s.Run("valid request", func() { + require := s.Require() + + auctionId := s.createAuction() + s.createBid(auctionId) + + resp, err := testutil.GetRequest(reqURL) + require.NoError(err) + + var response auction.QueryGetAuctionModuleBalanceResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + require.NotEmpty(response.GetBalance()) + }) +} diff --git a/tests/system/auction_test.go b/tests/system/auction_test.go new file mode 100644 index 00000000..7a9a8572 --- /dev/null +++ b/tests/system/auction_test.go @@ -0,0 +1,161 @@ +package system + +import ( + "fmt" + "os" + "path/filepath" + "testing" + + "git.vdb.to/cerc-io/laconicd/x/auction" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/stretchr/testify/suite" +) + +const ( + sampleCommitTime = "90s" + sampleRevealTime = "5s" + placeholderAuctionId = "placeholder_auction_id" +) + +type auctionSuite struct { + testSuite + + ownerAccount string + bidderAccount string + defaultAuctionId string +} + +func TestAuction(t *testing.T) { + suite.Run(t, new(auctionSuite)) +} + +func (s *auctionSuite) SetupTest() { + s.resetChain() + + s.ownerAccount = s.account(0) + s.bidderAccount = s.account(1) + + Sut.StartChain(s.T()) +} + +func (s *auctionSuite) TearDownTest() { + s.cleanupBidFiles() +} + +func (s *auctionSuite) TestQueryList() { + sr := s.Require() + + testCases := []struct { + name string + createAuction bool + }{ + { + "when no auctions exist", + false, + }, + { + "after creating an auction", + true, + }, + } + + for _, test := range testCases { + s.Run(test.name, func() { + if test.createAuction { + s.createAuction() + } + + out := s.cli().CustomQuery("q", "auction", "list") + var response auction.QueryAuctionsResponse + sr.NoError(s.codec.UnmarshalJSON([]byte(out), &response), out) + if test.createAuction { + sr.NotEmpty(response.Auctions.Auctions) + } + }) + } +} + +func (s *auctionSuite) TestTxCommitBid() { + auctionId := s.createAuction() + testCases := []struct { + name string + args []string + err bool + }{ + { + "with missing args", + []string{auctionId}, + true, + }, + { + "with zero bid", + []string{auctionId, ("0" + s.bondDenom)}, + true, + }, + { + "with invalid auction", + []string{"fake", ("200" + s.bondDenom)}, + true, + }, + { + "with valid args", + []string{auctionId, ("200" + s.bondDenom)}, + false, + }, + } + + for _, test := range testCases { + s.Run(test.name, func() { + cmd := []string{ + "tx", "auction", "commit-bid", + } + cmd = append(cmd, test.args...) + s.runTx(cmd, test.err) + }) + } +} + +func (s *auctionSuite) createAuction() string { + require := s.Require() + + cmd := []string{ + "tx", "auction", "create", + sampleCommitTime, + sampleRevealTime, + fmt.Sprintf("10%s", s.bondDenom), + fmt.Sprintf("10%s", s.bondDenom), + "--kind", auction.AuctionKindVickrey, + "--minimum-bid", fmt.Sprintf("100%s", s.bondDenom), + "--max-price", fmt.Sprintf("0%s", s.bondDenom), + "--num-providers", "0", + } + s.runTx(cmd, false) + + out := s.cli().CustomQuery("q", "auction", "list") + var response auction.QueryAuctionsResponse + require.NoError(s.codec.UnmarshalJSON([]byte(out), &response), out) + return response.Auctions.Auctions[0].Id +} + +func (s *auctionSuite) createBid(auctionId string) { + cmd := []string{ + "tx", "auction", "commit-bid", + auctionId, fmt.Sprintf("200%s", s.bondDenom), + fmt.Sprintf("--%s=%s", flags.FlagFrom, s.bidderAccount), + } + s.runTx(cmd, false) +} + +func (s *auctionSuite) cleanupBidFiles() { + matches, err := filepath.Glob(fmt.Sprintf("%s-*.json", s.bidderAccount)) + if err != nil { + s.T().Errorf("Error matching bidder files: %v\n", err) + } + + for _, match := range matches { + err := os.Remove(match) + if err != nil { + s.T().Errorf("Error removing bidder file: %v\n", err) + } + } +} diff --git a/tests/system/bond_grpc_test.go b/tests/system/bond_grpc_test.go new file mode 100644 index 00000000..16b5a511 --- /dev/null +++ b/tests/system/bond_grpc_test.go @@ -0,0 +1,168 @@ +package system + +import ( + "fmt" + + "github.com/stretchr/testify/require" + "github.com/tidwall/gjson" + + "github.com/cosmos/cosmos-sdk/testutil" + + "git.vdb.to/cerc-io/laconicd/x/bond" +) + +func (s *bondSuite) TestGRPCGetParams() { + reqURL := s.endpointURL("bond/v1/params") + + var params bond.QueryParamsResponse + resp, err := testutil.GetRequest(reqURL) + require.NoError(s.T(), err) + require.NoError(s.T(), s.codec.UnmarshalJSON(resp, ¶ms)) + + require.Equal(s.T(), bond.DefaultParams().MaxBondAmount, params.GetParams().MaxBondAmount) +} + +func (s *bondSuite) TestGRPCGetBond() { + reqURL := s.endpointURL("bond/v1/bonds") + + testcases := []struct { + name string + url string + errmsg string + prerun func() + }{ + { + "invalid request with headers", + reqURL + "asdasdas", + "Not Implemented", + func() {}, + }, + { + "valid request", + reqURL, + "", + func() { s.createBond() }, + }, + } + + for _, tc := range testcases { + s.Run(tc.name, func() { + require := s.Require() + tc.prerun() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, string(resp)) + } else { + var bonds bond.QueryBondsResponse + require.NoError(s.codec.UnmarshalJSON(resp, &bonds), string(resp)) + require.NotEmpty(bonds.GetBonds()) + } + }) + } +} + +func (s *bondSuite) TestGRPCGetBondsByOwner() { + reqURL := s.endpointURL("bond/v1/by-owner/%s") + accountAddress := s.cli().GetKeyAddr(s.account(0)) + + testcases := []struct { + name string + url string + err bool + prerun func() + }{ + { + "empty list", + fmt.Sprintf(reqURL, "asdasd"), + true, + func() {}, + }, + { + "valid request", + fmt.Sprintf(reqURL, accountAddress), + false, + func() { s.createBond() }, + }, + } + + for _, tc := range testcases { + s.Run(tc.name, func() { + require := s.Require() + tc.prerun() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + var bonds bond.QueryGetBondsByOwnerResponse + require.NoError(s.codec.UnmarshalJSON(resp, &bonds)) + if tc.err { + require.Empty(bonds.GetBonds()) + } else { + bondsList := bonds.GetBonds() + require.NotEmpty(bondsList) + require.Equal(accountAddress, bondsList[0].GetOwner()) + } + }) + } +} + +func (s *bondSuite) TestGRPCGetBondById() { + reqURL := s.endpointURL("bond/v1/bonds/%s") + + testcases := []struct { + name string + url string + err bool + prerun func() string + }{ + { + "invalid request", + reqURL, + true, + func() string { return "asdadad" }, + }, + { + "valid request", + reqURL, + false, + func() string { return s.createBond() }, + }, + } + + for _, tc := range testcases { + s.Run(tc.name, func() { + require := s.Require() + + bondId := tc.prerun() + tc.url = fmt.Sprintf(reqURL, bondId) + + var bond bond.QueryGetBondByIdResponse + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + if tc.err { + require.Error(s.codec.UnmarshalJSON(resp, &bond)) + } else { + require.NoError(s.codec.UnmarshalJSON(resp, &bond)) + require.Equal(bondId, bond.GetBond().GetId()) + } + }) + } +} + +func (s *bondSuite) TestGRPCGetBondModuleBalance() { + reqURL := s.endpointURL("bond/v1/balance") + + s.createBond() + + require := s.Require() + + resp, err := testutil.GetRequest(reqURL) + require.NoError(err) + + var response bond.QueryGetBondModuleBalanceResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response)) + require.False(response.GetBalance().IsZero()) +} diff --git a/tests/system/bond_test.go b/tests/system/bond_test.go new file mode 100644 index 00000000..63effcdd --- /dev/null +++ b/tests/system/bond_test.go @@ -0,0 +1,97 @@ +package system + +import ( + "encoding/json" + "fmt" + "testing" + + "git.vdb.to/cerc-io/laconicd/x/bond" + "github.com/stretchr/testify/suite" + "github.com/tidwall/gjson" +) + +type bondSuite struct { + testSuite +} + +func TestBonds(t *testing.T) { + suite.Run(t, new(bondSuite)) +} + +func (s *bondSuite) SetupTest() { + s.resetChain() + Sut.StartChain(s.T()) +} + +func (s *bondSuite) TestQueryList() { + testCases := []struct { + name string + args []string + prerun func() + }{ + { + "create and get bond lists", + nil, + func() { s.createBond() }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + tc.prerun() + out := s.cli().CustomQuery("q", "bond", "list") + s.Require().NotEmpty(gjson.Get(out, "bonds").Array(), out) + }) + } +} + +func (s *bondSuite) TestTxCreateBond() { + testCases := []struct { + name string + args []string + err bool + }{ + { + "without deposit", + []string{}, + true, + }, + { + "create bond", + []string{ + fmt.Sprintf("10%s", s.bondDenom), + }, + false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := append([]string{"tx", "bond", "create"}, tc.args...) + s.runTx(cmd, tc.err) + }) + } +} + +func (s *bondSuite) createBond() string { + return createBond(&s.testSuite) +} + +// free function for use in other suites +func createBond(s *testSuite) string { + require := s.Require() + + cli := s.cli() + cmd := []string{ + "tx", "bond", "create", ("1000000" + s.bondDenom), + } + s.runTx(cmd, false) + + raw := cli.CustomQuery("q", "bond", "list") + var queryResponse bond.QueryBondsResponse + require.NoError(json.Unmarshal([]byte(raw), &queryResponse)) + bonds := queryResponse.GetBonds() + require.NotEmpty(bonds) + + return bonds[0].GetId() +} diff --git a/tests/system/main_test.go b/tests/system/main_test.go new file mode 100644 index 00000000..f52324f0 --- /dev/null +++ b/tests/system/main_test.go @@ -0,0 +1,55 @@ +package system + +import ( + "flag" + "os" + "testing" + "time" + + "cosmossdk.io/systemtests" +) + +var ( + Sut *systemtests.SystemUnderTest + + verbose bool + nodesCount = flag.Int("nodes", 4, "number of nodes in the cluster") + blockTime = 3 * time.Second // expected time between blocks + // txTimeout = 10 * time.Second // timeout for transactions to be included in a block + txTimeout = 10 * time.Minute // timeout for transactions to be included in a block + + workDir string +) + +func TestMain(m *testing.M) { + // sdk systemtests expects this to be set for v2 server/runtime + os.Setenv("COSMOS_BUILD_OPTIONS", "v2") + + flag.BoolVar(&verbose, "verbose", false, "verbose output") + flag.Parse() + + dir, err := os.Getwd() + if err != nil { + panic(err) + } + workDir = dir + if verbose { + println("Work dir: ", workDir) + } + + Sut = systemtests.NewSystemUnderTest("laconicd", verbose, *nodesCount, blockTime) + // Sut.SetTestnetInitializer(initer) + + Sut.SetupChain() // setup chain and keyring + + // run tests + exitCode := m.Run() + + // postprocess + Sut.StopChain() + if verbose || exitCode != 0 { + Sut.PrintBuffer() + } + + os.Exit(exitCode) +} diff --git a/tests/system/nitro_test.go b/tests/system/nitro_test.go new file mode 100644 index 00000000..46eb1f51 --- /dev/null +++ b/tests/system/nitro_test.go @@ -0,0 +1,452 @@ +package system + +import ( + "encoding/json" + "math/big" + "os" + "os/signal" + "syscall" + "testing" + + nitrocrypto "github.com/statechannels/go-nitro/crypto" + chainutils "github.com/statechannels/go-nitro/node/chain" + "github.com/statechannels/go-nitro/node/query" + "github.com/statechannels/go-nitro/node_test" + nitrotypes "github.com/statechannels/go-nitro/types" + "github.com/stretchr/testify/suite" + "github.com/tidwall/gjson" + + systest "cosmossdk.io/systemtests" +) + +var ( + ethChainPort = "8546" + ethChainUrl = "ws://127.0.0.1:8546" +) + +type nitroSuite struct { + testSuite + + tokenDenom string + ethChainOpts *node_test.LocalChainOptions + + alice, bob nitrocrypto.Credential + intermediaries []nitrocrypto.Credential +} + +func TestNitro(t *testing.T) { + suite.Run(t, new(nitroSuite)) +} + +func (s *nitroSuite) SetupSuite() { + s.testSuite.SetupSuite() + + s.tokenDenom = "eth" + + // Set up Ethereum test chain + // TODO: use anvil for better self-containment + ethChainOpts := node_test.ExternalHardhatChainOptions(s.T()) + ethChainOpts.ChainUrl = ethChainUrl + aliceKey := ethChainOpts.ChainPks[0] + bobKey := ethChainOpts.ChainPks[1] + s.ethChainOpts = ethChainOpts + + ethChain, err := node_test.ConnectLocalChain(ethChainOpts, nitrotypes.BytesFromHex(aliceKey)) + s.Require().NoError(err) + s.T().Cleanup(func() { s.NoError(ethChain.Close()) }) + + s.alice = nitrocrypto.NewSimpleCredential(nitrotypes.BytesFromHex(aliceKey)) + s.bob = nitrocrypto.NewSimpleCredential(nitrotypes.BytesFromHex(bobKey)) + for _, pk := range ethChainOpts.ChainPks { + creds := nitrocrypto.NewSimpleCredential(nitrotypes.BytesFromHex(pk)) + s.intermediaries = append(s.intermediaries, creds) + } + + s.configureEthChain() + // TODO when using intermediaries, set more validator node pks here + s.setValidatorNitroKeys(s.ethChainOpts.ChainPks[1]) +} + +func (s *nitroSuite) SetupTest() { + s.resetChain() + + s.setClientKeys(s.ethChainOpts.ChainPks[0]) + + Sut.StartChain(s.T()) +} + +func (s *nitroSuite) SetupSubTest() { s.SetupTest() } + +func (s *nitroSuite) configureEthChain() { + cas, err := chainutils.LoadEnvContractAddresses() + s.Require().NoError(err) + + cmds := [][]string{ + {"config", "set", "app", "nitro.eth-na-address", "'" + cas.NaAddress.String() + "'"}, + {"config", "set", "app", "nitro.eth-vpa-address", "'" + cas.VpaAddress.String() + "'"}, + {"config", "set", "app", "nitro.eth-ca-address", "'" + cas.CaAddress.String() + "'"}, + {"config", "set", "app", "nitro.eth-url", ethChainUrl}, + } + _ = Sut.ForEachNodeExecAndWait(s.T(), cmds...) + for _, cmd := range cmds { + cmd = append(cmd, "--home", s.clientHome()) + _ = systest.MustRunShellCmd(s.T(), Sut.ExecBinary(), cmd...) + } +} + +func (s *nitroSuite) TestTxOpenChannel() { + testCases := []struct { + name string + args []string + err bool + }{ + { + "missing args", + []string{}, + true, + }, + { + "missing amount", + []string{s.bob.AsParticipant().String()}, + true, + }, + { + "valid request", + []string{s.bob.AsParticipant().String(), "10" + s.tokenDenom}, + false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := append([]string{"tx", "nitro", "open-channel"}, tc.args...) + s.runTx(cmd, tc.err) + }) + } +} + +func (s *nitroSuite) TestTxCloseChannel() { + testCases := []struct { + name string + args []string + err bool + setup func() []string + }{ + { + "missing args", + []string{}, + true, + nil, + }, + { + "invalid channel", + []string{"invalid-channel-id"}, + true, + nil, + }, + { + "valid channel", + nil, + false, + func() []string { return s.setupLedgerChannel("10") }, + }, + // { + // "valid channel with challenge", + // []string{"--challenge"}, + // false, + // func() []string { return s.setupLedgerChannel("10") }, + // }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := []string{"tx", "nitro", "close-channel"} + if tc.setup != nil { + cmd = append(cmd, tc.setup()...) + } + cmd = append(cmd, tc.args...) + s.runTx(cmd, tc.err) + }) + } +} + +func (s *nitroSuite) TestTxOpenPaymentChannel() { + + testCases := []struct { + name string + args []string + err bool + setup func() []string + }{ + { + "missing args", + []string{}, + true, + nil, + }, + { + "missing amount", + []string{s.bob.AsParticipant().String()}, + true, + nil, + }, + { + "zero hops", + []string{s.bob.AsParticipant().String(), "10" + s.tokenDenom}, + false, + func() []string { s.setupLedgerChannel("20"); return nil }, + }, + // { // TODO open n-hop ledger channels + // "one hop", + // []string{"10" + s.tokenDenom, s.bob.AsParticipant().String(), s.intermediaries[0].String()}, + // false, + // setupLedgerChannelForPaymentChannel, + // }, + // { // TODO use a different counterparty, cannot have duplicate channels + // "direct channel with challenge duration", + // []string{"10" + s.tokenDenom, s.bob.AsParticipant().String(), "--challenge-duration", "100"}, + // false, + // setupLedgerChannelForPaymentChannel, + // }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := []string{"tx", "nitro", "open-payment-channel"} + if tc.setup != nil { + tc.setup() + } + cmd = append(cmd, tc.args...) + s.runTx(cmd, tc.err) + }) + } +} + +func (s *nitroSuite) TestTxClosePaymentChannel() { + + testCases := []struct { + name string + args []string + err bool + setup func() []string + }{ + { + "missing args", + []string{}, + true, + nil, + }, + // { // TODO use different counterparty + // "invalid channel ID", + // []string{"invalid-channel-id"}, + // true, + // setupLedgerChannel, + // }, + { + "zero hops", + nil, + false, + func() []string { + s.setupLedgerChannel("20") + return s.setupPaymentChannel("10") + }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := []string{"tx", "nitro", "close-payment-channel"} + if tc.setup != nil { + cmd = append(cmd, tc.setup()...) + } + cmd = append(cmd, tc.args...) + s.runTx(cmd, tc.err) + }) + } +} + +func (s *nitroSuite) TestTxPay() { + + testCases := []struct { + name string + args []string + error bool + setup func() []string + paid *big.Int + }{ + { + name: "missing args", + error: true, + }, + { + name: "invalid channel ID", + args: []string{"invalid-channel-id", "10" + s.tokenDenom}, + error: true, + }, + { + name: "invalid amount format", + args: []string{"0x0102030000000000000000000000000000000000000000000000000000000000", "invalid-amount"}, + error: true, + }, + { + name: "nonexistent channel", + args: []string{"0x0102030000000000000000000000000000000000000000000000000000000000", "5" + s.tokenDenom}, + error: true, + }, + { + name: "valid payment", + args: []string{"10" + s.tokenDenom}, + setup: func() []string { + s.setupLedgerChannel("100") + return s.setupPaymentChannel("50") + }, + paid: big.NewInt(10), + }, + // { + // "insufficient funds", + // []string{"10" + s.tokenDenom}, + // false, + // func() []string { + // s.setupLedgerChannel("100") + // return s.setupPaymentChannel("50") + // }, + // }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + var channelId string + + cmd := []string{"tx", "nitro", "pay"} + if tc.setup != nil { + setupArgs := tc.setup() + cmd = append(cmd, setupArgs...) + + if !tc.error && len(setupArgs) > 0 { + channelId = setupArgs[0] + } + } + cmd = append(cmd, tc.args...) + s.runTx(cmd, tc.error) + + // Check balance change for successful payments + if channelId != "" { + balance := s.getChannelBalance(channelId) + s.Require().Equal(tc.paid, balance.PaidSoFar.ToInt()) + } + }) + } +} + +func (s *nitroSuite) TestFullPaymentFlow() { + s.Run("complete payment lifecycle", func() { + // Open ledger and payment channels + ledgerChannel := s.setupLedgerChannel("100")[0] + paymentChannel := s.setupPaymentChannel("50")[0] + + // Verify initial balance + s.Require().Equal("0", s.getChannelBalance(paymentChannel).PaidSoFar.ToInt().String()) + + // Make payments: 5 + 10 + 15 = 30 + s.runTx([]string{"tx", "nitro", "pay", paymentChannel, "5" + s.tokenDenom}, false) + s.runTx([]string{"tx", "nitro", "pay", paymentChannel, "10" + s.tokenDenom}, false) + s.runTx([]string{"tx", "nitro", "pay", paymentChannel, "15" + s.tokenDenom}, false) + + // Verify final balance + finalBalance := s.getChannelBalance(paymentChannel) + s.Require().Equal("30", finalBalance.PaidSoFar.ToInt().String()) + s.Require().Equal("20", finalBalance.RemainingFunds.ToInt().String()) + + // Close channels in correct order + s.runTx([]string{"tx", "nitro", "close-payment-channel", paymentChannel}, false) + s.runTx([]string{"tx", "nitro", "close-channel", ledgerChannel}, false) + }) + + s.Run("insufficient funds scenario", func() { + s.setupLedgerChannel("20") + paymentChannel := s.setupPaymentChannel("10")[0] + + s.runTx([]string{"tx", "nitro", "pay", paymentChannel, "5" + s.tokenDenom}, false) + s.runTx([]string{"tx", "nitro", "pay", paymentChannel, "10" + s.tokenDenom}, true) // insufficient funds + s.runTx([]string{"tx", "nitro", "pay", paymentChannel, "5" + s.tokenDenom}, false) + + // Verify all funds used + balance := s.getChannelBalance(paymentChannel) + s.Require().Equal("10", balance.PaidSoFar.ToInt().String()) + s.Require().Equal("0", balance.RemainingFunds.ToInt().String()) + }) + + s.Run("invalid closure order", func() { + // Open both channels + ledgerChannel := s.setupLedgerChannel("50")[0] + paymentChannel := s.setupPaymentChannel("30")[0] + + // Make a payment + s.runTx([]string{"tx", "nitro", "pay", paymentChannel, "10" + s.tokenDenom}, false) + + // Try to close ledger channel before payment channel - should fail + s.runTx([]string{"tx", "nitro", "close-channel", ledgerChannel}, true) + + // Correct order should work + s.runTx([]string{"tx", "nitro", "close-payment-channel", paymentChannel}, false) + s.runTx([]string{"tx", "nitro", "close-channel", ledgerChannel}, false) + }) +} + +// setupLedgerChannel creates a ledger channel and returns the channel ID as args +func (s *nitroSuite) setupLedgerChannel(amount string) []string { + openCmd := []string{"tx", "nitro", "open-channel", s.bob.AsParticipant().String(), amount + s.tokenDenom} + txhash := s.runTx(openCmd, false) + return []string{s.getChannelIdFromTx(txhash)} +} + +// setupPaymentChannel creates a ledger channel and payment channel, returns payment channel ID as args +func (s *nitroSuite) setupPaymentChannel(amount string) []string { + openPcCmd := []string{"tx", "nitro", "open-payment-channel", s.bob.AsParticipant().String(), amount + s.tokenDenom} + txhash := s.runTx(openPcCmd, false) + return []string{s.getChannelIdFromTx(txhash)} +} + +// getChannelIdFromTx opens a channel and extracts the channel ID from the transaction result +func (s *nitroSuite) getChannelIdFromTx(txHash string) string { + txDetails := s.cli().CustomQuery("query", "tx", txHash) + + // find channel_id in any event's attributes + channelId := gjson.Get(txDetails, "events.#.attributes.#(key==\"channel_id\").value|0") + s.Require().True(channelId.Exists(), "channel_id not found in transaction events") + + return channelId.String() +} + +func (s *nitroSuite) getChannelBalance(channelId string) query.PaymentChannelBalance { + channelInfo := s.cli().CustomQuery( + s.withNitroQueryFlags("q", "nitro", "get-channel", "--payment", channelId)..., + ) + + var info query.PaymentChannelInfo + err := json.Unmarshal([]byte(channelInfo), &info) + s.Require().NoError(err, "could not parse PaymentChannelInfo: %s", channelInfo) + return info.Balance +} + +func (s *nitroSuite) withNitroQueryFlags(cmd ...string) []string { + return append(cmd, "--home", s.clientHome()) +} + +func (s *nitroSuite) Test_Hang() { + hang := os.Getenv("HANG") + if hang == "" { + s.T().Skip("Placeholder to run the validator nodes and hang for manual testing") + } + + if hang == "ledger" || hang == "payment" { + s.setupLedgerChannel("20") + } + if hang == "payment" { + s.setupPaymentChannel("10") + } + + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + <-c +} diff --git a/tests/system/registry_grpc_test.go b/tests/system/registry_grpc_test.go new file mode 100644 index 00000000..6c35a37f --- /dev/null +++ b/tests/system/registry_grpc_test.go @@ -0,0 +1,389 @@ +package system + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/testutil" + "github.com/tidwall/gjson" + + "git.vdb.to/cerc-io/laconicd/x/registry" +) + +const badPath = "/asdasd" + +func (s *registrySuite) TestGRPCQueryParams() { + reqURL := s.endpointURL("registry/v1/params") + + testCases := []struct { + name string + url string + errmsg string + }{ + { + "invalid request", + reqURL + badPath, + "Not Implemented", + }, + { + "valid request", + reqURL, + "", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var response registry.QueryParamsResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + + params := registry.DefaultParams() + s.updateParams(¶ms) + require.Equal(params.String(), response.GetParams().String()) + } + }) + } +} + +func (s *registrySuite) TestGRPCQueryWhoIs() { + reqURL := s.endpointURL("registry/v1/whois/%s") + authorityName := "QueryWhoIS" + + testCases := []struct { + name string + url string + errmsg string + prerun func(string) + }{ + { + "invalid url", + reqURL + badPath, + "Not Implemented", + func(string) {}, + }, + { + "valid request", + reqURL, + "", + func(name string) { s.reserveName(name) }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + tc.prerun(authorityName) + url := fmt.Sprintf(tc.url, authorityName) + + resp, err := testutil.GetRequest(url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var response registry.QueryWhoisResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + require.Equal(registry.AuthorityActive, response.GetNameAuthority().Status) + } + }) + } +} + +func (s *registrySuite) TestGRPCQueryLookup() { + reqURL := s.endpointURL("registry/v1/lookup") + authorityName := "QueryLookUp" + + s.createNameRecord(authorityName) + + testCases := []struct { + name string + url string + errmsg string + }{ + { + "invalid url", + reqURL + badPath, + "Not Implemented", + }, + { + "nonexistent LRN", + fmt.Sprintf(reqURL+"?lrn=lrn://%s/", "nonexistent"), + "not found", + }, + { + "valid request", + fmt.Sprintf(reqURL+"?lrn=lrn://%s/", authorityName), + "", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var response registry.QueryLookupLrnResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + require.NotEmpty(response.Name.Latest.Id) + } + }) + } +} + +func (s *registrySuite) TestGRPCQueryListRecords() { + reqURL := s.endpointURL("registry/v1/records") + bondId := s.bondId + + testCases := []struct { + name string + url string + errmsg string + prerun func(string) + }{ + { + "invalid url", + reqURL + badPath, + "not found", + func(string) {}, + }, + { + "valid request", + reqURL, + "", + func(id string) { s.createRecord(id) }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + tc.prerun(bondId) + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var response registry.QueryRecordsResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + require.NotEmpty(response.GetRecords()) + require.Equal(bondId, response.GetRecords()[0].GetBondId()) + } + }) + } +} + +func (s *registrySuite) TestGRPCQueryGetRecordById() { + reqURL := s.endpointURL("registry/v1/records/%s") + bondId := s.bondId + + testCases := []struct { + name string + url string + errmsg string + prerun func(string) string + }{ + { + "invalid url", + reqURL + badPath, + "not found", + func(string) string { return "" }, + }, + { + "valid request", + reqURL, + "", + func(id string) string { + require := s.Require() + + // create a record and get the id + s.createRecord(id) + out := s.cli().CustomQuery("q", "registry", "list") + var response registry.QueryRecordsResponse + require.NoError(s.codec.UnmarshalJSON([]byte(out), &response), out) + require.NotEmpty(response.GetRecords()) + + return response.GetRecords()[0].Id + }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + recordId := tc.prerun(bondId) + url := fmt.Sprintf(tc.url, recordId) + + resp, err := testutil.GetRequest(url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var response registry.QueryGetRecordResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + record := response.GetRecord() + require.NotEmpty(record.GetId()) + require.Equal(recordId, record.GetId()) + } + }) + } +} + +func (s *registrySuite) TestGRPCQueryGetRecordByBondId() { + reqURL := s.endpointURL("registry/v1/records-by-bond-id/%s") + bondId := s.bondId + + testCases := []struct { + name string + url string + errmsg string + prerun func(string) + }{ + { + "invalid url", + reqURL + badPath, + "Not Implemented", + func(string) {}, + }, + { + "valid request", + reqURL, + "", + func(id string) { s.createRecord(id) }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + tc.prerun(bondId) + url := fmt.Sprintf(tc.url, bondId) + + resp, err := testutil.GetRequest(url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var response registry.QueryGetRecordsByBondIdResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + records := response.GetRecords() + require.NotEmpty(records) + require.Equal(bondId, records[0].GetBondId()) + } + }) + } +} + +func (s *registrySuite) TestGRPCQueryGetRegistryModuleBalance() { + reqURL := s.endpointURL("registry/v1/balance") + bondId := s.bondId + + testCases := []struct { + name string + url string + errmsg string + prerun func(string) + }{ + { + "invalid url", + reqURL + badPath, + "Not Implemented", + func(string) {}, + }, + { + "valid request", + reqURL, + "", + func(id string) { s.createRecord(id) }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + tc.prerun(bondId) + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var response registry.QueryGetRegistryModuleBalanceResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + require.NotEmpty(response.GetBalances()) + } + }) + } +} + +func (s *registrySuite) TestGRPCQueryNamesList() { + reqURL := s.endpointURL("registry/v1/names") + + testCases := []struct { + name string + url string + errmsg string + prerun func(string) + }{ + { + "invalid url", + reqURL + badPath, + "Not Implemented", + func(string) {}, + }, + { + "valid request", + reqURL, + "", + func(name string) { s.createNameRecord(name) }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + require := s.Require() + + tc.prerun("ListNameRecords") + + resp, err := testutil.GetRequest(tc.url) + require.NoError(err) + + if tc.errmsg != "" { + message := gjson.Get(string(resp), "message").String() + require.Contains(message, tc.errmsg, tc.url) + } else { + var response registry.QueryNameRecordsResponse + require.NoError(s.codec.UnmarshalJSON(resp, &response), string(resp)) + require.NotEmpty(response.GetNames()) + } + }) + } +} diff --git a/tests/system/registry_test.go b/tests/system/registry_test.go new file mode 100644 index 00000000..db0485ca --- /dev/null +++ b/tests/system/registry_test.go @@ -0,0 +1,157 @@ +package system + +import ( + "fmt" + "os" + "path/filepath" + "testing" + "time" + + "github.com/stretchr/testify/suite" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" + + // accounts "github.com/cosmos/cosmos-sdk/x/accounts/v1" + "cosmossdk.io/math" + systest "cosmossdk.io/systemtests" + sdk "github.com/cosmos/cosmos-sdk/types" + + // nitro "git.vdb.to/cerc-io/laconicd/x/nitro/v1" + "git.vdb.to/cerc-io/laconicd/x/registry" +) + +var recordFilePath = "../data/examples/service_provider_example.yml" + +func init() { + var err error + if recordFilePath, err = filepath.Abs(recordFilePath); err != nil { + panic(err) + } + if _, err = os.Stat(recordFilePath); err != nil { + panic(err) + } +} + +type registrySuite struct { + testSuite + + accountAddress string + bondId string +} + +func TestRegistry(t *testing.T) { + suite.Run(t, new(registrySuite)) +} + +func (s *registrySuite) SetupTest() { + s.resetChain() + + Sut.ModifyGenesisJSON(s.T(), UpdateGenesisRegistry(s)) + s.accountAddress = s.cli().GetKeyAddr(s.account(0)) + + Sut.StartChain(s.T()) + s.bondId = createBond(&s.testSuite) +} + +func (s *registrySuite) TestTxSetRecord() { + testCases := []struct { + name string + args []string + err bool + }{ + { + "request with invalid payload file arg", + []string{"bad-file", s.bondId}, + true, + }, + { + "success", + []string{recordFilePath, s.bondId}, + false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := []string{"tx", "registry", "set"} + cmd = append(cmd, tc.args...) + s.runTx(cmd, tc.err) + }) + } +} + +func (s *testSuite) updateParams(params *registry.Params) { + params.RecordRent = sdk.NewCoin(s.bondDenom, math.NewInt(1000)) + params.RecordRentDuration = 10 * time.Second + + params.AuthorityRent = sdk.NewCoin(s.bondDenom, math.NewInt(1000)) + params.AuthorityGracePeriod = 10 * time.Second + + params.AuthorityAuctionCommitFee = sdk.NewCoin(s.bondDenom, math.NewInt(100)) + params.AuthorityAuctionRevealFee = sdk.NewCoin(s.bondDenom, math.NewInt(100)) + params.AuthorityAuctionMinimumBid = sdk.NewCoin(s.bondDenom, math.NewInt(500)) +} + +func UpdateGenesisRegistry(s *registrySuite) systest.GenesisMutator { + require := s.Require() + + return func(genesis []byte) []byte { + var regState registry.GenesisState + raw := gjson.Get(string(genesis), "app_state.registry").String() + require.NoError(s.codec.UnmarshalJSON([]byte(raw), ®State)) + + s.updateParams(®State.Params) + regStateBz, err := s.codec.MarshalJSON(®State) + require.NoError(err) + genesis, err = sjson.SetRawBytes(genesis, "app_state.registry", regStateBz) + require.NoError(err) + + // // add consensus-controlled module account(s) + // bondinitmsg, err := codectypes.NewAnyWithValue(&nitro.MsgInitAccount{}) + // require.NoError(s.T(), err) + // var accountsState accounts.GenesisState + // raw = gjson.Get(string(genesis), "app_state.accounts").String() + // require.NoError(s.T(), cdc.UnmarshalJSON([]byte(raw), &accountsState)) + // accountsState.InitAccountMsgs = []*accounts.MsgInit{ + // { + // Sender: accountAddress, + // AccountType: "nitro", + // Message: bondinitmsg, + // }, + // } + // accountsStateBz, err := cdc.MarshalJSON(&accountsState) + // require.NoError(s.T(), err) + // genesis, err = sjson.SetRawBytes(genesis, "app_state.accounts", accountsStateBz) + // require.NoError(s.T(), err) + + return genesis + } +} + +func (s *registrySuite) reserveName(authorityName string) { + cmd := []string{ + "tx", "registry", "reserve-authority", authorityName, s.accountAddress, + } + s.runTx(cmd, false) +} + +func (s *registrySuite) createNameRecord(authorityName string) { + for _, cmd := range [][]string{ + // reserve name authority + {"tx", "registry", "reserve-authority", authorityName, s.accountAddress}, + // add bond-id to name authority + {"tx", "registry", "authority-bond", authorityName, s.bondId}, + // create actual name record + {"tx", "registry", "set-name", fmt.Sprintf("lrn://%s/", authorityName), "test_hello_cid"}, + } { + s.runTx(cmd, false) + } +} + +func (s *registrySuite) createRecord(bondId string) { + s.T().Helper() + cmd := []string{ + "tx", "registry", "set", recordFilePath, bondId, + } + s.runTx(cmd, false) +} diff --git a/tests/system/suite_test.go b/tests/system/suite_test.go new file mode 100644 index 00000000..cbeac4c4 --- /dev/null +++ b/tests/system/suite_test.go @@ -0,0 +1,170 @@ +package system + +import ( + "errors" + "fmt" + "os" + "os/exec" + "path/filepath" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" + "github.com/tidwall/gjson" + + systest "cosmossdk.io/systemtests" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "git.vdb.to/cerc-io/laconicd/app/params" +) + +type testSuite struct { + suite.Suite + + codec codec.Codec + accountNamePrefix string + fees string + bondDenom string + + clientEthKey string + validatorEthKey string +} + +func (s *testSuite) SetupSuite() { + s.codec = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + s.accountNamePrefix = "node" // from testnet (--node-dir-prefix) + s.fees = "1" + params.CoinUnit + s.bondDenom = sdk.DefaultBondDenom + + s.validatorEthKey = "validator-eth-key" + s.clientEthKey = "client-eth-key" + + // configure the validators and client + commonInitCommands := [][]string{ + {"config", "set", "client", "chain-id", "testing"}, + {"config", "set", "client", "keyring-backend", "test"}, + } + + // disable nitro on validators by default + Sut.ForEachNodeExecAndWait(s.T(), append(commonInitCommands, + []string{"config", "set", "app", "nitro.enable", "false"}, + )...) + + clientInitCommands := append(commonInitCommands, + []string{"config", "set", "app", "nitro.eth-key", s.clientEthKey}, + ) + for _, cmd := range clientInitCommands { + cmd = append(cmd, "--home", s.clientHome()) + _ = systest.MustRunShellCmd(s.T(), Sut.ExecBinary(), cmd...) + } +} + +func (s *testSuite) setValidatorNitroKeys(keys ...string) { + Sut.WithEachNodeHome(func(i int, home string) { + var cmds [][]string + // TODO: complete and enable distsig + // []string{"config", "set", "app", "distsig.enable", "true"}, + // []string{"config", "set", "app", "distsig.longterm-key", s.validatorNitroKey}, + // []string{"config", "set", "app", "nitro.use-distsig", "true"}, + + if i < len(keys) { + // configure validator as a payment channel (individual) counterparty + cmds = [][]string{ + {"config", "set", "app", "nitro.enable", "true"}, + + {"keys", "import-hex", s.validatorEthKey, keys[i]}, + {"config", "set", "app", "nitro.eth-key", s.validatorEthKey}, + } + } + + for _, cmd := range cmds { + systest.MustRunShellCmd(s.T(), Sut.ExecBinary(), append(cmd, "--home", home)...) + } + }) +} + +// note: keys have to be created after ResetChain, which clears the keyring +func (s *testSuite) setClientKeys(ethKey string) { + commands := [][]string{ + {"keys", "import-hex", s.clientEthKey, ethKey}, + } + for _, cmd := range commands { + cmd = append(cmd, "--home", s.clientHome()) + _ = systest.MustRunShellCmd(s.T(), Sut.ExecBinary(), cmd...) + } +} + +func (s *testSuite) resetChain() { + Sut.ResetChain(s.T()) + // clear the nitro data dirs + Sut.WithEachNodeHome(func(i int, home string) { + _ = os.RemoveAll(filepath.Join(home, "nitro")) + + }) + _ = os.RemoveAll(filepath.Join(s.clientHome(), "nitro")) +} + +func (s *testSuite) account(i int) string { + return fmt.Sprintf("%s%d", s.accountNamePrefix, i) +} + +// the home dir systemtests uses to run client commands +func (s *testSuite) clientHome() string { + return filepath.Join(workDir, "testnet") +} + +func (s *testSuite) endpointURL(endpoint string) string { + return fmt.Sprintf("%s/cerc/%s", Sut.APIAddress(), endpoint) +} + +func (s *testSuite) cli() *systest.CLIWrapper { + cli := systest.NewCLIWrapper(s.T(), Sut, verbose). + WithRunStderr(os.Stderr) + return &cli +} + +func (s *testSuite) assertWithStderr(asserter systest.RunErrorAssert) systest.RunErrorAssert { + return func(t assert.TestingT, err error, msgAndArgs ...any) bool { + if asserter(t, err, msgAndArgs...) { + return true + } + var exitError *exec.ExitError + if errors.As(err, &exitError) { + if stderr := exitError.Stderr; len(stderr) > 0 { + defer t.Errorf("stderr: %s", stderr) + } + } + return false + } +} + +func (s *testSuite) runTx(cmd []string, err bool) string { + s.T().Helper() + cli := s.cli() + asserter := assert.NoError + if err { + asserter = assert.Error + } + // don't use Run(), it will clobber our custom --home + out := cli. + WithRunErrorMatcher(s.assertWithStderr(asserter)). + RunCommandWithArgs(s.withTxFlags(cmd)...) + if err { + return "" + } + txResult, committed := cli.AwaitTxCommitted(out, txTimeout) + s.Require().True(committed) + systest.RequireTxSuccess(s.T(), txResult) + txHash := gjson.Get(out, "txhash") + s.Require().True(txHash.Exists(), "txhash not found in output: %s", out) + return txHash.String() +} + +func (s *testSuite) withTxFlags(cmd []string) []string { + cmd = s.cli().WithTXFlags(cmd...) + return append(cmd, []string{ + "--from", s.account(0), + "--fees", s.fees, + }...) +} diff --git a/testutil/keyring.go b/testutil/keyring.go new file mode 100644 index 00000000..4e9d49e3 --- /dev/null +++ b/testutil/keyring.go @@ -0,0 +1,11 @@ +package testutil + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keyring" + modtestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" +) + +func NewKeyring() keyring.Keyring { + encCfg := modtestutil.MakeTestEncodingConfig() + return keyring.NewInMemory(encCfg.Codec) +} diff --git a/utils/address.go b/utils/address.go new file mode 100644 index 00000000..9b79be4c --- /dev/null +++ b/utils/address.go @@ -0,0 +1,54 @@ +package utils + +import ( + "cosmossdk.io/core/address" + errorsmod "cosmossdk.io/errors" + + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/runtime" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "git.vdb.to/cerc-io/laconicd/app/params" +) + +type addressCodec struct { + address.Codec +} + +func (ac addressCodec) StringToBytes(text string) ([]byte, error) { + bz, err := ac.Codec.StringToBytes(text) + if err != nil { + return nil, err + } + if len(bz) != 20 && len(bz) != 32 { + return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, + "address length must be 20 or 32 bz, got %d", len(bz)) + } + return bz, nil +} + +func NewAddressCodec() address.Codec { + return addressCodec{ + Codec: addresscodec.NewBech32Codec(params.Bech32PrefixAccAddr), + } +} + +func NewValidatorAddressCodec() runtime.ValidatorAddressCodec { + return addressCodec{ + Codec: addresscodec.NewBech32Codec(params.Bech32PrefixValAddr), + } +} + +func NewConsensusAddressCodec() runtime.ConsensusAddressCodec { + return addressCodec{ + Codec: addresscodec.NewBech32Codec(params.Bech32PrefixConsAddr), + } +} + +func MustBytesToString(ac address.Codec, bz []byte) string { + str, err := ac.BytesToString(bz) + if err != nil { + panic(err) + } + return str +} diff --git a/utils/cmd.go b/utils/cmd.go new file mode 100644 index 00000000..9f3924bf --- /dev/null +++ b/utils/cmd.go @@ -0,0 +1,18 @@ +package utils + +import ( + "context" + "errors" + "fmt" +) + +func GetFromContext[T any](ctx context.Context, key string) (*T, error) { + if v := ctx.Value(key); v != nil { + val, ok := v.(*T) + if !ok { + return nil, fmt.Errorf("context value of wrong type; expected %T, got %T", new(T), v) + } + return val, nil + } + return nil, errors.New("key not found in context: " + key) +} diff --git a/utils/context.go b/utils/context.go index 7a82bb6e..0bfb597a 100644 --- a/utils/context.go +++ b/utils/context.go @@ -1,29 +1,39 @@ package utils import ( + "context" "fmt" + "cosmossdk.io/core/gas" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) -func CtxWithCustomKVGasConfig(ctx *sdk.Context) *sdk.Context { - updatedCtx := ctx.WithKVGasConfig(storetypes.GasConfig{ - HasCost: 0, - DeleteCost: 0, - ReadCostFlat: 0, - ReadCostPerByte: 0, - WriteCostFlat: 0, - WriteCostPerByte: 0, - IterNextCostFlat: 0, - }) +const RefundModuleGasDescriptor = "laconic module gas refund" - return &updatedCtx +// WithCustomGasConfig returns a context with a zero-cost gas config, and a function to log all consumed gas. +// +// Note: as planned in server/v2, the gas meter will not be available on the STF-provided context +// during tx execution, and must be accessed via gas.Service instead. This arg is a placeholder +// to ensure modules using this include the gas service in anticipation of that change. +// https://github.com/cosmos/cosmos-sdk/pull/16310 +func WithCustomGasConfig(ctx context.Context, _ gas.Service) (context.Context, func(log.Logger, string)) { + c := sdk.UnwrapSDKContext(ctx) + meter := c.GasMeter() + + startGas := meter.GasConsumed() + logGas := func(logger log.Logger, method string) { + endGas := meter.GasConsumed() + meter.RefundGas(endGas-startGas, RefundModuleGasDescriptor) + LogTxGasConsumed(meter, logger, method) + } + + // Set a zero-cost gas config on the returned context + return c.WithKVGasConfig(storetypes.GasConfig{}), logGas } -func LogTxGasConsumed(ctx sdk.Context, logger log.Logger, tx string) { - gasConsumed := ctx.GasMeter().GasConsumed() - logger.Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) +func LogTxGasConsumed(gm gas.Meter, logger log.Logger, method string) { + gasConsumed := gm.GasConsumed() + logger.Info("tx executed", "method", method, "gas_consumed", fmt.Sprintf("%d", gasConsumed)) } diff --git a/utils/keys.go b/utils/keys.go new file mode 100644 index 00000000..6378a86d --- /dev/null +++ b/utils/keys.go @@ -0,0 +1,79 @@ +package utils + +import ( + "cosmossdk.io/core/address" + sdkerrors "cosmossdk.io/errors" + cmtcrypto "github.com/cometbft/cometbft/crypto" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdkcrypto "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// cosmos-sdk crypto/keyring/record.go:138 +func extractPrivKeyFromLocal(rl *keyring.Record_Local) (cmtcrypto.PrivKey, error) { + if rl.PrivKey == nil { + return nil, keyring.ErrPrivKeyNotAvailable + } + + priv, ok := rl.PrivKey.GetCachedValue().(sdkcrypto.PrivKey) + if !ok { + return nil, sdkerrors.Wrap(keyring.ErrCastAny, "PrivKey") + } + return &PrivKey{priv}, nil +} + +func ExtractPrivateKey(r *keyring.Record) (cmtcrypto.PrivKey, error) { + local := r.GetLocal() + if local == nil { + return nil, keyring.ErrPrivKeyExtr + } + return extractPrivKeyFromLocal(local) +} + +func ExtractPrivateKeyByUid(kr keyring.Keyring, uid string) (cmtcrypto.PrivKey, error) { + r, err := kr.Key(uid) + if err != nil { + return nil, err + } + return ExtractPrivateKey(r) +} + +// GetKeyRecord tries to get a key by either address or uid +func GetKeyRecord(kr keyring.Keyring, from string, ac address.Codec) (*keyring.Record, error) { + var k *keyring.Record + addr, err := ac.StringToBytes(from) + if err == nil { + k, err = kr.KeyByAddress(sdk.AccAddress(addr)) + if err != nil { + return nil, err + } + } else { + k, err = kr.Key(from) + if err != nil { + return nil, err + } + } + return k, nil +} + +// PrivKey wraps the SDK PrivKey type to satisfy cometbft/crypto.PrivKey +type PrivKey struct{ sdkcrypto.PrivKey } + +func (k PrivKey) PubKey() cmtcrypto.PubKey { return PubKey{k.PrivKey.PubKey()} } + +func (k PrivKey) Equals(other cmtcrypto.PrivKey) bool { + if otherPk, ok := other.(*PrivKey); ok { + return k.PrivKey.Equals(otherPk.PrivKey) + } + return false +} + +// PubKey wraps the SDK PubKey type to satisfy cometbft/crypto.PubKey +type PubKey struct{ sdkcrypto.PubKey } + +func (k PubKey) Equals(other cmtcrypto.PubKey) bool { + if otherPk, ok := other.(*PubKey); ok { + return k.PubKey.Equals(otherPk.PubKey) + } + return false +} diff --git a/utils/modules.go b/utils/modules.go new file mode 100644 index 00000000..ee283c33 --- /dev/null +++ b/utils/modules.go @@ -0,0 +1,38 @@ +package utils + +import ( + "cosmossdk.io/core/address" + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" + addresstypes "github.com/cosmos/cosmos-sdk/types/address" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +// AddressOrModuleAddress returns with this precedence: +// - the preferred address if it is valid, or +// - a module address with the preferred name, or +// - a module address with the alt name +func AddressOrModuleAddress(preferred, alt string) types.AccAddress { + if preferred != "" { + addrCodec := NewAddressCodec() + if addr, err := addrCodec.StringToBytes(preferred); err == nil { + return addr + } + return addresstypes.Module(preferred) + } + return addresstypes.Module(alt) +} + +func CheckAuthorityAddress(ac address.Codec, expected sdk.AccAddress, msgaddr string) error { + authority, err := ac.StringToBytes(msgaddr) + if err != nil { + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msgaddr) + } + if !expected.Equals(types.AccAddress(authority)) { + return errorsmod.Wrapf(govtypes.ErrInvalidSigner, + "invalid authority; expected %s, got %s", MustBytesToString(ac, expected), msgaddr) + } + return nil +} diff --git a/utils/signature.go b/utils/signature.go index 7d818977..4ea1570e 100644 --- a/utils/signature.go +++ b/utils/signature.go @@ -2,17 +2,34 @@ package utils import ( "github.com/ethereum/go-ethereum/common" + ethcrypto "github.com/ethereum/go-ethereum/crypto" "github.com/statechannels/go-nitro/crypto" ) -func DecodeEthereumAddress(message []byte, sig string) (string, error) { +func DecodeEthereumAddress(message []byte, sig string) (common.Address, error) { if len(sig) > 2 && sig[:2] == "0x" { sig = sig[2:] } signature := crypto.SplitSignature(common.Hex2Bytes(sig)) - ethereumAddress, err := crypto.RecoverEthereumMessageSigner(message, signature) - - return ethereumAddress.String(), err + return crypto.RecoverEthMessageSignerAddress(message, signature) +} + +// TODO: use compressed pubkey encoding? +func DecodeEthereumPubKey(message []byte, sig string) ([]byte, error) { + if len(sig) > 2 && sig[:2] == "0x" { + sig = sig[2:] + } + + signature := crypto.SplitSignature(common.Hex2Bytes(sig)) + return crypto.RecoverEthMessageSignerPubKey(message, signature) +} + +func EthAddressFromPubKey(pubkey []byte) (common.Address, error) { + ecdsaPubKey, err := ethcrypto.UnmarshalPubkey(pubkey) + if err != nil { + return common.Address{}, err + } + return ethcrypto.PubkeyToAddress(*ecdsaPubKey), nil } diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index b5f71483..5637c117 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -4,20 +4,23 @@ import ( "encoding/hex" "fmt" "os" + "path/filepath" "strconv" "time" + "github.com/spf13/cobra" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/cobra" - - wnsUtils "git.vdb.to/cerc-io/laconicd/utils" + "git.vdb.to/cerc-io/laconicd/utils" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" ) +var FlagSaveBidsTo = "save-to" + // GetTxCmd returns transaction commands for this module. func GetTxCmd() *cobra.Command { auctionTxCmd := &cobra.Command{ @@ -63,28 +66,36 @@ func GetCmdCommitBid() *cobra.Command { return err } - mnemonic, err := wnsUtils.GenerateMnemonic() + mnemonic, err := utils.GenerateMnemonic() if err != nil { return err } auctionId := args[0] - + fromAddr := clientCtx.GetFromAddress().String() reveal := map[string]interface{}{ "chainId": chainId, "auctionId": auctionId, - "bidderAddress": clientCtx.GetFromAddress().String(), + "bidderAddress": fromAddr, "bidAmount": bidAmount.String(), "noise": mnemonic, } - commitHash, content, err := wnsUtils.GenerateHash(reveal) + commitHash, content, err := utils.GenerateHash(reveal) if err != nil { return err } // Save reveal file. - err = os.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600) + savedBidDir, _ := cmd.Flags().GetString(FlagSaveBidsTo) + // Make dir if it doesn't exist + if _, err := os.Stat(savedBidDir); os.IsNotExist(err) { + if err = os.MkdirAll(savedBidDir, 0o700); err != nil { + return fmt.Errorf("failed to create directory %s: %w", savedBidDir, err) + } + } + savedBidPath := filepath.Join(savedBidDir, fmt.Sprintf("%s-%s.json", clientCtx.FromName, commitHash)) + err = os.WriteFile(savedBidPath, content, 0o600) if err != nil { return err } @@ -99,6 +110,7 @@ func GetCmdCommitBid() *cobra.Command { }, } + cmd.Flags().String(FlagSaveBidsTo, "./bids", "Directory to save bid reveal files") flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/auction/codec.go b/x/auction/codec.go index d29b3327..9c475d2c 100644 --- a/x/auction/codec.go +++ b/x/auction/codec.go @@ -1,17 +1,17 @@ package auction import ( - types "github.com/cosmos/cosmos-sdk/codec/types" + registry "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateAuction{}, &MsgCommitBid{}, &MsgRevealBid{}, ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &Msg_serviceDesc) } diff --git a/x/auction/expected_keeper.go b/x/auction/expected_keeper.go index c158245c..7a69687c 100644 --- a/x/auction/expected_keeper.go +++ b/x/auction/expected_keeper.go @@ -1,16 +1,14 @@ package auction -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) +import "context" // AuctionUsageKeeper keep track of auction usage in other modules. // Used to, for example, prevent deletion of a auction that's in use. type AuctionUsageKeeper interface { ModuleName() string - UsesAuction(ctx sdk.Context, auctionId string) bool + UsesAuction(ctx context.Context, auctionId string) bool - OnAuctionWinnerSelected(ctx sdk.Context, auctionId string) + OnAuctionWinnerSelected(ctx context.Context, auctionId string, currentHeight uint64) } // AuctionHooksWrapper is a wrapper for modules to inject AuctionUsageKeeper using depinject. diff --git a/x/auction/keeper/genesis.go b/x/auction/keeper/genesis.go index 0a8622bc..2afd9ba5 100644 --- a/x/auction/keeper/genesis.go +++ b/x/auction/keeper/genesis.go @@ -1,13 +1,13 @@ package keeper import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "context" "git.vdb.to/cerc-io/laconicd/x/auction" ) // InitGenesis initializes the module state from a genesis state. -func (k *Keeper) InitGenesis(ctx sdk.Context, data *auction.GenesisState) error { +func (k *Keeper) InitGenesis(ctx context.Context, data *auction.GenesisState) error { if err := k.Params.Set(ctx, data.Params); err != nil { return err } @@ -23,7 +23,7 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *auction.GenesisState) error } // ExportGenesis exports the module state to a genesis state. -func (k *Keeper) ExportGenesis(ctx sdk.Context) (*auction.GenesisState, error) { +func (k *Keeper) ExportGenesis(ctx context.Context) (*auction.GenesisState, error) { params, err := k.Params.Get(ctx) if err != nil { return nil, err diff --git a/x/auction/keeper/invariants.go b/x/auction/keeper/invariants.go deleted file mode 100644 index c2f684c4..00000000 --- a/x/auction/keeper/invariants.go +++ /dev/null @@ -1,37 +0,0 @@ -package keeper - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - types "git.vdb.to/cerc-io/laconicd/x/auction" -) - -// RegisterInvariants registers all auction invariants -func RegisterInvariants(ir sdk.InvariantRegistry, k *Keeper) { - ir.RegisterRoute(types.ModuleName, "module-account", ModuleAccountInvariant(k)) -} - -// AllInvariants runs all invariants of the auction module. -func AllInvariants(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - return ModuleAccountInvariant(k)(ctx) - } -} - -// ModuleAccountInvariant checks that the 'auction' module account balance is non-negative. -func ModuleAccountInvariant(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName) - if k.bankKeeper.GetAllBalances(ctx, moduleAddress).IsAnyNegative() { - return sdk.FormatInvariant( - types.ModuleName, - "module-account", - fmt.Sprintf("Module account '%s' has negative balance.", types.ModuleName), - ), true - } - - return "", false - } -} diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 99a837b5..1e031ba4 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -1,27 +1,32 @@ package keeper import ( + "context" "encoding/hex" "encoding/json" "errors" - "fmt" "slices" "time" "cosmossdk.io/collections" "cosmossdk.io/collections/indexes" - storetypes "cosmossdk.io/core/store" + "cosmossdk.io/core/address" + "cosmossdk.io/core/event" + "cosmossdk.io/core/gas" + "cosmossdk.io/core/header" + store "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" - wnsUtils "git.vdb.to/cerc-io/laconicd/utils" + "git.vdb.to/cerc-io/laconicd/utils" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" ) @@ -66,10 +71,14 @@ func newBidsIndexes(sb *collections.SchemaBuilder) BidsIndexes { } type Keeper struct { - // Codecs - cdc codec.BinaryCodec + cdc codec.BinaryCodec + logger log.Logger + addressCodec address.Codec + headerService header.Service + eventService event.Service + gasService gas.Service - authority string + authority types.AccAddress // External keepers accountKeeper auth.AccountKeeper @@ -92,19 +101,23 @@ type Keeper struct { // NewKeeper creates a new Keeper instance func NewKeeper( cdc codec.BinaryCodec, - storeService storetypes.KVStoreService, + storeService store.KVStoreService, + headerService header.Service, + eventService event.Service, + gasService gas.Service, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, - authority string, + authority types.AccAddress, + logger log.Logger, ) *Keeper { - // ensure that authority is a valid AccAddress - if _, err := accountKeeper.AddressCodec().StringToBytes(authority); err != nil { - panic("authority is not a valid acc address") - } - sb := collections.NewSchemaBuilder(storeService) k := Keeper{ cdc: cdc, + addressCodec: accountKeeper.AddressCodec(), + headerService: headerService, + eventService: eventService, + gasService: gasService, + logger: logger.With(log.ModuleKey, "x/"+auctiontypes.ModuleName), authority: authority, accountKeeper: accountKeeper, bankKeeper: bankKeeper, @@ -131,15 +144,6 @@ func NewKeeper( return &k } -// Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return logger(ctx) -} - -func logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", auctiontypes.ModuleName) -} - func (k *Keeper) SetUsageKeepers(usageKeepers []auctiontypes.AuctionUsageKeeper) { if k.usageKeepers != nil { panic("cannot set auction hooks twice") @@ -149,12 +153,12 @@ func (k *Keeper) SetUsageKeepers(usageKeepers []auctiontypes.AuctionUsageKeeper) } // SaveAuction - saves a auction to the store. -func (k Keeper) SaveAuction(ctx sdk.Context, auction *auctiontypes.Auction) error { +func (k Keeper) SaveAuction(ctx context.Context, auction *auctiontypes.Auction) error { return k.Auctions.Set(ctx, auction.Id, *auction) } // DeleteAuction - deletes the auction. -func (k Keeper) DeleteAuction(ctx sdk.Context, auction auctiontypes.Auction) error { +func (k Keeper) DeleteAuction(ctx context.Context, auction auctiontypes.Auction) error { // Delete all bids first. bids, err := k.GetBids(ctx, auction.Id) if err != nil { @@ -170,7 +174,7 @@ func (k Keeper) DeleteAuction(ctx sdk.Context, auction auctiontypes.Auction) err return k.Auctions.Remove(ctx, auction.Id) } -func (k Keeper) HasAuction(ctx sdk.Context, id string) (bool, error) { +func (k Keeper) HasAuction(ctx context.Context, id string) (bool, error) { has, err := k.Auctions.Has(ctx, id) if err != nil { return false, err @@ -179,17 +183,17 @@ func (k Keeper) HasAuction(ctx sdk.Context, id string) (bool, error) { return has, nil } -func (k Keeper) SaveBid(ctx sdk.Context, bid *auctiontypes.Bid) error { +func (k Keeper) SaveBid(ctx context.Context, bid *auctiontypes.Bid) error { key := collections.Join(bid.AuctionId, bid.BidderAddress) return k.Bids.Set(ctx, key, *bid) } -func (k Keeper) DeleteBid(ctx sdk.Context, bid auctiontypes.Bid) error { +func (k Keeper) DeleteBid(ctx context.Context, bid auctiontypes.Bid) error { key := collections.Join(bid.AuctionId, bid.BidderAddress) return k.Bids.Remove(ctx, key) } -func (k Keeper) HasBid(ctx sdk.Context, id string, bidder string) (bool, error) { +func (k Keeper) HasBid(ctx context.Context, id string, bidder string) (bool, error) { key := collections.Join(id, bidder) has, err := k.Bids.Has(ctx, key) if err != nil { @@ -199,7 +203,7 @@ func (k Keeper) HasBid(ctx sdk.Context, id string, bidder string) (bool, error) return has, nil } -func (k Keeper) GetBid(ctx sdk.Context, id string, bidder string) (auctiontypes.Bid, error) { +func (k Keeper) GetBid(ctx context.Context, id string, bidder string) (auctiontypes.Bid, error) { key := collections.Join(id, bidder) bid, err := k.Bids.Get(ctx, key) if err != nil { @@ -210,7 +214,7 @@ func (k Keeper) GetBid(ctx sdk.Context, id string, bidder string) (auctiontypes. } // GetBids gets the auction bids. -func (k Keeper) GetBids(ctx sdk.Context, id string) ([]*auctiontypes.Bid, error) { +func (k Keeper) GetBids(ctx context.Context, id string) ([]*auctiontypes.Bid, error) { var bids []*auctiontypes.Bid err := k.Bids.Walk(ctx, @@ -231,7 +235,7 @@ func (k Keeper) GetBids(ctx sdk.Context, id string) ([]*auctiontypes.Bid, error) } // ListAuctions - get all auctions. -func (k Keeper) ListAuctions(ctx sdk.Context) ([]auctiontypes.Auction, error) { +func (k Keeper) ListAuctions(ctx context.Context) ([]auctiontypes.Auction, error) { iter, err := k.Auctions.Iterate(ctx, nil) if err != nil { return nil, err @@ -241,7 +245,7 @@ func (k Keeper) ListAuctions(ctx sdk.Context) ([]auctiontypes.Auction, error) { } // MatchAuctions - get all matching auctions. -func (k Keeper) MatchAuctions(ctx sdk.Context, matchFn func(*auctiontypes.Auction) (bool, error)) ([]*auctiontypes.Auction, error) { +func (k Keeper) MatchAuctions(ctx context.Context, matchFn func(*auctiontypes.Auction) (bool, error)) ([]*auctiontypes.Auction, error) { var auctions []*auctiontypes.Auction err := k.Auctions.Walk(ctx, nil, func(key string, value auctiontypes.Auction) (bool, error) { @@ -264,11 +268,11 @@ func (k Keeper) MatchAuctions(ctx sdk.Context, matchFn func(*auctiontypes.Auctio } // GetAuction - gets a record from the store. -func (k Keeper) GetAuctionById(ctx sdk.Context, id string) (auctiontypes.Auction, error) { +func (k Keeper) GetAuctionById(ctx context.Context, id string) (auctiontypes.Auction, error) { auction, err := k.Auctions.Get(ctx, id) if err != nil { if errors.Is(err, collections.ErrNotFound) { - return auctiontypes.Auction{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.") + return auctiontypes.Auction{}, errorsmod.Wrap(sdkerrors.ErrNotFound, "Auction not found") } return auctiontypes.Auction{}, err } @@ -276,7 +280,7 @@ func (k Keeper) GetAuctionById(ctx sdk.Context, id string) (auctiontypes.Auction return auction, nil } -func (k Keeper) GetAuctionsByOwner(ctx sdk.Context, owner string) ([]auctiontypes.Auction, error) { +func (k Keeper) GetAuctionsByOwner(ctx context.Context, owner string) ([]auctiontypes.Auction, error) { iter, err := k.Auctions.Indexes.Owner.MatchExact(ctx, owner) if err != nil { return nil, err @@ -286,7 +290,7 @@ func (k Keeper) GetAuctionsByOwner(ctx sdk.Context, owner string) ([]auctiontype } // QueryAuctionsByBidder - query auctions by bidder -func (k Keeper) QueryAuctionsByBidder(ctx sdk.Context, bidderAddress string) ([]auctiontypes.Auction, error) { +func (k Keeper) QueryAuctionsByBidder(ctx context.Context, bidderAddress string) ([]auctiontypes.Auction, error) { auctions := []auctiontypes.Auction{} iter, err := k.Bids.Indexes.Bidder.MatchExact(ctx, bidderAddress) @@ -312,14 +316,14 @@ func (k Keeper) QueryAuctionsByBidder(ctx sdk.Context, bidderAddress string) ([] } // CreateAuction creates a new auction. -func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction) (*auctiontypes.Auction, error) { +func (k Keeper) CreateAuction(ctx context.Context, msg auctiontypes.MsgCreateAuction) (*auctiontypes.Auction, error) { // Might be called from another module directly, always validate. err := msg.ValidateBasic() if err != nil { return nil, err } - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + signerAddress, err := utils.NewAddressCodec().StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -327,17 +331,17 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction // Generate auction Id. account := k.accountKeeper.GetAccount(ctx, signerAddress) if account == nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "Account not found.") + return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, msg.Signer) } auctionId := auctiontypes.AuctionId{ - Address: signerAddress, + Address: sdk.AccAddress(signerAddress), AccNum: account.GetAccountNumber(), Sequence: account.GetSequence(), - }.Generate() + }.Generate(k.addressCodec) // Compute timestamps. - now := ctx.BlockTime() + now := k.headerService.GetHeaderInfo(ctx).Time commitsEndTime := now.Add(msg.CommitsDuration) revealsEndTime := now.Add(msg.CommitsDuration + msg.RevealsDuration) @@ -346,7 +350,7 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction sdkErr := k.bankKeeper.SendCoinsFromAccountToModule(ctx, signerAddress, auctiontypes.ModuleName, sdk.NewCoins(totalLockedAmount)) if sdkErr != nil { - return nil, errorsmod.Wrap(sdkErr, "Auction error transferring maximum price amount") + return nil, errorsmod.Wrap(sdkErr, "Error transferring maximum price amount") } } @@ -354,7 +358,7 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction Id: auctionId, Kind: msg.Kind, Status: auctiontypes.AuctionStatusCommitPhase, - OwnerAddress: signerAddress.String(), + OwnerAddress: msg.Signer, CreateTime: now, CommitsEndTime: commitsEndTime, RevealsEndTime: revealsEndTime, @@ -373,12 +377,12 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction return &auction, nil } -func (k Keeper) CommitBid(ctx sdk.Context, msg auctiontypes.MsgCommitBid) (*auctiontypes.Bid, error) { +func (k Keeper) CommitBid(ctx context.Context, msg auctiontypes.MsgCommitBid) (*auctiontypes.Bid, error) { if has, err := k.HasAuction(ctx, msg.AuctionId); !has { if err != nil { return nil, err } - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "Auction not found") } auction, err := k.GetAuctionById(ctx, msg.AuctionId) @@ -387,10 +391,11 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg auctiontypes.MsgCommitBid) (*auct } if auction.Status != auctiontypes.AuctionStatusCommitPhase { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in commit phase.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in commit phase") } - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + signerAddress, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -403,14 +408,13 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg auctiontypes.MsgCommitBid) (*auct } // Check if an old bid already exists, if so, return old bids auction fee (update bid scenario). - bidder := signerAddress.String() - bidExists, err := k.HasBid(ctx, msg.AuctionId, bidder) + bidExists, err := k.HasBid(ctx, msg.AuctionId, msg.Signer) if err != nil { return nil, err } if bidExists { - oldBid, err := k.GetBid(ctx, msg.AuctionId, bidder) + oldBid, err := k.GetBid(ctx, msg.AuctionId, msg.Signer) if err != nil { return nil, err } @@ -425,10 +429,10 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg auctiontypes.MsgCommitBid) (*auct // Save new bid. bid := auctiontypes.Bid{ AuctionId: msg.AuctionId, - BidderAddress: bidder, + BidderAddress: msg.Signer, Status: auctiontypes.BidStatusCommitted, CommitHash: msg.CommitHash, - CommitTime: ctx.BlockTime(), + CommitTime: k.headerService.GetHeaderInfo(ctx).Time, CommitFee: auction.CommitFee, RevealFee: auction.RevealFee, } @@ -440,12 +444,12 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg auctiontypes.MsgCommitBid) (*auct return &bid, nil } -func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auctiontypes.Auction, error) { +func (k Keeper) RevealBid(ctx context.Context, msg auctiontypes.MsgRevealBid) (*auctiontypes.Auction, error) { if has, err := k.HasAuction(ctx, msg.AuctionId); !has { if err != nil { return nil, err } - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "Auction not found") } auction, err := k.GetAuctionById(ctx, msg.AuctionId) @@ -454,88 +458,89 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct } if auction.Status != auctiontypes.AuctionStatusRevealPhase { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in reveal phase.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in reveal phase") } - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + signerAddress, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } - bidder := signerAddress.String() - bidExists, err := k.HasBid(ctx, msg.AuctionId, bidder) + bidExists, err := k.HasBid(ctx, msg.AuctionId, msg.Signer) if err != nil { return nil, err } if !bidExists { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "Bid not found") } - bid, err := k.GetBid(ctx, msg.AuctionId, bidder) + bid, err := k.GetBid(ctx, msg.AuctionId, msg.Signer) if err != nil { return nil, err } if bid.Status != auctiontypes.BidStatusCommitted { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid not in committed state.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid not in committed state") } revealBytes, err := hex.DecodeString(msg.Reveal) if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal string.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal string") } - cid, err := wnsUtils.CIDFromJSONBytes(revealBytes) + cid, err := utils.CIDFromJSONBytes(revealBytes) if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON") } if bid.CommitHash != cid { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Commit hash mismatch.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Commit hash mismatch") } var reveal map[string]interface{} err = json.Unmarshal(revealBytes, &reveal) if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal JSON unmarshal error.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal JSON unmarshal error") } - chainId, err := wnsUtils.GetAttributeAsString(reveal, "chainId") - if err != nil || chainId != ctx.ChainID() { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal chainID.") + headerInfo := k.headerService.GetHeaderInfo(ctx) + chainId, err := utils.GetAttributeAsString(reveal, "chainId") + if err != nil || chainId != headerInfo.ChainID { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal chainID") } - auctionId, err := wnsUtils.GetAttributeAsString(reveal, "auctionId") + auctionId, err := utils.GetAttributeAsString(reveal, "auctionId") if err != nil || auctionId != msg.AuctionId { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal auction Id.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal auction Id") } - bidderAddress, err := wnsUtils.GetAttributeAsString(reveal, "bidderAddress") + bidderAddress, err := utils.GetAttributeAsString(reveal, "bidderAddress") if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid address.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid address") } - if bidderAddress != signerAddress.String() { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal bid address mismatch.") + if bidderAddress != msg.Signer { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal bid address mismatch") } - bidAmountStr, err := wnsUtils.GetAttributeAsString(reveal, "bidAmount") + bidAmountStr, err := utils.GetAttributeAsString(reveal, "bidAmount") if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount") } bidAmount, err := sdk.ParseCoinNormalized(bidAmountStr) if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount") } if auction.Kind == auctiontypes.AuctionKindVickrey && bidAmount.IsLT(auction.MinimumBid) { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid is lower than minimum bid.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid is lower than minimum bid") } if auction.Kind == auctiontypes.AuctionKindProvider && auction.MaxPrice.IsLT(bidAmount) { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid is higher than max price.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid is higher than max price") } // Lock bid amount. @@ -548,7 +553,7 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct // Update bid. bid.BidAmount = bidAmount - bid.RevealTime = ctx.BlockTime() + bid.RevealTime = headerInfo.Time bid.Status = auctiontypes.BidStatusRevealed if err = k.SaveBid(ctx, &bid); err != nil { return nil, err @@ -557,13 +562,8 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct return &auction, nil } -// GetAuthority returns the x/auction module's authority. -func (k Keeper) GetAuthority() string { - return k.authority -} - // GetParams gets the auction module's parameters. -func (k Keeper) GetParams(ctx sdk.Context) (*auctiontypes.Params, error) { +func (k Keeper) GetParams(ctx context.Context) (*auctiontypes.Params, error) { params, err := k.Params.Get(ctx) if err != nil { return nil, err @@ -573,19 +573,19 @@ func (k Keeper) GetParams(ctx sdk.Context) (*auctiontypes.Params, error) { } // SetParams sets the x/auction module parameters. -func (k Keeper) SetParams(ctx sdk.Context, params auctiontypes.Params) error { +func (k Keeper) SetParams(ctx context.Context, params auctiontypes.Params) error { return k.Params.Set(ctx, params) } // GetAuctionModuleBalances gets the auction module account(s) balances. -func (k Keeper) GetAuctionModuleBalances(ctx sdk.Context) sdk.Coins { +func (k Keeper) GetAuctionModuleBalances(ctx context.Context) sdk.Coins { moduleAddress := k.accountKeeper.GetModuleAddress(auctiontypes.ModuleName) balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress) return balances } -func (k Keeper) EndBlockerProcessAuctions(ctx sdk.Context) error { +func (k Keeper) EndBlockerProcessAuctions(ctx context.Context) error { // Transition auction state (commit, reveal, expired, completed). if err := k.processAuctionPhases(ctx); err != nil { return err @@ -595,7 +595,7 @@ func (k Keeper) EndBlockerProcessAuctions(ctx sdk.Context) error { return k.deleteCompletedAuctions(ctx) } -func (k Keeper) processAuctionPhases(ctx sdk.Context) error { +func (k Keeper) processAuctionPhases(ctx context.Context) error { auctions, err := k.MatchAuctions(ctx, func(_ *auctiontypes.Auction) (bool, error) { return true, nil }) @@ -603,25 +603,26 @@ func (k Keeper) processAuctionPhases(ctx sdk.Context) error { return err } + now := k.headerService.GetHeaderInfo(ctx).Time for _, auction := range auctions { // Commit -> Reveal state. - if auction.Status == auctiontypes.AuctionStatusCommitPhase && ctx.BlockTime().After(auction.CommitsEndTime) { + if auction.Status == auctiontypes.AuctionStatusCommitPhase && now.After(auction.CommitsEndTime) { auction.Status = auctiontypes.AuctionStatusRevealPhase if err = k.SaveAuction(ctx, auction); err != nil { return err } - k.Logger(ctx).Info(fmt.Sprintf("Moved auction %s to reveal phase.", auction.Id)) + k.logger.Info("Moved auction to reveal phase", "id", auction.Id) } // Reveal -> Expired state. - if auction.Status == auctiontypes.AuctionStatusRevealPhase && ctx.BlockTime().After(auction.RevealsEndTime) { + if auction.Status == auctiontypes.AuctionStatusRevealPhase && now.After(auction.RevealsEndTime) { auction.Status = auctiontypes.AuctionStatusExpired if err = k.SaveAuction(ctx, auction); err != nil { return err } - k.Logger(ctx).Info(fmt.Sprintf("Moved auction %s to expired state.", auction.Id)) + k.logger.Info("Moved auction to expired state", "id", auction.Id) } // If auction has expired, pick a winner from revealed bids. @@ -642,17 +643,17 @@ func (k Keeper) processAuctionPhases(ctx sdk.Context) error { } // Delete completed stale auctions. -func (k Keeper) deleteCompletedAuctions(ctx sdk.Context) error { +func (k Keeper) deleteCompletedAuctions(ctx context.Context) error { auctions, err := k.MatchAuctions(ctx, func(auction *auctiontypes.Auction) (bool, error) { deleteTime := auction.RevealsEndTime.Add(CompletedAuctionDeleteTimeout) - return auction.Status == auctiontypes.AuctionStatusCompleted && ctx.BlockTime().After(deleteTime), nil + return auction.Status == auctiontypes.AuctionStatusCompleted && k.headerService.GetHeaderInfo(ctx).Time.After(deleteTime), nil }) if err != nil { return err } for _, auction := range auctions { - k.Logger(ctx).Info(fmt.Sprintf("Deleting completed auction %s after timeout.", auction.Id)) + k.logger.Info("Deleting completed auction after timeout", "id", auction.Id) if err := k.DeleteAuction(ctx, *auction); err != nil { return err } @@ -662,8 +663,9 @@ func (k Keeper) deleteCompletedAuctions(ctx sdk.Context) error { } // Pick winner for vickrey auction -func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction) error { - k.Logger(ctx).Info(fmt.Sprintf("Picking auction %s winner.", auction.Id)) +func (k Keeper) pickAuctionWinner(ctx context.Context, auction *auctiontypes.Auction) error { + logger := k.logger.With("id", auction.Id) + logger.Info("Picking auction winner") var highestBid *auctiontypes.Bid var secondHighestBid *auctiontypes.Bid @@ -674,38 +676,38 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction } for _, bid := range bids { - k.Logger(ctx).Info(fmt.Sprintf("Processing bid %s %s", bid.BidderAddress, bid.BidAmount.String())) + logger.Info("Processing bid", "address", bid.BidderAddress, "amount", bid.BidAmount) // Only consider revealed bids. if bid.Status != auctiontypes.BidStatusRevealed { - k.Logger(ctx).Info(fmt.Sprintf("Ignoring unrevealed bid %s %s", bid.BidderAddress, bid.BidAmount.String())) + logger.Info("Ignoring unrevealed bid", "address", bid.BidderAddress, "amount", bid.BidAmount) continue } // Init highest bid. if highestBid == nil { highestBid = bid - k.Logger(ctx).Info(fmt.Sprintf("Initializing 1st bid %s %s", bid.BidderAddress, bid.BidAmount.String())) + logger.Info("Initializing 1st bid", "address", bid.BidderAddress, "amount", bid.BidAmount) continue } //nolint: all if highestBid.BidAmount.IsLT(bid.BidAmount) { - k.Logger(ctx).Info(fmt.Sprintf("New highest bid %s %s", bid.BidderAddress, bid.BidAmount.String())) + logger.Info("New highest bid", "address", bid.BidderAddress, "amount", bid.BidAmount) secondHighestBid = highestBid highestBid = bid - k.Logger(ctx).Info(fmt.Sprintf("Updated 1st bid %s %s", highestBid.BidderAddress, highestBid.BidAmount.String())) - k.Logger(ctx).Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String())) + logger.Info("Updated 1st bid", "address", highestBid.BidderAddress, "amount", highestBid.BidAmount) + logger.Info("Updated 2nd bid", "address", secondHighestBid.BidderAddress, "amount", secondHighestBid.BidAmount) } else if secondHighestBid == nil || secondHighestBid.BidAmount.IsLT(bid.BidAmount) { - k.Logger(ctx).Info(fmt.Sprintf("New 2nd highest bid %s %s", bid.BidderAddress, bid.BidAmount.String())) + logger.Info("New 2nd highest bid", "address", bid.BidderAddress, "amount", bid.BidAmount) secondHighestBid = bid - k.Logger(ctx).Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String())) + logger.Info("Updated 2nd bid", "address", secondHighestBid.BidderAddress, "amount", secondHighestBid.BidAmount) } else { - k.Logger(ctx).Info(fmt.Sprintf("Ignoring bid as it doesn't affect 1st/2nd price %s %s", bid.BidderAddress, bid.BidAmount.String())) + logger.Info("Ignoring bid as it doesn't affect 1st/2nd price", "address", bid.BidderAddress, "amount", bid.BidAmount) } } @@ -721,29 +723,32 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction if secondHighestBid != nil { auction.WinningPrice = secondHighestBid.BidAmount } - k.Logger(ctx).Info(fmt.Sprintf("Auction %s winner %s.", auction.Id, auction.WinnerAddresses[0])) - k.Logger(ctx).Info(fmt.Sprintf("Auction %s winner bid %s.", auction.Id, auction.WinningBids[0].String())) - k.Logger(ctx).Info(fmt.Sprintf("Auction %s winning price %s.", auction.Id, auction.WinningPrice.String())) + logger.Info("Auction winner chosen", + "address", auction.WinnerAddresses[0], + "bid", auction.WinningBids[0], + "price", auction.WinningPrice) } else { - k.Logger(ctx).Info(fmt.Sprintf("Auction %s has no valid revealed bids (no winner).", auction.Id)) + logger.Info("Auction has no valid revealed bids (no winner)") } if err := k.SaveAuction(ctx, auction); err != nil { return err } + addrCodec := utils.NewAddressCodec() + for _, bid := range bids { - bidderAddress, err := sdk.AccAddressFromBech32(bid.BidderAddress) + bidderAddress, err := addrCodec.StringToBytes(bid.BidderAddress) if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Invalid bidderAddress address. %v", err)) - panic("Invalid bidder address.") + logger.Error("Invalid bidderAddress address", "error", err) + panic("Invalid bidder address") } if bid.Status == auctiontypes.BidStatusRevealed { // Send reveal fee back to bidders that've revealed the bid. sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auctiontypes.ModuleName, bidderAddress, sdk.NewCoins(bid.RevealFee)) if sdkErr != nil { - k.Logger(ctx).Error(fmt.Sprintf("Auction error returning reveal fee: %v", sdkErr)) + logger.Error("Error returning reveal fee", "error", sdkErr) panic(sdkErr) } } @@ -751,31 +756,31 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction // Send back locked bid amount to all bidders. sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auctiontypes.ModuleName, bidderAddress, sdk.NewCoins(bid.BidAmount)) if sdkErr != nil { - k.Logger(ctx).Error(fmt.Sprintf("Auction error returning bid amount: %v", sdkErr)) + logger.Error("Error returning bid amount", "error", sdkErr) panic(sdkErr) } } // Process winner account (if nobody bids, there won't be a winner). if len(auction.WinnerAddresses) != 0 { - winnerAddress, err := sdk.AccAddressFromBech32(auction.WinnerAddresses[0]) + winnerAddress, err := addrCodec.StringToBytes(auction.WinnerAddresses[0]) if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Invalid winner address. %v", err)) - panic("Invalid winner address.") + logger.Error("Invalid winner address", "error", err) + panic("Invalid winner address") } // Take 2nd price from winner. sdkErr := k.bankKeeper.SendCoinsFromAccountToModule(ctx, winnerAddress, auctiontypes.ModuleName, sdk.NewCoins(auction.WinningPrice)) if sdkErr != nil { - k.Logger(ctx).Error(fmt.Sprintf("Auction error taking funds from winner: %v", sdkErr)) + logger.Error("Error taking funds from winner", "error", sdkErr) panic(sdkErr) } // Burn anything over the min. bid amount. amountToBurn := auction.WinningPrice.Sub(auction.MinimumBid) if amountToBurn.IsNegative() { - k.Logger(ctx).Error("Auction coins to burn cannot be negative.") - panic("Auction coins to burn cannot be negative.") + logger.Error("Auction coins to burn cannot be negative") + panic("Auction coins to burn cannot be negative") } // Use auction burn module account instead of actually burning coins to better keep track of supply. @@ -786,24 +791,25 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction sdk.NewCoins(amountToBurn), ) if sdkErr != nil { - k.Logger(ctx).Error(fmt.Sprintf("Auction error burning coins: %v", sdkErr)) + logger.Error("Error burning coins", "error", sdkErr) panic(sdkErr) } } // Notify other modules (hook). - k.Logger(ctx).Info(fmt.Sprintf("Auction %s notifying %d modules.", auction.Id, len(k.usageKeepers))) + // k.logger.Info(fmt.Sprintf("Auction notifying %d modules", len(k.usageKeepers))) for _, keeper := range k.usageKeepers { - k.Logger(ctx).Info(fmt.Sprintf("Auction %s notifying module %s.", auction.Id, keeper.ModuleName())) - keeper.OnAuctionWinnerSelected(ctx, auction.Id) + logger.Info("Auction notifying module", "module", keeper.ModuleName()) + keeper.OnAuctionWinnerSelected(ctx, auction.Id, uint64(k.headerService.GetHeaderInfo(ctx).Height)) } return nil } // Pick winner for provider auction -func (k Keeper) pickProviderAuctionWinners(ctx sdk.Context, auction *auctiontypes.Auction) error { - k.Logger(ctx).Info(fmt.Sprintf("Picking auction %s winners.", auction.Id)) +func (k Keeper) pickProviderAuctionWinners(ctx context.Context, auction *auctiontypes.Auction) error { + logger := k.logger.With("id", auction.Id) + logger.Info("Picking auction winners", auction.Id) bids, err := k.GetBids(ctx, auction.Id) if err != nil { @@ -812,11 +818,11 @@ func (k Keeper) pickProviderAuctionWinners(ctx sdk.Context, auction *auctiontype revealedBids := make([]*auctiontypes.Bid, 0, len(bids)) for _, bid := range bids { - k.Logger(ctx).Info(fmt.Sprintf("Processing bid %s %s", bid.BidderAddress, bid.BidAmount.String())) + logger.Info("Processing bid", "address", bid.BidderAddress, "amount", bid.BidAmount) // Only consider revealed bids. if bid.Status != auctiontypes.BidStatusRevealed { - k.Logger(ctx).Info(fmt.Sprintf("Ignoring unrevealed bid %s %s", bid.BidderAddress, bid.BidAmount.String())) + logger.Info("Ignoring unrevealed bid", "address", bid.BidderAddress, "amount", bid.BidAmount) continue } @@ -857,29 +863,31 @@ func (k Keeper) pickProviderAuctionWinners(ctx sdk.Context, auction *auctiontype auction.WinningPrice = winnerBids[len(winnerBids)-1].BidAmount for _, bid := range winnerBids { - k.Logger(ctx).Info(fmt.Sprintf("Auction %s winner address: %s, bid amount: %s.", auction.Id, bid.BidderAddress, bid.BidAmount.String())) + logger.Info("Auction winner", "address", bid.BidderAddress, "bid", bid.BidAmount) } - k.Logger(ctx).Info(fmt.Sprintf("Auction %s winning price %s.", auction.Id, auction.WinningPrice.String())) + logger.Info("Auction winning price", "price", auction.WinningPrice) } else { - k.Logger(ctx).Info(fmt.Sprintf("Auction %s has no valid revealed bids (no winner).", auction.Id)) + logger.Info("Auction has no valid revealed bids (no winner)") } if err := k.SaveAuction(ctx, auction); err != nil { return err } + addrCodec := utils.NewAddressCodec() + for _, bid := range bids { - bidderAddress, err := sdk.AccAddressFromBech32(bid.BidderAddress) + bidderAddress, err := addrCodec.StringToBytes(bid.BidderAddress) if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Invalid bidderAddress address. %v", err)) - panic("Invalid bidder address.") + logger.Error("Invalid bidderAddress address", "error", err) + panic("Invalid bidder address") } if bid.Status == auctiontypes.BidStatusRevealed { // Send reveal fee back to bidders that've revealed the bid. sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auctiontypes.ModuleName, bidderAddress, sdk.NewCoins(bid.RevealFee)) if sdkErr != nil { - k.Logger(ctx).Error(fmt.Sprintf("Auction error returning reveal fee: %v", sdkErr)) + logger.Error("Error returning reveal fee", "error", sdkErr) panic(sdkErr) } } @@ -891,10 +899,10 @@ func (k Keeper) pickProviderAuctionWinners(ctx sdk.Context, auction *auctiontype totalAmountPaid := auction.WinningPrice.Amount.Mul(math.NewInt(int64(len(auction.WinnerAddresses)))) creatorLeftOverAmount := sdk.NewCoin(auction.MaxPrice.Denom, totalLockedAmount.Sub(totalAmountPaid)) - ownerAccAddress, err := sdk.AccAddressFromBech32(auction.OwnerAddress) + ownerAccAddress, err := addrCodec.StringToBytes(auction.OwnerAddress) if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Invalid auction owner address. %v", err)) - panic("Invalid auction owner address.") + logger.Error("Invalid auction owner address", "error", err) + panic("Invalid auction owner address") } sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount( @@ -904,41 +912,40 @@ func (k Keeper) pickProviderAuctionWinners(ctx sdk.Context, auction *auctiontype sdk.NewCoins(creatorLeftOverAmount), ) if sdkErr != nil { - k.Logger(ctx).Error(fmt.Sprintf("Auction error returning leftover locked amount: %v", sdkErr)) + logger.Error("Error returning leftover locked amount", "error", sdkErr) panic(sdkErr) } // Notify other modules (hook). - k.Logger(ctx).Info(fmt.Sprintf("Auction %s notifying %d modules.", auction.Id, len(k.usageKeepers))) for _, keeper := range k.usageKeepers { - k.Logger(ctx).Info(fmt.Sprintf("Auction %s notifying module %s.", auction.Id, keeper.ModuleName())) - keeper.OnAuctionWinnerSelected(ctx, auction.Id) + logger.Info("Auction notifying module", "module", keeper.ModuleName()) + keeper.OnAuctionWinnerSelected(ctx, auction.Id, uint64(k.headerService.GetHeaderInfo(ctx).Height)) } return nil } -func (k Keeper) ReleaseFunds(ctx sdk.Context, msg auctiontypes.MsgReleaseFunds) (*auctiontypes.Auction, error) { +func (k Keeper) ReleaseFunds(ctx context.Context, msg auctiontypes.MsgReleaseFunds) (*auctiontypes.Auction, error) { auction, err := k.GetAuctionById(ctx, msg.AuctionId) if err != nil { return nil, err } if auction.Kind != auctiontypes.AuctionKindProvider { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction kind must be provider.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction kind must be provider") } // Only the auction owner can release funds. if msg.Signer != auction.OwnerAddress { - return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Only auction owner can release funds.") + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Only auction owner can release funds") } if auction.Status != auctiontypes.AuctionStatusCompleted { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not completed.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not completed") } if auction.FundsReleased { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction funds already released.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction funds already released") } // Mark funds as released in the stored auction @@ -947,23 +954,26 @@ func (k Keeper) ReleaseFunds(ctx sdk.Context, msg auctiontypes.MsgReleaseFunds) return nil, err } + addrCodec := utils.NewAddressCodec() + logger := k.logger.With("id", auction.Id) + // Process winner accounts. - for _, winnerAddress := range auction.WinnerAddresses { - winnerAccAddress, err := sdk.AccAddressFromBech32(winnerAddress) + for _, winner := range auction.WinnerAddresses { + winnerAddress, err := addrCodec.StringToBytes(winner) if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Invalid winner address. %v", err)) - panic("Invalid winner address.") + logger.Error("Invalid winner address", "error", err) + panic("Invalid winner address") } // Send winning price to winning bidders sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount( ctx, auctiontypes.ModuleName, - winnerAccAddress, + winnerAddress, sdk.NewCoins(auction.WinningPrice), ) if sdkErr != nil { - k.Logger(ctx).Error(fmt.Sprintf("Auction error sending funds to winner: %v", sdkErr)) + logger.Error("Error sending funds to winner", "error", sdkErr) panic(sdkErr) } } diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 68012679..52fb46a4 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -3,11 +3,12 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" + "cosmossdk.io/core/event" + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "git.vdb.to/cerc-io/laconicd/utils" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" - sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) var _ auctiontypes.MsgServer = msgServer{} @@ -21,11 +22,12 @@ func NewMsgServerImpl(keeper *Keeper) auctiontypes.MsgServer { return &msgServer{k: keeper} } -func (ms msgServer) CreateAuction(c context.Context, msg *auctiontypes.MsgCreateAuction) (*auctiontypes.MsgCreateAuctionResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) +func (ms msgServer) CreateAuction(ctx context.Context, msg *auctiontypes.MsgCreateAuction) (*auctiontypes.MsgCreateAuctionResponse, error) { + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.gasService) + defer logGas(ms.k.logger, "CreateAuction") - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -35,36 +37,39 @@ func (ms msgServer) CreateAuction(c context.Context, msg *auctiontypes.MsgCreate return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - auctiontypes.EventTypeCreateAuction, - sdk.NewAttribute(auctiontypes.AttributeKeyCommitsDuration, msg.CommitsDuration.String()), - sdk.NewAttribute(auctiontypes.AttributeKeyCommitFee, msg.CommitFee.String()), - sdk.NewAttribute(auctiontypes.AttributeKeyRevealFee, msg.RevealFee.String()), - sdk.NewAttribute(auctiontypes.AttributeKeyMinimumBid, msg.MinimumBid.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory), - sdk.NewAttribute(auctiontypes.AttributeKeySigner, signerAddress.String()), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "CreateAuction") + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + auctiontypes.EventTypeCreateAuction, + event.Attribute{Key: auctiontypes.AttributeKeyCommitsDuration, Value: msg.CommitsDuration.String()}, + event.Attribute{Key: auctiontypes.AttributeKeyCommitFee, Value: msg.CommitFee.String()}, + event.Attribute{Key: auctiontypes.AttributeKeyRevealFee, Value: msg.RevealFee.String()}, + event.Attribute{Key: auctiontypes.AttributeKeyMinimumBid, Value: msg.MinimumBid.String()}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", auctiontypes.EventTypeCreateAuction) + } + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: auctiontypes.AttributeValueCategory}, + event.Attribute{Key: auctiontypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &auctiontypes.MsgCreateAuctionResponse{Auction: resp}, nil } // CommitBid is the command for committing a bid -func (ms msgServer) CommitBid(c context.Context, msg *auctiontypes.MsgCommitBid) (*auctiontypes.MsgCommitBidResponse, error) { +func (ms msgServer) CommitBid(ctx context.Context, msg *auctiontypes.MsgCommitBid) (*auctiontypes.MsgCommitBidResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.gasService) + defer logGas(ms.k.logger, "CommitBid") - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -74,34 +79,37 @@ func (ms msgServer) CommitBid(c context.Context, msg *auctiontypes.MsgCommitBid) return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - auctiontypes.EventTypeCommitBid, - sdk.NewAttribute(auctiontypes.AttributeKeyAuctionId, msg.AuctionId), - sdk.NewAttribute(auctiontypes.AttributeKeyCommitHash, msg.CommitHash), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory), - sdk.NewAttribute(auctiontypes.AttributeKeySigner, signerAddress.String()), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "CommitBid") + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + auctiontypes.EventTypeCommitBid, + event.Attribute{Key: auctiontypes.AttributeKeyAuctionId, Value: msg.AuctionId}, + event.Attribute{Key: auctiontypes.AttributeKeyCommitHash, Value: msg.CommitHash}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", auctiontypes.EventTypeCommitBid) + } + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: auctiontypes.AttributeValueCategory}, + event.Attribute{Key: auctiontypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &auctiontypes.MsgCommitBidResponse{Bid: resp}, nil } // RevealBid is the command for revealing a bid -func (ms msgServer) RevealBid(c context.Context, msg *auctiontypes.MsgRevealBid) (*auctiontypes.MsgRevealBidResponse, error) { +func (ms msgServer) RevealBid(ctx context.Context, msg *auctiontypes.MsgRevealBid) (*auctiontypes.MsgRevealBidResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.gasService) + defer logGas(ms.k.logger, "RevealBid") - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -111,36 +119,36 @@ func (ms msgServer) RevealBid(c context.Context, msg *auctiontypes.MsgRevealBid) return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - auctiontypes.EventTypeRevealBid, - sdk.NewAttribute(auctiontypes.AttributeKeyAuctionId, msg.AuctionId), - sdk.NewAttribute(auctiontypes.AttributeKeyReveal, msg.Reveal), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory), - sdk.NewAttribute(auctiontypes.AttributeKeySigner, signerAddress.String()), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "RevealBid") + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + auctiontypes.EventTypeRevealBid, + event.Attribute{Key: auctiontypes.AttributeKeyAuctionId, Value: msg.AuctionId}, + event.Attribute{Key: auctiontypes.AttributeKeyReveal, Value: msg.Reveal}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", auctiontypes.EventTypeRevealBid) + } + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: auctiontypes.AttributeValueCategory}, + event.Attribute{Key: auctiontypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &auctiontypes.MsgRevealBidResponse{Auction: resp}, nil } // UpdateParams defines a method to perform updation of module params. -func (ms msgServer) UpdateParams(c context.Context, msg *auctiontypes.MsgUpdateParams) (*auctiontypes.MsgUpdateParamsResponse, error) { - if ms.k.authority != msg.Authority { - return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority) +func (ms msgServer) UpdateParams(ctx context.Context, msg *auctiontypes.MsgUpdateParams) (*auctiontypes.MsgUpdateParamsResponse, error) { + if err := utils.CheckAuthorityAddress(ms.k.addressCodec, ms.k.authority, msg.Authority); err != nil { + return nil, err } if err := msg.Params.Validate(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - if err := ms.k.SetParams(ctx, msg.Params); err != nil { return nil, err } @@ -149,15 +157,16 @@ func (ms msgServer) UpdateParams(c context.Context, msg *auctiontypes.MsgUpdateP } // ReleaseFunds is the command to pay the winning amounts to provider auction winners -func (ms msgServer) ReleaseFunds(c context.Context, msg *auctiontypes.MsgReleaseFunds) (*auctiontypes.MsgReleaseFundsResponse, error) { +func (ms msgServer) ReleaseFunds(ctx context.Context, msg *auctiontypes.MsgReleaseFunds) (*auctiontypes.MsgReleaseFundsResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.gasService) + defer logGas(ms.k.logger, "ReleaseFunds") - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -167,19 +176,21 @@ func (ms msgServer) ReleaseFunds(c context.Context, msg *auctiontypes.MsgRelease return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - auctiontypes.EventTypeReleaseFunds, - sdk.NewAttribute(auctiontypes.AttributeKeyAuctionId, msg.AuctionId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory), - sdk.NewAttribute(auctiontypes.AttributeKeySigner, signerAddress.String()), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "ReleaseFunds") + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + auctiontypes.EventTypeReleaseFunds, + event.Attribute{Key: auctiontypes.AttributeKeyAuctionId, Value: msg.AuctionId}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", auctiontypes.EventTypeReleaseFunds) + } + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: auctiontypes.AttributeValueCategory}, + event.Attribute{Key: auctiontypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &auctiontypes.MsgReleaseFundsResponse{Auction: resp}, nil } diff --git a/x/auction/keeper/query_server.go b/x/auction/keeper/query_server.go index 6f36ce14..1037628d 100644 --- a/x/auction/keeper/query_server.go +++ b/x/auction/keeper/query_server.go @@ -4,7 +4,6 @@ import ( "context" errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" @@ -22,9 +21,7 @@ func NewQueryServerImpl(k *Keeper) auctiontypes.QueryServer { } // Params implements the params query command -func (qs queryServer) Params(c context.Context, req *auctiontypes.QueryParamsRequest) (*auctiontypes.QueryParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) Params(ctx context.Context, req *auctiontypes.QueryParamsRequest) (*auctiontypes.QueryParamsResponse, error) { params, err := qs.k.GetParams(ctx) if err != nil { return nil, err @@ -34,9 +31,7 @@ func (qs queryServer) Params(c context.Context, req *auctiontypes.QueryParamsReq } // Auctions queries all auctions -func (qs queryServer) Auctions(c context.Context, req *auctiontypes.QueryAuctionsRequest) (*auctiontypes.QueryAuctionsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) Auctions(ctx context.Context, req *auctiontypes.QueryAuctionsRequest) (*auctiontypes.QueryAuctionsResponse, error) { auctions, err := qs.k.ListAuctions(ctx) if err != nil { return nil, err @@ -46,9 +41,7 @@ func (qs queryServer) Auctions(c context.Context, req *auctiontypes.QueryAuction } // GetAuction queries an auction by id -func (qs queryServer) GetAuction(c context.Context, req *auctiontypes.QueryGetAuctionRequest) (*auctiontypes.QueryGetAuctionResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) GetAuction(ctx context.Context, req *auctiontypes.QueryGetAuctionRequest) (*auctiontypes.QueryGetAuctionResponse, error) { if req.Id == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "auction id is required") } @@ -62,9 +55,7 @@ func (qs queryServer) GetAuction(c context.Context, req *auctiontypes.QueryGetAu } // GetBid queries an auction bid by auction-id and bidder -func (qs queryServer) GetBid(c context.Context, req *auctiontypes.QueryGetBidRequest) (*auctiontypes.QueryGetBidResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) GetBid(ctx context.Context, req *auctiontypes.QueryGetBidRequest) (*auctiontypes.QueryGetBidResponse, error) { if req.AuctionId == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "auction id is required") } @@ -82,9 +73,7 @@ func (qs queryServer) GetBid(c context.Context, req *auctiontypes.QueryGetBidReq } // GetBids queries all auction bids -func (qs queryServer) GetBids(c context.Context, req *auctiontypes.QueryGetBidsRequest) (*auctiontypes.QueryGetBidsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) GetBids(ctx context.Context, req *auctiontypes.QueryGetBidsRequest) (*auctiontypes.QueryGetBidsResponse, error) { if req.AuctionId == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "auction id is required") } @@ -99,11 +88,9 @@ func (qs queryServer) GetBids(c context.Context, req *auctiontypes.QueryGetBidsR // AuctionsByBidder queries auctions by bidder func (qs queryServer) AuctionsByBidder( - c context.Context, + ctx context.Context, req *auctiontypes.QueryAuctionsByBidderRequest, ) (*auctiontypes.QueryAuctionsByBidderResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - if req.BidderAddress == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "bidder address is required") } @@ -122,11 +109,9 @@ func (qs queryServer) AuctionsByBidder( // AuctionsByOwner queries auctions by owner func (qs queryServer) AuctionsByOwner( - c context.Context, + ctx context.Context, req *auctiontypes.QueryAuctionsByOwnerRequest, ) (*auctiontypes.QueryAuctionsByOwnerResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - if req.OwnerAddress == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "owner address is required") } @@ -141,10 +126,9 @@ func (qs queryServer) AuctionsByOwner( // GetAuctionModuleBalance queries the auction module account balance func (qs queryServer) GetAuctionModuleBalance( - c context.Context, + ctx context.Context, req *auctiontypes.QueryGetAuctionModuleBalanceRequest, ) (*auctiontypes.QueryGetAuctionModuleBalanceResponse, error) { - ctx := sdk.UnwrapSDKContext(c) balances := qs.k.GetAuctionModuleBalances(ctx) return &auctiontypes.QueryGetAuctionModuleBalanceResponse{Balance: balances}, nil diff --git a/x/auction/module/abci.go b/x/auction/module/abci.go index e17c5bc4..42914bcc 100644 --- a/x/auction/module/abci.go +++ b/x/auction/module/abci.go @@ -3,14 +3,10 @@ package module import ( "context" - sdk "github.com/cosmos/cosmos-sdk/types" - "git.vdb.to/cerc-io/laconicd/x/auction/keeper" ) // EndBlocker is called every block func EndBlocker(ctx context.Context, k *keeper.Keeper) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - return k.EndBlockerProcessAuctions(sdkCtx) + return k.EndBlockerProcessAuctions(ctx) } diff --git a/x/auction/module/autocli.go b/x/auction/module/autocli.go index e22afd8e..96547698 100644 --- a/x/auction/module/autocli.go +++ b/x/auction/module/autocli.go @@ -29,7 +29,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetAuction", - Use: "get [auction-id]", + Use: "get ", Short: "Get auction info by auction id", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "id"}, @@ -37,7 +37,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "AuctionsByOwner", - Use: "by-owner [owner-address]", + Use: "by-owner ", Short: "Get auctions list by owner / creator address", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "owner_address"}, @@ -45,7 +45,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetBid", - Use: "get-bid [auction-id] [bidder]", + Use: "get-bid ", Short: "Get auction bid by auction id and bidder", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "auction_id"}, @@ -54,7 +54,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetBids", - Use: "get-bids [auction-id]", + Use: "get-bids ", Short: "Get all auction bids", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "auction_id"}, @@ -62,7 +62,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "AuctionsByBidder", - Use: "by-bidder [bidder]", + Use: "by-bidder ", Short: "Get auctions list by bidder", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "bidder_address"}, @@ -81,7 +81,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "CreateAuction", - Use: "create [commits-duration] [reveals-duration] [commit-fee] [reveal-fee]", + Use: "create ", Short: "Create an auction", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "commits_duration"}, diff --git a/x/auction/module/depinject.go b/x/auction/module/depinject.go index 4c2e9618..9acaaa5f 100644 --- a/x/auction/module/depinject.go +++ b/x/auction/module/depinject.go @@ -2,16 +2,20 @@ package module import ( "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" + "cosmossdk.io/core/event" + "cosmossdk.io/core/gas" + "cosmossdk.io/core/header" + store "cosmossdk.io/core/store" "cosmossdk.io/depinject" - + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/auction/module/v1" + "git.vdb.to/cerc-io/laconicd/utils" "git.vdb.to/cerc-io/laconicd/x/auction" "git.vdb.to/cerc-io/laconicd/x/auction/keeper" ) @@ -25,22 +29,27 @@ func (am AppModule) IsOnePerModuleType() {} func (am AppModule) IsAppModule() {} func init() { - appmodule.Register( + appconfig.RegisterModule( &modulev1.Module{}, - appmodule.Provide(ProvideModule), - appmodule.Invoke(InvokeSetAuctionHooks), + appconfig.Provide(ProvideModule), + appconfig.Invoke(InvokeSetAuctionHooks), ) } type ModuleInputs struct { depinject.In - Config *modulev1.Module - Cdc codec.Codec - StoreService store.KVStoreService + StoreService store.KVStoreService + HeaderService header.Service + EventService event.Service + GasService gas.Service + Config *modulev1.Module + Cdc codec.Codec AccountKeeper auth.AccountKeeper BankKeeper bank.Keeper + + Logger log.Logger } type ModuleOutputs struct { @@ -56,12 +65,9 @@ type ModuleOutputs struct { func ProvideModule(in ModuleInputs) ModuleOutputs { // default to governance authority if not provided - authority := authtypes.NewModuleAddress(govtypes.ModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } + authority := utils.AddressOrModuleAddress(in.Config.Authority, govtypes.ModuleName) - k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper, in.BankKeeper, authority.String()) + k := keeper.NewKeeper(in.Cdc, in.StoreService, in.HeaderService, in.EventService, in.GasService, in.AccountKeeper, in.BankKeeper, authority, in.Logger) m := NewAppModule(in.Cdc, k) return ModuleOutputs{Module: m, Keeper: k} diff --git a/x/auction/module/module.go b/x/auction/module/module.go index aaac320b..073e6d1b 100644 --- a/x/auction/module/module.go +++ b/x/auction/module/module.go @@ -5,15 +5,15 @@ import ( "encoding/json" "fmt" - "cosmossdk.io/core/appmodule" - gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - + "cosmossdk.io/client/v2/autocli" + appmodule "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + registry "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" "git.vdb.to/cerc-io/laconicd/x/auction" "git.vdb.to/cerc-io/laconicd/x/auction/client/cli" @@ -22,12 +22,14 @@ import ( var ( _ module.AppModuleBasic = AppModule{} - _ appmodule.AppModule = AppModule{} _ module.HasGenesis = AppModule{} - _ module.HasServices = AppModule{} _ module.HasConsensusVersion = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} - _ module.HasInvariants = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} + + _ autocli.HasCustomTxCommand = AppModule{} ) // ConsensusVersion defines the current module consensus version @@ -46,18 +48,12 @@ func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule { } } -func NewAppModuleBasic(m AppModule) module.AppModuleBasic { - return module.CoreAppModuleBasicAdaptor(m.Name(), m) -} - -// module.AppModuleBasic +// module.AppModule // Name returns the auction module's name. func (AppModule) Name() string { return auction.ModuleName } -// RegisterLegacyAminoCodec registers the auction module's types on the LegacyAmino codec. -// New modules do not need to support Amino. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +// module.HasGRPCGateway // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the auction module. func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { @@ -66,25 +62,29 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } } +// appmodule.HasRegisterInterfaces + // RegisterInterfaces registers interfaces and implementations of the auction module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistry) { auction.RegisterInterfaces(registry) } +// appmodule.HasConsensusVersion + // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // module.HasGenesis // DefaultGenesis returns default genesis state as raw bytes for the module. -func (AppModule) DefaultGenesis(jsonCodec codec.JSONCodec) json.RawMessage { - return jsonCodec.MustMarshalJSON(auction.DefaultGenesisState()) +func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(auction.DefaultGenesisState()) } -// ValidateGenesis performs genesis state validation for the module. -func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error { +// ValidateGenesis performs genesis state validation for the auction module. +func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var data auction.GenesisState - if err := cdc.UnmarshalJSON(message, &data); err != nil { + if err := cdc.UnmarshalJSON(bz, &data); err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", auction.ModuleName, err) } @@ -102,12 +102,12 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. } } -// ExportGenesis returns the exported genesis state as raw bytes for the circuit +// ExportGenesis returns the exported genesis state as raw bytes for the auction // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { gs, err := am.keeper.ExportGenesis(ctx) if err != nil { - panic(fmt.Sprintf("failed to export %s genesis state: %v", auction.ModuleName, err)) + panic(fmt.Errorf("failed to export %s genesis state: %w", auction.ModuleName, err)) } return cdc.MustMarshalJSON(gs) @@ -115,10 +115,17 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // module.HasServices +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { // Register servers auction.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) auction.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) + + // Register in place module state migration migrations + // m := keeper.NewMigrator(am.keeper) + // if err := cfg.RegisterMigration(auction.ModuleName, 1, m.Migrate1to2); err != nil { + // panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", auction.ModuleName, err)) + // } } // appmodule.HasEndBlocker @@ -127,11 +134,11 @@ func (am AppModule) EndBlock(ctx context.Context) error { return EndBlocker(ctx, am.keeper) } -// module.HasInvariants +// autocli.HasCustomTxCommand -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - keeper.RegisterInvariants(ir, am.keeper) -} +// RegisterLegacyAminoCodec registers the auction module's types on the LegacyAmino codec. +// New modules do not need to support Amino. +func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // Get the root tx command of this module func (AppModule) GetTxCmd() *cobra.Command { diff --git a/x/auction/msgs.go b/x/auction/msgs.go index c35c7eda..ebcbb699 100644 --- a/x/auction/msgs.go +++ b/x/auction/msgs.go @@ -7,6 +7,8 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "git.vdb.to/cerc-io/laconicd/utils" ) var ( @@ -27,6 +29,10 @@ func NewMsgCreateAuction( numProviders int32, signer sdk.AccAddress, ) MsgCreateAuction { + signerStr, err := utils.NewAddressCodec().BytesToString(signer) + if err != nil { + panic(err) + } return MsgCreateAuction{ CommitsDuration: commitsDuration, RevealsDuration: revealsDuration, @@ -36,33 +42,45 @@ func NewMsgCreateAuction( MaxPrice: maxPrice, Kind: kind, NumProviders: numProviders, - Signer: signer.String(), + Signer: signerStr, } } // NewMsgCommitBid is the constructor function for MsgCommitBid. func NewMsgCommitBid(auctionId string, commitHash string, signer sdk.AccAddress) MsgCommitBid { + signerStr, err := utils.NewAddressCodec().BytesToString(signer) + if err != nil { + panic(err) + } return MsgCommitBid{ AuctionId: auctionId, CommitHash: commitHash, - Signer: signer.String(), + Signer: signerStr, } } // NewMsgRevealBid is the constructor function for MsgRevealBid. func NewMsgRevealBid(auctionId string, reveal string, signer sdk.AccAddress) MsgRevealBid { + signerStr, err := utils.NewAddressCodec().BytesToString(signer) + if err != nil { + panic(err) + } return MsgRevealBid{ AuctionId: auctionId, Reveal: reveal, - Signer: signer.String(), + Signer: signerStr, } } // NewMsgReleaseFunds is the constructor function for MsgReleaseFunds. func NewMsgReleaseFunds(auctionId string, signer sdk.AccAddress) MsgReleaseFunds { + signerStr, err := utils.NewAddressCodec().BytesToString(signer) + if err != nil { + panic(err) + } return MsgReleaseFunds{ AuctionId: auctionId, - Signer: signer.String(), + Signer: signerStr, } } diff --git a/x/auction/query.pb.go b/x/auction/query.pb.go index 78159a05..9ba95700 100644 --- a/x/auction/query.pb.go +++ b/x/auction/query.pb.go @@ -1160,6 +1160,7 @@ func _Query_GetAuctionModuleBalance_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cerc.auction.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/auction/tx.pb.go b/x/auction/tx.pb.go index 91cbdc5b..7aa266dc 100644 --- a/x/auction/tx.pb.go +++ b/x/auction/tx.pb.go @@ -765,6 +765,7 @@ func _Msg_ReleaseFunds_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cerc.auction.v1.Msg", HandlerType: (*MsgServer)(nil), diff --git a/x/auction/types.go b/x/auction/types.go index 266f0c32..0b771dee 100644 --- a/x/auction/types.go +++ b/x/auction/types.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "fmt" + "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -43,9 +44,13 @@ type AuctionId struct { } // Generate creates the auction id. -func (auctionId AuctionId) Generate() string { +func (auctionId AuctionId) Generate(ac address.Codec) string { hasher := sha256.New() - str := fmt.Sprintf("%s:%d:%d", auctionId.Address.String(), auctionId.AccNum, auctionId.Sequence) + addrStr, err := ac.BytesToString(auctionId.Address.Bytes()) + if err != nil { + panic(err) + } + str := fmt.Sprintf("%s:%d:%d", addrStr, auctionId.AccNum, auctionId.Sequence) hasher.Write([]byte(str)) return hex.EncodeToString(hasher.Sum(nil)) } diff --git a/x/bond/client/cli/query.go b/x/bond/client/cli/query.go deleted file mode 100644 index ad631c2d..00000000 --- a/x/bond/client/cli/query.go +++ /dev/null @@ -1,48 +0,0 @@ -package cli - -import ( - "fmt" - "strings" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/version" - "github.com/spf13/cobra" - - bondtypes "git.vdb.to/cerc-io/laconicd/x/bond" -) - -// GetQueryBondList implements the bond lists query command. -func GetQueryBondList() *cobra.Command { - cmd := &cobra.Command{ - Use: "list", - Short: "List bonds.", - Long: strings.TrimSpace( - fmt.Sprintf(`Get bond list . - -Example: -$ %s query %s list -`, - version.AppName, bondtypes.ModuleName, - ), - ), - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := bondtypes.NewQueryClient(clientCtx) - res, err := queryClient.Bonds(cmd.Context(), &bondtypes.QueryBondsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/bond/client/cli/tx.go b/x/bond/client/cli/tx.go deleted file mode 100644 index e494ae27..00000000 --- a/x/bond/client/cli/tx.go +++ /dev/null @@ -1,38 +0,0 @@ -package cli - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/cobra" - - bondtypes "git.vdb.to/cerc-io/laconicd/x/bond" -) - -// NewCreateBondCmd is the CLI command for creating a bond. -// Used in e2e tests -func NewCreateBondCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "create [amount]", - Short: "Create bond.", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - coin, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - - msg := bondtypes.NewMsgCreateBond(sdk.NewCoins(coin), clientCtx.GetFromAddress()) - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/bond/codec.go b/x/bond/codec.go index 6d1ba763..816d53e3 100644 --- a/x/bond/codec.go +++ b/x/bond/codec.go @@ -1,18 +1,18 @@ package bond import ( - types "github.com/cosmos/cosmos-sdk/codec/types" + registry "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateBond{}, &MsgRefillBond{}, &MsgCancelBond{}, &MsgWithdrawBond{}, ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &Msg_serviceDesc) } diff --git a/x/bond/expected_keeper.go b/x/bond/expected_keeper.go index bba62a12..df57fba2 100644 --- a/x/bond/expected_keeper.go +++ b/x/bond/expected_keeper.go @@ -1,14 +1,12 @@ package bond -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) +import context "context" // BondUsageKeeper keep track of bond usage in other modules. // Used to, for example, prevent deletion of a bond that's in use. type BondUsageKeeper interface { ModuleName() string - UsesBond(ctx sdk.Context, bondId string) bool + UsesBond(ctx context.Context, bondId string) bool } // BondHooksWrapper is a wrapper for modules to inject BondUsageKeeper using depinject. diff --git a/x/bond/keeper/genesis.go b/x/bond/keeper/genesis.go index f3cdde16..0e2720bc 100644 --- a/x/bond/keeper/genesis.go +++ b/x/bond/keeper/genesis.go @@ -1,12 +1,13 @@ package keeper import ( + "context" + "git.vdb.to/cerc-io/laconicd/x/bond" - sdk "github.com/cosmos/cosmos-sdk/types" ) // InitGenesis initializes the module state from a genesis state. -func (k *Keeper) InitGenesis(ctx sdk.Context, data *bond.GenesisState) error { +func (k *Keeper) InitGenesis(ctx context.Context, data *bond.GenesisState) error { if err := k.Params.Set(ctx, data.Params); err != nil { return err } @@ -22,7 +23,7 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *bond.GenesisState) error { } // ExportGenesis exports the module state to a genesis state. -func (k *Keeper) ExportGenesis(ctx sdk.Context) (*bond.GenesisState, error) { +func (k *Keeper) ExportGenesis(ctx context.Context) (*bond.GenesisState, error) { params, err := k.Params.Get(ctx) if err != nil { return nil, err diff --git a/x/bond/keeper/invariants.go b/x/bond/keeper/invariants.go deleted file mode 100644 index 178ba407..00000000 --- a/x/bond/keeper/invariants.go +++ /dev/null @@ -1,37 +0,0 @@ -package keeper - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - types "git.vdb.to/cerc-io/laconicd/x/bond" -) - -// RegisterInvariants registers all bond invariants -func RegisterInvariants(ir sdk.InvariantRegistry, k *Keeper) { - ir.RegisterRoute(types.ModuleName, "module-account", ModuleAccountInvariant(k)) -} - -// AllInvariants runs all invariants of the bond module. -func AllInvariants(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - return ModuleAccountInvariant(k)(ctx) - } -} - -// ModuleAccountInvariant checks that the 'bond' module account balance is non-negative. -func ModuleAccountInvariant(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName) - if k.bankKeeper.GetAllBalances(ctx, moduleAddress).IsAnyNegative() { - return sdk.FormatInvariant( - types.ModuleName, - "module-account", - fmt.Sprintf("Module account '%s' has negative balance.", types.ModuleName), - ), true - } - - return "", false - } -} diff --git a/x/bond/keeper/keeper.go b/x/bond/keeper/keeper.go index 97815a32..f7192379 100644 --- a/x/bond/keeper/keeper.go +++ b/x/bond/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "crypto/sha256" "encoding/hex" "errors" @@ -8,17 +9,22 @@ import ( "cosmossdk.io/collections" "cosmossdk.io/collections/indexes" - "cosmossdk.io/core/store" + "cosmossdk.io/core/address" + "cosmossdk.io/core/event" + "cosmossdk.io/core/gas" + store "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" bondtypes "git.vdb.to/cerc-io/laconicd/x/bond" + nitrokeeper "git.vdb.to/cerc-io/laconicd/x/nitro/keeper" ) type BondsIndexes struct { @@ -42,14 +48,18 @@ func newBondIndexes(sb *collections.SchemaBuilder) BondsIndexes { } type Keeper struct { - // Codecs - cdc codec.BinaryCodec + cdc codec.BinaryCodec + addressCodec address.Codec + logger log.Logger + eventService event.Service + GasService gas.Service - authority string + authority types.AccAddress // External keepers accountKeeper auth.AccountKeeper bankKeeper bank.Keeper + nitroKeeper nitrokeeper.Keeper // Track bond usage in other cosmos-sdk modules (more like a usage tracker). usageKeepers []bondtypes.BondUsageKeeper @@ -64,18 +74,20 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, storeService store.KVStoreService, + eventService event.Service, + gasService gas.Service, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, - authority string, + authority types.AccAddress, + logger log.Logger, ) *Keeper { - // ensure that authority is a valid AccAddress - if _, err := accountKeeper.AddressCodec().StringToBytes(authority); err != nil { - panic("authority is not a valid acc address") - } - sb := collections.NewSchemaBuilder(storeService) k := Keeper{ cdc: cdc, + addressCodec: accountKeeper.AddressCodec(), + eventService: eventService, + GasService: gasService, + logger: logger.With(log.ModuleKey, "x/"+bondtypes.ModuleName), authority: authority, accountKeeper: accountKeeper, bankKeeper: bankKeeper, @@ -96,11 +108,6 @@ func NewKeeper( return &k } -// Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", bondtypes.ModuleName) -} - func (k *Keeper) SetUsageKeepers(usageKeepers []bondtypes.BondUsageKeeper) { if k.usageKeepers != nil { panic("cannot set bond hooks twice") @@ -117,15 +124,19 @@ type BondId struct { } // Generate creates the bond Id. -func (bondId BondId) Generate() string { +func (bondId BondId) Generate(ac address.Codec) string { hasher := sha256.New() - str := fmt.Sprintf("%s:%d:%d", bondId.Address.String(), bondId.AccNum, bondId.Sequence) + addrStr, err := ac.BytesToString(bondId.Address.Bytes()) + if err != nil { + panic(err) + } + str := fmt.Sprintf("%s:%d:%d", addrStr, bondId.AccNum, bondId.Sequence) hasher.Write([]byte(str)) return hex.EncodeToString(hasher.Sum(nil)) } // HasBond - checks if a bond by the given Id exists. -func (k Keeper) HasBond(ctx sdk.Context, id string) (bool, error) { +func (k Keeper) HasBond(ctx context.Context, id string) (bool, error) { has, err := k.Bonds.Has(ctx, id) if err != nil { return false, err @@ -135,17 +146,18 @@ func (k Keeper) HasBond(ctx sdk.Context, id string) (bool, error) { } // SaveBond - saves a bond to the store. -func (k Keeper) SaveBond(ctx sdk.Context, bond *bondtypes.Bond) error { +func (k Keeper) SaveBond(ctx context.Context, bond *bondtypes.Bond) error { + fmt.Println(">>> saving bond:", bond) return k.Bonds.Set(ctx, bond.Id, *bond) } // DeleteBond - deletes the bond. -func (k Keeper) DeleteBond(ctx sdk.Context, bond bondtypes.Bond) error { +func (k Keeper) DeleteBond(ctx context.Context, bond bondtypes.Bond) error { return k.Bonds.Remove(ctx, bond.Id) } // ListBonds - get all bonds. -func (k Keeper) ListBonds(ctx sdk.Context) ([]*bondtypes.Bond, error) { +func (k Keeper) ListBonds(ctx context.Context) ([]*bondtypes.Bond, error) { var bonds []*bondtypes.Bond iter, err := k.Bonds.Iterate(ctx, nil) @@ -165,11 +177,11 @@ func (k Keeper) ListBonds(ctx sdk.Context) ([]*bondtypes.Bond, error) { return bonds, nil } -func (k Keeper) GetBondById(ctx sdk.Context, id string) (bondtypes.Bond, error) { +func (k Keeper) GetBondById(ctx context.Context, id string) (bondtypes.Bond, error) { bond, err := k.Bonds.Get(ctx, id) if err != nil { if errors.Is(err, collections.ErrNotFound) { - return bondtypes.Bond{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + err = errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found") } return bondtypes.Bond{}, err } @@ -177,7 +189,7 @@ func (k Keeper) GetBondById(ctx sdk.Context, id string) (bondtypes.Bond, error) return bond, nil } -func (k Keeper) GetBondsByOwner(ctx sdk.Context, owner string) ([]bondtypes.Bond, error) { +func (k Keeper) GetBondsByOwner(ctx context.Context, owner string) ([]bondtypes.Bond, error) { iter, err := k.Bonds.Indexes.Owner.MatchExact(ctx, owner) if err != nil { return []bondtypes.Bond{}, err @@ -187,7 +199,7 @@ func (k Keeper) GetBondsByOwner(ctx sdk.Context, owner string) ([]bondtypes.Bond } // GetBondModuleBalances gets the bond module account(s) balances. -func (k Keeper) GetBondModuleBalances(ctx sdk.Context) sdk.Coins { +func (k Keeper) GetBondModuleBalances(ctx context.Context) sdk.Coins { moduleAddress := k.accountKeeper.GetModuleAddress(bondtypes.ModuleName) balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress) @@ -195,12 +207,12 @@ func (k Keeper) GetBondModuleBalances(ctx sdk.Context) sdk.Coins { } // CreateBond creates a new bond. -func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) { +func (k Keeper) CreateBond(ctx context.Context, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) { // Check if account has funds. for _, coin := range coins { balance := k.bankKeeper.HasBalance(ctx, ownerAddress, coin) if !balance { - return nil, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "failed to create bond; Insufficient funds") + return nil, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "failed to create bond") } } @@ -210,16 +222,20 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s Address: ownerAddress, AccNum: account.GetAccountNumber(), Sequence: account.GetSequence(), - }.Generate() + }.Generate(k.addressCodec) maxBondAmount, err := k.getMaxBondAmount(ctx) if err != nil { return nil, err } - bond := bondtypes.Bond{Id: bondId, Owner: ownerAddress.String(), Balance: coins} + addrStr, err := k.addressCodec.BytesToString(ownerAddress) + if err != nil { + return nil, err + } + bond := bondtypes.Bond{Id: bondId, Owner: addrStr, Balance: coins} if bond.Balance.IsAnyGT(maxBondAmount) { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded") } // Move funds into the bond account module. @@ -228,6 +244,10 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s return nil, err } + // use a payment channel + // err = k.nitroKeeper.EnsurePaymentChannel(ownerAddress, bondtypes.ModuleAccountAddress, bond.Balance) + // err = k.nitroKeeper.Pay(ownerAddress, bondtypes.ModuleAccountAddress, bond.Balance) + // Save bond in store. err = k.SaveBond(ctx, &bond) if err != nil { @@ -237,12 +257,12 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s return &bond, nil } -func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) { +func (k Keeper) RefillBond(ctx context.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) { if has, err := k.HasBond(ctx, id); !has { if err != nil { return nil, err } - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found") } bond, err := k.GetBondById(ctx, id) @@ -250,14 +270,18 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre return nil, err } - if bond.Owner != ownerAddress.String() { - return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + addrStr, err := k.addressCodec.BytesToString(ownerAddress) + if err != nil { + return nil, err + } + if bond.Owner != addrStr { + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch") } // Check if account has funds. for _, coin := range coins { if !k.bankKeeper.HasBalance(ctx, ownerAddress, coin) { - return nil, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds.") + return nil, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds") } } @@ -268,9 +292,10 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre updatedBalance := bond.Balance.Add(coins...) if updatedBalance.IsAnyGT(maxBondAmount) { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded") } + // Nitro: create voucher on existing payment channel with new balance // Move funds into the bond account module. err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, bondtypes.ModuleName, coins) if err != nil { @@ -287,12 +312,12 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre return &bond, nil } -func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) { +func (k Keeper) WithdrawBond(ctx context.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) { if has, err := k.HasBond(ctx, id); !has { if err != nil { return nil, err } - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found") } bond, err := k.GetBondById(ctx, id) @@ -300,15 +325,20 @@ func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAdd return nil, err } - if bond.Owner != ownerAddress.String() { - return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + addrStr, err := k.addressCodec.BytesToString(ownerAddress) + if err != nil { + return nil, err + } + if bond.Owner != addrStr { + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch") } updatedBalance, isNeg := bond.Balance.SafeSub(coins...) if isNeg { - return nil, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient bond balance.") + return nil, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient bond balance") } + // Nitro: create voucher with lower balance (?) // Move funds from the bond into the account. err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, bondtypes.ModuleName, ownerAddress, coins) if err != nil { @@ -325,12 +355,12 @@ func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAdd return &bond, nil } -func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress) (*bondtypes.Bond, error) { +func (k Keeper) CancelBond(ctx context.Context, id string, ownerAddress sdk.AccAddress) (*bondtypes.Bond, error) { if has, err := k.HasBond(ctx, id); !has { if err != nil { return nil, err } - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found") } bond, err := k.GetBondById(ctx, id) @@ -338,17 +368,22 @@ func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre return nil, err } - if bond.Owner != ownerAddress.String() { - return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + addrStr, err := k.addressCodec.BytesToString(ownerAddress) + if err != nil { + return nil, err + } + if bond.Owner != addrStr { + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch") } // Check if bond is used in other modules. for _, usageKeeper := range k.usageKeepers { if usageKeeper.UsesBond(ctx, id) { - return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprintf("Bond in use by the '%s' module.", usageKeeper.ModuleName())) + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprintf("Bond in use by the '%s' module", usageKeeper.ModuleName())) } } + // Nitro: close payment channel, remaining funds just not sent // Move funds from the bond into the account. err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, bondtypes.ModuleName, ownerAddress, bond.Balance) if err != nil { @@ -364,13 +399,8 @@ func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre return &bond, nil } -// GetAuthority returns the x/bond module's authority. -func (k Keeper) GetAuthority() string { - return k.authority -} - // GetParams gets the bond module's parameters. -func (k Keeper) GetParams(ctx sdk.Context) (*bondtypes.Params, error) { +func (k Keeper) GetParams(ctx context.Context) (*bondtypes.Params, error) { params, err := k.Params.Get(ctx) if err != nil { return nil, err @@ -380,11 +410,11 @@ func (k Keeper) GetParams(ctx sdk.Context) (*bondtypes.Params, error) { } // SetParams sets the x/bond module parameters. -func (k Keeper) SetParams(ctx sdk.Context, params bondtypes.Params) error { +func (k Keeper) SetParams(ctx context.Context, params bondtypes.Params) error { return k.Params.Set(ctx, params) } -func (k Keeper) getMaxBondAmount(ctx sdk.Context) (sdk.Coins, error) { +func (k Keeper) getMaxBondAmount(ctx context.Context) (sdk.Coins, error) { params, err := k.GetParams(ctx) if err != nil { return nil, err @@ -394,32 +424,25 @@ func (k Keeper) getMaxBondAmount(ctx sdk.Context) (sdk.Coins, error) { return sdk.NewCoins(maxBondAmount), nil } -// TransferCoinsToModuleAccount moves funds from the bonds module account to another module account. -func (k Keeper) TransferCoinsToModuleAccount(ctx sdk.Context, id, moduleAccount string, coins sdk.Coins) error { - if has, err := k.HasBond(ctx, id); !has { - if err != nil { - return err - } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") - } - +// TransferRentToModuleAccount sends rent from a bond to a module account. +func (k Keeper) TransferRentToModuleAccount(ctx context.Context, id, moduleAccount string, rent sdk.Coins) error { bond, err := k.GetBondById(ctx, id) if err != nil { return err } // Deduct rent from bond. - updatedBalance, isNeg := bond.Balance.SafeSub(coins...) - + updatedBalance, isNeg := bond.Balance.SafeSub(rent...) if isNeg { // Check if bond has sufficient funds. - return errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds.") + return errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds") } + // Nitro: payment on module-module channel // Move funds from bond module to record rent module. - err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, bondtypes.ModuleName, moduleAccount, coins) + err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, bondtypes.ModuleName, moduleAccount, rent) if err != nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Error transferring funds.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Error transferring funds") } // Update bond balance. diff --git a/x/bond/keeper/msg_server.go b/x/bond/keeper/msg_server.go index 5527f7f3..e2df443f 100644 --- a/x/bond/keeper/msg_server.go +++ b/x/bond/keeper/msg_server.go @@ -3,71 +3,75 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" + "cosmossdk.io/core/event" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "git.vdb.to/cerc-io/laconicd/utils" "git.vdb.to/cerc-io/laconicd/x/bond" ) -var _ bond.MsgServer = msgServer{} - type msgServer struct { k *Keeper } // NewMsgServerImpl returns an implementation of the module MsgServer interface. -func NewMsgServerImpl(keeper *Keeper) bond.MsgServer { - return &msgServer{k: keeper} +func NewMsgServerImpl(keeper *Keeper) msgServer { + return msgServer{k: keeper} } -func (ms msgServer) CreateBond(c context.Context, msg *bond.MsgCreateBond) (*bond.MsgCreateBondResponse, error) { +func (ms msgServer) CreateBond(ctx context.Context, msg *bond.MsgCreateBond) (*bond.MsgCreateBondResponse, error) { + ms.k.logger.Debug("handlers.CreateBond", "msg", msg) + if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.GasService) + defer logGas(ms.k.logger, "CreateBond") - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + signerAddress, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } - resp, err := ms.k.CreateBond(ctx, signerAddress, msg.Coins) if err != nil { return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - bond.EventTypeCreateBond, - sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, bond.AttributeValueCategory), - sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "CreateBond") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + bond.EventTypeCreateBond, + event.Attribute{Key: bond.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: sdk.AttributeKeyAmount, Value: msg.Coins.String()}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", bond.EventTypeCreateBond) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: bond.AttributeValueCategory}, + event.Attribute{Key: bond.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &bond.MsgCreateBondResponse{Id: resp.Id}, nil } // RefillBond implements bond.MsgServer. -func (ms msgServer) RefillBond(c context.Context, msg *bond.MsgRefillBond) (*bond.MsgRefillBondResponse, error) { +func (ms msgServer) RefillBond(ctx context.Context, msg *bond.MsgRefillBond) (*bond.MsgRefillBondResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.GasService) + defer logGas(ms.k.logger, "RefillBond") - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + signerAddress, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -77,35 +81,39 @@ func (ms msgServer) RefillBond(c context.Context, msg *bond.MsgRefillBond) (*bon return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - bond.EventTypeRefillBond, - sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(bond.AttributeKeyBondId, msg.Id), - sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, bond.AttributeValueCategory), - sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "RefillBond") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + bond.EventTypeRefillBond, + event.Attribute{Key: bond.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: bond.AttributeKeyBondId, Value: msg.Id}, + event.Attribute{Key: sdk.AttributeKeyAmount, Value: msg.Coins.String()}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", bond.EventTypeRefillBond) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: bond.AttributeValueCategory}, + event.Attribute{Key: bond.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &bond.MsgRefillBondResponse{}, nil } // WithdrawBond implements bond.MsgServer. -func (ms msgServer) WithdrawBond(c context.Context, msg *bond.MsgWithdrawBond) (*bond.MsgWithdrawBondResponse, error) { +func (ms msgServer) WithdrawBond(ctx context.Context, msg *bond.MsgWithdrawBond) (*bond.MsgWithdrawBondResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.GasService) + defer logGas(ms.k.logger, "WithdrawBond") - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + signerAddress, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -115,35 +123,39 @@ func (ms msgServer) WithdrawBond(c context.Context, msg *bond.MsgWithdrawBond) ( return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - bond.EventTypeWithdrawBond, - sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(bond.AttributeKeyBondId, msg.Id), - sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, bond.AttributeValueCategory), - sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "WithdrawBond") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + bond.EventTypeWithdrawBond, + event.Attribute{Key: bond.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: bond.AttributeKeyBondId, Value: msg.Id}, + event.Attribute{Key: sdk.AttributeKeyAmount, Value: msg.Coins.String()}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", bond.EventTypeWithdrawBond) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: bond.AttributeValueCategory}, + event.Attribute{Key: bond.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &bond.MsgWithdrawBondResponse{}, nil } // CancelBond implements bond.MsgServer. -func (ms msgServer) CancelBond(c context.Context, msg *bond.MsgCancelBond) (*bond.MsgCancelBondResponse, error) { +func (ms msgServer) CancelBond(ctx context.Context, msg *bond.MsgCancelBond) (*bond.MsgCancelBondResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.GasService) + defer logGas(ms.k.logger, "CancelBond") - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + signerAddress, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -153,36 +165,37 @@ func (ms msgServer) CancelBond(c context.Context, msg *bond.MsgCancelBond) (*bon return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - bond.EventTypeCancelBond, - sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(bond.AttributeKeyBondId, msg.Id), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, bond.AttributeValueCategory), - sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "CancelBond") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + bond.EventTypeCancelBond, + event.Attribute{Key: bond.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: bond.AttributeKeyBondId, Value: msg.Id}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", bond.EventTypeCancelBond) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: bond.AttributeValueCategory}, + event.Attribute{Key: bond.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &bond.MsgCancelBondResponse{}, nil } // UpdateParams defines a method to perform updation of module params. -func (ms msgServer) UpdateParams(c context.Context, msg *bond.MsgUpdateParams) (*bond.MsgUpdateParamsResponse, error) { - if ms.k.authority != msg.Authority { - return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority) +func (ms msgServer) UpdateParams(ctx context.Context, msg *bond.MsgUpdateParams) (*bond.MsgUpdateParamsResponse, error) { + if err := utils.CheckAuthorityAddress(ms.k.addressCodec, ms.k.authority, msg.Authority); err != nil { + return nil, err } if err := msg.Params.Validate(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - if err := ms.k.SetParams(ctx, msg.Params); err != nil { return nil, err } diff --git a/x/bond/keeper/query_server.go b/x/bond/keeper/query_server.go index eec448e1..c6aecef4 100644 --- a/x/bond/keeper/query_server.go +++ b/x/bond/keeper/query_server.go @@ -4,27 +4,22 @@ import ( "context" errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" bondtypes "git.vdb.to/cerc-io/laconicd/x/bond" ) -var _ bondtypes.QueryServer = queryServer{} - -type queryServer struct { +type queryHandlers struct { k *Keeper } // NewQueryServerImpl returns an implementation of the module QueryServer. func NewQueryServerImpl(k *Keeper) bondtypes.QueryServer { - return queryServer{k} + return queryHandlers{k} } // Params implements bond.QueryServer. -func (qs queryServer) Params(c context.Context, _ *bondtypes.QueryParamsRequest) (*bondtypes.QueryParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryHandlers) Params(ctx context.Context, _ *bondtypes.QueryParamsRequest) (*bondtypes.QueryParamsResponse, error) { params, err := qs.k.GetParams(ctx) if err != nil { return nil, err @@ -34,9 +29,7 @@ func (qs queryServer) Params(c context.Context, _ *bondtypes.QueryParamsRequest) } // Bonds implements bond.QueryServer. -func (qs queryServer) Bonds(c context.Context, _ *bondtypes.QueryBondsRequest) (*bondtypes.QueryBondsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryHandlers) Bonds(ctx context.Context, _ *bondtypes.QueryBondsRequest) (*bondtypes.QueryBondsResponse, error) { resp, err := qs.k.ListBonds(ctx) if err != nil { return nil, err @@ -46,9 +39,7 @@ func (qs queryServer) Bonds(c context.Context, _ *bondtypes.QueryBondsRequest) ( } // GetBondById implements bond.QueryServer. -func (qs queryServer) GetBondById(c context.Context, req *bondtypes.QueryGetBondByIdRequest) (*bondtypes.QueryGetBondByIdResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryHandlers) GetBondById(ctx context.Context, req *bondtypes.QueryGetBondByIdRequest) (*bondtypes.QueryGetBondByIdResponse, error) { bondId := req.GetId() if len(bondId) == 0 { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "bond id required") @@ -63,12 +54,10 @@ func (qs queryServer) GetBondById(c context.Context, req *bondtypes.QueryGetBond } // GetBondsByOwner implements bond.QueryServer. -func (qs queryServer) GetBondsByOwner( - c context.Context, +func (qs queryHandlers) GetBondsByOwner( + ctx context.Context, req *bondtypes.QueryGetBondsByOwnerRequest, ) (*bondtypes.QueryGetBondsByOwnerResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - owner := req.GetOwner() if len(owner) == 0 { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, @@ -85,11 +74,10 @@ func (qs queryServer) GetBondsByOwner( } // GetBondModuleBalance implements bond.QueryServer. -func (qs queryServer) GetBondModuleBalance( - c context.Context, +func (qs queryHandlers) GetBondModuleBalance( + ctx context.Context, _ *bondtypes.QueryGetBondModuleBalanceRequest, ) (*bondtypes.QueryGetBondModuleBalanceResponse, error) { - ctx := sdk.UnwrapSDKContext(c) balances := qs.k.GetBondModuleBalances(ctx) return &bondtypes.QueryGetBondModuleBalanceResponse{ diff --git a/x/bond/keys.go b/x/bond/keys.go index 60c178a3..223ff96d 100644 --- a/x/bond/keys.go +++ b/x/bond/keys.go @@ -1,6 +1,9 @@ package bond -import "cosmossdk.io/collections" +import ( + "cosmossdk.io/collections" + "github.com/cosmos/cosmos-sdk/types/address" +) const ( ModuleName = "bond" @@ -16,3 +19,6 @@ var ( BondsPrefix = collections.NewPrefix(1) BondOwnerIndexPrefix = collections.NewPrefix(2) ) + +// ModuleAccountAddress defines the x/bond module address. +var ModuleAccountAddress = address.Module(ModuleName) diff --git a/x/bond/module/autocli.go b/x/bond/module/autocli.go index 391bf2e6..5ad9fac2 100644 --- a/x/bond/module/autocli.go +++ b/x/bond/module/autocli.go @@ -29,7 +29,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetBondById", - Use: "get [bond-id]", + Use: "get ", Short: "Get bond info by bond id", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "id"}, @@ -37,7 +37,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetBondsByOwner", - Use: "by-owner [owner-address]", + Use: "by-owner ", Short: "Get bonds list by owner address", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "owner"}, @@ -56,7 +56,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "CreateBond", - Use: "create [amount]", + Use: "create ", Short: "Create bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "coins"}, @@ -64,7 +64,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "RefillBond", - Use: "refill [bond-id] [amount]", + Use: "refill ", Short: "Refill bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "id"}, @@ -73,7 +73,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "WithdrawBond", - Use: "withdraw [bond-id] [amount]", + Use: "withdraw ", Short: "Withdraw amount from bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "id"}, @@ -82,7 +82,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "CancelBond", - Use: "cancel [bond-id]", + Use: "cancel ", Short: "Cancel bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "id"}, diff --git a/x/bond/module/depinject.go b/x/bond/module/depinject.go index 1868f376..38763c76 100644 --- a/x/bond/module/depinject.go +++ b/x/bond/module/depinject.go @@ -2,16 +2,19 @@ package module import ( "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" + "cosmossdk.io/core/event" + "cosmossdk.io/core/gas" + store "cosmossdk.io/core/store" "cosmossdk.io/depinject" - + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/bond/module/v1" + "git.vdb.to/cerc-io/laconicd/utils" "git.vdb.to/cerc-io/laconicd/x/bond" "git.vdb.to/cerc-io/laconicd/x/bond/keeper" ) @@ -25,22 +28,26 @@ func (am AppModule) IsOnePerModuleType() {} func (am AppModule) IsAppModule() {} func init() { - appmodule.Register( + appconfig.RegisterModule( &modulev1.Module{}, - appmodule.Provide(ProvideModule), - appmodule.Invoke(InvokeSetBondHooks), + appconfig.Provide(ProvideModule), + appconfig.Invoke(InvokeSetBondHooks), ) } type ModuleInputs struct { depinject.In + StoreService store.KVStoreService + EventService event.Service + GasService gas.Service Config *modulev1.Module Cdc codec.Codec - StoreService store.KVStoreService AccountKeeper auth.AccountKeeper BankKeeper bank.Keeper + + Logger log.Logger } type ModuleOutputs struct { @@ -52,12 +59,8 @@ type ModuleOutputs struct { func ProvideModule(in ModuleInputs) ModuleOutputs { // default to governance authority if not provided - authority := authtypes.NewModuleAddress(govtypes.ModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper, in.BankKeeper, authority.String()) + authority := utils.AddressOrModuleAddress(in.Config.Authority, govtypes.ModuleName) + k := keeper.NewKeeper(in.Cdc, in.StoreService, in.EventService, in.GasService, in.AccountKeeper, in.BankKeeper, authority, in.Logger) m := NewAppModule(in.Cdc, k) return ModuleOutputs{Module: m, Keeper: k} diff --git a/x/bond/module/module.go b/x/bond/module/module.go index a66ccd1c..7fb30614 100644 --- a/x/bond/module/module.go +++ b/x/bond/module/module.go @@ -5,12 +5,14 @@ import ( "encoding/json" "fmt" - "cosmossdk.io/core/appmodule" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" + // "google.golang.org/grpc" + + appmodule "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + registry "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -20,11 +22,11 @@ import ( var ( _ module.AppModuleBasic = AppModule{} - _ appmodule.AppModule = AppModule{} _ module.HasGenesis = AppModule{} - _ module.HasServices = AppModule{} _ module.HasConsensusVersion = AppModule{} - _ module.HasInvariants = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} ) // ConsensusVersion defines the current module consensus version @@ -43,18 +45,12 @@ func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule { } } -func NewAppModuleBasic(m AppModule) module.AppModuleBasic { - return module.CoreAppModuleBasicAdaptor(m.Name(), m) -} - -// module.AppModuleBasic +// module.AppModule // Name returns the bond module's name. func (AppModule) Name() string { return bond.ModuleName } -// RegisterLegacyAminoCodec registers the bond module's types on the LegacyAmino codec. -// New modules do not need to support Amino. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +// module.HasGRPCGateway // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bond module. func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { @@ -63,25 +59,29 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } } +// appmodule.HasRegisterInterfaces + // RegisterInterfaces registers interfaces and implementations of the bond module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistry) { bond.RegisterInterfaces(registry) } +// appmodule.HasConsensusVersion + // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } -// module.HasGenesis +// appmodule.HasGenesis // DefaultGenesis returns default genesis state as raw bytes for the module. -func (AppModule) DefaultGenesis(jsonCodec codec.JSONCodec) json.RawMessage { - return jsonCodec.MustMarshalJSON(bond.DefaultGenesisState()) +func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(bond.DefaultGenesisState()) } -// ValidateGenesis performs genesis state validation for the module. -func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error { +// ValidateGenesis performs genesis state validation for the bond module. +func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var data bond.GenesisState - if err := cdc.UnmarshalJSON(message, &data); err != nil { + if err := cdc.UnmarshalJSON(bz, &data); err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", bond.ModuleName, err) } @@ -99,12 +99,12 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. } } -// ExportGenesis returns the exported genesis state as raw bytes for the circuit +// ExportGenesis returns the exported genesis state as raw bytes for the bond // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { gs, err := am.keeper.ExportGenesis(ctx) if err != nil { - panic(fmt.Sprintf("failed to export %s genesis state: %v", bond.ModuleName, err)) + panic(fmt.Errorf("failed to export %s genesis state: %w", bond.ModuleName, err)) } return cdc.MustMarshalJSON(gs) @@ -112,14 +112,19 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // module.HasServices +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { // Register servers bond.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) bond.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) + + // Register in place module state migration migrations + // m := keeper.NewMigrator(am.keeper) + // if err := cfg.RegisterMigration(bond.ModuleName, 1, m.Migrate1to2); err != nil { + // panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", bond.ModuleName, err)) + // } } -// module.HasInvariants - -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - keeper.RegisterInvariants(ir, am.keeper) -} +// RegisterLegacyAminoCodec registers the bond module's types on the LegacyAmino codec. +// New modules do not need to support Amino. +func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} diff --git a/x/bond/msgs.go b/x/bond/msgs.go index f33c9209..1eaf7c91 100644 --- a/x/bond/msgs.go +++ b/x/bond/msgs.go @@ -4,15 +4,21 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "git.vdb.to/cerc-io/laconicd/utils" ) var _ sdk.Msg = &MsgCreateBond{} // NewMsgCreateBond is the constructor function for MsgCreateBond. func NewMsgCreateBond(coins sdk.Coins, signer sdk.AccAddress) MsgCreateBond { + signerStr, err := utils.NewAddressCodec().BytesToString(signer) + if err != nil { + panic(err) + } return MsgCreateBond{ Coins: coins, - Signer: signer.String(), + Signer: signerStr, } } @@ -21,7 +27,7 @@ func (msg MsgCreateBond) ValidateBasic() error { return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer) } if len(msg.Coins) == 0 || !msg.Coins.IsValid() { - return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.") + return sdkerrors.ErrInvalidCoins } return nil } @@ -34,7 +40,7 @@ func (msg MsgRefillBond) ValidateBasic() error { return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer) } if len(msg.Coins) == 0 || !msg.Coins.IsValid() { - return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.") + return sdkerrors.ErrInvalidCoins } return nil } @@ -47,7 +53,7 @@ func (msg MsgWithdrawBond) ValidateBasic() error { return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer) } if len(msg.Coins) == 0 || !msg.Coins.IsValid() { - return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.") + return sdkerrors.ErrInvalidCoins } return nil } diff --git a/x/bond/query.pb.go b/x/bond/query.pb.go index 4f5daaa6..6f246700 100644 --- a/x/bond/query.pb.go +++ b/x/bond/query.pb.go @@ -769,6 +769,7 @@ func _Query_GetBondModuleBalance_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cerc.bond.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/bond/tx.pb.go b/x/bond/tx.pb.go index 26915d04..312387ec 100644 --- a/x/bond/tx.pb.go +++ b/x/bond/tx.pb.go @@ -781,6 +781,7 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cerc.bond.v1.Msg", HandlerType: (*MsgServer)(nil), diff --git a/x/nitro/client/cli/query.go b/x/nitro/client/cli/query.go new file mode 100644 index 00000000..f0d461b9 --- /dev/null +++ b/x/nitro/client/cli/query.go @@ -0,0 +1,29 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + + "git.vdb.to/cerc-io/laconicd/server/nitro" + types "git.vdb.to/cerc-io/laconicd/x/nitro/types" +) + +// NewQueryCmd returns a root CLI handler for all x/nitro query commands. +func NewQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the auth module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + nitro.GetChannelCmd(), + nitro.ListChannelsCmd(), + nitro.ListPaymentChannelsCmd(), + nitro.IdentityCmd(), + ) + + return cmd +} diff --git a/x/nitro/client/cli/tx.go b/x/nitro/client/cli/tx.go new file mode 100644 index 00000000..a40a9d15 --- /dev/null +++ b/x/nitro/client/cli/tx.go @@ -0,0 +1,30 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + + "git.vdb.to/cerc-io/laconicd/server/nitro" + "git.vdb.to/cerc-io/laconicd/x/nitro/types" +) + +// NewTxCmd returns a root CLI command handler for all x/nitro transaction commands. +func NewTxCmd() *cobra.Command { + nitroTxCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Nitro transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + nitroTxCmd.AddCommand( + nitro.OpenChannelCmd(), + nitro.CloseChannelCmd(), + nitro.OpenPaymentChannelCmd(), + nitro.ClosePaymentChannelCmd(), + nitro.PayCmd(), + ) + + return nitroTxCmd +} diff --git a/x/nitro/codec.go b/x/nitro/codec.go new file mode 100644 index 00000000..a3665eb2 --- /dev/null +++ b/x/nitro/codec.go @@ -0,0 +1,21 @@ +package nitro + +import ( + registry "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + + "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1" +) + +// RegisterInterfaces registers the interfaces types with the interface registry. +func RegisterInterfaces(registry registry.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &v1.MsgOpenChannel{}, + &v1.MsgCloseChannel{}, + &v1.MsgCreatePaymentChannel{}, + &v1.MsgClosePaymentChannel{}, + &v1.MsgPay{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &v1.Msg_serviceDesc) +} diff --git a/x/nitro/keeper/genesis.go b/x/nitro/keeper/genesis.go new file mode 100644 index 00000000..98b53d49 --- /dev/null +++ b/x/nitro/keeper/genesis.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + "git.vdb.to/cerc-io/laconicd/x/nitro/types" +) + +// TODO + +// InitGenesis initializes the module state from a genesis state. +func (k *Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error { + return nil +} + +// ExportGenesis exports the module state to a genesis state. +func (k *Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) { + return &types.GenesisState{}, nil +} diff --git a/x/nitro/keeper/keeper.go b/x/nitro/keeper/keeper.go new file mode 100644 index 00000000..7ab27881 --- /dev/null +++ b/x/nitro/keeper/keeper.go @@ -0,0 +1,140 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/collections" + "cosmossdk.io/core/address" + "cosmossdk.io/core/event" + store "cosmossdk.io/core/store" + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/codec" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "git.vdb.to/cerc-io/laconicd/x/nitro/types" + "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1" +) + +type Keeper struct { + addressCodec address.Codec + logger log.Logger + eventService event.Service + + // use interface from bank module + accountKeeper banktypes.AccountKeeper + // TODO: the way to do this is probably the service + context key pattern + // distsigManager *distsig.Manager + + LedgerChannels collections.Map[string, v1.MsgOpenChannel] + PaymentChannels collections.Map[string, v1.PaymentChannel] +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeService store.KVStoreService, + eventService event.Service, + accountKeeper banktypes.AccountKeeper, + logger log.Logger, +) Keeper { + sb := collections.NewSchemaBuilder(storeService) + return Keeper{ + addressCodec: accountKeeper.AddressCodec(), + eventService: eventService, + logger: logger.With(log.ModuleKey, "x/"+types.ModuleName), + accountKeeper: accountKeeper, + + LedgerChannels: collections.NewMap( + sb, types.ChannelProposalsPrefix, "channel_proposals", + collections.StringKey, codec.CollValue[v1.MsgOpenChannel](cdc), + ), + PaymentChannels: collections.NewMap( + sb, types.PaymentChannelsPrefix, "payment_channels", + collections.StringKey, codec.CollValue[v1.PaymentChannel](cdc), + ), + } +} + +func (k Keeper) OpenChannel(ctx context.Context, req *v1.MsgOpenChannel) error { + k.logger.Info("opening channel", "from", req.NitroAddress) + + k.logger.Info("setting open channel", "req", *req) + return k.LedgerChannels.Set(ctx, req.ChannelId, *req) +} + +func (k Keeper) CloseChannel(ctx context.Context, req *v1.MsgCloseChannel) error { + k.logger.Info("closing channel", "channel_id", req.ChannelId, "is_challenge", req.IsChallenge) + + // Verify the channel exists + _, err := k.LedgerChannels.Get(ctx, req.ChannelId) + if err != nil { + return err + } + + // Remove the channel from storage upon close request + // In a full implementation, we might track close requests separately + // and only remove after actual nitro objective completion + k.logger.Info("removing closed channel", "channel_id", req.ChannelId) + return k.LedgerChannels.Remove(ctx, req.ChannelId) +} + +func (k Keeper) CreatePaymentChannel(ctx context.Context, req *v1.MsgCreatePaymentChannel) error { + k.logger.Info("creating payment channel", + "from", req.NitroAddress, + "counterparty", req.Counterparty, + "intermediaries", req.Intermediaries, + "challenge_duration", req.ChallengeDuration, + "funds", req.Funds, + "channel_id", req.ChannelId) + + // Store the payment channel + paymentChannel := &v1.PaymentChannel{ + ChannelId: req.ChannelId, + } + + return k.PaymentChannels.Set(ctx, req.ChannelId, *paymentChannel) +} + +func (k Keeper) ClosePaymentChannel(ctx context.Context, req *v1.MsgClosePaymentChannel) error { + k.logger.Info("closing payment channel", "channel_id", req.ChannelId) + + // Verify the payment channel exists + _, err := k.PaymentChannels.Get(ctx, req.ChannelId) + if err != nil { + return err + } + + // Remove the payment channel from storage upon close request + k.logger.Info("removing closed payment channel", "channel_id", req.ChannelId) + return k.PaymentChannels.Remove(ctx, req.ChannelId) +} + +func (k Keeper) Pay(ctx context.Context, req *v1.MsgPay) error { + k.logger.Info("processing payment", + "channel_id", req.ChannelId, + "amount", req.Amount) + + if req.Amount.Amount.IsZero() || req.Amount.Amount.IsNegative() { + return fmt.Errorf("payment amount must be positive, got %s", req.Amount.Amount.String()) + } + + // Verify the payment channel exists + _, err := k.PaymentChannels.Get(ctx, req.ChannelId) + if err != nil { + return fmt.Errorf("payment channel not found: %w", err) + } + + // No-op implementation for now + // In a full implementation, this would: + // - Verify the payment channel has sufficient balance + // - Verify the requester has permission to make payments from this channel + // - Create and send the payment voucher through the nitro node + // - Update channel state/balances + // - Emit payment events for tracking + + k.logger.Info("payment processed successfully", + "channel_id", req.ChannelId, + "amount", req.Amount.String()) + + return nil +} diff --git a/x/nitro/keeper/msg_server.go b/x/nitro/keeper/msg_server.go new file mode 100644 index 00000000..95be5a64 --- /dev/null +++ b/x/nitro/keeper/msg_server.go @@ -0,0 +1,111 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/core/event" + "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1" +) + +type msgServer struct { + k Keeper +} + +func NewMsgServer(k Keeper) *msgServer { + return &msgServer{k} +} + +func (m msgServer) OpenChannel(ctx context.Context, req *v1.MsgOpenChannel) (*v1.MsgOpenChannelResponse, error) { + if err := m.k.OpenChannel(ctx, req); err != nil { + return nil, err + } + eventManager := m.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + "open_channel", + event.Attribute{Key: "signer", Value: req.Signer}, + event.Attribute{Key: "funds", Value: req.Funds.String()}, + event.Attribute{Key: "nitro_address", Value: req.NitroAddress}, + event.Attribute{Key: "counterparty", Value: req.Counterparty}, + event.Attribute{Key: "channel_id", Value: req.ChannelId}, + ); err != nil { + return nil, err + } + + return &v1.MsgOpenChannelResponse{}, nil +} + +func (m msgServer) CloseChannel(ctx context.Context, req *v1.MsgCloseChannel) (*v1.MsgCloseChannelResponse, error) { + if err := m.k.CloseChannel(ctx, req); err != nil { + return nil, err + } + eventManager := m.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + "close_channel", + event.Attribute{Key: "signer", Value: req.Signer}, + event.Attribute{Key: "channel_id", Value: req.ChannelId}, + event.Attribute{Key: "is_challenge", Value: fmt.Sprintf("%t", req.IsChallenge)}, + ); err != nil { + return nil, err + } + + return &v1.MsgCloseChannelResponse{}, nil +} + +func (m msgServer) CreatePaymentChannel(ctx context.Context, req *v1.MsgCreatePaymentChannel) (*v1.MsgCreatePaymentChannelResponse, error) { + if err := m.k.CreatePaymentChannel(ctx, req); err != nil { + return nil, err + } + eventManager := m.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + "create_payment_channel", + event.Attribute{Key: "signer", Value: req.Signer}, + event.Attribute{Key: "intermediaries", Value: fmt.Sprintf("%v", req.Intermediaries)}, + event.Attribute{Key: "counterparty", Value: req.Counterparty}, + event.Attribute{Key: "challenge_duration", Value: fmt.Sprintf("%d", req.ChallengeDuration)}, + event.Attribute{Key: "funds", Value: req.Funds.String()}, + event.Attribute{Key: "channel_id", Value: req.ChannelId}, + ); err != nil { + return nil, err + } + + return &v1.MsgCreatePaymentChannelResponse{}, nil +} + +func (m msgServer) ClosePaymentChannel(ctx context.Context, req *v1.MsgClosePaymentChannel) (*v1.MsgClosePaymentChannelResponse, error) { + if err := m.k.ClosePaymentChannel(ctx, req); err != nil { + return nil, err + } + eventManager := m.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + "close_payment_channel", + event.Attribute{Key: "signer", Value: req.Signer}, + event.Attribute{Key: "channel_id", Value: req.ChannelId}, + ); err != nil { + return nil, err + } + + return &v1.MsgClosePaymentChannelResponse{}, nil +} + +func (m msgServer) Pay(ctx context.Context, req *v1.MsgPay) (*v1.MsgPayResponse, error) { + if err := m.k.Pay(ctx, req); err != nil { + return nil, err + } + eventManager := m.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + "pay", + event.Attribute{Key: "signer", Value: req.Signer}, + event.Attribute{Key: "channel_id", Value: req.ChannelId}, + event.Attribute{Key: "amount", Value: req.Amount.String()}, + ); err != nil { + return nil, err + } + + return &v1.MsgPayResponse{}, nil +} diff --git a/x/nitro/keeper/query_server.go b/x/nitro/keeper/query_server.go new file mode 100644 index 00000000..6a00b8f5 --- /dev/null +++ b/x/nitro/keeper/query_server.go @@ -0,0 +1,11 @@ +package keeper + +import types "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1" + +type queryHandlers struct { + k Keeper +} + +func NewQueryServer(k Keeper) types.QueryServer { + return queryHandlers{k} +} diff --git a/x/nitro/module/depinject.go b/x/nitro/module/depinject.go new file mode 100644 index 00000000..ba0fddbf --- /dev/null +++ b/x/nitro/module/depinject.go @@ -0,0 +1,58 @@ +package module + +import ( + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/event" + store "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/codec" + auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" + + modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/nitro/module/v1" + "git.vdb.to/cerc-io/laconicd/x/nitro/keeper" +) + +var _ appmodule.AppModule = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + StoreService store.KVStoreService + EventService event.Service + Config *modulev1.Module + Cdc codec.Codec + Logger log.Logger + + AccountKeeper auth.AccountKeeper +} + +type ModuleOutputs struct { + depinject.Out + + Keeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // // default to governance authority if not provided + // authority := utils.AddressOrModuleAddress(in.Config.Authority, govtypes.ModuleName) + k := keeper.NewKeeper(in.Cdc, in.StoreService, in.EventService, in.AccountKeeper, in.Logger) + m := NewAppModule(in.Cdc, k) + + return ModuleOutputs{Module: m, Keeper: k} +} diff --git a/x/nitro/module/module.go b/x/nitro/module/module.go new file mode 100644 index 00000000..cffbc90c --- /dev/null +++ b/x/nitro/module/module.go @@ -0,0 +1,143 @@ +package module + +import ( + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + "git.vdb.to/cerc-io/laconicd/x/bond" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + registry "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "git.vdb.to/cerc-io/laconicd/x/nitro" + "git.vdb.to/cerc-io/laconicd/x/nitro/client/cli" + "git.vdb.to/cerc-io/laconicd/x/nitro/keeper" + "git.vdb.to/cerc-io/laconicd/x/nitro/types" + v1 "git.vdb.to/cerc-io/laconicd/x/nitro/types/v1" +) + +var ( + _ module.AppModuleBasic = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasConsensusVersion = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} +) + +// ConsensusVersion defines the current module consensus version +const ConsensusVersion = 1 + +type AppModule struct { + cdc codec.Codec + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + cdc: cdc, + keeper: keeper, + } +} + +// module.AppModule + +// Name returns the bond module's name. +func (AppModule) Name() string { return types.ModuleName } + +// module.HasGRPCGateway + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bond module. +func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { + // TODO + + // if err := RegisterQueryHandlerClient(context.Background(), mux, NewQueryClient(clientCtx)); err != nil { + // panic(err) + // } +} + +// appmodule.HasRegisterInterfaces + +// RegisterInterfaces registers interfaces and implementations of the bond module. +func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistry) { + nitro.RegisterInterfaces(registry) +} + +// appmodule.HasConsensusVersion + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } + +// appmodule.HasGenesis + +// DefaultGenesis returns default genesis state as raw bytes for the module. +func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(&types.GenesisState{}) +} + +// ValidateGenesis performs genesis state validation for the bond module. +func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", bond.ModuleName, err) + } + + return data.Validate() +} + +// InitGenesis performs genesis initialization for the bond module. +// It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + + if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil { + panic(fmt.Sprintf("failed to initialize %s genesis state: %v", bond.ModuleName, err)) + } +} + +// ExportGenesis returns the exported genesis state as raw bytes for the bond +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs, err := am.keeper.ExportGenesis(ctx) + if err != nil { + panic(fmt.Errorf("failed to export %s genesis state: %w", bond.ModuleName, err)) + } + + return cdc.MustMarshalJSON(gs) +} + +// module.HasServices + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + // Register servers + v1.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) + v1.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) + + // Register in place module state migration migrations + // m := keeper.NewMigrator(am.keeper) + // if err := cfg.RegisterMigration(bond.ModuleName, 1, m.Migrate1to2); err != nil { + // panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", bond.ModuleName, err)) + // } +} + +// RegisterLegacyAminoCodec registers the bond module's types on the LegacyAmino codec. +// New modules do not need to support Amino. +func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// GetTxCmd returns the root tx command for the nitro module. +func (AppModule) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +// GetQueryCmd returns the root tx command for the nitro module. +func (AppModule) GetQueryCmd() *cobra.Command { + return cli.NewQueryCmd() +} diff --git a/x/nitro/types/genesis.go b/x/nitro/types/genesis.go new file mode 100644 index 00000000..1feb4dbe --- /dev/null +++ b/x/nitro/types/genesis.go @@ -0,0 +1,14 @@ +package types + +// TODO +type GenesisState struct{} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return "" } +func (*GenesisState) ProtoMessage() {} + +func (GenesisState) Validate() error { return nil } + +func DefaultGenesisState() *GenesisState { + return &GenesisState{} +} diff --git a/x/nitro/types/keys.go b/x/nitro/types/keys.go new file mode 100644 index 00000000..fad0c858 --- /dev/null +++ b/x/nitro/types/keys.go @@ -0,0 +1,18 @@ +package types + +import "cosmossdk.io/collections" + +const ( + ModuleName = "nitro" + + // StoreKey defines the primary module store key + StoreKey = ModuleName +) + +// Store prefixes +var ( + ParamsPrefix = collections.NewPrefix(0) + + ChannelProposalsPrefix = collections.NewPrefix(1) + PaymentChannelsPrefix = collections.NewPrefix(2) +) diff --git a/x/nitro/types/v1/nitro.pb.go b/x/nitro/types/v1/nitro.pb.go new file mode 100644 index 00000000..524171dc --- /dev/null +++ b/x/nitro/types/v1/nitro.pb.go @@ -0,0 +1,858 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cerc/nitro/v1/nitro.proto + +package v1 + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters of the nitro module. +type Params struct { + NitroAdjudicatorAddress []byte `protobuf:"bytes,1,opt,name=nitro_adjudicator_address,json=nitroAdjudicatorAddress,proto3" json:"nitro_adjudicator_address,omitempty"` + VirtualPaymentAppAddress []byte `protobuf:"bytes,2,opt,name=virtual_payment_app_address,json=virtualPaymentAppAddress,proto3" json:"virtual_payment_app_address,omitempty"` + ConsensusAppAddress []byte `protobuf:"bytes,3,opt,name=consensus_app_address,json=consensusAppAddress,proto3" json:"consensus_app_address,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_049df55f6ca5af66, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetNitroAdjudicatorAddress() []byte { + if m != nil { + return m.NitroAdjudicatorAddress + } + return nil +} + +func (m *Params) GetVirtualPaymentAppAddress() []byte { + if m != nil { + return m.VirtualPaymentAppAddress + } + return nil +} + +func (m *Params) GetConsensusAppAddress() []byte { + if m != nil { + return m.ConsensusAppAddress + } + return nil +} + +type PaymentChannel struct { + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *PaymentChannel) Reset() { *m = PaymentChannel{} } +func (m *PaymentChannel) String() string { return proto.CompactTextString(m) } +func (*PaymentChannel) ProtoMessage() {} +func (*PaymentChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_049df55f6ca5af66, []int{1} +} +func (m *PaymentChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PaymentChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PaymentChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PaymentChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_PaymentChannel.Merge(m, src) +} +func (m *PaymentChannel) XXX_Size() int { + return m.Size() +} +func (m *PaymentChannel) XXX_DiscardUnknown() { + xxx_messageInfo_PaymentChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_PaymentChannel proto.InternalMessageInfo + +func (m *PaymentChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +type Fund struct { + TokenAddress string `protobuf:"bytes,1,opt,name=token_address,json=tokenAddress,proto3" json:"token_address,omitempty"` + Amount cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` +} + +func (m *Fund) Reset() { *m = Fund{} } +func (m *Fund) String() string { return proto.CompactTextString(m) } +func (*Fund) ProtoMessage() {} +func (*Fund) Descriptor() ([]byte, []int) { + return fileDescriptor_049df55f6ca5af66, []int{2} +} +func (m *Fund) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Fund) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Fund.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Fund) XXX_Merge(src proto.Message) { + xxx_messageInfo_Fund.Merge(m, src) +} +func (m *Fund) XXX_Size() int { + return m.Size() +} +func (m *Fund) XXX_DiscardUnknown() { + xxx_messageInfo_Fund.DiscardUnknown(m) +} + +var xxx_messageInfo_Fund proto.InternalMessageInfo + +func (m *Fund) GetTokenAddress() string { + if m != nil { + return m.TokenAddress + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "cerc.nitro.v1.Params") + proto.RegisterType((*PaymentChannel)(nil), "cerc.nitro.v1.PaymentChannel") + proto.RegisterType((*Fund)(nil), "cerc.nitro.v1.Fund") +} + +func init() { proto.RegisterFile("cerc/nitro/v1/nitro.proto", fileDescriptor_049df55f6ca5af66) } + +var fileDescriptor_049df55f6ca5af66 = []byte{ + // 406 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x92, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0x13, 0x98, 0x2a, 0xc5, 0xda, 0x38, 0x04, 0xa6, 0xad, 0x03, 0x52, 0x54, 0x2e, 0x48, + 0xb0, 0x58, 0x85, 0xdb, 0x24, 0x0e, 0xdd, 0xa4, 0x49, 0xbd, 0x4d, 0x39, 0x72, 0x89, 0x3c, 0xdb, + 0xca, 0xcc, 0x12, 0x7f, 0x96, 0xed, 0x44, 0xec, 0x2d, 0x78, 0x04, 0x1e, 0x02, 0x89, 0x57, 0xe8, + 0xb1, 0xe2, 0x84, 0x38, 0x54, 0xa8, 0xbd, 0xf0, 0x18, 0x53, 0x6c, 0xb7, 0x55, 0x6f, 0x9f, 0xff, + 0xff, 0xff, 0xcf, 0xf9, 0xf2, 0x7d, 0x46, 0x43, 0xca, 0x35, 0xc5, 0x52, 0x58, 0x0d, 0xb8, 0x9b, + 0xf8, 0x22, 0x57, 0x1a, 0x2c, 0xa4, 0x47, 0xbd, 0x95, 0x7b, 0xa5, 0x9b, 0x9c, 0xbd, 0xaa, 0x00, + 0xaa, 0x9a, 0x63, 0xa2, 0x04, 0x26, 0x52, 0x82, 0x25, 0x56, 0x80, 0x34, 0x3e, 0x7c, 0x76, 0x42, + 0xc1, 0x34, 0x60, 0x70, 0x63, 0xaa, 0xfe, 0x9e, 0xc6, 0x54, 0xc1, 0x18, 0x7a, 0xa3, 0x74, 0x27, + 0xec, 0x0f, 0xc1, 0x7a, 0x51, 0x41, 0x05, 0x5e, 0xef, 0x2b, 0xaf, 0x8e, 0x7f, 0xc5, 0x68, 0x70, + 0x43, 0x34, 0x69, 0x4c, 0x7a, 0x81, 0x86, 0xee, 0xf3, 0x25, 0x61, 0x5f, 0x5b, 0x26, 0x28, 0xb1, + 0xa0, 0x4b, 0xc2, 0x98, 0xe6, 0xc6, 0x9c, 0xc6, 0x6f, 0xe2, 0x77, 0x87, 0xc5, 0x89, 0x0b, 0x4c, + 0x77, 0xfe, 0xd4, 0xdb, 0xe9, 0x67, 0xf4, 0xb2, 0x13, 0xda, 0xb6, 0xa4, 0x2e, 0x15, 0x79, 0x68, + 0xb8, 0xb4, 0x25, 0x51, 0x6a, 0x4b, 0x3f, 0x71, 0xf4, 0x69, 0x88, 0xdc, 0xf8, 0xc4, 0x54, 0xa9, + 0x0d, 0xfe, 0x11, 0x1d, 0x53, 0x90, 0x86, 0x4b, 0xd3, 0x9a, 0x3d, 0xf0, 0xa9, 0x03, 0x9f, 0x6f, + 0xcd, 0x1d, 0x33, 0xc6, 0xe8, 0x59, 0xb8, 0xe8, 0xea, 0x8e, 0x48, 0xc9, 0xeb, 0xf4, 0x35, 0x42, + 0xd4, 0x97, 0xa5, 0x60, 0xae, 0xe3, 0xa4, 0x48, 0x82, 0x32, 0x63, 0xe3, 0x0e, 0x1d, 0x5c, 0xb7, + 0x92, 0xa5, 0x6f, 0xd1, 0x91, 0x85, 0x7b, 0x2e, 0xf7, 0xfe, 0x2d, 0x29, 0x0e, 0x9d, 0xb8, 0xe9, + 0xe8, 0x0a, 0x0d, 0x48, 0x03, 0xad, 0xb4, 0xae, 0xf7, 0xe4, 0xf2, 0xfd, 0x7c, 0x39, 0x8a, 0xfe, + 0x2e, 0x47, 0xc7, 0x7e, 0xa6, 0x86, 0xdd, 0xe7, 0x02, 0x70, 0x43, 0xec, 0x5d, 0x3e, 0x93, 0xf6, + 0xf7, 0xcf, 0x73, 0x14, 0x86, 0x3d, 0x93, 0xb6, 0x08, 0xe8, 0xc5, 0xc1, 0xff, 0x1f, 0xa3, 0xf8, + 0xf2, 0x7a, 0xbe, 0xca, 0xe2, 0xc5, 0x2a, 0x8b, 0xff, 0xad, 0xb2, 0xf8, 0xfb, 0x3a, 0x8b, 0x16, + 0xeb, 0x2c, 0xfa, 0xb3, 0xce, 0xa2, 0x2f, 0x1f, 0x2a, 0x61, 0xf3, 0x8e, 0xdd, 0xe6, 0xfd, 0xae, + 0xb8, 0xa6, 0xe7, 0x02, 0x70, 0x4d, 0x28, 0x48, 0x41, 0x19, 0xfe, 0x16, 0xde, 0x89, 0x7d, 0x50, + 0xdc, 0xe0, 0x6e, 0x72, 0x3b, 0x70, 0x1b, 0xfb, 0xf4, 0x18, 0x00, 0x00, 0xff, 0xff, 0xb9, 0xee, + 0xf3, 0x35, 0x45, 0x02, 0x00, 0x00, +} + +func (this *Fund) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Fund) + if !ok { + that2, ok := that.(Fund) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.TokenAddress != that1.TokenAddress { + return false + } + if !this.Amount.Equal(that1.Amount) { + return false + } + return true +} +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ConsensusAppAddress) > 0 { + i -= len(m.ConsensusAppAddress) + copy(dAtA[i:], m.ConsensusAppAddress) + i = encodeVarintNitro(dAtA, i, uint64(len(m.ConsensusAppAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.VirtualPaymentAppAddress) > 0 { + i -= len(m.VirtualPaymentAppAddress) + copy(dAtA[i:], m.VirtualPaymentAppAddress) + i = encodeVarintNitro(dAtA, i, uint64(len(m.VirtualPaymentAppAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.NitroAdjudicatorAddress) > 0 { + i -= len(m.NitroAdjudicatorAddress) + copy(dAtA[i:], m.NitroAdjudicatorAddress) + i = encodeVarintNitro(dAtA, i, uint64(len(m.NitroAdjudicatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PaymentChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PaymentChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PaymentChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintNitro(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Fund) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Fund) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Fund) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintNitro(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.TokenAddress) > 0 { + i -= len(m.TokenAddress) + copy(dAtA[i:], m.TokenAddress) + i = encodeVarintNitro(dAtA, i, uint64(len(m.TokenAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintNitro(dAtA []byte, offset int, v uint64) int { + offset -= sovNitro(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NitroAdjudicatorAddress) + if l > 0 { + n += 1 + l + sovNitro(uint64(l)) + } + l = len(m.VirtualPaymentAppAddress) + if l > 0 { + n += 1 + l + sovNitro(uint64(l)) + } + l = len(m.ConsensusAppAddress) + if l > 0 { + n += 1 + l + sovNitro(uint64(l)) + } + return n +} + +func (m *PaymentChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovNitro(uint64(l)) + } + return n +} + +func (m *Fund) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TokenAddress) + if l > 0 { + n += 1 + l + sovNitro(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovNitro(uint64(l)) + return n +} + +func sovNitro(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozNitro(x uint64) (n int) { + return sovNitro(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NitroAdjudicatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthNitro + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthNitro + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NitroAdjudicatorAddress = append(m.NitroAdjudicatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.NitroAdjudicatorAddress == nil { + m.NitroAdjudicatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VirtualPaymentAppAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthNitro + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthNitro + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VirtualPaymentAppAddress = append(m.VirtualPaymentAppAddress[:0], dAtA[iNdEx:postIndex]...) + if m.VirtualPaymentAppAddress == nil { + m.VirtualPaymentAppAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusAppAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthNitro + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthNitro + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsensusAppAddress = append(m.ConsensusAppAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ConsensusAppAddress == nil { + m.ConsensusAppAddress = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipNitro(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNitro + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PaymentChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PaymentChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PaymentChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthNitro + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNitro + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipNitro(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNitro + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Fund) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Fund: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Fund: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthNitro + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNitro + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNitro + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthNitro + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNitro + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipNitro(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNitro + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipNitro(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowNitro + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowNitro + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowNitro + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthNitro + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupNitro + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthNitro + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthNitro = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowNitro = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupNitro = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/nitro/types/v1/query.pb.go b/x/nitro/types/v1/query.pb.go new file mode 100644 index 00000000..32cc55bd --- /dev/null +++ b/x/nitro/types/v1/query.pb.go @@ -0,0 +1,91 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cerc/nitro/v1/query.proto + +package v1 + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("cerc/nitro/v1/query.proto", fileDescriptor_c3082ce9521fe1bd) } + +var fileDescriptor_c3082ce9521fe1bd = []byte{ + // 209 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x2c, 0x8f, 0xb1, 0x6a, 0xc3, 0x30, + 0x10, 0x86, 0xed, 0xa1, 0x2d, 0x18, 0xba, 0x94, 0x42, 0xa9, 0x29, 0x7a, 0x82, 0x56, 0x87, 0xda, + 0x37, 0xe8, 0x90, 0x3d, 0x6b, 0x36, 0x59, 0x16, 0x42, 0x60, 0xeb, 0x1c, 0xe9, 0x22, 0xe2, 0xb7, + 0xc8, 0x63, 0x65, 0xf4, 0x98, 0x31, 0xd8, 0x2f, 0x12, 0x64, 0x6b, 0xfb, 0xb9, 0xef, 0xb8, 0xff, + 0xbb, 0xea, 0x53, 0x69, 0xaf, 0xc0, 0x59, 0xf2, 0x08, 0x51, 0xc0, 0xf1, 0xa4, 0xfd, 0xc8, 0x07, + 0x8f, 0x84, 0x6f, 0xaf, 0x09, 0xf1, 0x15, 0xf1, 0x28, 0xea, 0x2f, 0x83, 0x68, 0x3a, 0x0d, 0x72, + 0xb0, 0x20, 0x9d, 0x43, 0x92, 0x64, 0xd1, 0x85, 0x6d, 0xb9, 0x7e, 0x37, 0x68, 0x70, 0x8d, 0x90, + 0x52, 0x9e, 0x32, 0x85, 0xa1, 0xc7, 0x00, 0x8d, 0x0c, 0x1a, 0xa2, 0x68, 0x34, 0x49, 0x01, 0x0a, + 0xad, 0xcb, 0xfc, 0x23, 0xf3, 0x3e, 0x98, 0xd4, 0xde, 0x07, 0xb3, 0x81, 0xdf, 0x97, 0xea, 0x69, + 0x9f, 0x54, 0xfe, 0x77, 0xd7, 0x99, 0x95, 0xd3, 0xcc, 0xca, 0xfb, 0xcc, 0xca, 0xcb, 0xc2, 0x8a, + 0x69, 0x61, 0xc5, 0x6d, 0x61, 0xc5, 0xe1, 0xdb, 0x58, 0xe2, 0xb1, 0x6d, 0x38, 0x21, 0x24, 0xd3, + 0x1f, 0x8b, 0xd0, 0x49, 0x85, 0xce, 0xaa, 0x16, 0xce, 0xf9, 0x25, 0x1a, 0x07, 0x1d, 0x52, 0xf3, + 0xf3, 0x7a, 0xf7, 0xef, 0x11, 0x00, 0x00, 0xff, 0xff, 0x54, 0x84, 0x46, 0xad, 0xf0, 0x00, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +// QueryServer is the server API for Query service. +type QueryServer interface { +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +var Query_serviceDesc = _Query_serviceDesc +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cerc.nitro.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "cerc/nitro/v1/query.proto", +} diff --git a/x/nitro/types/v1/tx.pb.go b/x/nitro/types/v1/tx.pb.go new file mode 100644 index 00000000..69e8c117 --- /dev/null +++ b/x/nitro/types/v1/tx.pb.go @@ -0,0 +1,2652 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cerc/nitro/v1/tx.proto + +package v1 + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgOpenChannel struct { + // Nitro address of proposing party + NitroAddress string `protobuf:"bytes,1,opt,name=nitro_address,json=nitroAddress,proto3" json:"nitro_address,omitempty"` + // Nitro address of counterparty + Counterparty string `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty,omitempty"` + // Simplified outcome just includes the funding amount from payer + // TODO: review use of coins to represent ETH/ERC20 + Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` + // Nitro channel ID + ChannelId string `protobuf:"bytes,4,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // Tx signer address is independent of proposer ETH address + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgOpenChannel) Reset() { *m = MsgOpenChannel{} } +func (m *MsgOpenChannel) String() string { return proto.CompactTextString(m) } +func (*MsgOpenChannel) ProtoMessage() {} +func (*MsgOpenChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{0} +} +func (m *MsgOpenChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgOpenChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgOpenChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgOpenChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgOpenChannel.Merge(m, src) +} +func (m *MsgOpenChannel) XXX_Size() int { + return m.Size() +} +func (m *MsgOpenChannel) XXX_DiscardUnknown() { + xxx_messageInfo_MsgOpenChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgOpenChannel proto.InternalMessageInfo + +func (m *MsgOpenChannel) GetNitroAddress() string { + if m != nil { + return m.NitroAddress + } + return "" +} + +func (m *MsgOpenChannel) GetCounterparty() string { + if m != nil { + return m.Counterparty + } + return "" +} + +func (m *MsgOpenChannel) GetFunds() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Funds + } + return nil +} + +func (m *MsgOpenChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *MsgOpenChannel) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type MsgOpenChannelResponse struct { +} + +func (m *MsgOpenChannelResponse) Reset() { *m = MsgOpenChannelResponse{} } +func (m *MsgOpenChannelResponse) String() string { return proto.CompactTextString(m) } +func (*MsgOpenChannelResponse) ProtoMessage() {} +func (*MsgOpenChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{1} +} +func (m *MsgOpenChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgOpenChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgOpenChannelResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgOpenChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgOpenChannelResponse.Merge(m, src) +} +func (m *MsgOpenChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgOpenChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgOpenChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgOpenChannelResponse proto.InternalMessageInfo + +type MsgCloseChannel struct { + // Nitro channel ID to close + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // Whether to close via challenge (dispute resolution) or cooperative closure + IsChallenge bool `protobuf:"varint,2,opt,name=is_challenge,json=isChallenge,proto3" json:"is_challenge,omitempty"` + // Laconic address of proposing party + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgCloseChannel) Reset() { *m = MsgCloseChannel{} } +func (m *MsgCloseChannel) String() string { return proto.CompactTextString(m) } +func (*MsgCloseChannel) ProtoMessage() {} +func (*MsgCloseChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{2} +} +func (m *MsgCloseChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCloseChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCloseChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCloseChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCloseChannel.Merge(m, src) +} +func (m *MsgCloseChannel) XXX_Size() int { + return m.Size() +} +func (m *MsgCloseChannel) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCloseChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCloseChannel proto.InternalMessageInfo + +func (m *MsgCloseChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *MsgCloseChannel) GetIsChallenge() bool { + if m != nil { + return m.IsChallenge + } + return false +} + +func (m *MsgCloseChannel) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type MsgCloseChannelResponse struct { +} + +func (m *MsgCloseChannelResponse) Reset() { *m = MsgCloseChannelResponse{} } +func (m *MsgCloseChannelResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCloseChannelResponse) ProtoMessage() {} +func (*MsgCloseChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{3} +} +func (m *MsgCloseChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCloseChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCloseChannelResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCloseChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCloseChannelResponse.Merge(m, src) +} +func (m *MsgCloseChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCloseChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCloseChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCloseChannelResponse proto.InternalMessageInfo + +type MsgCreatePaymentChannel struct { + // Nitro address of proposing party + NitroAddress string `protobuf:"bytes,1,opt,name=nitro_address,json=nitroAddress,proto3" json:"nitro_address,omitempty"` + // Nitro address of counterparty + Counterparty string `protobuf:"bytes,2,opt,name=counterparty,proto3" json:"counterparty,omitempty"` + // Nitro addresses of intermediaries + Intermediaries []string `protobuf:"bytes,3,rep,name=intermediaries,proto3" json:"intermediaries,omitempty"` + // Challenge duration for the channel + ChallengeDuration uint32 `protobuf:"varint,4,opt,name=challenge_duration,json=challengeDuration,proto3" json:"challenge_duration,omitempty"` + // Funding amount for the payment channel + Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,5,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` + // Nitro channel ID + ChannelId string `protobuf:"bytes,6,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // Laconic address of proposing party + Signer string `protobuf:"bytes,7,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgCreatePaymentChannel) Reset() { *m = MsgCreatePaymentChannel{} } +func (m *MsgCreatePaymentChannel) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePaymentChannel) ProtoMessage() {} +func (*MsgCreatePaymentChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{4} +} +func (m *MsgCreatePaymentChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePaymentChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePaymentChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreatePaymentChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePaymentChannel.Merge(m, src) +} +func (m *MsgCreatePaymentChannel) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePaymentChannel) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePaymentChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePaymentChannel proto.InternalMessageInfo + +func (m *MsgCreatePaymentChannel) GetNitroAddress() string { + if m != nil { + return m.NitroAddress + } + return "" +} + +func (m *MsgCreatePaymentChannel) GetCounterparty() string { + if m != nil { + return m.Counterparty + } + return "" +} + +func (m *MsgCreatePaymentChannel) GetIntermediaries() []string { + if m != nil { + return m.Intermediaries + } + return nil +} + +func (m *MsgCreatePaymentChannel) GetChallengeDuration() uint32 { + if m != nil { + return m.ChallengeDuration + } + return 0 +} + +func (m *MsgCreatePaymentChannel) GetFunds() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Funds + } + return nil +} + +func (m *MsgCreatePaymentChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *MsgCreatePaymentChannel) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type MsgCreatePaymentChannelResponse struct { +} + +func (m *MsgCreatePaymentChannelResponse) Reset() { *m = MsgCreatePaymentChannelResponse{} } +func (m *MsgCreatePaymentChannelResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePaymentChannelResponse) ProtoMessage() {} +func (*MsgCreatePaymentChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{5} +} +func (m *MsgCreatePaymentChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePaymentChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePaymentChannelResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreatePaymentChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePaymentChannelResponse.Merge(m, src) +} +func (m *MsgCreatePaymentChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePaymentChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePaymentChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePaymentChannelResponse proto.InternalMessageInfo + +type MsgClosePaymentChannel struct { + // Nitro channel ID to close + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // Laconic address of proposing party + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgClosePaymentChannel) Reset() { *m = MsgClosePaymentChannel{} } +func (m *MsgClosePaymentChannel) String() string { return proto.CompactTextString(m) } +func (*MsgClosePaymentChannel) ProtoMessage() {} +func (*MsgClosePaymentChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{6} +} +func (m *MsgClosePaymentChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClosePaymentChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClosePaymentChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgClosePaymentChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClosePaymentChannel.Merge(m, src) +} +func (m *MsgClosePaymentChannel) XXX_Size() int { + return m.Size() +} +func (m *MsgClosePaymentChannel) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClosePaymentChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClosePaymentChannel proto.InternalMessageInfo + +func (m *MsgClosePaymentChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *MsgClosePaymentChannel) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type MsgClosePaymentChannelResponse struct { +} + +func (m *MsgClosePaymentChannelResponse) Reset() { *m = MsgClosePaymentChannelResponse{} } +func (m *MsgClosePaymentChannelResponse) String() string { return proto.CompactTextString(m) } +func (*MsgClosePaymentChannelResponse) ProtoMessage() {} +func (*MsgClosePaymentChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{7} +} +func (m *MsgClosePaymentChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClosePaymentChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClosePaymentChannelResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgClosePaymentChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClosePaymentChannelResponse.Merge(m, src) +} +func (m *MsgClosePaymentChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgClosePaymentChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClosePaymentChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClosePaymentChannelResponse proto.InternalMessageInfo + +type MsgPay struct { + // Nitro channel ID through which to send payment + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // Amount to pay + Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount"` + // Laconic address of the payer + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgPay) Reset() { *m = MsgPay{} } +func (m *MsgPay) String() string { return proto.CompactTextString(m) } +func (*MsgPay) ProtoMessage() {} +func (*MsgPay) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{8} +} +func (m *MsgPay) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPay) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPay.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPay) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPay.Merge(m, src) +} +func (m *MsgPay) XXX_Size() int { + return m.Size() +} +func (m *MsgPay) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPay.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPay proto.InternalMessageInfo + +func (m *MsgPay) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *MsgPay) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +func (m *MsgPay) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type MsgPayResponse struct { +} + +func (m *MsgPayResponse) Reset() { *m = MsgPayResponse{} } +func (m *MsgPayResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPayResponse) ProtoMessage() {} +func (*MsgPayResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b7ef3b32bf46dfb1, []int{9} +} +func (m *MsgPayResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPayResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPayResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPayResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPayResponse.Merge(m, src) +} +func (m *MsgPayResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPayResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPayResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPayResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgOpenChannel)(nil), "cerc.nitro.v1.MsgOpenChannel") + proto.RegisterType((*MsgOpenChannelResponse)(nil), "cerc.nitro.v1.MsgOpenChannelResponse") + proto.RegisterType((*MsgCloseChannel)(nil), "cerc.nitro.v1.MsgCloseChannel") + proto.RegisterType((*MsgCloseChannelResponse)(nil), "cerc.nitro.v1.MsgCloseChannelResponse") + proto.RegisterType((*MsgCreatePaymentChannel)(nil), "cerc.nitro.v1.MsgCreatePaymentChannel") + proto.RegisterType((*MsgCreatePaymentChannelResponse)(nil), "cerc.nitro.v1.MsgCreatePaymentChannelResponse") + proto.RegisterType((*MsgClosePaymentChannel)(nil), "cerc.nitro.v1.MsgClosePaymentChannel") + proto.RegisterType((*MsgClosePaymentChannelResponse)(nil), "cerc.nitro.v1.MsgClosePaymentChannelResponse") + proto.RegisterType((*MsgPay)(nil), "cerc.nitro.v1.MsgPay") + proto.RegisterType((*MsgPayResponse)(nil), "cerc.nitro.v1.MsgPayResponse") +} + +func init() { proto.RegisterFile("cerc/nitro/v1/tx.proto", fileDescriptor_b7ef3b32bf46dfb1) } + +var fileDescriptor_b7ef3b32bf46dfb1 = []byte{ + // 753 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0x4f, 0x4f, 0x13, 0x4f, + 0x18, 0xc7, 0xbb, 0x2d, 0xed, 0xef, 0xc7, 0xb4, 0xa0, 0xae, 0x08, 0x65, 0xa5, 0x0b, 0x2c, 0x7f, + 0x24, 0x84, 0xee, 0x5a, 0x3c, 0x98, 0x78, 0x93, 0x1a, 0x13, 0x0f, 0x8d, 0x4d, 0x2f, 0x26, 0xc6, + 0xa4, 0x99, 0xee, 0x8e, 0xc3, 0xc4, 0x76, 0x66, 0xb3, 0x33, 0x6d, 0xda, 0xc4, 0x03, 0x21, 0xf1, + 0x6e, 0xe2, 0x89, 0x83, 0x6f, 0xc0, 0x13, 0x2f, 0x83, 0x23, 0x89, 0x17, 0x4f, 0x4a, 0xc0, 0x84, + 0xb7, 0x61, 0x76, 0x76, 0x59, 0xda, 0x65, 0x0b, 0x1c, 0x8c, 0xa7, 0x76, 0x9e, 0xe7, 0x99, 0xf9, + 0x7e, 0xe6, 0x79, 0x9e, 0x79, 0x16, 0xcc, 0xda, 0xc8, 0xb3, 0x2d, 0x4a, 0x84, 0xc7, 0xac, 0x5e, + 0xc5, 0x12, 0x7d, 0xd3, 0xf5, 0x98, 0x60, 0xea, 0x94, 0x6f, 0x37, 0xa5, 0xdd, 0xec, 0x55, 0xb4, + 0x05, 0xcc, 0x18, 0x6e, 0x23, 0x0b, 0xba, 0xc4, 0x82, 0x94, 0x32, 0x01, 0x05, 0x61, 0x94, 0x07, + 0xc1, 0xda, 0x0c, 0x66, 0x98, 0xc9, 0xbf, 0x96, 0xff, 0x2f, 0xb4, 0xea, 0x36, 0xe3, 0x1d, 0xc6, + 0xad, 0x16, 0xe4, 0xc8, 0xea, 0x55, 0x5a, 0x48, 0xc0, 0x8a, 0x65, 0x33, 0x42, 0x43, 0xff, 0x5c, + 0xe8, 0xef, 0x70, 0xec, 0x4b, 0x77, 0x38, 0x0e, 0x1c, 0xc6, 0x5e, 0x1a, 0x4c, 0xd7, 0x38, 0x7e, + 0xed, 0x22, 0x5a, 0xdd, 0x85, 0x94, 0xa2, 0xb6, 0xba, 0x02, 0xa6, 0x24, 0x4b, 0x13, 0x3a, 0x8e, + 0x87, 0x38, 0x2f, 0x2a, 0x4b, 0xca, 0xc6, 0x64, 0xa3, 0x20, 0x8d, 0xcf, 0x03, 0x9b, 0x6a, 0x80, + 0x82, 0xcd, 0xba, 0x54, 0x20, 0xcf, 0x85, 0x9e, 0x18, 0x14, 0xd3, 0x41, 0xcc, 0xb0, 0x4d, 0x85, + 0x20, 0xfb, 0xbe, 0x4b, 0x1d, 0x5e, 0xcc, 0x2c, 0x65, 0x36, 0xf2, 0xdb, 0xf3, 0x66, 0x00, 0x61, + 0xfa, 0x90, 0x66, 0x08, 0x69, 0x56, 0x19, 0xa1, 0x3b, 0x8f, 0x8f, 0x7e, 0x2e, 0xa6, 0xbe, 0xfd, + 0x5a, 0xdc, 0xc0, 0x44, 0xec, 0x76, 0x5b, 0xa6, 0xcd, 0x3a, 0x56, 0x48, 0x1c, 0xfc, 0x94, 0xb9, + 0xf3, 0xc1, 0x12, 0x03, 0x17, 0x71, 0xb9, 0x81, 0x37, 0x82, 0x93, 0xd5, 0x12, 0x00, 0x76, 0x80, + 0xdd, 0x24, 0x4e, 0x71, 0x42, 0x42, 0x4c, 0x86, 0x96, 0x57, 0x8e, 0x3a, 0x0b, 0x72, 0x9c, 0x60, + 0x8a, 0xbc, 0x62, 0x56, 0xba, 0xc2, 0xd5, 0xb3, 0xfc, 0xfe, 0xf9, 0xe1, 0x66, 0xb8, 0x30, 0x8a, + 0x60, 0x76, 0x34, 0x03, 0x0d, 0xc4, 0x5d, 0x46, 0x39, 0x32, 0xfa, 0xe0, 0x4e, 0x8d, 0xe3, 0x6a, + 0x9b, 0x71, 0x74, 0x91, 0x9c, 0x51, 0x41, 0x25, 0x2e, 0xb8, 0x0c, 0x0a, 0x84, 0x37, 0xed, 0x5d, + 0xd8, 0x6e, 0x23, 0x8a, 0x91, 0x4c, 0xcb, 0xff, 0x8d, 0x3c, 0xe1, 0xd5, 0x0b, 0xd3, 0x10, 0x53, + 0x66, 0x3c, 0xd3, 0x3c, 0x98, 0x8b, 0x29, 0x47, 0x50, 0x27, 0xe9, 0xc0, 0xe7, 0x21, 0x28, 0x50, + 0x1d, 0x0e, 0x3a, 0x88, 0x8a, 0xbf, 0x5e, 0xba, 0x75, 0x30, 0x4d, 0xfc, 0x55, 0x07, 0x39, 0x04, + 0x7a, 0x04, 0x05, 0x35, 0x9c, 0x6c, 0xc4, 0xac, 0x6a, 0x19, 0xa8, 0xd1, 0x65, 0x9b, 0x4e, 0xd7, + 0x93, 0xad, 0x2a, 0xeb, 0x30, 0xd5, 0xb8, 0x17, 0x79, 0x5e, 0x84, 0x8e, 0xcb, 0x8e, 0xc8, 0xfe, + 0xa3, 0x8e, 0xc8, 0x8d, 0xef, 0x88, 0xff, 0xc6, 0x67, 0x7f, 0x19, 0x2c, 0x8e, 0xc9, 0x70, 0x54, + 0x85, 0x77, 0xb2, 0x69, 0x64, 0x81, 0x62, 0x35, 0xb8, 0xa1, 0x43, 0x2e, 0x01, 0xd2, 0xe3, 0x01, + 0x96, 0x80, 0x9e, 0x7c, 0x7a, 0xa4, 0xff, 0x49, 0x01, 0xb9, 0x1a, 0xc7, 0x75, 0x38, 0xb8, 0x49, + 0xf0, 0x29, 0xc8, 0xc1, 0x8e, 0x5f, 0x5b, 0x29, 0x78, 0x6d, 0xd2, 0x27, 0xfc, 0xa4, 0x37, 0xc2, + 0xf0, 0xdb, 0x35, 0xea, 0x5d, 0x39, 0x3e, 0xea, 0x70, 0x70, 0x41, 0xb6, 0x7d, 0x90, 0x05, 0x99, + 0x1a, 0xc7, 0x6a, 0x1f, 0xe4, 0x87, 0xa7, 0x4a, 0xc9, 0x1c, 0x99, 0x72, 0xe6, 0xe8, 0x93, 0xd3, + 0xd6, 0xae, 0x75, 0x47, 0xd7, 0x5e, 0xd9, 0xff, 0xfe, 0xfb, 0x4b, 0xba, 0x64, 0x3c, 0xb4, 0x46, + 0x67, 0x29, 0x73, 0x11, 0x6d, 0x86, 0x77, 0x56, 0x3f, 0x82, 0xc2, 0xc8, 0x9b, 0xd5, 0xaf, 0x9e, + 0x3d, 0xec, 0xd7, 0xd6, 0xaf, 0xf7, 0x47, 0xe2, 0xab, 0x52, 0x5c, 0x37, 0x16, 0x62, 0xe2, 0xb6, + 0x1f, 0x1c, 0xa9, 0x7f, 0x55, 0xc0, 0x4c, 0xe2, 0xe3, 0x4c, 0x92, 0x49, 0x88, 0xd3, 0xcc, 0xdb, + 0xc5, 0x45, 0x58, 0x65, 0x89, 0xf5, 0xc8, 0x58, 0x8b, 0x63, 0xc9, 0x4d, 0x4d, 0x37, 0xd8, 0x15, + 0xf1, 0x1d, 0x28, 0xe0, 0x7e, 0x52, 0xdf, 0xae, 0x8d, 0xc9, 0x42, 0x8c, 0xae, 0x7c, 0xab, 0xb0, + 0x08, 0x6e, 0x4b, 0xc2, 0xad, 0x1b, 0xab, 0x89, 0x39, 0x8b, 0xb3, 0xbd, 0x01, 0x19, 0xbf, 0xa3, + 0x1f, 0x5c, 0xd5, 0xa8, 0xc3, 0x81, 0x56, 0x4a, 0x34, 0x47, 0x52, 0x9a, 0x94, 0x9a, 0x31, 0xd4, + 0x98, 0x94, 0x0b, 0x07, 0x5a, 0x76, 0xef, 0xfc, 0x70, 0x53, 0xd9, 0x79, 0x79, 0x74, 0xaa, 0x2b, + 0xc7, 0xa7, 0xba, 0x72, 0x72, 0xaa, 0x2b, 0x9f, 0xcf, 0xf4, 0xd4, 0xf1, 0x99, 0x9e, 0xfa, 0x71, + 0xa6, 0xa7, 0xde, 0x6e, 0x61, 0x22, 0xcc, 0x9e, 0xd3, 0x32, 0x05, 0x93, 0xdb, 0xcb, 0x84, 0x59, + 0x6d, 0x68, 0x33, 0x4a, 0x6c, 0xc7, 0xea, 0x87, 0x87, 0xc9, 0x71, 0xe3, 0x7f, 0x5e, 0x73, 0xf2, + 0xe3, 0xf9, 0xe4, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xae, 0xc4, 0xed, 0x93, 0xd2, 0x07, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // TODO: OpenLedgerChannel? + OpenChannel(ctx context.Context, in *MsgOpenChannel, opts ...grpc.CallOption) (*MsgOpenChannelResponse, error) + CloseChannel(ctx context.Context, in *MsgCloseChannel, opts ...grpc.CallOption) (*MsgCloseChannelResponse, error) + CreatePaymentChannel(ctx context.Context, in *MsgCreatePaymentChannel, opts ...grpc.CallOption) (*MsgCreatePaymentChannelResponse, error) + ClosePaymentChannel(ctx context.Context, in *MsgClosePaymentChannel, opts ...grpc.CallOption) (*MsgClosePaymentChannelResponse, error) + Pay(ctx context.Context, in *MsgPay, opts ...grpc.CallOption) (*MsgPayResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) OpenChannel(ctx context.Context, in *MsgOpenChannel, opts ...grpc.CallOption) (*MsgOpenChannelResponse, error) { + out := new(MsgOpenChannelResponse) + err := c.cc.Invoke(ctx, "/cerc.nitro.v1.Msg/OpenChannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CloseChannel(ctx context.Context, in *MsgCloseChannel, opts ...grpc.CallOption) (*MsgCloseChannelResponse, error) { + out := new(MsgCloseChannelResponse) + err := c.cc.Invoke(ctx, "/cerc.nitro.v1.Msg/CloseChannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CreatePaymentChannel(ctx context.Context, in *MsgCreatePaymentChannel, opts ...grpc.CallOption) (*MsgCreatePaymentChannelResponse, error) { + out := new(MsgCreatePaymentChannelResponse) + err := c.cc.Invoke(ctx, "/cerc.nitro.v1.Msg/CreatePaymentChannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ClosePaymentChannel(ctx context.Context, in *MsgClosePaymentChannel, opts ...grpc.CallOption) (*MsgClosePaymentChannelResponse, error) { + out := new(MsgClosePaymentChannelResponse) + err := c.cc.Invoke(ctx, "/cerc.nitro.v1.Msg/ClosePaymentChannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Pay(ctx context.Context, in *MsgPay, opts ...grpc.CallOption) (*MsgPayResponse, error) { + out := new(MsgPayResponse) + err := c.cc.Invoke(ctx, "/cerc.nitro.v1.Msg/Pay", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // TODO: OpenLedgerChannel? + OpenChannel(context.Context, *MsgOpenChannel) (*MsgOpenChannelResponse, error) + CloseChannel(context.Context, *MsgCloseChannel) (*MsgCloseChannelResponse, error) + CreatePaymentChannel(context.Context, *MsgCreatePaymentChannel) (*MsgCreatePaymentChannelResponse, error) + ClosePaymentChannel(context.Context, *MsgClosePaymentChannel) (*MsgClosePaymentChannelResponse, error) + Pay(context.Context, *MsgPay) (*MsgPayResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) OpenChannel(ctx context.Context, req *MsgOpenChannel) (*MsgOpenChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OpenChannel not implemented") +} +func (*UnimplementedMsgServer) CloseChannel(ctx context.Context, req *MsgCloseChannel) (*MsgCloseChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CloseChannel not implemented") +} +func (*UnimplementedMsgServer) CreatePaymentChannel(ctx context.Context, req *MsgCreatePaymentChannel) (*MsgCreatePaymentChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePaymentChannel not implemented") +} +func (*UnimplementedMsgServer) ClosePaymentChannel(ctx context.Context, req *MsgClosePaymentChannel) (*MsgClosePaymentChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClosePaymentChannel not implemented") +} +func (*UnimplementedMsgServer) Pay(ctx context.Context, req *MsgPay) (*MsgPayResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Pay not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_OpenChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgOpenChannel) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).OpenChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cerc.nitro.v1.Msg/OpenChannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).OpenChannel(ctx, req.(*MsgOpenChannel)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CloseChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCloseChannel) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CloseChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cerc.nitro.v1.Msg/CloseChannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CloseChannel(ctx, req.(*MsgCloseChannel)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CreatePaymentChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreatePaymentChannel) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreatePaymentChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cerc.nitro.v1.Msg/CreatePaymentChannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreatePaymentChannel(ctx, req.(*MsgCreatePaymentChannel)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ClosePaymentChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgClosePaymentChannel) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ClosePaymentChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cerc.nitro.v1.Msg/ClosePaymentChannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ClosePaymentChannel(ctx, req.(*MsgClosePaymentChannel)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Pay_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPay) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Pay(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cerc.nitro.v1.Msg/Pay", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Pay(ctx, req.(*MsgPay)) + } + return interceptor(ctx, in, info, handler) +} + +var Msg_serviceDesc = _Msg_serviceDesc +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cerc.nitro.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "OpenChannel", + Handler: _Msg_OpenChannel_Handler, + }, + { + MethodName: "CloseChannel", + Handler: _Msg_CloseChannel_Handler, + }, + { + MethodName: "CreatePaymentChannel", + Handler: _Msg_CreatePaymentChannel_Handler, + }, + { + MethodName: "ClosePaymentChannel", + Handler: _Msg_ClosePaymentChannel_Handler, + }, + { + MethodName: "Pay", + Handler: _Msg_Pay_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cerc/nitro/v1/tx.proto", +} + +func (m *MsgOpenChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgOpenChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgOpenChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x22 + } + if len(m.Funds) > 0 { + for iNdEx := len(m.Funds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Counterparty) > 0 { + i -= len(m.Counterparty) + copy(dAtA[i:], m.Counterparty) + i = encodeVarintTx(dAtA, i, uint64(len(m.Counterparty))) + i-- + dAtA[i] = 0x12 + } + if len(m.NitroAddress) > 0 { + i -= len(m.NitroAddress) + copy(dAtA[i:], m.NitroAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.NitroAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgOpenChannelResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgOpenChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgOpenChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCloseChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCloseChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCloseChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + if m.IsChallenge { + i-- + if m.IsChallenge { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCloseChannelResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCloseChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCloseChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreatePaymentChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreatePaymentChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePaymentChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x3a + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x32 + } + if len(m.Funds) > 0 { + for iNdEx := len(m.Funds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.ChallengeDuration != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ChallengeDuration)) + i-- + dAtA[i] = 0x20 + } + if len(m.Intermediaries) > 0 { + for iNdEx := len(m.Intermediaries) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Intermediaries[iNdEx]) + copy(dAtA[i:], m.Intermediaries[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Intermediaries[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Counterparty) > 0 { + i -= len(m.Counterparty) + copy(dAtA[i:], m.Counterparty) + i = encodeVarintTx(dAtA, i, uint64(len(m.Counterparty))) + i-- + dAtA[i] = 0x12 + } + if len(m.NitroAddress) > 0 { + i -= len(m.NitroAddress) + copy(dAtA[i:], m.NitroAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.NitroAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreatePaymentChannelResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreatePaymentChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePaymentChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgClosePaymentChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgClosePaymentChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClosePaymentChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgClosePaymentChannelResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgClosePaymentChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClosePaymentChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgPay) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPay) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPay) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgPayResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPayResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPayResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgOpenChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NitroAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Counterparty) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Funds) > 0 { + for _, e := range m.Funds { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgOpenChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCloseChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.IsChallenge { + n += 2 + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCloseChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreatePaymentChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NitroAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Counterparty) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Intermediaries) > 0 { + for _, s := range m.Intermediaries { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + if m.ChallengeDuration != 0 { + n += 1 + sovTx(uint64(m.ChallengeDuration)) + } + if len(m.Funds) > 0 { + for _, e := range m.Funds { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreatePaymentChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgClosePaymentChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgClosePaymentChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgPay) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgPayResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgOpenChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgOpenChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgOpenChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NitroAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NitroAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Counterparty = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Funds = append(m.Funds, types.Coin{}) + if err := m.Funds[len(m.Funds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgOpenChannelResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgOpenChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgOpenChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCloseChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCloseChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCloseChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsChallenge", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsChallenge = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCloseChannelResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCloseChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCloseChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreatePaymentChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreatePaymentChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePaymentChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NitroAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NitroAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Counterparty = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Intermediaries", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Intermediaries = append(m.Intermediaries, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChallengeDuration", wireType) + } + m.ChallengeDuration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChallengeDuration |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Funds = append(m.Funds, types.Coin{}) + if err := m.Funds[len(m.Funds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreatePaymentChannelResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreatePaymentChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePaymentChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgClosePaymentChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgClosePaymentChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClosePaymentChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgClosePaymentChannelResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgClosePaymentChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClosePaymentChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPay) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPay: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPay: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPayResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPayResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPayResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/nitro/types/v1/tx.pb.gw.go b/x/nitro/types/v1/tx.pb.gw.go new file mode 100644 index 00000000..db7db2b5 --- /dev/null +++ b/x/nitro/types/v1/tx.pb.gw.go @@ -0,0 +1,503 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: cerc/nitro/v1/tx.proto + +/* +Package v1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package v1 + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Msg_OpenChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_OpenChannel_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgOpenChannel + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_OpenChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.OpenChannel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_OpenChannel_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgOpenChannel + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_OpenChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.OpenChannel(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Msg_CloseChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_CloseChannel_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgCloseChannel + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CloseChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CloseChannel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_CloseChannel_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgCloseChannel + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CloseChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CloseChannel(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Msg_CreatePaymentChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_CreatePaymentChannel_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgCreatePaymentChannel + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CreatePaymentChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreatePaymentChannel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_CreatePaymentChannel_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgCreatePaymentChannel + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CreatePaymentChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreatePaymentChannel(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Msg_ClosePaymentChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_ClosePaymentChannel_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgClosePaymentChannel + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ClosePaymentChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ClosePaymentChannel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_ClosePaymentChannel_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgClosePaymentChannel + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ClosePaymentChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ClosePaymentChannel(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Msg_Pay_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_Pay_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgPay + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Pay_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Pay(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_Pay_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgPay + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Pay_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Pay(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". +// UnaryRPC :call MsgServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. +func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { + + mux.Handle("POST", pattern_Msg_OpenChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Msg_OpenChannel_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_OpenChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_CloseChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Msg_CloseChannel_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_CloseChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_CreatePaymentChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Msg_CreatePaymentChannel_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_CreatePaymentChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_ClosePaymentChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Msg_ClosePaymentChannel_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_ClosePaymentChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_Pay_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Msg_Pay_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_Pay_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterMsgHandler(ctx, mux, conn) +} + +// RegisterMsgHandler registers the http handlers for service Msg to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) +} + +// RegisterMsgHandlerClient registers the http handlers for service Msg +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "MsgClient" to call the correct interceptors. +func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { + + mux.Handle("POST", pattern_Msg_OpenChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Msg_OpenChannel_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_OpenChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_CloseChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Msg_CloseChannel_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_CloseChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_CreatePaymentChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Msg_CreatePaymentChannel_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_CreatePaymentChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_ClosePaymentChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Msg_ClosePaymentChannel_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_ClosePaymentChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_Pay_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Msg_Pay_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_Pay_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Msg_OpenChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cerc", "nitro", "v1", "open_channel"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_CloseChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cerc", "nitro", "v1", "close_channel"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_CreatePaymentChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cerc", "nitro", "v1", "create_payment_channel"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_ClosePaymentChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cerc", "nitro", "v1", "close_payment_channel"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_Pay_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cerc", "nitro", "v1", "pay"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Msg_OpenChannel_0 = runtime.ForwardResponseMessage + + forward_Msg_CloseChannel_0 = runtime.ForwardResponseMessage + + forward_Msg_CreatePaymentChannel_0 = runtime.ForwardResponseMessage + + forward_Msg_ClosePaymentChannel_0 = runtime.ForwardResponseMessage + + forward_Msg_Pay_0 = runtime.ForwardResponseMessage +) diff --git a/x/onboarding/codec.go b/x/onboarding/codec.go index e57fdfba..b97bad4e 100644 --- a/x/onboarding/codec.go +++ b/x/onboarding/codec.go @@ -1,15 +1,15 @@ package onboarding import ( - types "github.com/cosmos/cosmos-sdk/codec/types" + registry "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgOnboardParticipant{}, ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &Msg_serviceDesc) } diff --git a/x/onboarding/keeper/keeper.go b/x/onboarding/keeper/keeper.go index f53e0ca1..e85859dc 100644 --- a/x/onboarding/keeper/keeper.go +++ b/x/onboarding/keeper/keeper.go @@ -1,52 +1,65 @@ package keeper import ( + "context" "encoding/json" "errors" - "fmt" "cosmossdk.io/collections" "cosmossdk.io/core/address" - storetypes "cosmossdk.io/core/store" + "cosmossdk.io/core/event" + "cosmossdk.io/core/gas" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" + storetypes "cosmossdk.io/core/store" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "git.vdb.to/cerc-io/laconicd/utils" - onboardingTypes "git.vdb.to/cerc-io/laconicd/x/onboarding" + "git.vdb.to/cerc-io/laconicd/x/onboarding" ) type Keeper struct { cdc codec.BinaryCodec addressCodec address.Codec + eventService event.Service + gasService gas.Service + logger log.Logger // authority is the address capable of executing a MsgUpdateParams and other authority-gated message. // typically, this should be the x/gov module account. - authority string + authority types.AccAddress // state management Schema collections.Schema - Params collections.Item[onboardingTypes.Params] - Participants collections.Map[string, onboardingTypes.Participant] + Params collections.Item[onboarding.Params] + Participants collections.Map[string, onboarding.Participant] } // NewKeeper creates a new Keeper instance -func NewKeeper(cdc codec.BinaryCodec, addressCodec address.Codec, storeService storetypes.KVStoreService, authority string) *Keeper { - if _, err := addressCodec.StringToBytes(authority); err != nil { - panic(fmt.Errorf("invalid authority address: %w", err)) - } - +func NewKeeper( + cdc codec.BinaryCodec, + addressCodec address.Codec, + storeService storetypes.KVStoreService, + eventService event.Service, + gasService gas.Service, + authority types.AccAddress, + logger log.Logger, +) *Keeper { sb := collections.NewSchemaBuilder(storeService) k := Keeper{ cdc: cdc, addressCodec: addressCodec, + eventService: eventService, + gasService: gasService, + logger: logger.With(log.ModuleKey, "x/"+onboarding.ModuleName), authority: authority, - Params: collections.NewItem(sb, onboardingTypes.ParamsPrefix, "params", codec.CollValue[onboardingTypes.Params](cdc)), + Params: collections.NewItem(sb, onboarding.ParamsPrefix, "params", codec.CollValue[onboarding.Params](cdc)), Participants: collections.NewMap( - sb, onboardingTypes.ParticipantsPrefix, "participants", collections.StringKey, codec.CollValue[onboardingTypes.Participant](cdc), + sb, onboarding.ParticipantsPrefix, "participants", collections.StringKey, codec.CollValue[onboarding.Participant](cdc), ), } @@ -60,20 +73,11 @@ func NewKeeper(cdc codec.BinaryCodec, addressCodec address.Codec, storeService s return &k } -// GetAuthority returns the module's authority. -func (k Keeper) GetAuthority() string { - return k.authority -} - -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", onboardingTypes.ModuleName) -} - func (k Keeper) OnboardParticipant( - ctx sdk.Context, - msg *onboardingTypes.MsgOnboardParticipant, + ctx context.Context, + msg *onboarding.MsgOnboardParticipant, signerAddress sdk.AccAddress, -) (*onboardingTypes.MsgOnboardParticipantResponse, error) { +) (*onboarding.MsgOnboardParticipantResponse, error) { params, err := k.Params.Get(ctx) if err != nil { return nil, err @@ -88,19 +92,27 @@ func (k Keeper) OnboardParticipant( return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid format for payload") } - // Decode eth address from signature which should be the nitro address of the participant - nitroAddress, err := utils.DecodeEthereumAddress(message, msg.EthSignature) + // Decode eth pubkey from signature. The derived address should be the nitro address of the participant + nitroPubKey, err := utils.DecodeEthereumPubKey(message, msg.EthSignature) if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Failed to decode Ethereum address") + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Failed to decode Ethereum public key") + } + nitroAddress, err := utils.EthAddressFromPubKey(nitroPubKey) + if err != nil { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Failed to derive Ethereum address from public key") } - if nitroAddress != msg.EthPayload.Address { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Recovered ethereum address does not match the address set in payload") + if nitroAddress.String() != msg.EthPayload.Address { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Recovered Ethereum address does not match the address set in payload") } - participant := &onboardingTypes.Participant{ - CosmosAddress: signerAddress.String(), - NitroAddress: nitroAddress, + cosmosAddr, err := k.addressCodec.BytesToString(signerAddress) + if err != nil { + return nil, err + } + participant := &onboarding.Participant{ + CosmosAddress: cosmosAddr, + PublicKey: nitroPubKey, Role: msg.Role, KycId: msg.KycId, } @@ -109,17 +121,17 @@ func (k Keeper) OnboardParticipant( return nil, err } - return &onboardingTypes.MsgOnboardParticipantResponse{}, nil + return &onboarding.MsgOnboardParticipantResponse{}, nil } -func (k Keeper) StoreParticipant(ctx sdk.Context, participant *onboardingTypes.Participant) error { +func (k Keeper) StoreParticipant(ctx context.Context, participant *onboarding.Participant) error { key := participant.CosmosAddress return k.Participants.Set(ctx, key, *participant) } // ListParticipants - get all participants. -func (k Keeper) ListParticipants(ctx sdk.Context) ([]*onboardingTypes.Participant, error) { - var participants []*onboardingTypes.Participant +func (k Keeper) ListParticipants(ctx context.Context) ([]*onboarding.Participant, error) { + var participants []*onboarding.Participant iter, err := k.Participants.Iterate(ctx, nil) if err != nil { @@ -139,32 +151,38 @@ func (k Keeper) ListParticipants(ctx sdk.Context) ([]*onboardingTypes.Participan } // GetParticipantByAddress - get participant by cosmos (laconic) address. -func (k Keeper) GetParticipantByAddress(ctx sdk.Context, address string) (onboardingTypes.Participant, error) { +// Returns nil if participant is not found. +func (k Keeper) GetParticipantByAddress(ctx context.Context, address string) (*onboarding.Participant, error) { participant, err := k.Participants.Get(ctx, address) if err != nil { if errors.Is(err, collections.ErrNotFound) { - return onboardingTypes.Participant{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "participant with given address not found.") + return nil, nil } - return onboardingTypes.Participant{}, err + return nil, err } - return participant, nil + return &participant, nil } // GetParticipantByNitroAddress - get participant by nitro address. -func (k Keeper) GetParticipantByNitroAddress(ctx sdk.Context, nitroAddress string) (onboardingTypes.Participant, error) { - var participant onboardingTypes.Participant +// Returns nil if participant is not found. +func (k Keeper) GetParticipantByNitroAddress(ctx context.Context, nitroAddress string) (*onboarding.Participant, error) { + var participant *onboarding.Participant - err := k.Participants.Walk(ctx, nil, func(key string, value onboardingTypes.Participant) (bool, error) { - if value.NitroAddress == nitroAddress { - participant = value + err := k.Participants.Walk(ctx, nil, func(key string, value onboarding.Participant) (bool, error) { + ethAddr, err := utils.EthAddressFromPubKey(value.PublicKey) + if err != nil { + return false, err + } + if ethAddr.String() == nitroAddress { + participant = &value return true, nil } return false, nil }) if err != nil { - return onboardingTypes.Participant{}, err + return nil, err } return participant, nil diff --git a/x/onboarding/keeper/msg_server.go b/x/onboarding/keeper/msg_server.go index ac8f6ae5..820bb247 100644 --- a/x/onboarding/keeper/msg_server.go +++ b/x/onboarding/keeper/msg_server.go @@ -3,6 +3,8 @@ package keeper import ( "context" + "cosmossdk.io/core/event" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "git.vdb.to/cerc-io/laconicd/utils" @@ -20,15 +22,16 @@ func NewMsgServerImpl(keeper *Keeper) onboarding.MsgServer { return &msgServer{k: *keeper} } -func (ms msgServer) OnboardParticipant(c context.Context, msg *onboarding.MsgOnboardParticipant) (*onboarding.MsgOnboardParticipantResponse, error) { +func (ms msgServer) OnboardParticipant(ctx context.Context, msg *onboarding.MsgOnboardParticipant) (*onboarding.MsgOnboardParticipantResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + ctx, logGas := utils.WithCustomGasConfig(ctx, ms.k.gasService) + defer logGas(ms.k.logger, "OnboardParticipant") - signerAddress, err := sdk.AccAddressFromBech32(msg.Participant) + addrCodec := utils.NewAddressCodec() + signerAddress, err := addrCodec.StringToBytes(msg.Participant) if err != nil { return nil, err } @@ -38,20 +41,22 @@ func (ms msgServer) OnboardParticipant(c context.Context, msg *onboarding.MsgOnb return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - onboarding.EventTypeOnboardParticipant, - sdk.NewAttribute(onboarding.AttributeKeySigner, msg.Participant), - sdk.NewAttribute(onboarding.AttributeKeyEthAddress, msg.EthPayload.Address), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, onboarding.AttributeValueCategory), - sdk.NewAttribute(onboarding.AttributeKeySigner, msg.Participant), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "OnboardParticipant") + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + onboarding.EventTypeOnboardParticipant, + event.Attribute{Key: onboarding.AttributeKeySigner, Value: msg.Participant}, + event.Attribute{Key: onboarding.AttributeKeyEthAddress, Value: msg.EthPayload.Address}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", onboarding.EventTypeOnboardParticipant) + } + if err := ms.k.eventService.EventManager(ctx).EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: onboarding.AttributeValueCategory}, + event.Attribute{Key: onboarding.AttributeKeySigner, Value: msg.Participant}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return &onboarding.MsgOnboardParticipantResponse{}, nil } diff --git a/x/onboarding/keeper/query_server.go b/x/onboarding/keeper/query_server.go index d8ba7517..608efc04 100644 --- a/x/onboarding/keeper/query_server.go +++ b/x/onboarding/keeper/query_server.go @@ -4,7 +4,6 @@ import ( "context" errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" onboardingtypes "git.vdb.to/cerc-io/laconicd/x/onboarding" @@ -23,11 +22,9 @@ func NewQueryServerImpl(k *Keeper) onboardingtypes.QueryServer { // Participants implements Participants.QueryServer. func (qs queryServer) Participants( - c context.Context, + ctx context.Context, _ *onboardingtypes.QueryParticipantsRequest, ) (*onboardingtypes.QueryParticipantsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - resp, err := qs.k.ListParticipants(ctx) if err != nil { return nil, err @@ -38,11 +35,9 @@ func (qs queryServer) Participants( // GetParticipantByAddress implements the GetParticipantByAddress query. func (qs queryServer) GetParticipantByAddress( - c context.Context, + ctx context.Context, req *onboardingtypes.QueryGetParticipantByAddressRequest, ) (*onboardingtypes.QueryGetParticipantByAddressResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - if req.Address == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "cosmos (laconic) address is required") } @@ -51,17 +46,17 @@ func (qs queryServer) GetParticipantByAddress( if err != nil { return nil, err } - - return &onboardingtypes.QueryGetParticipantByAddressResponse{Participant: &participant}, nil + if participant == nil { + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "participant with given address not found") + } + return &onboardingtypes.QueryGetParticipantByAddressResponse{Participant: participant}, nil } // GetParticipantByNitroAddress implements the GetParticipantByNitroAddress query. func (qs queryServer) GetParticipantByNitroAddress( - c context.Context, + ctx context.Context, req *onboardingtypes.QueryGetParticipantByNitroAddressRequest, ) (*onboardingtypes.QueryGetParticipantByNitroAddressResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - if req.NitroAddress == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "nitro address is required") } @@ -70,6 +65,8 @@ func (qs queryServer) GetParticipantByNitroAddress( if err != nil { return nil, err } - - return &onboardingtypes.QueryGetParticipantByNitroAddressResponse{Participant: &participant}, nil + if participant == nil { + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "participant with given Nitro address not found") + } + return &onboardingtypes.QueryGetParticipantByNitroAddressResponse{Participant: participant}, nil } diff --git a/x/onboarding/module/autocli.go b/x/onboarding/module/autocli.go index bc1a090c..6f00e87a 100644 --- a/x/onboarding/module/autocli.go +++ b/x/onboarding/module/autocli.go @@ -20,7 +20,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetParticipantByAddress", - Use: "get-by-address [address]", + Use: "get-by-address
", Short: "Get participant by address", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "address"}, @@ -28,7 +28,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetParticipantByNitroAddress", - Use: "get-by-nitro-address [nitro_address]", + Use: "get-by-nitro-address ", Short: "Get participant by nitro address", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "nitro_address"}, @@ -42,7 +42,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "OnboardParticipant", - Use: "enroll [eth_payload] [eth_signature] [role] [kyc_id]", + Use: "enroll ", Short: "Enroll a testnet validator", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "eth_payload"}, diff --git a/x/onboarding/module/depinject.go b/x/onboarding/module/depinject.go index d70163a7..72fe2213 100644 --- a/x/onboarding/module/depinject.go +++ b/x/onboarding/module/depinject.go @@ -3,18 +3,21 @@ package module import ( "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/event" + "cosmossdk.io/core/gas" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/onboarding/module/v1" + "git.vdb.to/cerc-io/laconicd/utils" "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper" ) -var _ appmodule.AppModule = AppModule{} - // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (am AppModule) IsOnePerModuleType() {} @@ -22,9 +25,9 @@ func (am AppModule) IsOnePerModuleType() {} func (am AppModule) IsAppModule() {} func init() { - appmodule.Register( + appconfig.RegisterModule( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + appconfig.Provide(ProvideModule), ) } @@ -34,6 +37,9 @@ type ModuleInputs struct { Cdc codec.Codec StoreService store.KVStoreService AddressCodec address.Codec + EventService event.Service + GasService gas.Service + Logger log.Logger Config *modulev1.Module } @@ -47,12 +53,8 @@ type ModuleOutputs struct { func ProvideModule(in ModuleInputs) ModuleOutputs { // default to governance as authority if not provided - authority := authtypes.NewModuleAddress("gov") - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - k := keeper.NewKeeper(in.Cdc, in.AddressCodec, in.StoreService, authority.String()) + authority := utils.AddressOrModuleAddress(in.Config.Authority, govtypes.ModuleName) + k := keeper.NewKeeper(in.Cdc, in.AddressCodec, in.StoreService, in.EventService, in.GasService, authority, in.Logger) m := NewAppModule(in.Cdc, k) return ModuleOutputs{Module: m, Keeper: k} diff --git a/x/onboarding/module/module.go b/x/onboarding/module/module.go index c483c2fe..9e7e3a0a 100644 --- a/x/onboarding/module/module.go +++ b/x/onboarding/module/module.go @@ -6,22 +6,24 @@ import ( "fmt" "cosmossdk.io/core/appmodule" - gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + registry "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "git.vdb.to/cerc-io/laconicd/x/onboarding" "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper" ) var ( - _ module.AppModuleBasic = AppModule{} - _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} + _ module.AppModuleBasic = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasConsensusVersion = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} ) // ConsensusVersion defines the current module consensus version. @@ -40,16 +42,12 @@ func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule { } } -func NewAppModuleBasic(m AppModule) module.AppModuleBasic { - return module.CoreAppModuleBasicAdaptor(m.Name(), m) -} +// module.AppModule // Name returns the onboarding module's name. func (AppModule) Name() string { return onboarding.ModuleName } -// RegisterLegacyAminoCodec registers the onboarding module's types on the LegacyAmino codec. -// New modules do not need to support Amino. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +// module.HasGRPCGateway // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the onboarding module. func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { @@ -58,14 +56,20 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } } +// appmodule.HasRegisterInterfaces + // RegisterInterfaces registers interfaces and implementations of the onboarding module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistry) { onboarding.RegisterInterfaces(registry) } +// appmodule.HasConsensusVersion + // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } +// module.HasServices + // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { // Register servers @@ -110,8 +114,12 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { gs, err := am.keeper.ExportGenesis(ctx) if err != nil { - panic(fmt.Sprintf("failed to export %s genesis state: %v", onboarding.ModuleName, err)) + panic(fmt.Errorf("failed to export %s genesis state: %w", onboarding.ModuleName, err)) } return cdc.MustMarshalJSON(gs) } + +// RegisterLegacyAminoCodec registers the onboarding module's types on the LegacyAmino codec. +// New modules do not need to support Amino. +func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} diff --git a/x/onboarding/msgs.go b/x/onboarding/msgs.go index c9f5a8c2..50cce28b 100644 --- a/x/onboarding/msgs.go +++ b/x/onboarding/msgs.go @@ -22,11 +22,11 @@ func (msg MsgOnboardParticipant) ValidateBasic() error { } if len(msg.EthSignature) != 132 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid signature.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid Eth signature") } if len(msg.KycId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Empty KYC ID.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Empty KYC ID") } isRoleValid := false diff --git a/x/onboarding/onboarding.pb.go b/x/onboarding/onboarding.pb.go index da16f232..8c611814 100644 --- a/x/onboarding/onboarding.pb.go +++ b/x/onboarding/onboarding.pb.go @@ -73,8 +73,8 @@ func (m *Params) GetOnboardingEnabled() bool { type Participant struct { // participant's cosmos (laconic) address CosmosAddress string `protobuf:"bytes,1,opt,name=cosmos_address,json=cosmosAddress,proto3" json:"cosmos_address,omitempty" json:"cosmos_address" yaml:"cosmos_address"` - // participant's Nitro address - NitroAddress string `protobuf:"bytes,2,opt,name=nitro_address,json=nitroAddress,proto3" json:"nitro_address,omitempty" json:"nitro_address" yaml:"nitro_address"` + // full public key used to derive participant's Nitro address + PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` // participant's role (participant | validator) Role string `protobuf:"bytes,3,opt,name=role,proto3" json:"role,omitempty" json:"role" yaml:"role"` // participant's KYC receipt ID @@ -121,11 +121,11 @@ func (m *Participant) GetCosmosAddress() string { return "" } -func (m *Participant) GetNitroAddress() string { +func (m *Participant) GetPublicKey() []byte { if m != nil { - return m.NitroAddress + return m.PublicKey } - return "" + return nil } func (m *Participant) GetRole() string { @@ -206,32 +206,32 @@ func init() { } var fileDescriptor_59afed779274eaf0 = []byte{ - // 399 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xc1, 0xce, 0xd2, 0x40, - 0x14, 0x85, 0xe9, 0x0f, 0xa2, 0x8e, 0x62, 0xe2, 0x44, 0x23, 0x4a, 0xec, 0x60, 0xdd, 0x60, 0x08, - 0x9d, 0x10, 0x12, 0x4d, 0x74, 0x65, 0x13, 0x16, 0xee, 0x48, 0x17, 0x2e, 0xdc, 0x90, 0xe9, 0x4c, - 0xad, 0x23, 0x6d, 0x87, 0xcc, 0x34, 0x8d, 0x7d, 0x0b, 0x9f, 0xc1, 0xa7, 0x71, 0xc9, 0xd2, 0x55, - 0x63, 0xe0, 0x0d, 0xfa, 0x04, 0xa6, 0x33, 0x14, 0x28, 0xfe, 0xbb, 0x7b, 0xcf, 0x3d, 0xe7, 0xbb, - 0xd3, 0xe6, 0x82, 0xd7, 0x34, 0x94, 0x14, 0x8b, 0x34, 0x10, 0x44, 0x32, 0x9e, 0x46, 0x38, 0x9f, - 0x5f, 0x74, 0xee, 0x56, 0x8a, 0x4c, 0x40, 0x58, 0x9b, 0xdc, 0x0b, 0x39, 0x9f, 0xbf, 0x78, 0x12, - 0x89, 0x48, 0xe8, 0x31, 0xae, 0x2b, 0xe3, 0x74, 0xb6, 0xa0, 0xbf, 0x22, 0x92, 0x24, 0x0a, 0x7e, - 0x05, 0xf0, 0x1c, 0x58, 0x87, 0x29, 0x09, 0xe2, 0x90, 0x0d, 0xad, 0xb1, 0x35, 0xb9, 0xe7, 0xbd, - 0xab, 0x4a, 0xb4, 0xf8, 0xae, 0x44, 0xfa, 0xde, 0xf9, 0xdf, 0xe3, 0x8c, 0x0b, 0x92, 0xc4, 0xb7, - 0x4e, 0xfc, 0xc7, 0x67, 0x71, 0x79, 0xd4, 0x7e, 0xdd, 0x80, 0x07, 0x2b, 0x22, 0x33, 0x4e, 0xf9, - 0x96, 0xa4, 0x19, 0xfc, 0x0c, 0x1e, 0x51, 0xa1, 0x12, 0xa1, 0xd6, 0x84, 0x31, 0x19, 0x2a, 0xa5, - 0x77, 0xde, 0xf7, 0x70, 0x55, 0xa2, 0xa9, 0xd9, 0xd9, 0x9e, 0x37, 0xfb, 0xae, 0x54, 0x7f, 0x60, - 0x84, 0x8f, 0xa6, 0x87, 0x3e, 0x18, 0xa4, 0x3c, 0x93, 0xe2, 0x84, 0xbd, 0xd1, 0xd8, 0x59, 0x55, - 0xa2, 0x37, 0x06, 0xdb, 0x1a, 0x37, 0xd4, 0xb6, 0xe8, 0x3f, 0xd4, 0x7d, 0xc3, 0xc4, 0xa0, 0x27, - 0x45, 0x1c, 0x0e, 0xbb, 0x1a, 0x35, 0xaa, 0x4a, 0xf4, 0xcc, 0xa0, 0x6a, 0xb5, 0x21, 0xe8, 0xda, - 0xd7, 0x46, 0xf8, 0x16, 0xf4, 0x37, 0x05, 0x5d, 0x73, 0x36, 0xec, 0xe9, 0x08, 0xaa, 0x4a, 0x34, - 0x32, 0x11, 0xa3, 0x37, 0xa1, 0x63, 0xe7, 0xdf, 0xd9, 0x14, 0xf4, 0x13, 0x73, 0x72, 0x00, 0x96, - 0xd9, 0xb7, 0x15, 0x29, 0x62, 0x41, 0x18, 0xfc, 0x00, 0xee, 0xb6, 0xff, 0xcd, 0xab, 0xaa, 0x44, - 0x2f, 0x0d, 0xe6, 0xea, 0xf9, 0xa7, 0x87, 0x37, 0x09, 0x38, 0x05, 0xdd, 0x44, 0x45, 0xc7, 0xaf, - 0x7f, 0x5e, 0x95, 0xe8, 0xa9, 0x09, 0x26, 0x2a, 0x6a, 0x42, 0x75, 0xe9, 0xd7, 0x2e, 0xcf, 0xfb, - 0xbd, 0xb7, 0xad, 0xdd, 0xde, 0xb6, 0xfe, 0xee, 0x6d, 0xeb, 0xe7, 0xc1, 0xee, 0xec, 0x0e, 0x76, - 0xe7, 0xcf, 0xc1, 0xee, 0x7c, 0x99, 0x44, 0x3c, 0x73, 0x73, 0x16, 0xb8, 0x99, 0xc0, 0xf5, 0x75, - 0xcd, 0xb8, 0xc0, 0x31, 0xa1, 0x22, 0xe5, 0x94, 0xe1, 0x1f, 0x17, 0x27, 0x18, 0xf4, 0xf5, 0x65, - 0x2d, 0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0x87, 0xe5, 0xd5, 0x6b, 0xaa, 0x02, 0x00, 0x00, + // 397 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x3f, 0x8b, 0xdb, 0x30, + 0x18, 0xc6, 0xe3, 0x26, 0x4d, 0x1b, 0xf5, 0x0f, 0x54, 0xb4, 0xd4, 0x6d, 0x88, 0x9d, 0xba, 0x4b, + 0x20, 0xd4, 0x22, 0x04, 0x5a, 0x68, 0xa7, 0x1a, 0x32, 0x94, 0x2e, 0xc1, 0x43, 0x87, 0x2e, 0x46, + 0x96, 0x5c, 0x57, 0x17, 0xdb, 0x32, 0x96, 0xcf, 0x9c, 0xbf, 0xc5, 0x7d, 0xac, 0x1b, 0x33, 0xde, + 0x64, 0x8e, 0x64, 0xbe, 0xc5, 0x9f, 0xe0, 0xb0, 0x14, 0x5f, 0xfe, 0xdc, 0x6d, 0x7a, 0x7f, 0xef, + 0xf3, 0xe8, 0xe1, 0x81, 0x17, 0x7c, 0x26, 0x41, 0x46, 0x10, 0x4f, 0x7c, 0x8e, 0x33, 0xca, 0x92, + 0x10, 0x15, 0xb3, 0x83, 0xc9, 0x4e, 0x33, 0x9e, 0x73, 0x08, 0x1b, 0x91, 0x7d, 0x80, 0x8b, 0xd9, + 0xc7, 0xb7, 0x21, 0x0f, 0xb9, 0x5c, 0xa3, 0xe6, 0xa5, 0x94, 0x56, 0x0a, 0xfa, 0x4b, 0x9c, 0xe1, + 0x58, 0xc0, 0x7f, 0x00, 0xee, 0x0d, 0x5e, 0x90, 0x60, 0x3f, 0x0a, 0xa8, 0xae, 0x8d, 0xb5, 0xc9, + 0x73, 0xe7, 0x5b, 0x5d, 0x99, 0xf3, 0x33, 0xc1, 0x93, 0xef, 0xd6, 0x43, 0x8d, 0x35, 0x2e, 0x71, + 0x1c, 0x3d, 0xba, 0x71, 0xdf, 0xec, 0xe1, 0x62, 0xc7, 0x6e, 0x35, 0xf0, 0x62, 0x89, 0xb3, 0x9c, + 0x11, 0x96, 0xe2, 0x24, 0x87, 0x7f, 0xc0, 0x6b, 0xc2, 0x45, 0xcc, 0x85, 0x87, 0x29, 0xcd, 0x02, + 0x21, 0x64, 0xe6, 0xc0, 0x41, 0x75, 0x65, 0x4e, 0x55, 0xe6, 0xf1, 0xbe, 0xcd, 0x3b, 0xa1, 0xee, + 0x2b, 0x05, 0x7e, 0xaa, 0x19, 0x8e, 0x00, 0x48, 0xcf, 0xfd, 0x88, 0x11, 0x6f, 0x15, 0x94, 0xfa, + 0x93, 0xb1, 0x36, 0x79, 0xe9, 0x0e, 0x14, 0xf9, 0x1d, 0x94, 0x10, 0x81, 0x5e, 0xc6, 0xa3, 0x40, + 0xef, 0xca, 0xb0, 0x61, 0x5d, 0x99, 0xef, 0x55, 0x58, 0x43, 0xdb, 0x08, 0xf9, 0x76, 0xa5, 0x10, + 0x7e, 0x05, 0xfd, 0x55, 0x49, 0x3c, 0x46, 0xf5, 0x9e, 0xb4, 0x98, 0x75, 0x65, 0x0e, 0x95, 0x45, + 0xf1, 0xd6, 0xb4, 0x9b, 0xdc, 0xa7, 0xab, 0x92, 0xfc, 0xa2, 0x56, 0x01, 0xc0, 0x22, 0xff, 0xbf, + 0xc4, 0x65, 0xc4, 0x31, 0x85, 0x3f, 0xc0, 0xb3, 0xe3, 0x9a, 0x9f, 0xea, 0xca, 0x1c, 0xa9, 0x6f, + 0x4e, 0xfa, 0xdd, 0x17, 0x6b, 0x1d, 0x70, 0x0a, 0xba, 0xb1, 0x08, 0x65, 0x97, 0x81, 0xf3, 0xa1, + 0xae, 0xcc, 0x77, 0xca, 0x18, 0x8b, 0xb0, 0x35, 0x35, 0x4f, 0xb7, 0x51, 0x39, 0xce, 0xd5, 0xc6, + 0xd0, 0xd6, 0x1b, 0x43, 0xbb, 0xd9, 0x18, 0xda, 0xe5, 0xd6, 0xe8, 0xac, 0xb7, 0x46, 0xe7, 0x7a, + 0x6b, 0x74, 0xfe, 0x4e, 0x42, 0x96, 0xdb, 0x05, 0xf5, 0xed, 0x9c, 0xa3, 0xe6, 0x50, 0xbe, 0x30, + 0x8e, 0x22, 0x4c, 0x78, 0xc2, 0x08, 0x45, 0x17, 0x07, 0xd7, 0xe4, 0xf7, 0xe5, 0x91, 0xcc, 0xef, + 0x02, 0x00, 0x00, 0xff, 0xff, 0xdb, 0xbd, 0x79, 0xd2, 0x75, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -301,10 +301,10 @@ func (m *Participant) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.NitroAddress) > 0 { - i -= len(m.NitroAddress) - copy(dAtA[i:], m.NitroAddress) - i = encodeVarintOnboarding(dAtA, i, uint64(len(m.NitroAddress))) + if len(m.PublicKey) > 0 { + i -= len(m.PublicKey) + copy(dAtA[i:], m.PublicKey) + i = encodeVarintOnboarding(dAtA, i, uint64(len(m.PublicKey))) i-- dAtA[i] = 0x12 } @@ -388,7 +388,7 @@ func (m *Participant) Size() (n int) { if l > 0 { n += 1 + l + sovOnboarding(uint64(l)) } - l = len(m.NitroAddress) + l = len(m.PublicKey) if l > 0 { n += 1 + l + sovOnboarding(uint64(l)) } @@ -559,9 +559,9 @@ func (m *Participant) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NitroAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowOnboarding @@ -571,23 +571,25 @@ func (m *Participant) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthOnboarding } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthOnboarding } if postIndex > l { return io.ErrUnexpectedEOF } - m.NitroAddress = string(dAtA[iNdEx:postIndex]) + m.PublicKey = append(m.PublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.PublicKey == nil { + m.PublicKey = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { diff --git a/x/onboarding/query.pb.go b/x/onboarding/query.pb.go index da9e079f..ee990692 100644 --- a/x/onboarding/query.pb.go +++ b/x/onboarding/query.pb.go @@ -336,41 +336,41 @@ func init() { func init() { proto.RegisterFile("cerc/onboarding/v1/query.proto", fileDescriptor_80831d904221d27d) } var fileDescriptor_80831d904221d27d = []byte{ - // 535 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xce, 0x96, 0x3f, 0xb1, 0x09, 0x97, 0x15, 0x12, 0x21, 0xaa, 0xdc, 0xc8, 0x41, 0xd4, 0x94, - 0x76, 0x97, 0x98, 0x03, 0x15, 0x02, 0xa1, 0xe6, 0x40, 0x6f, 0x50, 0x7c, 0xe4, 0x82, 0xd6, 0xf6, - 0xca, 0x5a, 0x94, 0xee, 0xba, 0xde, 0x6d, 0x44, 0x84, 0x7a, 0xe1, 0x09, 0x90, 0x10, 0x2f, 0xc3, - 0x89, 0x23, 0xc7, 0x4a, 0x08, 0xc4, 0x09, 0xa1, 0x84, 0x27, 0xe0, 0x09, 0x90, 0xd7, 0x86, 0xae, - 0x8b, 0xf3, 0x03, 0xe2, 0x66, 0xcf, 0xcc, 0x37, 0xdf, 0xf7, 0xcd, 0x8c, 0x0d, 0x9d, 0x88, 0x65, - 0x11, 0x91, 0x22, 0x94, 0x34, 0x8b, 0xb9, 0x48, 0xc8, 0xa8, 0x4f, 0x0e, 0x0e, 0x59, 0x36, 0xc6, - 0x69, 0x26, 0xb5, 0x44, 0x28, 0xcf, 0xe3, 0x93, 0x3c, 0x1e, 0xf5, 0x3b, 0x97, 0x13, 0x99, 0x48, - 0x93, 0x26, 0xf9, 0x53, 0x51, 0xd9, 0xd9, 0x88, 0xa4, 0xda, 0x97, 0x8a, 0x84, 0x54, 0xb1, 0xa2, - 0x05, 0x19, 0xf5, 0x43, 0xa6, 0x69, 0x9f, 0xa4, 0x34, 0xe1, 0x82, 0x6a, 0x2e, 0x45, 0x59, 0xdb, - 0xab, 0x61, 0xb5, 0x38, 0x8a, 0xa2, 0xd5, 0x44, 0xca, 0x64, 0xc8, 0x08, 0x4d, 0x39, 0xa1, 0x42, - 0x48, 0x6d, 0x3a, 0xa8, 0x22, 0xeb, 0x86, 0xb0, 0xfd, 0x24, 0x27, 0xd9, 0xa3, 0x99, 0xe6, 0x11, - 0x4f, 0xa9, 0xd0, 0x2a, 0x60, 0x07, 0x87, 0x4c, 0x69, 0xf4, 0x10, 0xc2, 0x13, 0xca, 0x36, 0xe8, - 0x02, 0xaf, 0xe9, 0x5f, 0xc7, 0x85, 0x3e, 0x9c, 0xeb, 0xc3, 0x85, 0xc5, 0x52, 0x1f, 0xde, 0xa3, - 0x09, 0x2b, 0xb1, 0x81, 0x85, 0x74, 0x3f, 0x03, 0x78, 0xb5, 0x86, 0x44, 0xa5, 0x52, 0x28, 0x86, - 0x52, 0xd8, 0x4a, 0xad, 0x78, 0x1b, 0x74, 0xcf, 0x78, 0x4d, 0x7f, 0x0d, 0xff, 0x39, 0x31, 0x6c, - 0xe1, 0x07, 0x37, 0x7f, 0x7c, 0x5d, 0x5b, 0x7f, 0xae, 0xa4, 0xb8, 0xeb, 0xda, 0x70, 0xb7, 0x3b, - 0xa6, 0xfb, 0xc3, 0x53, 0xb1, 0xa0, 0xc2, 0x80, 0x76, 0x2b, 0xbe, 0x56, 0x8c, 0xaf, 0xf5, 0x85, - 0xbe, 0x0a, 0xb9, 0x15, 0x63, 0x0f, 0x60, 0xcf, 0xf8, 0xda, 0x65, 0xda, 0x96, 0x36, 0xde, 0x89, - 0xe3, 0x8c, 0xa9, 0xdf, 0x73, 0x6c, 0xc3, 0x0b, 0xb4, 0x88, 0x98, 0x21, 0x5e, 0x0c, 0x7e, 0xbd, - 0xba, 0x1c, 0x5e, 0x9b, 0xdf, 0xa0, 0x9c, 0xd1, 0x0e, 0x6c, 0x5a, 0x0e, 0xca, 0x55, 0x2c, 0x1a, - 0x51, 0x60, 0x63, 0xdc, 0xc7, 0xd0, 0xab, 0xa5, 0x7a, 0xc4, 0x75, 0x26, 0x4f, 0x09, 0xee, 0xc1, - 0x4b, 0x22, 0x0f, 0x3f, 0xab, 0xca, 0x6e, 0x09, 0xab, 0xd6, 0x15, 0xf0, 0xc6, 0x12, 0x0d, 0xff, - 0x9b, 0x01, 0xff, 0xdd, 0x59, 0x78, 0xce, 0x10, 0xa2, 0xb7, 0x00, 0xb6, 0xec, 0x53, 0x42, 0x9b, - 0x75, 0x8d, 0x66, 0x9d, 0x75, 0x67, 0x6b, 0xc9, 0xea, 0x42, 0xba, 0xeb, 0xbd, 0xfa, 0xf8, 0xfd, - 0xcd, 0x8a, 0x8b, 0xba, 0xa4, 0xe6, 0x6b, 0xab, 0xdc, 0xd5, 0x7b, 0x00, 0xaf, 0xcc, 0xd8, 0x24, - 0xba, 0x33, 0x93, 0x74, 0xfe, 0xf1, 0x74, 0xb6, 0xff, 0x1e, 0x58, 0x0a, 0xf7, 0x8d, 0xf0, 0x4d, - 0xb4, 0xb1, 0x48, 0x38, 0x79, 0x59, 0xee, 0xf9, 0x08, 0x7d, 0x02, 0x70, 0x75, 0xde, 0x42, 0xd1, - 0xbd, 0xa5, 0xe5, 0xd4, 0x1c, 0x56, 0xe7, 0xfe, 0x3f, 0xa2, 0x4b, 0x47, 0xdb, 0xc6, 0x91, 0x8f, - 0x6e, 0x2d, 0x76, 0x54, 0xb9, 0xdf, 0xa3, 0xc1, 0xe0, 0xc3, 0xc4, 0x01, 0xc7, 0x13, 0x07, 0x7c, - 0x9b, 0x38, 0xe0, 0xf5, 0xd4, 0x69, 0x1c, 0x4f, 0x9d, 0xc6, 0x97, 0xa9, 0xd3, 0x78, 0xea, 0x25, - 0x5c, 0xe3, 0x51, 0x1c, 0x62, 0x2d, 0x4d, 0xd7, 0x2d, 0x2e, 0xc9, 0x90, 0x46, 0x52, 0xf0, 0x28, - 0x26, 0x2f, 0x2c, 0x8e, 0xf0, 0xbc, 0xf9, 0x63, 0xde, 0xfe, 0x19, 0x00, 0x00, 0xff, 0xff, 0x80, - 0xc2, 0x03, 0x70, 0xec, 0x05, 0x00, 0x00, + // 542 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x6e, 0xd3, 0x4c, + 0x18, 0xcd, 0xf4, 0xff, 0x01, 0x31, 0x09, 0x9b, 0x11, 0x12, 0x21, 0xaa, 0xdc, 0xc8, 0x41, 0xd4, + 0x94, 0x66, 0x46, 0x09, 0x0b, 0xee, 0x42, 0xc9, 0x82, 0xee, 0xa0, 0x78, 0xc9, 0x06, 0x8d, 0xed, + 0x91, 0x35, 0x28, 0x9d, 0x71, 0x3d, 0xd3, 0x88, 0xa8, 0xea, 0x86, 0x27, 0x40, 0x42, 0xbc, 0x0f, + 0x12, 0x1b, 0x96, 0x95, 0x90, 0x10, 0xab, 0x0a, 0x25, 0x3c, 0x01, 0x4f, 0x80, 0x3c, 0x36, 0x74, + 0x5c, 0x9c, 0x0b, 0x88, 0x9d, 0xfd, 0xdd, 0xce, 0x39, 0xdf, 0x77, 0x6c, 0xe8, 0x84, 0x2c, 0x0d, + 0x89, 0x14, 0x81, 0xa4, 0x69, 0xc4, 0x45, 0x4c, 0xc6, 0x3d, 0xb2, 0x7f, 0xc0, 0xd2, 0x09, 0x4e, + 0x52, 0xa9, 0x25, 0x42, 0x59, 0x1e, 0x9f, 0xe6, 0xf1, 0xb8, 0xd7, 0xba, 0x1c, 0xcb, 0x58, 0x9a, + 0x34, 0xc9, 0x9e, 0xf2, 0xca, 0xd6, 0x56, 0x28, 0xd5, 0x9e, 0x54, 0x24, 0xa0, 0x8a, 0xe5, 0x23, + 0xc8, 0xb8, 0x17, 0x30, 0x4d, 0x7b, 0x24, 0xa1, 0x31, 0x17, 0x54, 0x73, 0x29, 0x8a, 0xda, 0x4e, + 0x05, 0xaa, 0x85, 0x91, 0x17, 0xad, 0xc7, 0x52, 0xc6, 0x23, 0x46, 0x68, 0xc2, 0x09, 0x15, 0x42, + 0x6a, 0x33, 0x41, 0xe5, 0x59, 0x37, 0x80, 0xcd, 0x67, 0x19, 0xc8, 0x2e, 0x4d, 0x35, 0x0f, 0x79, + 0x42, 0x85, 0x56, 0x3e, 0xdb, 0x3f, 0x60, 0x4a, 0xa3, 0xc7, 0x10, 0x9e, 0x42, 0x36, 0x41, 0x1b, + 0x78, 0xf5, 0xfe, 0x75, 0x9c, 0xf3, 0xc3, 0x19, 0x3f, 0x9c, 0x4b, 0x2c, 0xf8, 0xe1, 0x5d, 0x1a, + 0xb3, 0xa2, 0xd7, 0xb7, 0x3a, 0xdd, 0xcf, 0x00, 0x5e, 0xad, 0x00, 0x51, 0x89, 0x14, 0x8a, 0xa1, + 0x04, 0x36, 0x12, 0x2b, 0xde, 0x04, 0xed, 0xff, 0xbc, 0x7a, 0x7f, 0x03, 0xff, 0xbe, 0x31, 0x6c, + 0xf5, 0x0f, 0x6f, 0x7e, 0x3f, 0xd9, 0xd8, 0x7c, 0xa9, 0xa4, 0xb8, 0xe7, 0xda, 0xed, 0x6e, 0x7b, + 0x42, 0xf7, 0x46, 0x67, 0x62, 0x7e, 0x09, 0x01, 0xed, 0x94, 0x74, 0xad, 0x19, 0x5d, 0x9b, 0x4b, + 0x75, 0xe5, 0x74, 0x4b, 0xc2, 0x1e, 0xc1, 0x8e, 0xd1, 0xb5, 0xc3, 0xb4, 0x4d, 0x6d, 0x32, 0x88, + 0xa2, 0x94, 0xa9, 0x5f, 0x7b, 0x6c, 0xc2, 0x0b, 0x34, 0x8f, 0x98, 0x25, 0x5e, 0xf4, 0x7f, 0xbe, + 0xba, 0x1c, 0x5e, 0x5b, 0x3c, 0xa0, 0xd8, 0xd1, 0x00, 0xd6, 0x2d, 0x05, 0xc5, 0x29, 0x96, 0xad, + 0xc8, 0xb7, 0x7b, 0xdc, 0xa7, 0xd0, 0xab, 0x84, 0x7a, 0xc2, 0x75, 0x2a, 0xcf, 0x10, 0xee, 0xc0, + 0x4b, 0x22, 0x0b, 0xbf, 0x28, 0xd3, 0x6e, 0x08, 0xab, 0xd6, 0x15, 0xf0, 0xc6, 0x0a, 0x03, 0xff, + 0x99, 0x80, 0xfe, 0x87, 0xff, 0xe1, 0x39, 0x03, 0x88, 0xde, 0x01, 0xd8, 0xb0, 0xad, 0x84, 0xb6, + 0xab, 0x06, 0xcd, 0xb3, 0x75, 0xab, 0xbb, 0x62, 0x75, 0x4e, 0xdd, 0xf5, 0x5e, 0x7f, 0xfa, 0xf6, + 0x76, 0xcd, 0x45, 0x6d, 0x52, 0xf1, 0xb5, 0x95, 0x7c, 0xf5, 0x1e, 0xc0, 0x2b, 0x73, 0x2e, 0x89, + 0x6e, 0xcf, 0x05, 0x5d, 0x6c, 0x9e, 0xd6, 0x9d, 0x3f, 0x6f, 0x2c, 0x88, 0xf7, 0x0d, 0xf1, 0x6d, + 0xb4, 0xb5, 0x8c, 0x38, 0x39, 0x2c, 0xee, 0x7c, 0x84, 0x4e, 0x00, 0x5c, 0x5f, 0x74, 0x50, 0xf4, + 0x60, 0x65, 0x3a, 0x15, 0xc6, 0x6a, 0x3d, 0xfc, 0xcb, 0xee, 0x42, 0xd1, 0xc0, 0x28, 0xba, 0x8f, + 0xee, 0x2e, 0x53, 0xd4, 0x0d, 0x26, 0x5d, 0x63, 0x56, 0x72, 0x58, 0x32, 0xf2, 0xd1, 0x70, 0xf8, + 0x71, 0xea, 0x80, 0xe3, 0xa9, 0x03, 0xbe, 0x4e, 0x1d, 0xf0, 0x66, 0xe6, 0xd4, 0x8e, 0x67, 0x4e, + 0xed, 0xcb, 0xcc, 0xa9, 0x3d, 0xf7, 0x62, 0xae, 0xf1, 0x38, 0x0a, 0xb0, 0x96, 0x66, 0x7c, 0x97, + 0x4b, 0x32, 0xa2, 0xa1, 0x14, 0x3c, 0x8c, 0xc8, 0x2b, 0x0b, 0x2c, 0x38, 0x6f, 0x7e, 0x9d, 0xb7, + 0x7e, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x10, 0xfa, 0xab, 0xf5, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -510,6 +510,7 @@ func _Query_GetParticipantByNitroAddress_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cerc.onboarding.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/onboarding/query.pb.gw.go b/x/onboarding/query.pb.gw.go index abdd95aa..a8daf04d 100644 --- a/x/onboarding/query.pb.gw.go +++ b/x/onboarding/query.pb.gw.go @@ -361,7 +361,7 @@ var ( pattern_Query_GetParticipantByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cerc", "onboarding", "v1", "participants", "address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_GetParticipantByNitroAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cerc", "onboarding", "v1", "participants", "nitro_address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_GetParticipantByNitroAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cerc", "onboarding", "v1", "participants-by-nitro", "nitro_address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/onboarding/tx.pb.go b/x/onboarding/tx.pb.go index 8c2f3d20..37f45ac3 100644 --- a/x/onboarding/tx.pb.go +++ b/x/onboarding/tx.pb.go @@ -252,6 +252,7 @@ func _Msg_OnboardParticipant_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cerc.onboarding.v1.Msg", HandlerType: (*MsgServer)(nil), diff --git a/x/registry/client/cli/tx.go b/x/registry/client/cli/tx.go index b14ad854..47fa1793 100644 --- a/x/registry/client/cli/tx.go +++ b/x/registry/client/cli/tx.go @@ -5,14 +5,14 @@ import ( "os" "strings" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - "gopkg.in/yaml.v3" - - "github.com/spf13/cobra" registrytypes "git.vdb.to/cerc-io/laconicd/x/registry" ) diff --git a/x/registry/codec.go b/x/registry/codec.go index cb6317c0..d1a792dc 100644 --- a/x/registry/codec.go +++ b/x/registry/codec.go @@ -1,12 +1,12 @@ package registry import ( - "github.com/cosmos/cosmos-sdk/codec/types" + registry "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSetName{}, &MsgReserveAuthority{}, @@ -21,5 +21,5 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgReassociateRecords{}, ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &Msg_serviceDesc) } diff --git a/x/registry/keeper/genesis.go b/x/registry/keeper/genesis.go index 9618253c..5bd7e4ed 100644 --- a/x/registry/keeper/genesis.go +++ b/x/registry/keeper/genesis.go @@ -1,31 +1,29 @@ package keeper import ( + "context" "time" - sdk "github.com/cosmos/cosmos-sdk/types" - "git.vdb.to/cerc-io/laconicd/x/registry" ) // InitGenesis initializes the module state from a genesis state. -func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error { +func (k *Keeper) InitGenesis(ctx context.Context, data *registry.GenesisState) error { if err := k.Params.Set(ctx, data.Params); err != nil { return err } + headerInfo := k.headerService.GetHeaderInfo(ctx) for _, record := range data.Records { if err := k.SaveRecord(ctx, record); err != nil { return err } - // Add to record expiry queue if expiry time is in the future. expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) if err != nil { return err } - - if expiryTime.After(ctx.BlockTime()) { + if expiryTime.After(headerInfo.Time) { if err := k.insertRecordExpiryQueue(ctx, record); err != nil { return err } @@ -41,11 +39,10 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error // Only import authorities that are marked active. if authority.Entry.Status == registry.AuthorityActive { // Reset authority height - authority.Entry.Height = uint64(ctx.BlockHeight()) + authority.Entry.Height = uint64(headerInfo.Height) if err := k.SaveNameAuthority(ctx, authority.Name, authority.Entry); err != nil { return err } - // Add authority name to expiry queue. if err := k.insertAuthorityExpiryQueue(ctx, authority.Name, authority.Entry.ExpiryTime); err != nil { return err @@ -58,27 +55,23 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error return err } } - return nil } // ExportGenesis exports the module state to a genesis state. -func (k *Keeper) ExportGenesis(ctx sdk.Context) (*registry.GenesisState, error) { +func (k *Keeper) ExportGenesis(ctx context.Context) (*registry.GenesisState, error) { params, err := k.Params.Get(ctx) if err != nil { return nil, err } - records, _, err := k.PaginatedListRecords(ctx, nil) if err != nil { return nil, err } - authorityEntries, err := k.ListNameAuthorityRecords(ctx, "") if err != nil { return nil, err } - names, err := k.ListNameRecords(ctx) if err != nil { return nil, err diff --git a/x/registry/keeper/invariants.go b/x/registry/keeper/invariants.go deleted file mode 100644 index 09cceada..00000000 --- a/x/registry/keeper/invariants.go +++ /dev/null @@ -1,74 +0,0 @@ -package keeper - -import ( - "errors" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - types "git.vdb.to/cerc-io/laconicd/x/registry" -) - -// RegisterInvariants registers all registry invariants -func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) { - ir.RegisterRoute(types.ModuleName, "module-account", ModuleAccountInvariant(&k)) - ir.RegisterRoute(types.ModuleName, "record-bond", RecordBondInvariant(&k)) -} - -// AllInvariants runs all invariants of the registry module. -func AllInvariants(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - res, stop := ModuleAccountInvariant(k)(ctx) - if stop { - return res, stop - } - - return RecordBondInvariant(k)(ctx) - } -} - -// ModuleAccountInvariant checks that the 'registry' module account balance is non-negative. -func ModuleAccountInvariant(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName) - if k.bankKeeper.GetAllBalances(ctx, moduleAddress).IsAnyNegative() { - return sdk.FormatInvariant( - types.ModuleName, - "module-account", - fmt.Sprintf("Module account '%s' has negative balance.", types.ModuleName), - ), true - } - - return "", false - } -} - -// RecordBondInvariant checks that for every record: -// if bondId is not null, associated bond exists -func RecordBondInvariant(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - err := k.Records.Walk(ctx, nil, func(key string, record types.Record) (bool, error) { - if record.BondId != "" { - bondExists, err := k.bondKeeper.HasBond(ctx, record.BondId) - if err != nil { - return true, err - } - - if !bondExists { - return true, errors.New(record.Id) - } - } - - return false, nil - }) - if err != nil { - return sdk.FormatInvariant( - types.ModuleName, - "record-bond", - fmt.Sprintf("Bond not found for record id: '%s'.", err.Error()), - ), true - } - - return "", false - } -} diff --git a/x/registry/keeper/keeper.go b/x/registry/keeper/keeper.go index e71c9f4d..8373f403 100644 --- a/x/registry/keeper/keeper.go +++ b/x/registry/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "bytes" + "context" "errors" "fmt" "sort" @@ -9,11 +10,15 @@ import ( "cosmossdk.io/collections" "cosmossdk.io/collections/indexes" - storetypes "cosmossdk.io/core/store" + "cosmossdk.io/core/address" + "cosmossdk.io/core/event" + "cosmossdk.io/core/header" + store "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -93,9 +98,13 @@ func newNameRecordIndexes(sb *collections.SchemaBuilder) NameRecordsIndexes { } type Keeper struct { - cdc codec.BinaryCodec + cdc codec.BinaryCodec + addressCodec address.Codec + logger log.Logger + headerService header.Service + eventService event.Service - authority string + authority types.AccAddress accountKeeper auth.AccountKeeper bankKeeper bank.Keeper @@ -116,21 +125,23 @@ type Keeper struct { // NewKeeper creates a new Keeper instance func NewKeeper( cdc codec.BinaryCodec, - storeService storetypes.KVStoreService, + storeService store.KVStoreService, + headerService header.Service, + eventService event.Service, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, bondKeeper *bondkeeper.Keeper, auctionKeeper *auctionkeeper.Keeper, - authority string, + authority types.AccAddress, + logger log.Logger, ) Keeper { - // ensure that authority is a valid AccAddress - if _, err := accountKeeper.AddressCodec().StringToBytes(authority); err != nil { - panic("authority is not a valid acc address") - } - sb := collections.NewSchemaBuilder(storeService) k := Keeper{ cdc: cdc, + addressCodec: accountKeeper.AddressCodec(), + headerService: headerService, + eventService: eventService, + logger: logger.With(log.ModuleKey, "x/"+registrytypes.ModuleName), authority: authority, accountKeeper: accountKeeper, bankKeeper: bankKeeper, @@ -176,27 +187,13 @@ func NewKeeper( return k } -// Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return logger(ctx) -} - -func logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", registrytypes.ModuleName) -} - -// GetAuthority returns the x/registry module's authority. -func (k Keeper) GetAuthority() string { - return k.authority -} - // SetParams sets the x/registry module parameters. -func (k Keeper) SetParams(ctx sdk.Context, params registrytypes.Params) error { +func (k Keeper) SetParams(ctx context.Context, params registrytypes.Params) error { return k.Params.Set(ctx, params) } // HasRecord - checks if a record by the given id exists. -func (k Keeper) HasRecord(ctx sdk.Context, id string) (bool, error) { +func (k Keeper) HasRecord(ctx context.Context, id string) (bool, error) { has, err := k.Records.Has(ctx, id) if err != nil { return false, err @@ -206,7 +203,7 @@ func (k Keeper) HasRecord(ctx sdk.Context, id string) (bool, error) { } // PaginatedListRecords - get all records with optional pagination. -func (k Keeper) PaginatedListRecords(ctx sdk.Context, pagination *query.PageRequest) ([]registrytypes.Record, *query.PageResponse, error) { +func (k Keeper) PaginatedListRecords(ctx context.Context, pagination *query.PageRequest) ([]registrytypes.Record, *query.PageResponse, error) { var records []registrytypes.Record var pageResp *query.PageResponse @@ -244,7 +241,7 @@ func (k Keeper) PaginatedListRecords(ctx sdk.Context, pagination *query.PageRequ } // GetRecordById - gets a record from the store. -func (k Keeper) GetRecordById(ctx sdk.Context, id string) (registrytypes.Record, error) { +func (k Keeper) GetRecordById(ctx context.Context, id string) (registrytypes.Record, error) { record, err := k.Records.Get(ctx, id) if err != nil { return registrytypes.Record{}, err @@ -258,7 +255,7 @@ func (k Keeper) GetRecordById(ctx sdk.Context, id string) (registrytypes.Record, } // GetRecordsByBondId - gets a record from the store. -func (k Keeper) GetRecordsByBondId(ctx sdk.Context, bondId string) ([]registrytypes.Record, error) { +func (k Keeper) GetRecordsByBondId(ctx context.Context, bondId string) ([]registrytypes.Record, error) { var records []registrytypes.Record err := k.Records.Indexes.BondId.Walk(ctx, collections.NewPrefixedPairRange[string, string](bondId), func(bondId string, id string) (bool, error) { @@ -284,7 +281,7 @@ func (k Keeper) GetRecordsByBondId(ctx sdk.Context, bondId string) ([]registryty // PaginatedRecordsFromAttributes gets a list of records whose attributes match all provided values // with optional pagination. func (k Keeper) PaginatedRecordsFromAttributes( - ctx sdk.Context, + ctx context.Context, attributes []*registrytypes.QueryRecordsRequest_KeyValueInput, all bool, pagination *query.PageRequest, @@ -385,12 +382,12 @@ func QueryValueToJSON(input *registrytypes.QueryRecordsRequest_ValueInput) ([]by } // PutRecord - saves a record to the store. -func (k Keeper) SaveRecord(ctx sdk.Context, record registrytypes.Record) error { +func (k Keeper) SaveRecord(ctx context.Context, record registrytypes.Record) error { return k.Records.Set(ctx, record.Id, record) } // ProcessSetRecord creates a record. -func (k Keeper) SetRecord(ctx sdk.Context, msg registrytypes.MsgSetRecord) (*registrytypes.ReadableRecord, error) { +func (k Keeper) SetRecord(ctx context.Context, msg registrytypes.MsgSetRecord) (*registrytypes.ReadableRecord, error) { payload := msg.Payload.ToReadablePayload() record := registrytypes.ReadableRecord{Attributes: payload.RecordAttributes, BondId: msg.BondId} @@ -436,21 +433,23 @@ func (k Keeper) SetRecord(ctx sdk.Context, msg registrytypes.MsgSetRecord) (*reg return &record, nil } -func (k Keeper) processRecord(ctx sdk.Context, record *registrytypes.ReadableRecord) error { +func (k Keeper) processRecord(ctx context.Context, record *registrytypes.ReadableRecord) error { params, err := k.GetParams(ctx) if err != nil { return err } rent := params.RecordRent - if err = k.bondKeeper.TransferCoinsToModuleAccount( + if err = k.bondKeeper.TransferRentToModuleAccount( ctx, record.BondId, registrytypes.RecordRentModuleAccountName, sdk.NewCoins(rent), ); err != nil { return err } - record.CreateTime = ctx.BlockHeader().Time.Format(time.RFC3339) - record.ExpiryTime = ctx.BlockHeader().Time.Add(params.RecordRentDuration).Format(time.RFC3339) + // TODO use HeaderService + createTime := k.headerService.GetHeaderInfo(ctx).Time + record.CreateTime = createTime.Format(time.RFC3339) + record.ExpiryTime = createTime.Add(params.RecordRentDuration).Format(time.RFC3339) record.Deleted = false recordObj, err := record.ToRecordObj() @@ -472,7 +471,7 @@ func (k Keeper) processRecord(ctx sdk.Context, record *registrytypes.ReadableRec return k.insertRecordExpiryQueue(ctx, recordObj) } -func (k Keeper) processAttributes(ctx sdk.Context, attrs registrytypes.AttributeMap, id string) error { +func (k Keeper) processAttributes(ctx context.Context, attrs registrytypes.AttributeMap, id string) error { np := basicnode.Prototype.Map nb := np.NewBuilder() encAttrs, err := canonicaljson.Marshal(attrs) @@ -494,7 +493,7 @@ func (k Keeper) processAttributes(ctx sdk.Context, attrs registrytypes.Attribute return k.processAttributeMap(ctx, n, id, "") } -func (k Keeper) processAttributeMap(ctx sdk.Context, n ipld.Node, id string, prefix string) error { +func (k Keeper) processAttributeMap(ctx context.Context, n ipld.Node, id string, prefix string) error { for it := n.MapIterator(); !it.Done(); { //nolint:misspell keynode, valuenode, err := it.Next() @@ -527,7 +526,7 @@ func (k Keeper) processAttributeMap(ctx sdk.Context, n ipld.Node, id string, pre return nil } -func (k Keeper) setAttributeMapping(ctx sdk.Context, key collections.Pair[string, string], recordId string) error { +func (k Keeper) setAttributeMapping(ctx context.Context, key collections.Pair[string, string], recordId string) error { var recordIds []string has, err := k.AttributesMap.Has(ctx, key) @@ -547,13 +546,13 @@ func (k Keeper) setAttributeMapping(ctx sdk.Context, key collections.Pair[string return k.AttributesMap.Set(ctx, key, registrytypes.RecordsList{Value: recordIds}) } -func (k Keeper) getAttributeMapping(ctx sdk.Context, key collections.Pair[string, string]) ([]string, error) { +func (k Keeper) getAttributeMapping(ctx context.Context, key collections.Pair[string, string]) ([]string, error) { if has, err := k.AttributesMap.Has(ctx, key); !has { if err != nil { return []string{}, err } - k.Logger(ctx).Debug(fmt.Sprintf("store doesn't have key: %v", key)) + k.logger.Debug(fmt.Sprintf("store doesn't have key: %v", key)) return []string{}, nil } @@ -565,7 +564,7 @@ func (k Keeper) getAttributeMapping(ctx sdk.Context, key collections.Pair[string return value.Value, nil } -func (k Keeper) populateRecordNames(ctx sdk.Context, record *registrytypes.Record) error { +func (k Keeper) populateRecordNames(ctx context.Context, record *registrytypes.Record) error { iter, err := k.NameRecords.Indexes.Cid.MatchExact(ctx, record.Id) if err != nil { return err @@ -581,7 +580,7 @@ func (k Keeper) populateRecordNames(ctx sdk.Context, record *registrytypes.Recor } // GetModuleBalances gets the registry module account(s) balances. -func (k Keeper) GetModuleBalances(ctx sdk.Context) []*registrytypes.AccountBalance { +func (k Keeper) GetModuleBalances(ctx context.Context) []*registrytypes.AccountBalance { var balances []*registrytypes.AccountBalance accountNames := []string{ registrytypes.RecordRentModuleAccountName, @@ -605,8 +604,8 @@ func (k Keeper) GetModuleBalances(ctx sdk.Context) []*registrytypes.AccountBalan } // ProcessRecordExpiryQueue tries to renew expiring records (by collecting rent) else marks them as deleted. -func (k Keeper) ProcessRecordExpiryQueue(ctx sdk.Context) error { - cids, err := k.getAllExpiredRecords(ctx, ctx.BlockHeader().Time) +func (k Keeper) ProcessRecordExpiryQueue(ctx context.Context) error { + cids, err := k.getAllExpiredRecords(ctx, k.headerService.GetHeaderInfo(ctx).Time) if err != nil { return err } @@ -647,7 +646,7 @@ func (k Keeper) ProcessRecordExpiryQueue(ctx sdk.Context) error { } // getAllExpiredRecords returns a concatenated list of all the timeslices before currTime. -func (k Keeper) getAllExpiredRecords(ctx sdk.Context, currTime time.Time) ([]string, error) { +func (k Keeper) getAllExpiredRecords(ctx context.Context, currTime time.Time) ([]string, error) { var expiredRecordCIDs []string // Get all the records with expiry time until currTime @@ -664,7 +663,7 @@ func (k Keeper) getAllExpiredRecords(ctx sdk.Context, currTime time.Time) ([]str } // insertRecordExpiryQueue inserts a record CID to the appropriate timeslice in the record expiry queue. -func (k Keeper) insertRecordExpiryQueue(ctx sdk.Context, record registrytypes.Record) error { +func (k Keeper) insertRecordExpiryQueue(ctx context.Context, record registrytypes.Record) error { expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) if err != nil { return err @@ -688,7 +687,7 @@ func (k Keeper) insertRecordExpiryQueue(ctx sdk.Context, record registrytypes.Re } // deleteRecordExpiryQueue deletes a record CID from the record expiry queue. -func (k Keeper) deleteRecordExpiryQueue(ctx sdk.Context, record registrytypes.Record) error { +func (k Keeper) deleteRecordExpiryQueue(ctx context.Context, record registrytypes.Record) error { expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) if err != nil { return err @@ -715,14 +714,14 @@ func (k Keeper) deleteRecordExpiryQueue(ctx sdk.Context, record registrytypes.Re } // tryTakeRecordRent tries to take rent from the record bond. -func (k Keeper) tryTakeRecordRent(ctx sdk.Context, record registrytypes.Record) error { +func (k Keeper) tryTakeRecordRent(ctx context.Context, record registrytypes.Record) error { params, err := k.GetParams(ctx) if err != nil { return err } rent := params.RecordRent - sdkErr := k.bondKeeper.TransferCoinsToModuleAccount(ctx, record.BondId, registrytypes.RecordRentModuleAccountName, sdk.NewCoins(rent)) + sdkErr := k.bondKeeper.TransferRentToModuleAccount(ctx, record.BondId, registrytypes.RecordRentModuleAccountName, sdk.NewCoins(rent)) if sdkErr != nil { // Insufficient funds, mark record as deleted. record.Deleted = true @@ -738,7 +737,7 @@ func (k Keeper) tryTakeRecordRent(ctx sdk.Context, record registrytypes.Record) return err } - record.ExpiryTime = ctx.BlockHeader().Time.Add(params.RecordRentDuration).Format(time.RFC3339) + record.ExpiryTime = k.headerService.GetHeaderInfo(ctx).Time.Add(params.RecordRentDuration).Format(time.RFC3339) if err := k.insertRecordExpiryQueue(ctx, record); err != nil { return err } diff --git a/x/registry/keeper/msg_server.go b/x/registry/keeper/msg_server.go index 1d11519b..01646eb8 100644 --- a/x/registry/keeper/msg_server.go +++ b/x/registry/keeper/msg_server.go @@ -3,9 +3,9 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" + "cosmossdk.io/core/event" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "git.vdb.to/cerc-io/laconicd/utils" registrytypes "git.vdb.to/cerc-io/laconicd/x/registry" @@ -22,15 +22,15 @@ func NewMsgServerImpl(keeper Keeper) registrytypes.MsgServer { return &msgServer{k: keeper} } -func (ms msgServer) SetRecord(c context.Context, msg *registrytypes.MsgSetRecord) (*registrytypes.MsgSetRecordResponse, error) { +func (ms msgServer) SetRecord(ctx context.Context, msg *registrytypes.MsgSetRecord) (*registrytypes.MsgSetRecordResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -40,35 +40,38 @@ func (ms msgServer) SetRecord(c context.Context, msg *registrytypes.MsgSetRecord return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeSetRecord, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.GetSigner()), - sdk.NewAttribute(registrytypes.AttributeKeyBondId, msg.GetBondId()), - sdk.NewAttribute(registrytypes.AttributeKeyPayload, msg.Payload.Record.Id), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "SetRecord") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeSetRecord, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.GetSigner()}, + event.Attribute{Key: registrytypes.AttributeKeyBondId, Value: msg.GetBondId()}, + event.Attribute{Key: registrytypes.AttributeKeyPayload, Value: msg.Payload.Record.Id}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeSetRecord) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgSetRecordResponse{Id: record.Id}, nil } // nolint: all -func (ms msgServer) SetName(c context.Context, msg *registrytypes.MsgSetName) (*registrytypes.MsgSetNameResponse, error) { +func (ms msgServer) SetName(ctx context.Context, msg *registrytypes.MsgSetName) (*registrytypes.MsgSetNameResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -78,38 +81,41 @@ func (ms msgServer) SetName(c context.Context, msg *registrytypes.MsgSetName) (* return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeSetRecord, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyLRN, msg.Lrn), - sdk.NewAttribute(registrytypes.AttributeKeyCID, msg.Cid), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "SetName") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeSetRecord, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyLRN, Value: msg.Lrn}, + event.Attribute{Key: registrytypes.AttributeKeyCID, Value: msg.Cid}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeSetRecord) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgSetNameResponse{}, nil } -func (ms msgServer) ReserveAuthority(c context.Context, msg *registrytypes.MsgReserveAuthority) (*registrytypes.MsgReserveAuthorityResponse, error) { +func (ms msgServer) ReserveAuthority(ctx context.Context, msg *registrytypes.MsgReserveAuthority) (*registrytypes.MsgReserveAuthorityResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } - _, err = sdk.AccAddressFromBech32(msg.Owner) + _, err = addrCodec.StringToBytes(msg.Owner) if err != nil { return nil, err } @@ -119,35 +125,38 @@ func (ms msgServer) ReserveAuthority(c context.Context, msg *registrytypes.MsgRe return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeReserveAuthority, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyName, msg.Name), - sdk.NewAttribute(registrytypes.AttributeKeyOwner, msg.Owner), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "ReserveAuthority") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeReserveAuthority, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyName, Value: msg.Name}, + event.Attribute{Key: registrytypes.AttributeKeyOwner, Value: msg.Owner}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeReserveAuthority) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgReserveAuthorityResponse{}, nil } // nolint: all -func (ms msgServer) SetAuthorityBond(c context.Context, msg *registrytypes.MsgSetAuthorityBond) (*registrytypes.MsgSetAuthorityBondResponse, error) { +func (ms msgServer) SetAuthorityBond(ctx context.Context, msg *registrytypes.MsgSetAuthorityBond) (*registrytypes.MsgSetAuthorityBondResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -157,34 +166,37 @@ func (ms msgServer) SetAuthorityBond(c context.Context, msg *registrytypes.MsgSe return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeAuthorityBond, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyName, msg.Name), - sdk.NewAttribute(registrytypes.AttributeKeyBondId, msg.BondId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "SetAuthorityBond") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeAuthorityBond, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyName, Value: msg.Name}, + event.Attribute{Key: registrytypes.AttributeKeyBondId, Value: msg.BondId}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeAuthorityBond) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgSetAuthorityBondResponse{}, nil } -func (ms msgServer) DeleteName(c context.Context, msg *registrytypes.MsgDeleteName) (*registrytypes.MsgDeleteNameResponse, error) { +func (ms msgServer) DeleteName(ctx context.Context, msg *registrytypes.MsgDeleteName) (*registrytypes.MsgDeleteNameResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -194,70 +206,76 @@ func (ms msgServer) DeleteName(c context.Context, msg *registrytypes.MsgDeleteNa return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeDeleteName, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyLRN, msg.Lrn), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "DeleteName") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeDeleteName, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyLRN, Value: msg.Lrn}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeDeleteName) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgDeleteNameResponse{}, nil } -func (ms msgServer) RenewRecord(c context.Context, msg *registrytypes.MsgRenewRecord) (*registrytypes.MsgRenewRecordResponse, error) { +func (ms msgServer) RenewRecord(ctx context.Context, msg *registrytypes.MsgRenewRecord) (*registrytypes.MsgRenewRecordResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } - err = ms.k.RenewRecord(ctx, *msg) + err = ms.k.RenewRecord(ctx, *msg, ms.k.headerService.GetHeaderInfo(ctx).Time) if err != nil { return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeRenewRecord, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyRecordId, msg.RecordId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "RenewRecord") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeRenewRecord, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyRecordId, Value: msg.RecordId}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeRenewRecord) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgRenewRecordResponse{}, nil } // nolint: all -func (ms msgServer) AssociateBond(c context.Context, msg *registrytypes.MsgAssociateBond) (*registrytypes.MsgAssociateBondResponse, error) { +func (ms msgServer) AssociateBond(ctx context.Context, msg *registrytypes.MsgAssociateBond) (*registrytypes.MsgAssociateBondResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -267,34 +285,37 @@ func (ms msgServer) AssociateBond(c context.Context, msg *registrytypes.MsgAssoc return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeAssociateBond, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyRecordId, msg.RecordId), - sdk.NewAttribute(registrytypes.AttributeKeyBondId, msg.BondId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "AssociateBond") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeAssociateBond, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyRecordId, Value: msg.RecordId}, + event.Attribute{Key: registrytypes.AttributeKeyBondId, Value: msg.BondId}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeAssociateBond) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgAssociateBondResponse{}, nil } -func (ms msgServer) DissociateBond(c context.Context, msg *registrytypes.MsgDissociateBond) (*registrytypes.MsgDissociateBondResponse, error) { +func (ms msgServer) DissociateBond(ctx context.Context, msg *registrytypes.MsgDissociateBond) (*registrytypes.MsgDissociateBondResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -304,36 +325,39 @@ func (ms msgServer) DissociateBond(c context.Context, msg *registrytypes.MsgDiss return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeDissociateBond, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyRecordId, msg.RecordId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "DissociateBond") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeDissociateBond, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyRecordId, Value: msg.RecordId}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeDissociateBond) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgDissociateBondResponse{}, nil } func (ms msgServer) DissociateRecords( - c context.Context, + ctx context.Context, msg *registrytypes.MsgDissociateRecords, ) (*registrytypes.MsgDissociateRecordsResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -343,33 +367,36 @@ func (ms msgServer) DissociateRecords( return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeDissociateRecords, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyBondId, msg.BondId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "DissociateRecords") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeDissociateRecords, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyBondId, Value: msg.BondId}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeDissociateRecords) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgDissociateRecordsResponse{}, nil } -func (ms msgServer) ReassociateRecords(c context.Context, msg *registrytypes.MsgReassociateRecords) (*registrytypes.MsgReassociateRecordsResponse, error) { //nolint: all +func (ms msgServer) ReassociateRecords(ctx context.Context, msg *registrytypes.MsgReassociateRecords) (*registrytypes.MsgReassociateRecordsResponse, error) { //nolint: all if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - ctx = *utils.CtxWithCustomKVGasConfig(&ctx) + // Registry module doesn't use gas tracking - _, err := sdk.AccAddressFromBech32(msg.Signer) + addrCodec := utils.NewAddressCodec() + _, err := addrCodec.StringToBytes(msg.Signer) if err != nil { return nil, err } @@ -379,37 +406,38 @@ func (ms msgServer) ReassociateRecords(c context.Context, msg *registrytypes.Msg return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - registrytypes.EventTypeReassociateRecords, - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - sdk.NewAttribute(registrytypes.AttributeKeyOldBondId, msg.OldBondId), - sdk.NewAttribute(registrytypes.AttributeKeyNewBondId, msg.NewBondId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, registrytypes.AttributeValueCategory), - sdk.NewAttribute(registrytypes.AttributeKeySigner, msg.Signer), - ), - }) - - utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "ReassociateRecords") + eventManager := ms.k.eventService.EventManager(ctx) + if err := eventManager.EmitKV( + ctx, + registrytypes.EventTypeReassociateRecords, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + event.Attribute{Key: registrytypes.AttributeKeyOldBondId, Value: msg.OldBondId}, + event.Attribute{Key: registrytypes.AttributeKeyNewBondId, Value: msg.NewBondId}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", registrytypes.EventTypeReassociateRecords) + } + if err := eventManager.EmitKV( + ctx, + sdk.EventTypeMessage, + event.Attribute{Key: sdk.AttributeKeyModule, Value: registrytypes.AttributeValueCategory}, + event.Attribute{Key: registrytypes.AttributeKeySigner, Value: msg.Signer}, + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", sdk.EventTypeMessage) + } return ®istrytypes.MsgReassociateRecordsResponse{}, nil } // UpdateParams defines a method to perform updation of module params. -func (ms msgServer) UpdateParams(c context.Context, msg *registrytypes.MsgUpdateParams) (*registrytypes.MsgUpdateParamsResponse, error) { - if ms.k.authority != msg.Authority { - return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority) +func (ms msgServer) UpdateParams(ctx context.Context, msg *registrytypes.MsgUpdateParams) (*registrytypes.MsgUpdateParamsResponse, error) { + if err := utils.CheckAuthorityAddress(ms.k.addressCodec, ms.k.authority, msg.Authority); err != nil { + return nil, err } if err := msg.Params.Validate(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c) - if err := ms.k.SetParams(ctx, msg.Params); err != nil { return nil, err } diff --git a/x/registry/keeper/naming_keeper.go b/x/registry/keeper/naming_keeper.go index 096d1272..df851f69 100644 --- a/x/registry/keeper/naming_keeper.go +++ b/x/registry/keeper/naming_keeper.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "errors" "fmt" "net/url" @@ -16,13 +17,14 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "git.vdb.to/cerc-io/laconicd/app/params" + "git.vdb.to/cerc-io/laconicd/utils" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" registrytypes "git.vdb.to/cerc-io/laconicd/x/registry" "git.vdb.to/cerc-io/laconicd/x/registry/helpers" ) // HasNameAuthority - checks if a name/authority exists. -func (k Keeper) HasNameAuthority(ctx sdk.Context, name string) (bool, error) { +func (k Keeper) HasNameAuthority(ctx context.Context, name string) (bool, error) { has, err := k.Authorities.Has(ctx, name) if err != nil { return false, err @@ -32,11 +34,11 @@ func (k Keeper) HasNameAuthority(ctx sdk.Context, name string) (bool, error) { } // GetNameAuthority - gets a name authority from the store. -func (k Keeper) GetNameAuthority(ctx sdk.Context, name string) (registrytypes.NameAuthority, error) { +func (k Keeper) GetNameAuthority(ctx context.Context, name string) (registrytypes.NameAuthority, error) { authority, err := k.Authorities.Get(ctx, name) if err != nil { if errors.Is(err, collections.ErrNotFound) { - return registrytypes.NameAuthority{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Name authority not found.") + return registrytypes.NameAuthority{}, errorsmod.Wrap(sdkerrors.ErrNotFound, "name authority not found") } return registrytypes.NameAuthority{}, err } @@ -46,7 +48,7 @@ func (k Keeper) GetNameAuthority(ctx sdk.Context, name string) (registrytypes.Na // ListNameAuthorityRecords - get all name authority records for given owner // Returns all authorities if owner set to "" -func (k Keeper) ListNameAuthorityRecords(ctx sdk.Context, owner string) ([]registrytypes.AuthorityEntry, error) { +func (k Keeper) ListNameAuthorityRecords(ctx context.Context, owner string) ([]registrytypes.AuthorityEntry, error) { authorityEntries := []registrytypes.AuthorityEntry{} err := k.Authorities.Walk(ctx, nil, func(key string, value registrytypes.NameAuthority) (bool, error) { @@ -71,12 +73,12 @@ func (k Keeper) ListNameAuthorityRecords(ctx sdk.Context, owner string) ([]regis } // HasNameRecord - checks if a name record exists. -func (k Keeper) HasNameRecord(ctx sdk.Context, lrn string) (bool, error) { +func (k Keeper) HasNameRecord(ctx context.Context, lrn string) (bool, error) { return k.NameRecords.Has(ctx, lrn) } // GetNameRecord - gets a name record from the store. -func (k Keeper) GetNameRecord(ctx sdk.Context, lrn string) (*registrytypes.NameRecord, error) { +func (k Keeper) GetNameRecord(ctx context.Context, lrn string) (*registrytypes.NameRecord, error) { nameRecord, err := k.NameRecords.Get(ctx, lrn) if err != nil { if errors.Is(err, collections.ErrNotFound) { @@ -89,7 +91,7 @@ func (k Keeper) GetNameRecord(ctx sdk.Context, lrn string) (*registrytypes.NameR } // LookupNameRecord - gets a name record which is not stale and under active authority. -func (k Keeper) LookupNameRecord(ctx sdk.Context, lrn string) (*registrytypes.NameRecord, error) { +func (k Keeper) LookupNameRecord(ctx context.Context, lrn string) (*registrytypes.NameRecord, error) { _, _, authority, err := k.getAuthority(ctx, lrn) if err != nil || authority.Status != registrytypes.AuthorityActive { // If authority is not active (or any other error), lookup fails. @@ -113,7 +115,7 @@ func (k Keeper) LookupNameRecord(ctx sdk.Context, lrn string) (*registrytypes.Na } // ListNameRecords - get all name records. -func (k Keeper) ListNameRecords(ctx sdk.Context) ([]registrytypes.NameEntry, error) { +func (k Keeper) ListNameRecords(ctx context.Context) ([]registrytypes.NameEntry, error) { var nameEntries []registrytypes.NameEntry err := k.NameRecords.Walk(ctx, nil, func(key string, value registrytypes.NameRecord) (stop bool, err error) { @@ -129,7 +131,7 @@ func (k Keeper) ListNameRecords(ctx sdk.Context) ([]registrytypes.NameEntry, err } // SaveNameRecord - sets a name record. -func (k Keeper) SaveNameRecord(ctx sdk.Context, lrn string, id string) error { +func (k Keeper) SaveNameRecord(ctx context.Context, lrn string, id string) error { var nameRecord registrytypes.NameRecord existingNameRecord, err := k.GetNameRecord(ctx, lrn) if err != nil { @@ -143,15 +145,15 @@ func (k Keeper) SaveNameRecord(ctx sdk.Context, lrn string, id string) error { nameRecord.Latest = ®istrytypes.NameRecordEntry{ Id: id, - Height: uint64(ctx.BlockHeight()), + Height: uint64(k.headerService.GetHeaderInfo(ctx).Height), } return k.NameRecords.Set(ctx, lrn, nameRecord) } // SetName creates a LRN -> Record ID mapping. -func (k Keeper) SetName(ctx sdk.Context, msg registrytypes.MsgSetName) error { - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) +func (k Keeper) SetName(ctx context.Context, msg registrytypes.MsgSetName) error { + signerAddress, err := utils.NewAddressCodec().StringToBytes(msg.Signer) if err != nil { return err } @@ -172,12 +174,12 @@ func (k Keeper) SetName(ctx sdk.Context, msg registrytypes.MsgSetName) error { } // SaveNameAuthority creates the NameAuthority record. -func (k Keeper) SaveNameAuthority(ctx sdk.Context, name string, authority *registrytypes.NameAuthority) error { +func (k Keeper) SaveNameAuthority(ctx context.Context, name string, authority *registrytypes.NameAuthority) error { return k.Authorities.Set(ctx, name, *authority) } // ReserveAuthority reserves a name authority. -func (k Keeper) ReserveAuthority(ctx sdk.Context, msg registrytypes.MsgReserveAuthority) error { +func (k Keeper) ReserveAuthority(ctx context.Context, msg registrytypes.MsgReserveAuthority) error { lrn := fmt.Sprintf("lrn://%s", msg.GetName()) parsedLrn, err := url.Parse(lrn) if err != nil { @@ -202,7 +204,7 @@ func (k Keeper) ReserveAuthority(ctx sdk.Context, msg registrytypes.MsgReserveAu } // ReserveSubAuthority reserves a sub-authority. -func (k Keeper) ReserveSubAuthority(ctx sdk.Context, name string, msg registrytypes.MsgReserveAuthority) error { +func (k Keeper) ReserveSubAuthority(ctx context.Context, name string, msg registrytypes.MsgReserveAuthority) error { // Get parent authority name. names := strings.Split(name, ".") parent := strings.Join(names[1:], ".") @@ -212,8 +214,7 @@ func (k Keeper) ReserveSubAuthority(ctx sdk.Context, name string, msg registryty if err != nil { return err } - - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Parent authority not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "parent authority") } parentAuthority, err := k.GetNameAuthority(ctx, parent) if err != nil { @@ -222,7 +223,7 @@ func (k Keeper) ReserveSubAuthority(ctx sdk.Context, name string, msg registryty // Sub-authority creator needs to be the owner of the parent authority. if parentAuthority.OwnerAddress != msg.Signer { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Access denied.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Access denied") } // Sub-authority owner defaults to parent authority owner. @@ -240,7 +241,7 @@ func (k Keeper) ReserveSubAuthority(ctx sdk.Context, name string, msg registryty return nil } -func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRoot bool) error { +func (k Keeper) createAuthority(ctx context.Context, name string, owner string, isRoot bool) error { moduleParams, err := k.GetParams(ctx) if err != nil { return err @@ -257,27 +258,28 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo } if authority.Status != registrytypes.AuthorityExpired { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Name already reserved.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Name already reserved") } } - ownerAddress, err := sdk.AccAddressFromBech32(owner) + ownerAddress, err := utils.NewAddressCodec().StringToBytes(owner) if err != nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid owner address.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid owner address") } ownerAccount := k.accountKeeper.GetAccount(ctx, ownerAddress) if ownerAccount == nil { - return errorsmod.Wrap(sdkerrors.ErrUnknownAddress, "Owner account not found.") + return errorsmod.Wrap(sdkerrors.ErrUnknownAddress, "Owner account not found") } + headerInfo := k.headerService.GetHeaderInfo(ctx) authority := registrytypes.NameAuthority{ OwnerPublicKey: getAuthorityPubKey(ownerAccount.GetPubKey()), OwnerAddress: owner, - Height: uint64(ctx.BlockHeight()), + Height: uint64(headerInfo.Height), Status: registrytypes.AuthorityActive, AuctionId: "", BondId: "", - ExpiryTime: ctx.BlockTime().Add(moduleParams.AuthorityGracePeriod), + ExpiryTime: headerInfo.Time.Add(moduleParams.AuthorityGracePeriod), } if isRoot && moduleParams.AuthorityAuctionEnabled { @@ -319,7 +321,7 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo return k.insertAuthorityExpiryQueue(ctx, name, authority.ExpiryTime) } -func (k Keeper) SetAuthorityBond(ctx sdk.Context, msg registrytypes.MsgSetAuthorityBond) error { +func (k Keeper) SetAuthorityBond(ctx context.Context, msg registrytypes.MsgSetAuthorityBond) error { name := msg.GetName() signer := msg.GetSigner() @@ -328,7 +330,7 @@ func (k Keeper) SetAuthorityBond(ctx sdk.Context, msg registrytypes.MsgSetAuthor return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Name authority not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "Name authority not found") } authority, err := k.GetNameAuthority(ctx, name) @@ -336,14 +338,14 @@ func (k Keeper) SetAuthorityBond(ctx sdk.Context, msg registrytypes.MsgSetAuthor return err } if authority.OwnerAddress != signer { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Access denied.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Access denied") } if has, err := k.bondKeeper.HasBond(ctx, msg.BondId); !has { if err != nil { return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "Bond not found") } bond, err := k.bondKeeper.GetBondById(ctx, msg.BondId) @@ -351,7 +353,7 @@ func (k Keeper) SetAuthorityBond(ctx sdk.Context, msg registrytypes.MsgSetAuthor return err } if bond.Owner != signer { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch") } // No-op if bond hasn't changed. @@ -369,8 +371,8 @@ func (k Keeper) SetAuthorityBond(ctx sdk.Context, msg registrytypes.MsgSetAuthor } // DeleteName removes a LRN -> Record ID mapping. -func (k Keeper) DeleteName(ctx sdk.Context, msg registrytypes.MsgDeleteName) error { - signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) +func (k Keeper) DeleteName(ctx context.Context, msg registrytypes.MsgDeleteName) error { + signerAddress, err := utils.NewAddressCodec().StringToBytes(msg.Signer) if err != nil { return err } @@ -384,7 +386,7 @@ func (k Keeper) DeleteName(ctx sdk.Context, msg registrytypes.MsgDeleteName) err return err } if !lrnExists { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Name not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "Name not found") } // Set CID to empty string. @@ -392,7 +394,7 @@ func (k Keeper) DeleteName(ctx sdk.Context, msg registrytypes.MsgDeleteName) err } // ResolveLRN resolves a LRN to a record. -func (k Keeper) ResolveLRN(ctx sdk.Context, lrn string) (*registrytypes.Record, error) { +func (k Keeper) ResolveLRN(ctx context.Context, lrn string) (*registrytypes.Record, error) { _, _, authority, err := k.getAuthority(ctx, lrn) if err != nil || authority.Status != registrytypes.AuthorityActive { // If authority is not active (or any other error), resolution fails. @@ -412,7 +414,7 @@ func (k Keeper) ResolveLRN(ctx sdk.Context, lrn string) (*registrytypes.Record, return record, nil } -func (k Keeper) resolveLRNRecord(ctx sdk.Context, lrn string) (*registrytypes.Record, *registrytypes.NameRecord, error) { +func (k Keeper) resolveLRNRecord(ctx context.Context, lrn string) (*registrytypes.Record, *registrytypes.NameRecord, error) { nameRecord, err := k.GetNameRecord(ctx, lrn) if nameRecord == nil { return nil, nil, err @@ -439,10 +441,10 @@ func (k Keeper) resolveLRNRecord(ctx sdk.Context, lrn string) (*registrytypes.Re return &record, nameRecord, nil } -func (k Keeper) getAuthority(ctx sdk.Context, lrn string) (string, *url.URL, *registrytypes.NameAuthority, error) { +func (k Keeper) getAuthority(ctx context.Context, lrn string) (string, *url.URL, *registrytypes.NameAuthority, error) { parsedLRN, err := url.Parse(lrn) if err != nil { - return "", nil, nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid LRN.") + return "", nil, nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid LRN") } name := parsedLRN.Host @@ -451,7 +453,7 @@ func (k Keeper) getAuthority(ctx sdk.Context, lrn string) (string, *url.URL, *re return "", nil, nil, err } - return "", nil, nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Name authority not found.") + return "", nil, nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "name authority not found") } authority, err := k.GetNameAuthority(ctx, name) @@ -462,7 +464,7 @@ func (k Keeper) getAuthority(ctx sdk.Context, lrn string) (string, *url.URL, *re return name, parsedLRN, &authority, nil } -func (k Keeper) checkLRNAccess(ctx sdk.Context, signer sdk.AccAddress, lrn string) error { +func (k Keeper) checkLRNAccess(ctx context.Context, signer sdk.AccAddress, lrn string) error { name, parsedLRN, authority, err := k.getAuthority(ctx, lrn) if err != nil { return err @@ -470,19 +472,23 @@ func (k Keeper) checkLRNAccess(ctx sdk.Context, signer sdk.AccAddress, lrn strin formattedLRN := fmt.Sprintf("lrn://%s%s", name, parsedLRN.RequestURI()) if formattedLRN != lrn { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid LRN.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid LRN") } - if authority.OwnerAddress != signer.String() { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Access denied.") + signerAddr, err := k.addressCodec.BytesToString(signer) + if err != nil { + return err + } + if authority.OwnerAddress != signerAddr { + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Access denied") } if authority.Status != registrytypes.AuthorityActive { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Authority is not active.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Authority is not active") } if authority.BondId == "" || len(authority.BondId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Authority bond not found.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Authority bond not found") } if authority.OwnerPublicKey == "" { @@ -502,8 +508,8 @@ func (k Keeper) checkLRNAccess(ctx sdk.Context, signer sdk.AccAddress, lrn strin } // ProcessAuthorityExpiryQueue tries to renew expiring authorities (by collecting rent) else marks them as expired. -func (k Keeper) ProcessAuthorityExpiryQueue(ctx sdk.Context) error { - names, err := k.getAllExpiredAuthorities(ctx, ctx.BlockHeader().Time) +func (k Keeper) ProcessAuthorityExpiryQueue(ctx context.Context) error { + names, err := k.getAllExpiredAuthorities(ctx, k.headerService.GetHeaderInfo(ctx).Time) if err != nil { return err } @@ -533,7 +539,7 @@ func (k Keeper) ProcessAuthorityExpiryQueue(ctx sdk.Context) error { return err } - k.Logger(ctx).Info(fmt.Sprintf("Marking authority expired as no bond present: %s", name)) + k.logger.Info(fmt.Sprintf("Marking authority expired as no bond present: %s", name)) // Continue with the loop continue @@ -549,7 +555,7 @@ func (k Keeper) ProcessAuthorityExpiryQueue(ctx sdk.Context) error { } // getAllExpiredAuthorities returns a concatenated list of all the timeslices before currTime. -func (k Keeper) getAllExpiredAuthorities(ctx sdk.Context, currTime time.Time) ([]string, error) { +func (k Keeper) getAllExpiredAuthorities(ctx context.Context, currTime time.Time) ([]string, error) { var expiredAuthorityNames []string // Get all the authorities with expiry time until currTime @@ -565,7 +571,7 @@ func (k Keeper) getAllExpiredAuthorities(ctx sdk.Context, currTime time.Time) ([ return expiredAuthorityNames, nil } -func (k Keeper) insertAuthorityExpiryQueue(ctx sdk.Context, name string, expiryTime time.Time) error { +func (k Keeper) insertAuthorityExpiryQueue(ctx context.Context, name string, expiryTime time.Time) error { existingNamesList, err := k.AuthorityExpiryQueue.Get(ctx, expiryTime) if err != nil { if errors.Is(err, collections.ErrNotFound) { @@ -583,7 +589,7 @@ func (k Keeper) insertAuthorityExpiryQueue(ctx sdk.Context, name string, expiryT } // deleteAuthorityExpiryQueue deletes an authority name from the authority expiry queue. -func (k Keeper) deleteAuthorityExpiryQueue(ctx sdk.Context, name string, authority registrytypes.NameAuthority) error { +func (k Keeper) deleteAuthorityExpiryQueue(ctx context.Context, name string, authority registrytypes.NameAuthority) error { expiryTime := authority.ExpiryTime existingNamesList, err := k.AuthorityExpiryQueue.Get(ctx, expiryTime) @@ -611,8 +617,8 @@ func (k Keeper) deleteAuthorityExpiryQueue(ctx sdk.Context, name string, authori } // tryTakeAuthorityRent tries to take rent from the authority bond. -func (k Keeper) tryTakeAuthorityRent(ctx sdk.Context, name string, authority registrytypes.NameAuthority) error { - k.Logger(ctx).Info(fmt.Sprintf("Trying to take rent for authority: %s", name)) +func (k Keeper) tryTakeAuthorityRent(ctx context.Context, name string, authority registrytypes.NameAuthority) error { + k.logger.Info(fmt.Sprintf("Trying to take rent for authority: %s", name)) params, err := k.GetParams(ctx) if err != nil { @@ -620,7 +626,7 @@ func (k Keeper) tryTakeAuthorityRent(ctx sdk.Context, name string, authority reg } rent := params.AuthorityRent - sdkErr := k.bondKeeper.TransferCoinsToModuleAccount(ctx, authority.BondId, registrytypes.AuthorityRentModuleAccountName, sdk.NewCoins(rent)) + sdkErr := k.bondKeeper.TransferRentToModuleAccount(ctx, authority.BondId, registrytypes.AuthorityRentModuleAccountName, sdk.NewCoins(rent)) if sdkErr != nil { // Insufficient funds, mark authority as expired. authority.Status = registrytypes.AuthorityExpired @@ -628,7 +634,7 @@ func (k Keeper) tryTakeAuthorityRent(ctx sdk.Context, name string, authority reg return err } - k.Logger(ctx).Info(fmt.Sprintf("Insufficient funds in owner account to pay authority rent, marking as expired: %s", name)) + k.logger.Info(fmt.Sprintf("Insufficient funds in owner account to pay authority rent, marking as expired: %s", name)) return k.deleteAuthorityExpiryQueue(ctx, name, authority) } @@ -638,7 +644,7 @@ func (k Keeper) tryTakeAuthorityRent(ctx sdk.Context, name string, authority reg return err } - authority.ExpiryTime = ctx.BlockTime().Add(params.AuthorityRentDuration) + authority.ExpiryTime = k.headerService.GetHeaderInfo(ctx).Time.Add(params.AuthorityRentDuration) if err := k.insertAuthorityExpiryQueue(ctx, name, authority.ExpiryTime); err != nil { return err } @@ -646,7 +652,7 @@ func (k Keeper) tryTakeAuthorityRent(ctx sdk.Context, name string, authority reg // Save authority. authority.Status = registrytypes.AuthorityActive - k.Logger(ctx).Info(fmt.Sprintf("Authority rent paid successfully: %s", name)) + k.logger.Info(fmt.Sprintf("Authority rent paid successfully: %s", name)) return k.SaveNameAuthority(ctx, name, &authority) } diff --git a/x/registry/keeper/params.go b/x/registry/keeper/params.go index 297aabda..9dc7e337 100644 --- a/x/registry/keeper/params.go +++ b/x/registry/keeper/params.go @@ -1,12 +1,13 @@ package keeper import ( + "context" + registrytypes "git.vdb.to/cerc-io/laconicd/x/registry" - sdk "github.com/cosmos/cosmos-sdk/types" ) // GetParams - Get all parameters as types.Params. -func (k Keeper) GetParams(ctx sdk.Context) (*registrytypes.Params, error) { +func (k Keeper) GetParams(ctx context.Context) (*registrytypes.Params, error) { params, err := k.Params.Get(ctx) if err != nil { return nil, err diff --git a/x/registry/keeper/query_server.go b/x/registry/keeper/query_server.go index b34e69ce..aa38a0e8 100644 --- a/x/registry/keeper/query_server.go +++ b/x/registry/keeper/query_server.go @@ -4,7 +4,6 @@ import ( "context" errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -22,9 +21,7 @@ func NewQueryServerImpl(k Keeper) registrytypes.QueryServer { return queryServer{k} } -func (qs queryServer) Params(c context.Context, _ *registrytypes.QueryParamsRequest) (*registrytypes.QueryParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) Params(ctx context.Context, _ *registrytypes.QueryParamsRequest) (*registrytypes.QueryParamsResponse, error) { params, err := qs.k.GetParams(ctx) if err != nil { return nil, err @@ -33,9 +30,7 @@ func (qs queryServer) Params(c context.Context, _ *registrytypes.QueryParamsRequ return ®istrytypes.QueryParamsResponse{Params: params}, nil } -func (qs queryServer) Records(c context.Context, req *registrytypes.QueryRecordsRequest) (*registrytypes.QueryRecordsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) Records(ctx context.Context, req *registrytypes.QueryRecordsRequest) (*registrytypes.QueryRecordsResponse, error) { attributes := req.GetAttributes() all := req.GetAll() @@ -57,8 +52,7 @@ func (qs queryServer) Records(c context.Context, req *registrytypes.QueryRecords return ®istrytypes.QueryRecordsResponse{Records: records, Pagination: pageResp}, nil } -func (qs queryServer) GetRecord(c context.Context, req *registrytypes.QueryGetRecordRequest) (*registrytypes.QueryGetRecordResponse, error) { - ctx := sdk.UnwrapSDKContext(c) +func (qs queryServer) GetRecord(ctx context.Context, req *registrytypes.QueryGetRecordRequest) (*registrytypes.QueryGetRecordResponse, error) { id := req.GetId() if has, err := qs.k.HasRecord(ctx, req.Id); !has { @@ -66,7 +60,7 @@ func (qs queryServer) GetRecord(c context.Context, req *registrytypes.QueryGetRe return nil, err } - return nil, errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "Record not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "record not found") } record, err := qs.k.GetRecordById(ctx, id) @@ -78,11 +72,9 @@ func (qs queryServer) GetRecord(c context.Context, req *registrytypes.QueryGetRe } func (qs queryServer) GetRecordsByBondId( - c context.Context, + ctx context.Context, req *registrytypes.QueryGetRecordsByBondIdRequest, ) (*registrytypes.QueryGetRecordsByBondIdResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - records, err := qs.k.GetRecordsByBondId(ctx, req.GetId()) if err != nil { return nil, err @@ -91,11 +83,9 @@ func (qs queryServer) GetRecordsByBondId( return ®istrytypes.QueryGetRecordsByBondIdResponse{Records: records}, nil } -func (qs queryServer) GetRegistryModuleBalance(c context.Context, +func (qs queryServer) GetRegistryModuleBalance(ctx context.Context, _ *registrytypes.QueryGetRegistryModuleBalanceRequest, ) (*registrytypes.QueryGetRegistryModuleBalanceResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - balances := qs.k.GetModuleBalances(ctx) return ®istrytypes.QueryGetRegistryModuleBalanceResponse{ @@ -103,9 +93,7 @@ func (qs queryServer) GetRegistryModuleBalance(c context.Context, }, nil } -func (qs queryServer) NameRecords(c context.Context, _ *registrytypes.QueryNameRecordsRequest) (*registrytypes.QueryNameRecordsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) NameRecords(ctx context.Context, _ *registrytypes.QueryNameRecordsRequest) (*registrytypes.QueryNameRecordsResponse, error) { nameRecords, err := qs.k.ListNameRecords(ctx) if err != nil { return nil, err @@ -114,9 +102,7 @@ func (qs queryServer) NameRecords(c context.Context, _ *registrytypes.QueryNameR return ®istrytypes.QueryNameRecordsResponse{Names: nameRecords}, nil } -func (qs queryServer) Whois(c context.Context, req *registrytypes.QueryWhoisRequest) (*registrytypes.QueryWhoisResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) Whois(ctx context.Context, req *registrytypes.QueryWhoisRequest) (*registrytypes.QueryWhoisResponse, error) { nameAuthority, err := qs.k.GetNameAuthority(ctx, req.GetName()) if err != nil { return nil, err @@ -125,9 +111,7 @@ func (qs queryServer) Whois(c context.Context, req *registrytypes.QueryWhoisRequ return ®istrytypes.QueryWhoisResponse{NameAuthority: nameAuthority}, nil } -func (qs queryServer) Authorities(c context.Context, req *registrytypes.QueryAuthoritiesRequest) (*registrytypes.QueryAuthoritiesResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) Authorities(ctx context.Context, req *registrytypes.QueryAuthoritiesRequest) (*registrytypes.QueryAuthoritiesResponse, error) { authorityEntries, err := qs.k.ListNameAuthorityRecords(ctx, req.GetOwner()) if err != nil { return nil, err @@ -136,8 +120,7 @@ func (qs queryServer) Authorities(c context.Context, req *registrytypes.QueryAut return ®istrytypes.QueryAuthoritiesResponse{Authorities: authorityEntries}, nil } -func (qs queryServer) LookupLrn(c context.Context, req *registrytypes.QueryLookupLrnRequest) (*registrytypes.QueryLookupLrnResponse, error) { - ctx := sdk.UnwrapSDKContext(c) +func (qs queryServer) LookupLrn(ctx context.Context, req *registrytypes.QueryLookupLrnRequest) (*registrytypes.QueryLookupLrnResponse, error) { lrn := req.GetLrn() lrnExists, err := qs.k.HasNameRecord(ctx, lrn) @@ -145,7 +128,7 @@ func (qs queryServer) LookupLrn(c context.Context, req *registrytypes.QueryLooku return nil, err } if !lrnExists { - return nil, errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "LRN not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "LRN not found") } nameRecord, err := qs.k.LookupNameRecord(ctx, lrn) @@ -154,15 +137,13 @@ func (qs queryServer) LookupLrn(c context.Context, req *registrytypes.QueryLooku return nil, err } - return nil, errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "name record not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "name record not found") } return ®istrytypes.QueryLookupLrnResponse{Name: nameRecord}, nil } -func (qs queryServer) ResolveLrn(c context.Context, req *registrytypes.QueryResolveLrnRequest) (*registrytypes.QueryResolveLrnResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - +func (qs queryServer) ResolveLrn(ctx context.Context, req *registrytypes.QueryResolveLrnRequest) (*registrytypes.QueryResolveLrnResponse, error) { lrn := req.GetLrn() record, err := qs.k.ResolveLRN(ctx, lrn) if record == nil { @@ -170,7 +151,7 @@ func (qs queryServer) ResolveLrn(c context.Context, req *registrytypes.QueryReso return nil, err } - return nil, errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "record not found.") + return nil, errorsmod.Wrap(sdkerrors.ErrNotFound, "record not found") } return ®istrytypes.QueryResolveLrnResponse{Record: record}, nil diff --git a/x/registry/keeper/record_keeper.go b/x/registry/keeper/record_keeper.go index db197cf1..a2334aea 100644 --- a/x/registry/keeper/record_keeper.go +++ b/x/registry/keeper/record_keeper.go @@ -1,14 +1,15 @@ package keeper import ( + "context" "errors" "fmt" "time" "cosmossdk.io/collections" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" @@ -28,14 +29,21 @@ type RecordKeeper struct { cdc codec.BinaryCodec // The wire codec for binary encoding/decoding. k *Keeper auctionKeeper *auctionkeeper.Keeper + logger log.Logger } // NewRecordKeeper creates new instances of the registry RecordKeeper -func NewRecordKeeper(cdc codec.BinaryCodec, k *Keeper, auctionKeeper *auctionkeeper.Keeper) RecordKeeper { +func NewRecordKeeper( + cdc codec.BinaryCodec, + k *Keeper, + auctionKeeper *auctionkeeper.Keeper, + logger log.Logger, +) RecordKeeper { return RecordKeeper{ cdc: cdc, k: k, auctionKeeper: auctionKeeper, + logger: logger.With(log.ModuleKey, "x/"+registrytypes.ModuleName), } } @@ -44,7 +52,7 @@ func (rk RecordKeeper) ModuleName() string { return registrytypes.ModuleName } -func (rk RecordKeeper) UsesAuction(ctx sdk.Context, auctionId string) bool { +func (rk RecordKeeper) UsesAuction(ctx context.Context, auctionId string) bool { iter, err := rk.k.Authorities.Indexes.AuctionId.MatchExact(ctx, auctionId) if err != nil { panic(err) @@ -53,7 +61,7 @@ func (rk RecordKeeper) UsesAuction(ctx sdk.Context, auctionId string) bool { return iter.Valid() } -func (rk RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionId string) { +func (rk RecordKeeper) OnAuctionWinnerSelected(ctx context.Context, auctionId string, blockHeight uint64) { // Update authority status based on auction status/winner. iter, err := rk.k.Authorities.Indexes.AuctionId.MatchExact(ctx, auctionId) if err != nil && !errors.Is(err, collections.ErrNotFound) { @@ -66,7 +74,7 @@ func (rk RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionId string if len(names) == 0 { // We don't know about this auction, ignore. - logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, name mapping not found: %s", auctionId)) + rk.logger.Info(fmt.Sprintf("Ignoring auction notification, name mapping not found: %s", auctionId)) return } @@ -79,7 +87,7 @@ func (rk RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionId string } // We don't know about this authority, ignore. - logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, authority not found: %s", auctionId)) + rk.logger.Info(fmt.Sprintf("Ignoring auction notification, authority not found: %s", auctionId)) return } @@ -104,17 +112,17 @@ func (rk RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionId string // Update height for updated/changed authority (owner). // Can be used to check if names are older than the authority itself (stale names). - authority.Height = uint64(ctx.BlockHeight()) + authority.Height = blockHeight - logger(ctx).Info(fmt.Sprintf("Winner selected, marking authority as active: %s", name)) + rk.logger.Info(fmt.Sprintf("Winner selected, marking authority as active: %s", name)) } else { // Mark as expired. authority.Status = registrytypes.AuthorityExpired - logger(ctx).Info(fmt.Sprintf("No winner, marking authority as expired: %s", name)) + rk.logger.Info(fmt.Sprintf("No winner, marking authority as expired: %s", name)) - logger(ctx).Info(fmt.Sprintf("Deleting the expiry queue entry: %s", name)) + rk.logger.Info(fmt.Sprintf("Deleting the expiry queue entry: %s", name)) if err = rk.k.deleteAuthorityExpiryQueue(ctx, name, authority); err != nil { - logger(ctx).Error("Unable to delete expiry queue entry", err) + rk.logger.Error("Unable to delete expiry queue entry", err) } } @@ -125,12 +133,12 @@ func (rk RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionId string panic(err) } } else { - logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, status: %s", auctionObj.Status)) + rk.logger.Info(fmt.Sprintf("Ignoring auction notification, status: %s", auctionObj.Status)) } } // UsesBond returns true if the bond has associated records. -func (rk RecordKeeper) UsesBond(ctx sdk.Context, bondId string) bool { +func (rk RecordKeeper) UsesBond(ctx context.Context, bondId string) bool { iter, err := rk.k.Records.Indexes.BondId.MatchExact(ctx, bondId) if err != nil { panic(err) @@ -140,12 +148,12 @@ func (rk RecordKeeper) UsesBond(ctx sdk.Context, bondId string) bool { } // RenewRecord renews a record. -func (k Keeper) RenewRecord(ctx sdk.Context, msg registrytypes.MsgRenewRecord) error { +func (k Keeper) RenewRecord(ctx context.Context, msg registrytypes.MsgRenewRecord, now time.Time) error { if has, err := k.HasRecord(ctx, msg.RecordId); !has { if err != nil { return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "record not found") } // Check if renewal is required (i.e. expired record marked as deleted). @@ -159,8 +167,8 @@ func (k Keeper) RenewRecord(ctx sdk.Context, msg registrytypes.MsgRenewRecord) e return err } - if !record.Deleted || expiryTime.After(ctx.BlockTime()) { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Renewal not required.") + if !record.Deleted || expiryTime.After(now) { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Renewal not required") } readableRecord := record.ToReadableRecord() @@ -168,19 +176,19 @@ func (k Keeper) RenewRecord(ctx sdk.Context, msg registrytypes.MsgRenewRecord) e } // AssociateBond associates a record with a bond. -func (k Keeper) AssociateBond(ctx sdk.Context, msg registrytypes.MsgAssociateBond) error { +func (k Keeper) AssociateBond(ctx context.Context, msg registrytypes.MsgAssociateBond) error { if has, err := k.HasRecord(ctx, msg.RecordId); !has { if err != nil { return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "record not found") } if has, err := k.bondKeeper.HasBond(ctx, msg.BondId); !has { if err != nil { return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "bond not found") } // Check if already associated with a bond. @@ -190,7 +198,7 @@ func (k Keeper) AssociateBond(ctx sdk.Context, msg registrytypes.MsgAssociateBon } if len(record.BondId) != 0 { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond already exists.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond already exists") } // Only the bond owner can associate a record with the bond. @@ -199,7 +207,7 @@ func (k Keeper) AssociateBond(ctx sdk.Context, msg registrytypes.MsgAssociateBon return err } if msg.Signer != bond.Owner { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch") } record.BondId = msg.BondId @@ -216,12 +224,12 @@ func (k Keeper) AssociateBond(ctx sdk.Context, msg registrytypes.MsgAssociateBon } // DissociateBond dissociates a record from its bond. -func (k Keeper) DissociateBond(ctx sdk.Context, msg registrytypes.MsgDissociateBond) error { +func (k Keeper) DissociateBond(ctx context.Context, msg registrytypes.MsgDissociateBond) error { if has, err := k.HasRecord(ctx, msg.RecordId); !has { if err != nil { return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "record not found") } record, err := k.GetRecordById(ctx, msg.RecordId) @@ -232,7 +240,7 @@ func (k Keeper) DissociateBond(ctx sdk.Context, msg registrytypes.MsgDissociateB // Check if record associated with a bond. bondId := record.BondId if len(bondId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "bond not found") } // Only the bond owner can dissociate a record with the bond. @@ -241,7 +249,7 @@ func (k Keeper) DissociateBond(ctx sdk.Context, msg registrytypes.MsgDissociateB return err } if msg.Signer != bond.Owner { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch") } // Clear bond Id. @@ -250,12 +258,12 @@ func (k Keeper) DissociateBond(ctx sdk.Context, msg registrytypes.MsgDissociateB } // DissociateRecords dissociates all records associated with a given bond. -func (k Keeper) DissociateRecords(ctx sdk.Context, msg registrytypes.MsgDissociateRecords) error { +func (k Keeper) DissociateRecords(ctx context.Context, msg registrytypes.MsgDissociateRecords) error { if has, err := k.bondKeeper.HasBond(ctx, msg.BondId); !has { if err != nil { return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "bond not found") } // Only the bond owner can dissociate all records from the bond. @@ -264,7 +272,7 @@ func (k Keeper) DissociateRecords(ctx sdk.Context, msg registrytypes.MsgDissocia return err } if msg.Signer != bond.Owner { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch") } // Dissociate all records from the bond. @@ -285,19 +293,19 @@ func (k Keeper) DissociateRecords(ctx sdk.Context, msg registrytypes.MsgDissocia } // ReassociateRecords switches records from and old to new bond. -func (k Keeper) ReassociateRecords(ctx sdk.Context, msg registrytypes.MsgReassociateRecords) error { +func (k Keeper) ReassociateRecords(ctx context.Context, msg registrytypes.MsgReassociateRecords) error { if has, err := k.bondKeeper.HasBond(ctx, msg.OldBondId); !has { if err != nil { return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Old bond not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "old bond not found") } if has, err := k.bondKeeper.HasBond(ctx, msg.NewBondId); !has { if err != nil { return err } - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "New bond not found.") + return errorsmod.Wrap(sdkerrors.ErrNotFound, "new bond not found") } // Only the bond owner can re-associate all records. @@ -306,7 +314,7 @@ func (k Keeper) ReassociateRecords(ctx sdk.Context, msg registrytypes.MsgReassoc return err } if msg.Signer != oldBond.Owner { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Old bond owner mismatch.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "old bond owner mismatch") } newBond, err := k.bondKeeper.GetBondById(ctx, msg.NewBondId) @@ -314,7 +322,7 @@ func (k Keeper) ReassociateRecords(ctx sdk.Context, msg registrytypes.MsgReassoc return err } if msg.Signer != newBond.Owner { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "New bond owner mismatch.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "new bond owner mismatch") } // Re-associate all records. diff --git a/x/registry/module/abci.go b/x/registry/module/abci.go index e42c0f3f..ff497403 100644 --- a/x/registry/module/abci.go +++ b/x/registry/module/abci.go @@ -3,20 +3,16 @@ package module import ( "context" - sdk "github.com/cosmos/cosmos-sdk/types" - "git.vdb.to/cerc-io/laconicd/x/registry/keeper" ) // EndBlocker is called every block func EndBlocker(ctx context.Context, k keeper.Keeper) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - if err := k.ProcessRecordExpiryQueue(sdkCtx); err != nil { + if err := k.ProcessRecordExpiryQueue(ctx); err != nil { return err } - if err := k.ProcessAuthorityExpiryQueue(sdkCtx); err != nil { + if err := k.ProcessAuthorityExpiryQueue(ctx); err != nil { return err } diff --git a/x/registry/module/autocli.go b/x/registry/module/autocli.go index 8dd62952..e6401d1e 100644 --- a/x/registry/module/autocli.go +++ b/x/registry/module/autocli.go @@ -29,7 +29,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetRecord", - Use: "get [record-id]", + Use: "get ", Short: "Get record info by record id", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "id"}, @@ -37,7 +37,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetRecordsByBondId", - Use: "get-records-by-bond-id [bond-id]", + Use: "get-records-by-bond-id ", Short: "Get records by bond id", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "id"}, @@ -45,7 +45,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "Whois", - Use: "whois [name]", + Use: "whois ", Short: "Get name authority info", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "name"}, @@ -71,7 +71,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "LookupLrn", - Use: "lookup [lrn]", + Use: "lookup ", Short: "Get naming info for LRN", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "lrn"}, @@ -79,7 +79,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "ResolveLrn", - Use: "resolve [lrn]", + Use: "resolve ", Short: "Resolve LRN to record", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "lrn"}, @@ -98,7 +98,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "RenewRecord", - Use: "renew-record [record-id]", + Use: "renew-record ", Short: "Renew (expired) record", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "record_id"}, @@ -106,7 +106,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "ReserveAuthority", - Use: "reserve-authority [name] [owner]", + Use: "reserve-authority ", Short: "Reserve authority name", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "name"}, @@ -115,7 +115,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "SetAuthorityBond", - Use: "authority-bond [name] [bond-id]", + Use: "authority-bond ", Short: "Associate authority with bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "name"}, @@ -124,7 +124,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "SetName", - Use: "set-name [lrn] [cid]", + Use: "set-name ", Short: "Set LRN to CID mapping", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "lrn"}, @@ -133,7 +133,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "DeleteName", - Use: "delete-name [lrn]", + Use: "delete-name ", Short: "Delete LRN", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "lrn"}, @@ -141,7 +141,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "AssociateBond", - Use: "associate-bond [record-id] [bond-id]", + Use: "associate-bond ", Short: "Associate record with a bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "record_id"}, @@ -150,7 +150,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "DissociateBond", - Use: "dissociate-bond [record-id]", + Use: "dissociate-bond ", Short: "Dissociate record from (existing) bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "record_id"}, @@ -158,7 +158,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "DissociateRecords", - Use: "dissociate-records [bond-id]", + Use: "dissociate-records ", Short: "Dissociate all records from a bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "bond_id"}, @@ -166,7 +166,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "ReassociateRecords", - Use: "reassociate-records [old-bond-id] [new-bond-id]", + Use: "reassociate-records ", Short: "Re-associate all records from an old to a new bond", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "old_bond_id"}, diff --git a/x/registry/module/depinject.go b/x/registry/module/depinject.go index 1ad692ff..8598281b 100644 --- a/x/registry/module/depinject.go +++ b/x/registry/module/depinject.go @@ -2,16 +2,19 @@ package module import ( "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" + "cosmossdk.io/core/event" + "cosmossdk.io/core/header" + store "cosmossdk.io/core/store" "cosmossdk.io/depinject" - + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/registry/module/v1" + "git.vdb.to/cerc-io/laconicd/utils" "git.vdb.to/cerc-io/laconicd/x/auction" auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper" "git.vdb.to/cerc-io/laconicd/x/bond" @@ -28,18 +31,21 @@ func (am AppModule) IsOnePerModuleType() {} func (am AppModule) IsAppModule() {} func init() { - appmodule.Register( + appconfig.RegisterModule( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + appconfig.Provide(ProvideModule), ) } type ModuleInputs struct { depinject.In - Config *modulev1.Module - Cdc codec.Codec - StoreService store.KVStoreService + StoreService store.KVStoreService + HeaderService header.Service + EventService event.Service + Config *modulev1.Module + Cdc codec.Codec + Logger log.Logger AccountKeeper auth.AccountKeeper BankKeeper bank.Keeper @@ -60,22 +66,23 @@ type ModuleOutputs struct { func ProvideModule(in ModuleInputs) ModuleOutputs { // default to governance authority if not provided - authority := authtypes.NewModuleAddress(govtypes.ModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } + authority := utils.AddressOrModuleAddress(in.Config.Authority, govtypes.ModuleName) k := keeper.NewKeeper( in.Cdc, in.StoreService, + + in.HeaderService, + in.EventService, in.AccountKeeper, in.BankKeeper, in.BondKeeper, in.AuctionKeeper, - authority.String(), + authority, + in.Logger, ) m := NewAppModule(in.Cdc, k) - recordKeeper := keeper.NewRecordKeeper(in.Cdc, &k, in.AuctionKeeper) + recordKeeper := keeper.NewRecordKeeper(in.Cdc, &k, in.AuctionKeeper, in.Logger) return ModuleOutputs{ Module: m, Keeper: k, diff --git a/x/registry/module/module.go b/x/registry/module/module.go index 7ee50901..7e0ed39a 100644 --- a/x/registry/module/module.go +++ b/x/registry/module/module.go @@ -5,15 +5,15 @@ import ( "encoding/json" "fmt" - "cosmossdk.io/core/appmodule" - gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - + "cosmossdk.io/client/v2/autocli" + appmodule "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + registry "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" registrytypes "git.vdb.to/cerc-io/laconicd/x/registry" "git.vdb.to/cerc-io/laconicd/x/registry/client/cli" @@ -22,12 +22,14 @@ import ( var ( _ module.AppModuleBasic = AppModule{} - _ appmodule.AppModule = AppModule{} _ module.HasGenesis = AppModule{} - _ module.HasServices = AppModule{} _ module.HasConsensusVersion = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} - _ module.HasInvariants = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} + + _ autocli.HasCustomTxCommand = AppModule{} ) // ConsensusVersion defines the current module consensus version. @@ -46,18 +48,12 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { } } -func NewAppModuleBasic(m AppModule) module.AppModuleBasic { - return module.CoreAppModuleBasicAdaptor(m.Name(), m) -} - -// module.AppModuleBasic +// module.AppModule // Name returns the registry module's name. func (AppModule) Name() string { return registrytypes.ModuleName } -// RegisterLegacyAminoCodec registers the registry module's types on the LegacyAmino codec. -// New modules do not need to support Amino. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +// module.HasGRPCGateway // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the registry module. func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { @@ -66,22 +62,24 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } } +// appmodule.HasRegisterInterfaces + // RegisterInterfaces registers interfaces and implementations of the registry module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistry) { registrytypes.RegisterInterfaces(registry) } // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } -// module.HasGenesis +// appmodule.HasGenesis // DefaultGenesis returns default genesis state as raw bytes for the module. func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(registrytypes.DefaultGenesisState()) } -// ValidateGenesis performs genesis state validation for the circuit module. +// ValidateGenesis performs genesis state validation for the registry module. func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var data registrytypes.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { @@ -102,12 +100,12 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. } } -// ExportGenesis returns the exported genesis state as raw bytes for the circuit +// ExportGenesis returns the exported genesis state as raw bytes for the registry // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { gs, err := am.keeper.ExportGenesis(ctx) if err != nil { - panic(fmt.Sprintf("failed to export %s genesis state: %v", registrytypes.ModuleName, err)) + panic(fmt.Errorf("failed to export %s genesis state: %w", registrytypes.ModuleName, err)) } return cdc.MustMarshalJSON(gs) @@ -120,6 +118,12 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // Register servers registrytypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) registrytypes.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) + + // Register in place module state migration migrations + // m := keeper.NewMigrator(am.keeper) + // if err := cfg.RegisterMigration(registrytypes.ModuleName, 1, m.Migrate1to2); err != nil { + // panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", registrytypes.ModuleName, err)) + // } } // appmodule.HasEndBlocker @@ -128,11 +132,11 @@ func (am AppModule) EndBlock(ctx context.Context) error { return EndBlocker(ctx, am.keeper) } -// module.HasInvariants +// autocli.HasCustomTxCommand -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - keeper.RegisterInvariants(ir, am.keeper) -} +// RegisterLegacyAminoCodec registers the registry module's types on the LegacyAmino codec. +// New modules do not need to support Amino. +func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // Get the root tx command of this module func (AppModule) GetTxCmd() *cobra.Command { diff --git a/x/registry/msgs.go b/x/registry/msgs.go index c797af08..6272c01b 100644 --- a/x/registry/msgs.go +++ b/x/registry/msgs.go @@ -2,35 +2,39 @@ package registry import ( "net/url" + "slices" errorsmod "cosmossdk.io/errors" + "git.vdb.to/cerc-io/laconicd/utils" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // NewMsgSetRecord is the constructor function for MsgSetRecord. func NewMsgSetRecord(payload Payload, bondId string, signer sdk.AccAddress) *MsgSetRecord { + signerStr, err := utils.NewAddressCodec().BytesToString(signer) + if err != nil { + panic(err) + } return &MsgSetRecord{ Payload: payload, BondId: bondId, - Signer: signer.String(), + Signer: signerStr, } } func (msg MsgSetRecord) ValidateBasic() error { if len(msg.Signer) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer) + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "empty signer address") } owners := msg.Payload.Record.Owners - for _, owner := range owners { - if owner == "" { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Record owner not set.") - } + if slices.Contains(owners, "") { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "record owner not set") } if len(msg.BondId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond Id is required.") + return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "bond ID is required") } return nil @@ -38,11 +42,11 @@ func (msg MsgSetRecord) ValidateBasic() error { func (msg MsgRenewRecord) ValidateBasic() error { if len(msg.RecordId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "record ID is required") } if len(msg.Signer) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil @@ -50,17 +54,26 @@ func (msg MsgRenewRecord) ValidateBasic() error { // NewMsgReserveAuthority is the constructor function for MsgReserveName. func NewMsgReserveAuthority(name string, signer sdk.AccAddress, owner sdk.AccAddress) MsgReserveAuthority { + addrCodec := utils.NewAddressCodec() + ownerStr, err := addrCodec.BytesToString(owner) + if err != nil { + panic(err) + } + signerStr, err := addrCodec.BytesToString(signer) + if err != nil { + panic(err) + } return MsgReserveAuthority{ Name: name, - Owner: owner.String(), - Signer: signer.String(), + Owner: ownerStr, + Signer: signerStr, } } // ValidateBasic Implements Msg. func (msg MsgReserveAuthority) ValidateBasic() error { if len(msg.Name) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "name is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "name is required") } if len(msg.Signer) == 0 { @@ -72,24 +85,28 @@ func (msg MsgReserveAuthority) ValidateBasic() error { // NewMsgSetAuthorityBond is the constructor function for MsgSetAuthorityBond. func NewMsgSetAuthorityBond(name string, bondID string, signer sdk.AccAddress) MsgSetAuthorityBond { + signerStr, err := utils.NewAddressCodec().BytesToString(signer) + if err != nil { + panic(err) + } return MsgSetAuthorityBond{ Name: name, - Signer: signer.String(), + Signer: signerStr, BondId: bondID, } } func (msg MsgSetAuthorityBond) ValidateBasic() error { if len(msg.Name) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "name is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "name is required") } if len(msg.Signer) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } if len(msg.BondId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "bond id is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "bond id is required") } return nil @@ -97,21 +114,25 @@ func (msg MsgSetAuthorityBond) ValidateBasic() error { // NewMsgSetName is the constructor function for MsgSetName. func NewMsgSetName(lrn string, cid string, signer sdk.AccAddress) *MsgSetName { + signerStr, err := utils.NewAddressCodec().BytesToString(signer) + if err != nil { + panic(err) + } return &MsgSetName{ Lrn: lrn, Cid: cid, - Signer: signer.String(), + Signer: signerStr, } } // ValidateBasic Implements Msg. func (msg MsgSetName) ValidateBasic() error { if msg.Lrn == "" { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "LRN is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "LRN is required") } if msg.Cid == "" { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "CID is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "CID is required") } if len(msg.Signer) == 0 { @@ -123,16 +144,16 @@ func (msg MsgSetName) ValidateBasic() error { func (msg MsgDeleteName) ValidateBasic() error { if len(msg.Lrn) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "lrn is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "lrn is required") } if len(msg.Signer) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } _, err := url.Parse(msg.Lrn) if err != nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid lrn.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid lrn") } return nil @@ -140,13 +161,13 @@ func (msg MsgDeleteName) ValidateBasic() error { func (msg MsgAssociateBond) ValidateBasic() error { if len(msg.RecordId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "record id is required") } if len(msg.BondId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required") } if len(msg.Signer) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil @@ -154,10 +175,10 @@ func (msg MsgAssociateBond) ValidateBasic() error { func (msg MsgDissociateBond) ValidateBasic() error { if len(msg.RecordId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "record id is required") } if len(msg.Signer) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil @@ -165,10 +186,10 @@ func (msg MsgDissociateBond) ValidateBasic() error { func (msg MsgDissociateRecords) ValidateBasic() error { if len(msg.BondId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required") } if len(msg.Signer) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil @@ -176,13 +197,13 @@ func (msg MsgDissociateRecords) ValidateBasic() error { func (msg MsgReassociateRecords) ValidateBasic() error { if len(msg.OldBondId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "old-bond-id is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "old-bond-id is required") } if len(msg.NewBondId) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "new-bond-id is required.") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "new-bond-id is required") } if len(msg.Signer) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil diff --git a/x/registry/query.pb.go b/x/registry/query.pb.go index 1f906afe..75673fd8 100644 --- a/x/registry/query.pb.go +++ b/x/registry/query.pb.go @@ -1827,6 +1827,7 @@ func _Query_Authorities_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cerc.registry.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/registry/registry.pb.go b/x/registry/registry.pb.go index 07883290..09705a63 100644 --- a/x/registry/registry.pb.go +++ b/x/registry/registry.pb.go @@ -164,7 +164,7 @@ type Record struct { Owners []string `protobuf:"bytes,6,rep,name=owners,proto3" json:"owners,omitempty" json:"owners" yaml:"owners"` Attributes []byte `protobuf:"bytes,7,opt,name=attributes,proto3" json:"attributes,omitempty" json:"attributes" yaml:"attributes"` Names []string `protobuf:"bytes,8,rep,name=names,proto3" json:"names,omitempty" json:"names" yaml:"names"` - Type string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty" json:"types" yaml:"types"` + Types string `protobuf:"bytes,9,opt,name=types,proto3" json:"types,omitempty" json:"types" yaml:"types"` } func (m *Record) Reset() { *m = Record{} } @@ -256,9 +256,9 @@ func (m *Record) GetNames() []string { return nil } -func (m *Record) GetType() string { +func (m *Record) GetTypes() string { if m != nil { - return m.Type + return m.Types } return "" } @@ -743,82 +743,82 @@ func init() { proto.RegisterFile("cerc/registry/v1/registry.proto", fileDescript var fileDescriptor_d792f2373089b5b9 = []byte{ // 1235 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcb, 0x6e, 0xdb, 0x46, - 0x17, 0x36, 0x6d, 0x59, 0xb6, 0x8e, 0x62, 0xff, 0xc1, 0xfc, 0x4e, 0x22, 0xbb, 0x89, 0xe8, 0x28, - 0x68, 0x93, 0x20, 0x30, 0x09, 0xc5, 0x28, 0x82, 0x24, 0x28, 0x50, 0xcb, 0x75, 0x0c, 0x37, 0xbd, - 0x38, 0xe3, 0xac, 0x5a, 0x14, 0x02, 0x2f, 0x13, 0x79, 0x5a, 0x91, 0x14, 0xc8, 0xa1, 0x1a, 0x2d, - 0x0b, 0x74, 0xd3, 0x9d, 0x97, 0x59, 0xf4, 0x0d, 0xba, 0xe8, 0x63, 0x34, 0xcb, 0x2c, 0xbb, 0x29, - 0x5b, 0xd8, 0x40, 0x1f, 0x40, 0x4f, 0x50, 0x70, 0x66, 0x78, 0x95, 0x14, 0xb5, 0xc8, 0x8e, 0xe7, - 0xf6, 0xcd, 0x77, 0xce, 0x9c, 0x33, 0x33, 0x04, 0xd5, 0x22, 0xbe, 0xa5, 0xfb, 0xa4, 0x47, 0x03, - 0xe6, 0x8f, 0xf4, 0x61, 0x3b, 0xfd, 0xd6, 0x06, 0xbe, 0xc7, 0x3c, 0x74, 0x39, 0x76, 0xd0, 0x52, - 0xe5, 0xb0, 0xbd, 0xd5, 0xec, 0x79, 0x5e, 0xaf, 0x4f, 0x74, 0x6e, 0x37, 0xc3, 0x17, 0xba, 0x1d, - 0xfa, 0x06, 0xa3, 0x9e, 0x2b, 0x22, 0xb6, 0xd4, 0xb2, 0x9d, 0x51, 0x87, 0x04, 0xcc, 0x70, 0x06, - 0xd2, 0x61, 0xa3, 0xe7, 0xf5, 0x3c, 0xfe, 0xa9, 0xc7, 0x5f, 0x52, 0xdb, 0xb4, 0xbc, 0xc0, 0xf1, - 0x02, 0xdd, 0x34, 0x02, 0xa2, 0x0f, 0xdb, 0x26, 0x61, 0x46, 0x5b, 0xb7, 0x3c, 0x2a, 0x61, 0x5b, - 0x7f, 0xac, 0x41, 0xf5, 0xd8, 0xf0, 0x0d, 0x27, 0x40, 0x14, 0xea, 0x3e, 0xb1, 0x3c, 0xdf, 0xee, - 0xfa, 0xc4, 0x65, 0x0d, 0x65, 0x5b, 0xb9, 0x53, 0xbf, 0xbf, 0xa9, 0x09, 0x00, 0x2d, 0x06, 0xd0, - 0x24, 0x80, 0xb6, 0xef, 0x51, 0xb7, 0xb3, 0xf3, 0x3a, 0x52, 0x17, 0xc6, 0x91, 0xfa, 0xfe, 0xb7, - 0x81, 0xe7, 0x3e, 0x6a, 0xe5, 0x62, 0x5b, 0xdb, 0x23, 0xc3, 0xe9, 0x17, 0x55, 0x18, 0x84, 0x84, - 0x89, 0xcb, 0xd0, 0x99, 0x02, 0x1b, 0x39, 0x63, 0x37, 0xc9, 0xb5, 0xb1, 0x28, 0x17, 0x15, 0xc9, - 0x6a, 0x49, 0xb2, 0xda, 0x27, 0xd2, 0xa1, 0xb3, 0x2f, 0x17, 0x7d, 0x30, 0xb1, 0x68, 0x0a, 0x32, - 0x65, 0xf5, 0xcc, 0xf6, 0xea, 0x4f, 0x55, 0xc1, 0x28, 0xa3, 0x92, 0x00, 0xa3, 0x10, 0xd6, 0x8d, - 0x90, 0x9d, 0x7a, 0x3e, 0x65, 0x23, 0x51, 0x80, 0xa5, 0x79, 0x05, 0xd8, 0x95, 0x5c, 0xee, 0x09, - 0x2e, 0xc5, 0xf0, 0x84, 0x45, 0x49, 0x8b, 0xd7, 0x52, 0x05, 0xaf, 0xc4, 0xcf, 0x0a, 0x5c, 0x2b, - 0xba, 0x64, 0xc5, 0xa8, 0xcc, 0x2b, 0xc6, 0x91, 0x24, 0xf0, 0xd1, 0x34, 0x02, 0x13, 0xf5, 0x98, - 0x65, 0xe6, 0x25, 0xb9, 0x52, 0xa0, 0x95, 0x56, 0xe5, 0x95, 0x02, 0x57, 0xb3, 0xb8, 0x9e, 0x6f, - 0x58, 0xa4, 0x3b, 0x20, 0x3e, 0xf5, 0xec, 0xc6, 0xf2, 0x3c, 0x76, 0x87, 0x92, 0xdd, 0xe3, 0x32, - 0xbb, 0x3c, 0xcc, 0x24, 0xb9, 0x82, 0x95, 0x73, 0xdb, 0x48, 0x8d, 0x87, 0xb1, 0xed, 0x98, 0x9b, - 0xd0, 0x0f, 0x0a, 0x6c, 0x66, 0x51, 0x46, 0x68, 0xc5, 0x8b, 0x76, 0x89, 0x6b, 0x98, 0x7d, 0x62, - 0x37, 0xaa, 0xdb, 0xca, 0x9d, 0xd5, 0xce, 0xc1, 0x38, 0x52, 0xf7, 0xca, 0xcb, 0x97, 0x5c, 0x27, - 0x19, 0x94, 0x1d, 0x70, 0xb6, 0x43, 0x7b, 0xc2, 0x74, 0x20, 0x2c, 0xe8, 0x37, 0x05, 0xa6, 0xc4, - 0x59, 0x9e, 0xe3, 0x50, 0x16, 0x64, 0x1b, 0xb9, 0x32, 0xaf, 0x54, 0x5d, 0x59, 0xaa, 0x93, 0x59, - 0x5c, 0xcb, 0x90, 0xb3, 0x49, 0x4f, 0x78, 0xf2, 0x12, 0xaa, 0xe5, 0x0c, 0xf6, 0x85, 0x5b, 0xba, - 0xd1, 0xd3, 0x33, 0xf1, 0xc9, 0x90, 0x18, 0xfd, 0x5c, 0x26, 0xab, 0xef, 0x9c, 0x49, 0x19, 0x72, - 0x76, 0x26, 0x13, 0x9e, 0xd3, 0x33, 0xc1, 0xc2, 0x2d, 0xcd, 0xe4, 0x17, 0x05, 0xae, 0xcf, 0x2a, - 0x4b, 0xf7, 0x05, 0x21, 0x8d, 0xda, 0xbc, 0xb9, 0xfe, 0x52, 0xe6, 0x70, 0xf8, 0xf6, 0xdd, 0x88, - 0xc1, 0xe6, 0xed, 0x03, 0xf7, 0xc1, 0x9b, 0xd3, 0xab, 0xff, 0x84, 0x90, 0x19, 0x6c, 0x45, 0xea, - 0x9c, 0x2d, 0xbc, 0x33, 0xdb, 0x0c, 0x6c, 0x5e, 0xad, 0x67, 0xb0, 0x15, 0x15, 0x8e, 0xd9, 0xfe, - 0xaa, 0xc0, 0x8d, 0xc9, 0x60, 0x87, 0xba, 0xd4, 0x09, 0x9d, 0xae, 0x49, 0xed, 0x46, 0x7d, 0x1e, - 0xdd, 0x67, 0x92, 0xee, 0xd1, 0x2c, 0xba, 0x39, 0xb4, 0xd9, 0x7c, 0xf3, 0x4e, 0x78, 0xab, 0x4c, - 0xf8, 0x73, 0x61, 0xed, 0x50, 0xbb, 0xf5, 0x53, 0x05, 0xaa, 0x98, 0x9f, 0xf6, 0xe8, 0x36, 0x2c, - 0x52, 0x9b, 0x5f, 0x6b, 0xb5, 0xce, 0xb5, 0x71, 0xa4, 0xfe, 0x5f, 0x30, 0xc8, 0x96, 0x89, 0xb1, - 0x16, 0xa9, 0x8d, 0x1e, 0xc1, 0x8a, 0xe9, 0xb9, 0x76, 0x97, 0xda, 0xfc, 0x3e, 0xaa, 0x75, 0x6e, - 0x8e, 0x23, 0xf5, 0x86, 0xf0, 0x96, 0x86, 0x24, 0x24, 0x11, 0x71, 0x35, 0xfe, 0x3a, 0xb2, 0xd1, - 0xa7, 0x50, 0xb7, 0x7c, 0x62, 0x30, 0xd2, 0x8d, 0xef, 0x67, 0x7e, 0x87, 0xd4, 0x3a, 0x77, 0xb3, - 0x5b, 0x32, 0x67, 0x4c, 0x30, 0xf2, 0x2a, 0x0c, 0x42, 0x7a, 0x4e, 0x1d, 0x12, 0x63, 0x91, 0x97, - 0x03, 0xea, 0x8f, 0x04, 0x56, 0xa5, 0x8c, 0x95, 0x33, 0x26, 0x58, 0x79, 0x15, 0x06, 0x21, 0x71, - 0xac, 0x06, 0xac, 0xd8, 0xa4, 0x4f, 0x18, 0x11, 0x07, 0xf7, 0x2a, 0x4e, 0x44, 0xf4, 0x00, 0xaa, - 0xde, 0xf7, 0x2e, 0xf1, 0x83, 0x46, 0x75, 0x7b, 0xe9, 0x4e, 0xad, 0xa3, 0x8e, 0x23, 0xf5, 0x3d, - 0xb1, 0x80, 0xd0, 0x27, 0xd8, 0x52, 0xc2, 0xd2, 0x1d, 0x1d, 0x02, 0x18, 0x8c, 0xf9, 0xd4, 0x0c, - 0x19, 0x09, 0xf8, 0x19, 0x77, 0xa9, 0x73, 0x7b, 0x1c, 0xa9, 0xb7, 0xe4, 0xce, 0xa6, 0xb6, 0x74, - 0x1b, 0x33, 0x0d, 0xce, 0x85, 0xa2, 0x5d, 0x58, 0x76, 0x0d, 0x87, 0x04, 0x8d, 0x55, 0x4e, 0xe0, - 0xc6, 0x38, 0x52, 0x37, 0x05, 0x06, 0x57, 0x27, 0xe1, 0x42, 0xc0, 0xc2, 0x17, 0xb5, 0xa1, 0xc2, - 0x46, 0x03, 0x31, 0xcd, 0x85, 0x98, 0x58, 0x9b, 0xc6, 0x08, 0x01, 0x73, 0xd7, 0xd6, 0xd7, 0xb0, - 0xbe, 0x97, 0x74, 0xca, 0x81, 0xcb, 0xfc, 0x11, 0x42, 0x50, 0x89, 0xd1, 0x44, 0x53, 0x60, 0xfe, - 0x8d, 0x3e, 0x84, 0x65, 0x12, 0x1b, 0xe5, 0x5b, 0x44, 0xd5, 0xca, 0x4f, 0x35, 0xed, 0x0b, 0xc3, - 0x21, 0x29, 0x10, 0x16, 0xde, 0xad, 0xbf, 0x97, 0x60, 0xad, 0x60, 0x40, 0xdf, 0xc0, 0x65, 0x5e, - 0xa9, 0xee, 0x20, 0x34, 0xfb, 0xd4, 0xea, 0x7e, 0x47, 0x46, 0xb2, 0xfb, 0x76, 0xc7, 0x91, 0xaa, - 0xe7, 0x4a, 0x9c, 0xf3, 0x28, 0x14, 0x3b, 0xaf, 0xc7, 0xeb, 0x5c, 0x75, 0xcc, 0x35, 0x4f, 0xc9, - 0x08, 0x61, 0x58, 0x13, 0x4e, 0x86, 0x6d, 0xfb, 0x24, 0x08, 0x64, 0xaf, 0xee, 0x8c, 0x23, 0xf5, - 0x6e, 0x1e, 0x5b, 0x9a, 0x8b, 0xc0, 0x89, 0x12, 0x5f, 0xe2, 0xf2, 0x9e, 0x10, 0xd1, 0x55, 0xa8, - 0x9e, 0x12, 0xda, 0x3b, 0x15, 0x8f, 0x9f, 0x0a, 0x96, 0x52, 0xac, 0x0f, 0x98, 0xc1, 0xc2, 0x40, - 0x34, 0x21, 0x96, 0x12, 0x7a, 0x02, 0x90, 0x4c, 0x24, 0x15, 0x8d, 0x55, 0x2b, 0xb4, 0x40, 0x6a, - 0xcb, 0x26, 0x39, 0xd5, 0xe0, 0x9a, 0x14, 0x8e, 0x0a, 0x13, 0x57, 0xfd, 0xaf, 0x13, 0xe7, 0x16, - 0xa7, 0x44, 0xdc, 0xb5, 0x5b, 0x13, 0x37, 0xd4, 0xf3, 0xe4, 0xb9, 0xdc, 0x69, 0x17, 0xdf, 0xad, - 0x73, 0xa6, 0xe8, 0x2c, 0xbe, 0x74, 0x72, 0x93, 0xd4, 0x3a, 0x81, 0x5a, 0xbc, 0xcf, 0xb3, 0x1b, - 0xe8, 0x7e, 0xb1, 0x81, 0xae, 0x4f, 0x6f, 0x20, 0x71, 0x28, 0x25, 0xdd, 0xf3, 0xa3, 0x02, 0x90, - 0x69, 0xd1, 0x43, 0xa8, 0xf6, 0x0d, 0x46, 0x82, 0xe4, 0x15, 0x7e, 0xf3, 0x6d, 0x18, 0x9c, 0x09, - 0x96, 0x01, 0xe8, 0x31, 0xac, 0x9c, 0xd2, 0x80, 0x79, 0x7c, 0xfd, 0xa5, 0x7f, 0x17, 0x9b, 0x44, - 0xb4, 0x1e, 0xc2, 0xff, 0x4a, 0x36, 0xb4, 0x9e, 0x9d, 0x9a, 0xfc, 0x70, 0xcc, 0x5a, 0x64, 0x31, - 0xdf, 0x22, 0x2d, 0x06, 0xb5, 0x13, 0xda, 0x73, 0x0d, 0x16, 0xfa, 0x04, 0xdd, 0x83, 0xa5, 0x80, - 0xf6, 0x64, 0xb7, 0x6f, 0x8e, 0x23, 0xf5, 0x8a, 0xa8, 0x75, 0x40, 0x7b, 0x49, 0x8d, 0xe3, 0x4f, - 0x1c, 0x7b, 0xc5, 0x9b, 0x3f, 0x08, 0x4d, 0x3e, 0x1e, 0x13, 0xc7, 0xad, 0x34, 0x24, 0x41, 0x89, - 0x88, 0xab, 0x83, 0xd0, 0x7c, 0x4a, 0x46, 0xad, 0x5d, 0xa8, 0x1f, 0xf0, 0xad, 0x79, 0x16, 0x92, - 0x90, 0x4c, 0x90, 0xdd, 0x80, 0xe5, 0xa1, 0xd1, 0x0f, 0x09, 0x2f, 0x45, 0x0d, 0x0b, 0xa1, 0x75, - 0x0b, 0xea, 0x22, 0xc3, 0xe0, 0x33, 0x1a, 0xb0, 0xcc, 0x49, 0xc9, 0x39, 0x75, 0x3e, 0x7e, 0x7d, - 0xde, 0x54, 0xde, 0x9c, 0x37, 0x95, 0xbf, 0xce, 0x9b, 0xca, 0xd9, 0x45, 0x73, 0xe1, 0xcd, 0x45, - 0x73, 0xe1, 0xf7, 0x8b, 0xe6, 0xc2, 0x57, 0x1f, 0xf4, 0x28, 0xd3, 0x86, 0xb6, 0xa9, 0x31, 0x4f, - 0x8f, 0x4b, 0xbb, 0x43, 0x3d, 0xbd, 0x6f, 0x58, 0x9e, 0x4b, 0x2d, 0x5b, 0x7f, 0x99, 0xfe, 0xe9, - 0x99, 0x55, 0xde, 0x7b, 0xbb, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x50, 0xe6, 0xc7, 0xe7, 0x0d, + 0x17, 0x36, 0x7d, 0x91, 0xad, 0xa3, 0xd8, 0x7f, 0x30, 0xbf, 0x93, 0xc8, 0x6e, 0x22, 0x3a, 0x0a, + 0xda, 0x24, 0x08, 0x4c, 0xc2, 0x31, 0x8a, 0x20, 0x09, 0x0a, 0xd4, 0x72, 0x1d, 0xc3, 0x4d, 0x2f, + 0xce, 0x38, 0xab, 0x16, 0x85, 0xc0, 0xcb, 0x44, 0x9e, 0x56, 0x24, 0x05, 0x72, 0xa8, 0x46, 0xcb, + 0x02, 0xdd, 0x75, 0xe3, 0x65, 0x16, 0x7d, 0x83, 0x2e, 0xfa, 0x18, 0xcd, 0x32, 0xcb, 0x6e, 0xaa, + 0x16, 0x36, 0xd0, 0x07, 0xd0, 0x13, 0x14, 0x9c, 0x0b, 0x6f, 0x92, 0xa2, 0x16, 0xd9, 0xf1, 0xdc, + 0xbe, 0xf9, 0xce, 0x99, 0x73, 0x66, 0x86, 0xa0, 0x3b, 0x24, 0x74, 0xcc, 0x90, 0x74, 0x68, 0xc4, + 0xc2, 0x81, 0xd9, 0xdf, 0x49, 0xbf, 0x8d, 0x5e, 0x18, 0xb0, 0x00, 0x5d, 0x4e, 0x1c, 0x8c, 0x54, + 0xd9, 0xdf, 0xd9, 0x6c, 0x74, 0x82, 0xa0, 0xd3, 0x25, 0x26, 0xb7, 0xdb, 0xf1, 0x0b, 0xd3, 0x8d, + 0x43, 0x8b, 0xd1, 0xc0, 0x17, 0x11, 0x9b, 0x7a, 0xd9, 0xce, 0xa8, 0x47, 0x22, 0x66, 0x79, 0x3d, + 0xe9, 0xb0, 0xde, 0x09, 0x3a, 0x01, 0xff, 0x34, 0x93, 0x2f, 0xa9, 0x6d, 0x38, 0x41, 0xe4, 0x05, + 0x91, 0x69, 0x5b, 0x11, 0x31, 0xfb, 0x3b, 0x36, 0x61, 0xd6, 0x8e, 0xe9, 0x04, 0x54, 0xc2, 0x36, + 0xff, 0x58, 0x85, 0xca, 0xb1, 0x15, 0x5a, 0x5e, 0x84, 0x28, 0xd4, 0x42, 0xe2, 0x04, 0xa1, 0xdb, + 0x0e, 0x89, 0xcf, 0xea, 0xda, 0x96, 0x76, 0xa7, 0x76, 0x7f, 0xc3, 0x10, 0x00, 0x46, 0x02, 0x60, + 0x48, 0x00, 0x63, 0x3f, 0xa0, 0x7e, 0x6b, 0xfb, 0xf5, 0x50, 0x9f, 0x1b, 0x0d, 0xf5, 0xf7, 0xbf, + 0x8d, 0x02, 0xff, 0x51, 0x33, 0x17, 0xdb, 0xdc, 0x1a, 0x58, 0x5e, 0xb7, 0xa8, 0xc2, 0x20, 0x24, + 0x4c, 0x7c, 0x86, 0xce, 0x34, 0x58, 0xcf, 0x19, 0xdb, 0x2a, 0xd7, 0xfa, 0xbc, 0x5c, 0x54, 0x24, + 0x6b, 0xa8, 0x64, 0x8d, 0x4f, 0xa4, 0x43, 0x6b, 0x5f, 0x2e, 0xfa, 0x60, 0x6c, 0xd1, 0x14, 0x64, + 0xc2, 0xea, 0x99, 0xed, 0xd5, 0x9f, 0xba, 0x86, 0x51, 0x46, 0x45, 0x01, 0xa3, 0x18, 0xd6, 0xac, + 0x98, 0x9d, 0x06, 0x21, 0x65, 0x03, 0x51, 0x80, 0x85, 0x59, 0x05, 0xd8, 0x95, 0x5c, 0xee, 0x09, + 0x2e, 0xc5, 0x70, 0xc5, 0xa2, 0xa4, 0xc5, 0xab, 0xa9, 0x82, 0x57, 0xe2, 0x67, 0x0d, 0xae, 0x15, + 0x5d, 0xb2, 0x62, 0x2c, 0xce, 0x2a, 0xc6, 0x91, 0x24, 0xf0, 0xd1, 0x24, 0x02, 0x63, 0xf5, 0x98, + 0x66, 0xe6, 0x25, 0xb9, 0x52, 0xa0, 0x95, 0x56, 0xe5, 0x95, 0x06, 0x57, 0xb3, 0xb8, 0x4e, 0x68, + 0x39, 0xa4, 0xdd, 0x23, 0x21, 0x0d, 0xdc, 0xfa, 0xd2, 0x2c, 0x76, 0x87, 0x92, 0xdd, 0xe3, 0x32, + 0xbb, 0x3c, 0xcc, 0x38, 0xb9, 0x82, 0x95, 0x73, 0x5b, 0x4f, 0x8d, 0x87, 0x89, 0xed, 0x98, 0x9b, + 0xd0, 0x0f, 0x1a, 0x6c, 0x64, 0x51, 0x56, 0xec, 0x24, 0x8b, 0xb6, 0x89, 0x6f, 0xd9, 0x5d, 0xe2, + 0xd6, 0x2b, 0x5b, 0xda, 0x9d, 0x95, 0xd6, 0xc1, 0x68, 0xa8, 0xef, 0x95, 0x97, 0x2f, 0xb9, 0x8e, + 0x33, 0x28, 0x3b, 0xe0, 0x6c, 0x87, 0xf6, 0x84, 0xe9, 0x40, 0x58, 0xd0, 0x6f, 0x1a, 0x4c, 0x88, + 0x73, 0x02, 0xcf, 0xa3, 0x2c, 0xca, 0x36, 0x72, 0x79, 0x56, 0xa9, 0xda, 0xb2, 0x54, 0x27, 0xd3, + 0xb8, 0x96, 0x21, 0xa7, 0x93, 0x1e, 0xf3, 0xe4, 0x25, 0xd4, 0xcb, 0x19, 0xec, 0x0b, 0xb7, 0x74, + 0xa3, 0x27, 0x67, 0x12, 0x92, 0x3e, 0xb1, 0xba, 0xb9, 0x4c, 0x56, 0xde, 0x39, 0x93, 0x32, 0xe4, + 0xf4, 0x4c, 0xc6, 0x3c, 0x27, 0x67, 0x82, 0x85, 0x5b, 0x9a, 0xc9, 0x2f, 0x1a, 0x5c, 0x9f, 0x56, + 0x96, 0xf6, 0x0b, 0x42, 0xea, 0xd5, 0x59, 0x73, 0xfd, 0xa5, 0xcc, 0xe1, 0xf0, 0xed, 0xbb, 0x91, + 0x80, 0xcd, 0xda, 0x07, 0xee, 0x83, 0x37, 0x26, 0x57, 0xff, 0x09, 0x21, 0x53, 0xd8, 0x8a, 0xd4, + 0x39, 0x5b, 0x78, 0x67, 0xb6, 0x19, 0xd8, 0xac, 0x5a, 0x4f, 0x61, 0x2b, 0x2a, 0x9c, 0xb0, 0xfd, + 0x55, 0x83, 0x1b, 0xe3, 0xc1, 0x1e, 0xf5, 0xa9, 0x17, 0x7b, 0x6d, 0x9b, 0xba, 0xf5, 0xda, 0x2c, + 0xba, 0xcf, 0x24, 0xdd, 0xa3, 0x69, 0x74, 0x73, 0x68, 0xd3, 0xf9, 0xe6, 0x9d, 0xf0, 0x66, 0x99, + 0xf0, 0xe7, 0xc2, 0xda, 0xa2, 0x6e, 0xf3, 0xa7, 0x45, 0xa8, 0x60, 0x7e, 0xda, 0xa3, 0xdb, 0x30, + 0x4f, 0x5d, 0x7e, 0xad, 0x55, 0x5b, 0xd7, 0x46, 0x43, 0xfd, 0xff, 0x82, 0x41, 0xb6, 0x4c, 0x82, + 0x35, 0x4f, 0x5d, 0xf4, 0x08, 0x96, 0xed, 0xc0, 0x77, 0xdb, 0xd4, 0xe5, 0xf7, 0x51, 0xb5, 0x75, + 0x73, 0x34, 0xd4, 0x6f, 0x08, 0x6f, 0x69, 0x50, 0x21, 0x4a, 0xc4, 0x95, 0xe4, 0xeb, 0xc8, 0x45, + 0x9f, 0x42, 0xcd, 0x09, 0x89, 0xc5, 0x48, 0x3b, 0xb9, 0x9f, 0xf9, 0x1d, 0x52, 0x6d, 0xdd, 0xcd, + 0x6e, 0xc9, 0x9c, 0x51, 0x61, 0xe4, 0x55, 0x18, 0x84, 0xf4, 0x9c, 0x7a, 0x24, 0xc1, 0x22, 0x2f, + 0x7b, 0x34, 0x1c, 0x08, 0xac, 0xc5, 0x32, 0x56, 0xce, 0xa8, 0xb0, 0xf2, 0x2a, 0x0c, 0x42, 0xe2, + 0x58, 0x75, 0x58, 0x76, 0x49, 0x97, 0x30, 0x22, 0x0e, 0xee, 0x15, 0xac, 0x44, 0xf4, 0x00, 0x2a, + 0xc1, 0xf7, 0x3e, 0x09, 0xa3, 0x7a, 0x65, 0x6b, 0xe1, 0x4e, 0xb5, 0xa5, 0x8f, 0x86, 0xfa, 0x7b, + 0x62, 0x01, 0xa1, 0x57, 0xd8, 0x52, 0xc2, 0xd2, 0x1d, 0x1d, 0x02, 0x58, 0x8c, 0x85, 0xd4, 0x8e, + 0x19, 0x89, 0xf8, 0x19, 0x77, 0xa9, 0x75, 0x7b, 0x34, 0xd4, 0x6f, 0xc9, 0x9d, 0x4d, 0x6d, 0xe9, + 0x36, 0x66, 0x1a, 0x9c, 0x0b, 0x45, 0xbb, 0xb0, 0xe4, 0x5b, 0x1e, 0x89, 0xea, 0x2b, 0x9c, 0xc0, + 0x8d, 0xd1, 0x50, 0xdf, 0x10, 0x18, 0x5c, 0xad, 0xc2, 0x85, 0x80, 0x85, 0x6f, 0x12, 0xc4, 0x06, + 0x3d, 0x12, 0xf1, 0x71, 0x2e, 0x04, 0x71, 0xb5, 0x0a, 0x12, 0x02, 0x16, 0xbe, 0xcd, 0xaf, 0x61, + 0x6d, 0x4f, 0xf5, 0xca, 0x81, 0xcf, 0xc2, 0x01, 0x42, 0xb0, 0x98, 0xe0, 0x89, 0xb6, 0xc0, 0xfc, + 0x1b, 0x7d, 0x08, 0x4b, 0x24, 0x31, 0xca, 0xd7, 0x88, 0x6e, 0x94, 0x1f, 0x6b, 0xc6, 0x17, 0x96, + 0x47, 0x52, 0x20, 0x2c, 0xbc, 0x9b, 0x7f, 0x2f, 0xc0, 0x6a, 0xc1, 0x80, 0xbe, 0x81, 0xcb, 0xbc, + 0x56, 0xed, 0x5e, 0x6c, 0x77, 0xa9, 0xd3, 0xfe, 0x8e, 0x0c, 0x64, 0xff, 0xed, 0x8e, 0x86, 0xba, + 0x99, 0x2b, 0x72, 0xce, 0xa3, 0x50, 0xee, 0xbc, 0x1e, 0xaf, 0x71, 0xd5, 0x31, 0xd7, 0x3c, 0x25, + 0x03, 0x84, 0x61, 0x55, 0x38, 0x59, 0xae, 0x1b, 0x92, 0x28, 0x92, 0xdd, 0xba, 0x3d, 0x1a, 0xea, + 0x77, 0xf3, 0xd8, 0xd2, 0x5c, 0x04, 0x56, 0x4a, 0x7c, 0x89, 0xcb, 0x7b, 0x42, 0x44, 0x57, 0xa1, + 0x72, 0x4a, 0x68, 0xe7, 0x54, 0x3c, 0x7f, 0x16, 0xb1, 0x94, 0x12, 0x7d, 0xc4, 0x2c, 0x16, 0x47, + 0xa2, 0x0d, 0xb1, 0x94, 0xd0, 0x13, 0x00, 0x35, 0x93, 0x54, 0xb4, 0x56, 0xb5, 0xd0, 0x04, 0xa9, + 0x2d, 0x9b, 0xe5, 0x54, 0x83, 0xab, 0x52, 0x38, 0x2a, 0xcc, 0x5c, 0xe5, 0xbf, 0xce, 0x9c, 0x5f, + 0x9c, 0x13, 0x71, 0xdb, 0x6e, 0x8e, 0xdd, 0x51, 0xcf, 0xd5, 0x83, 0xb9, 0xb5, 0x53, 0x7c, 0xb9, + 0xce, 0x98, 0xa3, 0xb3, 0xe4, 0xda, 0xc9, 0xcd, 0x52, 0xf3, 0x04, 0xaa, 0xc9, 0x3e, 0x4f, 0x6f, + 0xa0, 0xfb, 0xc5, 0x06, 0xba, 0x3e, 0xb9, 0x81, 0xc4, 0xb1, 0xa4, 0xba, 0xe7, 0x47, 0x0d, 0x20, + 0xd3, 0xa2, 0x87, 0x50, 0xe9, 0x5a, 0x8c, 0x44, 0xea, 0x1d, 0x7e, 0xf3, 0x6d, 0x18, 0x9c, 0x09, + 0x96, 0x01, 0xe8, 0x31, 0x2c, 0x9f, 0xd2, 0x88, 0x05, 0x7c, 0xfd, 0x85, 0x7f, 0x17, 0xab, 0x22, + 0x9a, 0x0f, 0xe1, 0x7f, 0x25, 0x1b, 0x5a, 0xcb, 0xce, 0x4d, 0x7e, 0x3c, 0x66, 0x2d, 0x32, 0x9f, + 0x6f, 0x91, 0x26, 0x83, 0xea, 0x09, 0xed, 0xf8, 0x16, 0x8b, 0x43, 0x82, 0xee, 0xc1, 0x42, 0x44, + 0x3b, 0xb2, 0xdb, 0x37, 0x46, 0x43, 0xfd, 0x8a, 0xa8, 0x75, 0x44, 0x3b, 0xaa, 0xc6, 0xc9, 0x27, + 0x4e, 0xbc, 0x92, 0xcd, 0xef, 0xc5, 0x36, 0x1f, 0x8f, 0xb1, 0x03, 0x57, 0x1a, 0x54, 0x90, 0x12, + 0x71, 0xa5, 0x17, 0xdb, 0x4f, 0xc9, 0xa0, 0xb9, 0x0b, 0xb5, 0x03, 0xbe, 0x35, 0xcf, 0x62, 0x12, + 0x93, 0x31, 0xb2, 0xeb, 0xb0, 0xd4, 0xb7, 0xba, 0x31, 0xe1, 0xa5, 0xa8, 0x62, 0x21, 0x34, 0x6f, + 0x41, 0x4d, 0x64, 0x18, 0x7d, 0x46, 0x23, 0x96, 0x39, 0x69, 0x39, 0xa7, 0xd6, 0xc7, 0xaf, 0xcf, + 0x1b, 0xda, 0x9b, 0xf3, 0x86, 0xf6, 0xd7, 0x79, 0x43, 0x3b, 0xbb, 0x68, 0xcc, 0xbd, 0xb9, 0x68, + 0xcc, 0xfd, 0x7e, 0xd1, 0x98, 0xfb, 0xea, 0x83, 0x0e, 0x65, 0x46, 0xdf, 0xb5, 0x0d, 0x16, 0x98, + 0x49, 0x69, 0xb7, 0x69, 0x60, 0x76, 0x2d, 0x27, 0xf0, 0xa9, 0xe3, 0x9a, 0x2f, 0xd3, 0x7f, 0x3d, + 0xbb, 0xc2, 0x7b, 0x6f, 0xf7, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0xc8, 0xe1, 0xd4, 0x0f, 0x0e, 0x00, 0x00, } @@ -965,10 +965,10 @@ func (m *Record) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Type) > 0 { - i -= len(m.Type) - copy(dAtA[i:], m.Type) - i = encodeVarintRegistry(dAtA, i, uint64(len(m.Type))) + if len(m.Types) > 0 { + i -= len(m.Types) + copy(dAtA[i:], m.Types) + i = encodeVarintRegistry(dAtA, i, uint64(len(m.Types))) i-- dAtA[i] = 0x4a } @@ -1469,7 +1469,7 @@ func (m *Record) Size() (n int) { n += 1 + l + sovRegistry(uint64(l)) } } - l = len(m.Type) + l = len(m.Types) if l > 0 { n += 1 + l + sovRegistry(uint64(l)) } @@ -2313,7 +2313,7 @@ func (m *Record) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Types", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2341,7 +2341,7 @@ func (m *Record) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Type = string(dAtA[iNdEx:postIndex]) + m.Types = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/registry/tx.pb.go b/x/registry/tx.pb.go index 2d6a8934..8b6e4efa 100644 --- a/x/registry/tx.pb.go +++ b/x/registry/tx.pb.go @@ -1652,6 +1652,7 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cerc.registry.v1.Msg", HandlerType: (*MsgServer)(nil),