forked from cerc-io/laconicd
Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d130608f67 | ||
|
|
33574a8f89 | ||
|
|
5aa2594073 | ||
|
|
a8ebc0aceb | ||
|
|
e02d221dea | ||
|
|
59236e5ce6 | ||
|
|
7af9e9d496 | ||
|
|
31ef3afb9a | ||
|
|
f4cf8ac744 | ||
|
|
c14f1d3b00 | ||
|
|
07297a27d1 | ||
|
|
d3a06319ce | ||
|
|
973bf51573 | ||
|
|
aee4758538 | ||
|
|
c3854c30cf | ||
|
|
65957d6199 | ||
|
|
c807a9db80 | ||
|
|
3a551bce99 | ||
|
|
6f75370b17 | ||
|
|
52e8d322fa | ||
|
|
df43322ef3 | ||
|
|
94ba057807 | ||
|
|
a01a5d24d1 | ||
|
|
debfb82205 | ||
|
|
3c5cd002e1 | ||
|
|
b5a76a920e | ||
|
|
f176a5889e | ||
|
|
5e7d5fc47c | ||
|
|
c162396298 | ||
|
|
7a88c82816 | ||
|
|
9fab3f8326 | ||
|
|
ec6e2f3776 |
+3
-3
@@ -7,7 +7,7 @@ on:
|
||||
- release/**
|
||||
|
||||
jobs:
|
||||
sdk_tests_auctions:
|
||||
sdk_tests_authority_auctions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -35,6 +35,6 @@ jobs:
|
||||
TEST_AUCTION_ENABLED: true
|
||||
run: docker compose up -d
|
||||
|
||||
- name: Run auction tests
|
||||
- name: Run authority auction tests
|
||||
working-directory: tests/sdk_tests
|
||||
run: ./run-tests.sh test:auctions
|
||||
run: ./run-tests.sh test:authority-auctions
|
||||
+13
-7
@@ -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,18 +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 \
|
||||
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
|
||||
|
||||
WORKDIR /
|
||||
# # Copy over binary from the builder
|
||||
# COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/build/laconicd /usr/bin/laconicd
|
||||
|
||||
# # 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"]
|
||||
|
||||
@@ -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,8 +42,8 @@ build-linux:
|
||||
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build
|
||||
|
||||
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
|
||||
@echo "--> installing laconicd"
|
||||
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...
|
||||
@echo "--> $@ing laconicd"
|
||||
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/laconicd
|
||||
|
||||
$(BUILDDIR)/:
|
||||
mkdir -p $(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
|
||||
|
||||
@@ -27,6 +27,8 @@ Run with a single node fixture:
|
||||
./scripts/init.sh clean
|
||||
```
|
||||
|
||||
See [lockup.md](./lockup.md) for lockup account usage.
|
||||
|
||||
## Tests
|
||||
|
||||
Run tests:
|
||||
@@ -35,8 +37,8 @@ Run tests:
|
||||
# integration tests
|
||||
make test-integration
|
||||
|
||||
# e2e tests
|
||||
make test-e2e
|
||||
# system tests
|
||||
make test-system
|
||||
```
|
||||
|
||||
## Community
|
||||
|
||||
@@ -14,12 +14,14 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
md_Module protoreflect.MessageDescriptor
|
||||
md_Module protoreflect.MessageDescriptor
|
||||
fd_Module_authority protoreflect.FieldDescriptor
|
||||
)
|
||||
|
||||
func init() {
|
||||
file_cerc_auction_module_v1_module_proto_init()
|
||||
md_Module = File_cerc_auction_module_v1_module_proto.Messages().ByName("Module")
|
||||
fd_Module_authority = md_Module.Fields().ByName("authority")
|
||||
}
|
||||
|
||||
var _ protoreflect.Message = (*fastReflection_Module)(nil)
|
||||
@@ -87,6 +89,12 @@ func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage {
|
||||
// While iterating, mutating operations may only be performed
|
||||
// on the current field descriptor.
|
||||
func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
if x.Authority != "" {
|
||||
value := protoreflect.ValueOfString(x.Authority)
|
||||
if !f(fd_Module_authority, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Has reports whether a field is populated.
|
||||
@@ -102,6 +110,8 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto
|
||||
// a repeated field is populated if it is non-empty.
|
||||
func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
switch fd.FullName() {
|
||||
case "cerc.auction.module.v1.Module.authority":
|
||||
return x.Authority != ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.auction.module.v1.Module"))
|
||||
@@ -118,6 +128,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
// Clear is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.auction.module.v1.Module.authority":
|
||||
x.Authority = ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.auction.module.v1.Module"))
|
||||
@@ -134,6 +146,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
||||
// of the value; to obtain a mutable reference, use Mutable.
|
||||
func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch descriptor.FullName() {
|
||||
case "cerc.auction.module.v1.Module.authority":
|
||||
value := x.Authority
|
||||
return protoreflect.ValueOfString(value)
|
||||
default:
|
||||
if descriptor.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.auction.module.v1.Module"))
|
||||
@@ -154,6 +169,8 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro
|
||||
// Set is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.auction.module.v1.Module.authority":
|
||||
x.Authority = value.Interface().(string)
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.auction.module.v1.Module"))
|
||||
@@ -174,6 +191,8 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto
|
||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.auction.module.v1.Module.authority":
|
||||
panic(fmt.Errorf("field authority of message cerc.auction.module.v1.Module is not mutable"))
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.auction.module.v1.Module"))
|
||||
@@ -187,6 +206,8 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore
|
||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
||||
func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.auction.module.v1.Module.authority":
|
||||
return protoreflect.ValueOfString("")
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.auction.module.v1.Module"))
|
||||
@@ -256,6 +277,10 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
var n int
|
||||
var l int
|
||||
_ = l
|
||||
l = len(x.Authority)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
if x.unknownFields != nil {
|
||||
n += len(x.unknownFields)
|
||||
}
|
||||
@@ -285,6 +310,13 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
i -= len(x.unknownFields)
|
||||
copy(dAtA[i:], x.unknownFields)
|
||||
}
|
||||
if len(x.Authority) > 0 {
|
||||
i -= len(x.Authority)
|
||||
copy(dAtA[i:], x.Authority)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if input.Buf != nil {
|
||||
input.Buf = append(input.Buf, dAtA...)
|
||||
} else {
|
||||
@@ -334,6 +366,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
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.Authority = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := runtime.Skip(dAtA[iNdEx:])
|
||||
@@ -388,6 +452,10 @@ type Module struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// authority defines the custom module authority. If not set, defaults to the
|
||||
// governance module.
|
||||
Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Module) Reset() {
|
||||
@@ -410,6 +478,13 @@ func (*Module) Descriptor() ([]byte, []int) {
|
||||
return file_cerc_auction_module_v1_module_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Module) GetAuthority() string {
|
||||
if x != nil {
|
||||
return x.Authority
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_cerc_auction_module_v1_module_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_cerc_auction_module_v1_module_proto_rawDesc = []byte{
|
||||
@@ -419,25 +494,27 @@ var file_cerc_auction_module_v1_module_proto_rawDesc = []byte{
|
||||
0x69, 0x6f, 0x6e, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63,
|
||||
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68,
|
||||
0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x37, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x2d, 0xba, 0xc0, 0x96, 0xda, 0x01,
|
||||
0x27, 0x0a, 0x25, 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, 0x78,
|
||||
0x2f, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xe5, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d,
|
||||
0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6d, 0x6f,
|
||||
0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 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, 0x61, 0x75, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d,
|
||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x4d, 0xaa, 0x02, 0x16,
|
||||
0x43, 0x65, 0x72, 0x63, 0x2e, 0x41, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x41, 0x75,
|
||||
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2,
|
||||
0x02, 0x22, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x41, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x4d,
|
||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
|
||||
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x43, 0x65, 0x72, 0x63, 0x3a, 0x3a, 0x41, 0x75, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x55, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x75, 0x74,
|
||||
0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75,
|
||||
0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3a, 0x2d, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x27, 0x0a,
|
||||
0x25, 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, 0x78, 0x2f, 0x61,
|
||||
0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xe5, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63,
|
||||
0x65, 0x72, 0x63, 0x2e, 0x61, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6d, 0x6f, 0x64, 0x75,
|
||||
0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 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, 0x61, 0x75, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x4d, 0xaa, 0x02, 0x16, 0x43, 0x65,
|
||||
0x72, 0x63, 0x2e, 0x41, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c,
|
||||
0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x41, 0x75, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x22,
|
||||
0x43, 0x65, 0x72, 0x63, 0x5c, 0x41, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x4d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
|
||||
0x74, 0x61, 0xea, 0x02, 0x19, 0x43, 0x65, 0x72, 0x63, 0x3a, 0x3a, 0x41, 0x75, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
+2453
-180
File diff suppressed because it is too large
Load Diff
@@ -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,18 +15,22 @@ 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"
|
||||
Msg_CommitBid_FullMethodName = "/cerc.auction.v1.Msg/CommitBid"
|
||||
Msg_RevealBid_FullMethodName = "/cerc.auction.v1.Msg/RevealBid"
|
||||
Msg_UpdateParams_FullMethodName = "/cerc.auction.v1.Msg/UpdateParams"
|
||||
Msg_ReleaseFunds_FullMethodName = "/cerc.auction.v1.Msg/ReleaseFunds"
|
||||
)
|
||||
|
||||
// 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)
|
||||
@@ -34,6 +38,11 @@ type MsgClient interface {
|
||||
CommitBid(ctx context.Context, in *MsgCommitBid, opts ...grpc.CallOption) (*MsgCommitBidResponse, error)
|
||||
// RevealBid is the command for revealing a bid
|
||||
RevealBid(ctx context.Context, in *MsgRevealBid, opts ...grpc.CallOption) (*MsgRevealBidResponse, error)
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
||||
// ReleaseFunds is the command for paying the winners of provider auctions
|
||||
ReleaseFunds(ctx context.Context, in *MsgReleaseFunds, opts ...grpc.CallOption) (*MsgReleaseFundsResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@@ -45,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
|
||||
}
|
||||
@@ -54,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
|
||||
}
|
||||
@@ -63,8 +74,29 @@ 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
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
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, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
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, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -73,7 +105,9 @@ func (c *msgClient) RevealBid(ctx context.Context, in *MsgRevealBid, opts ...grp
|
||||
|
||||
// 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)
|
||||
@@ -81,12 +115,20 @@ type MsgServer interface {
|
||||
CommitBid(context.Context, *MsgCommitBid) (*MsgCommitBidResponse, error)
|
||||
// RevealBid is the command for revealing a bid
|
||||
RevealBid(context.Context, *MsgRevealBid) (*MsgRevealBidResponse, error)
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
||||
// ReleaseFunds is the command for paying the winners of provider auctions
|
||||
ReleaseFunds(context.Context, *MsgReleaseFunds) (*MsgReleaseFundsResponse, 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) CreateAuction(context.Context, *MsgCreateAuction) (*MsgCreateAuctionResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateAuction not implemented")
|
||||
@@ -97,7 +139,14 @@ func (UnimplementedMsgServer) CommitBid(context.Context, *MsgCommitBid) (*MsgCom
|
||||
func (UnimplementedMsgServer) RevealBid(context.Context, *MsgRevealBid) (*MsgRevealBidResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RevealBid not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) ReleaseFunds(context.Context, *MsgReleaseFunds) (*MsgReleaseFundsResponse, error) {
|
||||
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
|
||||
@@ -107,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)
|
||||
}
|
||||
|
||||
@@ -164,6 +220,42 @@ func _Msg_RevealBid_Handler(srv interface{}, ctx context.Context, dec func(inter
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgUpdateParams)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).UpdateParams(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_UpdateParams_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_ReleaseFunds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgReleaseFunds)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).ReleaseFunds(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_ReleaseFunds_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).ReleaseFunds(ctx, req.(*MsgReleaseFunds))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -183,6 +275,14 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "RevealBid",
|
||||
Handler: _Msg_RevealBid_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReleaseFunds",
|
||||
Handler: _Msg_ReleaseFunds_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/auction/v1/tx.proto",
|
||||
|
||||
@@ -14,12 +14,14 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
md_Module protoreflect.MessageDescriptor
|
||||
md_Module protoreflect.MessageDescriptor
|
||||
fd_Module_authority protoreflect.FieldDescriptor
|
||||
)
|
||||
|
||||
func init() {
|
||||
file_cerc_bond_module_v1_module_proto_init()
|
||||
md_Module = File_cerc_bond_module_v1_module_proto.Messages().ByName("Module")
|
||||
fd_Module_authority = md_Module.Fields().ByName("authority")
|
||||
}
|
||||
|
||||
var _ protoreflect.Message = (*fastReflection_Module)(nil)
|
||||
@@ -87,6 +89,12 @@ func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage {
|
||||
// While iterating, mutating operations may only be performed
|
||||
// on the current field descriptor.
|
||||
func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
if x.Authority != "" {
|
||||
value := protoreflect.ValueOfString(x.Authority)
|
||||
if !f(fd_Module_authority, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Has reports whether a field is populated.
|
||||
@@ -102,6 +110,8 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto
|
||||
// a repeated field is populated if it is non-empty.
|
||||
func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
switch fd.FullName() {
|
||||
case "cerc.bond.module.v1.Module.authority":
|
||||
return x.Authority != ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.bond.module.v1.Module"))
|
||||
@@ -118,6 +128,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
// Clear is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.bond.module.v1.Module.authority":
|
||||
x.Authority = ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.bond.module.v1.Module"))
|
||||
@@ -134,6 +146,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
||||
// of the value; to obtain a mutable reference, use Mutable.
|
||||
func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch descriptor.FullName() {
|
||||
case "cerc.bond.module.v1.Module.authority":
|
||||
value := x.Authority
|
||||
return protoreflect.ValueOfString(value)
|
||||
default:
|
||||
if descriptor.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.bond.module.v1.Module"))
|
||||
@@ -154,6 +169,8 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro
|
||||
// Set is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.bond.module.v1.Module.authority":
|
||||
x.Authority = value.Interface().(string)
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.bond.module.v1.Module"))
|
||||
@@ -174,6 +191,8 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto
|
||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.bond.module.v1.Module.authority":
|
||||
panic(fmt.Errorf("field authority of message cerc.bond.module.v1.Module is not mutable"))
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.bond.module.v1.Module"))
|
||||
@@ -187,6 +206,8 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore
|
||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
||||
func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.bond.module.v1.Module.authority":
|
||||
return protoreflect.ValueOfString("")
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.bond.module.v1.Module"))
|
||||
@@ -256,6 +277,10 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
var n int
|
||||
var l int
|
||||
_ = l
|
||||
l = len(x.Authority)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
if x.unknownFields != nil {
|
||||
n += len(x.unknownFields)
|
||||
}
|
||||
@@ -285,6 +310,13 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
i -= len(x.unknownFields)
|
||||
copy(dAtA[i:], x.unknownFields)
|
||||
}
|
||||
if len(x.Authority) > 0 {
|
||||
i -= len(x.Authority)
|
||||
copy(dAtA[i:], x.Authority)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if input.Buf != nil {
|
||||
input.Buf = append(input.Buf, dAtA...)
|
||||
} else {
|
||||
@@ -334,6 +366,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
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.Authority = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := runtime.Skip(dAtA[iNdEx:])
|
||||
@@ -388,6 +452,10 @@ type Module struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// authority defines the custom module authority. If not set, defaults to the
|
||||
// governance module.
|
||||
Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Module) Reset() {
|
||||
@@ -410,6 +478,13 @@ func (*Module) Descriptor() ([]byte, []int) {
|
||||
return file_cerc_bond_module_v1_module_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Module) GetAuthority() string {
|
||||
if x != nil {
|
||||
return x.Authority
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_cerc_bond_module_v1_module_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_cerc_bond_module_v1_module_proto_rawDesc = []byte{
|
||||
@@ -418,24 +493,26 @@ var file_cerc_bond_module_v1_module_proto_rawDesc = []byte{
|
||||
0x74, 0x6f, 0x12, 0x13, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x62, 0x6f, 0x6e, 0x64, 0x2e, 0x6d, 0x6f,
|
||||
0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f,
|
||||
0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x34, 0x0a, 0x06, 0x4d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x3a, 0x2a, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x24, 0x0a, 0x22, 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, 0x78, 0x2f, 0x62, 0x6f, 0x6e, 0x64, 0x42,
|
||||
0xd3, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x62, 0x6f, 0x6e,
|
||||
0x64, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 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, 0x62, 0x6f, 0x6e, 0x64, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b,
|
||||
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x4d, 0xaa, 0x02,
|
||||
0x13, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x42, 0x6f, 0x6e, 0x64, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c,
|
||||
0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x42, 0x6f, 0x6e, 0x64,
|
||||
0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x65, 0x72,
|
||||
0x63, 0x5c, 0x42, 0x6f, 0x6e, 0x64, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31,
|
||||
0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x43,
|
||||
0x65, 0x72, 0x63, 0x3a, 0x3a, 0x42, 0x6f, 0x6e, 0x64, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c,
|
||||
0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x52, 0x0a, 0x06, 0x4d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74,
|
||||
0x79, 0x3a, 0x2a, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x24, 0x0a, 0x22, 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, 0x78, 0x2f, 0x62, 0x6f, 0x6e, 0x64, 0x42, 0xd3, 0x01,
|
||||
0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x62, 0x6f, 0x6e, 0x64, 0x2e,
|
||||
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c,
|
||||
0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 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, 0x62,
|
||||
0x6f, 0x6e, 0x64, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f,
|
||||
0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x4d, 0xaa, 0x02, 0x13, 0x43,
|
||||
0x65, 0x72, 0x63, 0x2e, 0x42, 0x6f, 0x6e, 0x64, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e,
|
||||
0x56, 0x31, 0xca, 0x02, 0x13, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x42, 0x6f, 0x6e, 0x64, 0x5c, 0x4d,
|
||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x65, 0x72, 0x63, 0x5c,
|
||||
0x42, 0x6f, 0x6e, 0x64, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47,
|
||||
0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x43, 0x65, 0x72,
|
||||
0x63, 0x3a, 0x3a, 0x42, 0x6f, 0x6e, 0x64, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a,
|
||||
0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
+1091
-108
File diff suppressed because it is too large
Load Diff
@@ -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,19 +15,22 @@ 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"
|
||||
Msg_RefillBond_FullMethodName = "/cerc.bond.v1.Msg/RefillBond"
|
||||
Msg_WithdrawBond_FullMethodName = "/cerc.bond.v1.Msg/WithdrawBond"
|
||||
Msg_CancelBond_FullMethodName = "/cerc.bond.v1.Msg/CancelBond"
|
||||
Msg_UpdateParams_FullMethodName = "/cerc.bond.v1.Msg/UpdateParams"
|
||||
)
|
||||
|
||||
// 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)
|
||||
@@ -37,6 +40,9 @@ type MsgClient interface {
|
||||
WithdrawBond(ctx context.Context, in *MsgWithdrawBond, opts ...grpc.CallOption) (*MsgWithdrawBondResponse, error)
|
||||
// CancelBond defines a method for cancelling a bond.
|
||||
CancelBond(ctx context.Context, in *MsgCancelBond, opts ...grpc.CallOption) (*MsgCancelBondResponse, error)
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@@ -48,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
|
||||
}
|
||||
@@ -57,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
|
||||
}
|
||||
@@ -66,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
|
||||
}
|
||||
@@ -75,8 +84,19 @@ 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
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
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, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -85,7 +105,9 @@ func (c *msgClient) CancelBond(ctx context.Context, in *MsgCancelBond, opts ...g
|
||||
|
||||
// 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)
|
||||
@@ -95,12 +117,18 @@ type MsgServer interface {
|
||||
WithdrawBond(context.Context, *MsgWithdrawBond) (*MsgWithdrawBondResponse, error)
|
||||
// CancelBond defines a method for cancelling a bond.
|
||||
CancelBond(context.Context, *MsgCancelBond) (*MsgCancelBondResponse, error)
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, 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) CreateBond(context.Context, *MsgCreateBond) (*MsgCreateBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateBond not implemented")
|
||||
@@ -114,7 +142,11 @@ func (UnimplementedMsgServer) WithdrawBond(context.Context, *MsgWithdrawBond) (*
|
||||
func (UnimplementedMsgServer) CancelBond(context.Context, *MsgCancelBond) (*MsgCancelBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CancelBond not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
||||
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
|
||||
@@ -124,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)
|
||||
}
|
||||
|
||||
@@ -199,6 +238,24 @@ func _Msg_CancelBond_Handler(srv interface{}, ctx context.Context, dec func(inte
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgUpdateParams)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).UpdateParams(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_UpdateParams_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -222,6 +279,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "CancelBond",
|
||||
Handler: _Msg_CancelBond_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/bond/v1/tx.proto",
|
||||
|
||||
@@ -426,14 +426,18 @@ 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
|
||||
)
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
var _ protoreflect.Message = (*fastReflection_Participant)(nil)
|
||||
@@ -507,9 +511,21 @@ 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
|
||||
}
|
||||
}
|
||||
if x.Role != "" {
|
||||
value := protoreflect.ValueOfString(x.Role)
|
||||
if !f(fd_Participant_role, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if x.KycId != "" {
|
||||
value := protoreflect.ValueOfString(x.KycId)
|
||||
if !f(fd_Participant_kyc_id, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -530,8 +546,12 @@ 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":
|
||||
return x.KycId != ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.Participant"))
|
||||
@@ -550,8 +570,12 @@ 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":
|
||||
x.KycId = ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.Participant"))
|
||||
@@ -571,8 +595,14 @@ 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
|
||||
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)
|
||||
case "cerc.onboarding.v1.Participant.kyc_id":
|
||||
value := x.KycId
|
||||
return protoreflect.ValueOfString(value)
|
||||
default:
|
||||
if descriptor.IsExtension() {
|
||||
@@ -596,8 +626,12 @@ 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":
|
||||
x.KycId = value.Interface().(string)
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.Participant"))
|
||||
@@ -620,8 +654,12 @@ 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":
|
||||
panic(fmt.Errorf("field kyc_id of message cerc.onboarding.v1.Participant is not mutable"))
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.Participant"))
|
||||
@@ -637,7 +675,11 @@ 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":
|
||||
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":
|
||||
return protoreflect.ValueOfString("")
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
@@ -712,7 +754,15 @@ 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))
|
||||
}
|
||||
l = len(x.Role)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
l = len(x.KycId)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
@@ -745,10 +795,24 @@ func (x *fastReflection_Participant) ProtoMethods() *protoiface.Methods {
|
||||
i -= len(x.unknownFields)
|
||||
copy(dAtA[i:], x.unknownFields)
|
||||
}
|
||||
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.KycId) > 0 {
|
||||
i -= len(x.KycId)
|
||||
copy(dAtA[i:], x.KycId)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.KycId)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if len(x.Role) > 0 {
|
||||
i -= len(x.Role)
|
||||
copy(dAtA[i:], x.Role)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Role)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
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
|
||||
}
|
||||
@@ -842,7 +906,41 @@ 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 byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
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.PublicKey = append(x.PublicKey[:0], dAtA[iNdEx:postIndex]...)
|
||||
if x.PublicKey == nil {
|
||||
x.PublicKey = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@@ -870,7 +968,39 @@ func (x *fastReflection_Participant) ProtoMethods() *protoiface.Methods {
|
||||
if postIndex > l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
x.NitroAddress = string(dAtA[iNdEx:postIndex])
|
||||
x.Role = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field KycId", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
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.KycId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
@@ -1447,8 +1577,14 @@ type Participant struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// participant's cosmos (laconic) address
|
||||
CosmosAddress string `protobuf:"bytes,1,opt,name=cosmos_address,json=cosmosAddress,proto3" json:"cosmos_address,omitempty"`
|
||||
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
|
||||
KycId string `protobuf:"bytes,4,opt,name=kyc_id,json=kycId,proto3" json:"kyc_id,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Participant) Reset() {
|
||||
@@ -1478,9 +1614,23 @@ 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 nil
|
||||
}
|
||||
|
||||
func (x *Participant) GetRole() string {
|
||||
if x != nil {
|
||||
return x.Role
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Participant) GetKycId() string {
|
||||
if x != nil {
|
||||
return x.KycId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -1544,40 +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, 0xb9, 0x01, 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, 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 (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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,19 +15,27 @@ 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"
|
||||
Query_Participants_FullMethodName = "/cerc.onboarding.v1.Query/Participants"
|
||||
Query_GetParticipantByAddress_FullMethodName = "/cerc.onboarding.v1.Query/GetParticipantByAddress"
|
||||
Query_GetParticipantByNitroAddress_FullMethodName = "/cerc.onboarding.v1.Query/GetParticipantByNitroAddress"
|
||||
)
|
||||
|
||||
// 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)
|
||||
// GetParticipantByAddress queries a participant by cosmos (laconic) address
|
||||
GetParticipantByAddress(ctx context.Context, in *QueryGetParticipantByAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByAddressResponse, error)
|
||||
// GetParticipantByNitroAddress queries a participant by nitro address
|
||||
GetParticipantByNitroAddress(ctx context.Context, in *QueryGetParticipantByNitroAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByNitroAddressResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
@@ -39,8 +47,29 @@ 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
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
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, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
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, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -49,21 +78,37 @@ func (c *queryClient) Participants(ctx context.Context, in *QueryParticipantsReq
|
||||
|
||||
// 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)
|
||||
// GetParticipantByAddress queries a participant by cosmos (laconic) address
|
||||
GetParticipantByAddress(context.Context, *QueryGetParticipantByAddressRequest) (*QueryGetParticipantByAddressResponse, error)
|
||||
// GetParticipantByNitroAddress queries a participant by nitro address
|
||||
GetParticipantByNitroAddress(context.Context, *QueryGetParticipantByNitroAddressRequest) (*QueryGetParticipantByNitroAddressResponse, error)
|
||||
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")
|
||||
}
|
||||
func (UnimplementedQueryServer) GetParticipantByAddress(context.Context, *QueryGetParticipantByAddressRequest) (*QueryGetParticipantByAddressResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetParticipantByAddress not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) GetParticipantByNitroAddress(context.Context, *QueryGetParticipantByNitroAddressRequest) (*QueryGetParticipantByNitroAddressResponse, error) {
|
||||
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
|
||||
@@ -73,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)
|
||||
}
|
||||
|
||||
@@ -94,6 +146,42 @@ func _Query_Participants_Handler(srv interface{}, ctx context.Context, dec func(
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_GetParticipantByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryGetParticipantByAddressRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).GetParticipantByAddress(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_GetParticipantByAddress_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).GetParticipantByAddress(ctx, req.(*QueryGetParticipantByAddressRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_GetParticipantByNitroAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryGetParticipantByNitroAddressRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).GetParticipantByNitroAddress(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_GetParticipantByNitroAddress_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).GetParticipantByNitroAddress(ctx, req.(*QueryGetParticipantByNitroAddressRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -105,6 +193,14 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "Participants",
|
||||
Handler: _Query_Participants_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetParticipantByAddress",
|
||||
Handler: _Query_GetParticipantByAddress_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetParticipantByNitroAddress",
|
||||
Handler: _Query_GetParticipantByNitroAddress_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/onboarding/v1/query.proto",
|
||||
|
||||
@@ -20,6 +20,8 @@ var (
|
||||
fd_MsgOnboardParticipant_participant protoreflect.FieldDescriptor
|
||||
fd_MsgOnboardParticipant_eth_payload protoreflect.FieldDescriptor
|
||||
fd_MsgOnboardParticipant_eth_signature protoreflect.FieldDescriptor
|
||||
fd_MsgOnboardParticipant_role protoreflect.FieldDescriptor
|
||||
fd_MsgOnboardParticipant_kyc_id protoreflect.FieldDescriptor
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -28,6 +30,8 @@ func init() {
|
||||
fd_MsgOnboardParticipant_participant = md_MsgOnboardParticipant.Fields().ByName("participant")
|
||||
fd_MsgOnboardParticipant_eth_payload = md_MsgOnboardParticipant.Fields().ByName("eth_payload")
|
||||
fd_MsgOnboardParticipant_eth_signature = md_MsgOnboardParticipant.Fields().ByName("eth_signature")
|
||||
fd_MsgOnboardParticipant_role = md_MsgOnboardParticipant.Fields().ByName("role")
|
||||
fd_MsgOnboardParticipant_kyc_id = md_MsgOnboardParticipant.Fields().ByName("kyc_id")
|
||||
}
|
||||
|
||||
var _ protoreflect.Message = (*fastReflection_MsgOnboardParticipant)(nil)
|
||||
@@ -113,6 +117,18 @@ func (x *fastReflection_MsgOnboardParticipant) Range(f func(protoreflect.FieldDe
|
||||
return
|
||||
}
|
||||
}
|
||||
if x.Role != "" {
|
||||
value := protoreflect.ValueOfString(x.Role)
|
||||
if !f(fd_MsgOnboardParticipant_role, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if x.KycId != "" {
|
||||
value := protoreflect.ValueOfString(x.KycId)
|
||||
if !f(fd_MsgOnboardParticipant_kyc_id, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Has reports whether a field is populated.
|
||||
@@ -134,6 +150,10 @@ func (x *fastReflection_MsgOnboardParticipant) Has(fd protoreflect.FieldDescript
|
||||
return x.EthPayload != nil
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.eth_signature":
|
||||
return x.EthSignature != ""
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.role":
|
||||
return x.Role != ""
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.kyc_id":
|
||||
return x.KycId != ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.MsgOnboardParticipant"))
|
||||
@@ -156,6 +176,10 @@ func (x *fastReflection_MsgOnboardParticipant) Clear(fd protoreflect.FieldDescri
|
||||
x.EthPayload = nil
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.eth_signature":
|
||||
x.EthSignature = ""
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.role":
|
||||
x.Role = ""
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.kyc_id":
|
||||
x.KycId = ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.MsgOnboardParticipant"))
|
||||
@@ -181,6 +205,12 @@ func (x *fastReflection_MsgOnboardParticipant) Get(descriptor protoreflect.Field
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.eth_signature":
|
||||
value := x.EthSignature
|
||||
return protoreflect.ValueOfString(value)
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.role":
|
||||
value := x.Role
|
||||
return protoreflect.ValueOfString(value)
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.kyc_id":
|
||||
value := x.KycId
|
||||
return protoreflect.ValueOfString(value)
|
||||
default:
|
||||
if descriptor.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.MsgOnboardParticipant"))
|
||||
@@ -207,6 +237,10 @@ func (x *fastReflection_MsgOnboardParticipant) Set(fd protoreflect.FieldDescript
|
||||
x.EthPayload = value.Message().Interface().(*EthPayload)
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.eth_signature":
|
||||
x.EthSignature = value.Interface().(string)
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.role":
|
||||
x.Role = value.Interface().(string)
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.kyc_id":
|
||||
x.KycId = value.Interface().(string)
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.MsgOnboardParticipant"))
|
||||
@@ -236,6 +270,10 @@ func (x *fastReflection_MsgOnboardParticipant) Mutable(fd protoreflect.FieldDesc
|
||||
panic(fmt.Errorf("field participant of message cerc.onboarding.v1.MsgOnboardParticipant is not mutable"))
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.eth_signature":
|
||||
panic(fmt.Errorf("field eth_signature of message cerc.onboarding.v1.MsgOnboardParticipant is not mutable"))
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.role":
|
||||
panic(fmt.Errorf("field role of message cerc.onboarding.v1.MsgOnboardParticipant is not mutable"))
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.kyc_id":
|
||||
panic(fmt.Errorf("field kyc_id of message cerc.onboarding.v1.MsgOnboardParticipant is not mutable"))
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.MsgOnboardParticipant"))
|
||||
@@ -256,6 +294,10 @@ func (x *fastReflection_MsgOnboardParticipant) NewField(fd protoreflect.FieldDes
|
||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.eth_signature":
|
||||
return protoreflect.ValueOfString("")
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.role":
|
||||
return protoreflect.ValueOfString("")
|
||||
case "cerc.onboarding.v1.MsgOnboardParticipant.kyc_id":
|
||||
return protoreflect.ValueOfString("")
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.onboarding.v1.MsgOnboardParticipant"))
|
||||
@@ -337,6 +379,14 @@ func (x *fastReflection_MsgOnboardParticipant) ProtoMethods() *protoiface.Method
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
l = len(x.Role)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
l = len(x.KycId)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
if x.unknownFields != nil {
|
||||
n += len(x.unknownFields)
|
||||
}
|
||||
@@ -366,6 +416,20 @@ func (x *fastReflection_MsgOnboardParticipant) ProtoMethods() *protoiface.Method
|
||||
i -= len(x.unknownFields)
|
||||
copy(dAtA[i:], x.unknownFields)
|
||||
}
|
||||
if len(x.KycId) > 0 {
|
||||
i -= len(x.KycId)
|
||||
copy(dAtA[i:], x.KycId)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.KycId)))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
}
|
||||
if len(x.Role) > 0 {
|
||||
i -= len(x.Role)
|
||||
copy(dAtA[i:], x.Role)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Role)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if len(x.EthSignature) > 0 {
|
||||
i -= len(x.EthSignature)
|
||||
copy(dAtA[i:], x.EthSignature)
|
||||
@@ -543,6 +607,70 @@ func (x *fastReflection_MsgOnboardParticipant) ProtoMethods() *protoiface.Method
|
||||
}
|
||||
x.EthSignature = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
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.Role = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field KycId", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
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.KycId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := runtime.Skip(dAtA[iNdEx:])
|
||||
@@ -957,6 +1085,8 @@ type MsgOnboardParticipant struct {
|
||||
Participant string `protobuf:"bytes,1,opt,name=participant,proto3" json:"participant,omitempty"`
|
||||
EthPayload *EthPayload `protobuf:"bytes,2,opt,name=eth_payload,json=ethPayload,proto3" json:"eth_payload,omitempty"`
|
||||
EthSignature string `protobuf:"bytes,3,opt,name=eth_signature,json=ethSignature,proto3" json:"eth_signature,omitempty"`
|
||||
Role string `protobuf:"bytes,4,opt,name=role,proto3" json:"role,omitempty"`
|
||||
KycId string `protobuf:"bytes,5,opt,name=kyc_id,json=kycId,proto3" json:"kyc_id,omitempty"`
|
||||
}
|
||||
|
||||
func (x *MsgOnboardParticipant) Reset() {
|
||||
@@ -1000,6 +1130,20 @@ func (x *MsgOnboardParticipant) GetEthSignature() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MsgOnboardParticipant) GetRole() string {
|
||||
if x != nil {
|
||||
return x.Role
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MsgOnboardParticipant) GetKycId() string {
|
||||
if x != nil {
|
||||
return x.KycId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response
|
||||
// type.
|
||||
type MsgOnboardParticipantResponse struct {
|
||||
@@ -1041,7 +1185,7 @@ var file_cerc_onboarding_v1_tx_proto_rawDesc = []byte{
|
||||
0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x23,
|
||||
0x63, 0x65, 0x72, 0x63, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2f,
|
||||
0x76, 0x31, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x22, 0xb7, 0x01, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x4f, 0x6e, 0x62, 0x6f, 0x61,
|
||||
0x6f, 0x74, 0x6f, 0x22, 0xe2, 0x01, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x4f, 0x6e, 0x62, 0x6f, 0x61,
|
||||
0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x20, 0x0a,
|
||||
0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12,
|
||||
@@ -1051,35 +1195,38 @@ var file_cerc_onboarding_v1_tx_proto_rawDesc = []byte{
|
||||
0x6c, 0x6f, 0x61, 0x64, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0a, 0x65, 0x74, 0x68, 0x50,
|
||||
0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x74, 0x68, 0x5f, 0x73, 0x69,
|
||||
0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65,
|
||||
0x74, 0x68, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x3a, 0x10, 0x82, 0xe7, 0xb0,
|
||||
0x2a, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x22, 0x1f, 0x0a,
|
||||
0x1d, 0x4d, 0x73, 0x67, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69,
|
||||
0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb2,
|
||||
0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0xa3, 0x01, 0x0a, 0x12, 0x4f, 0x6e, 0x62, 0x6f, 0x61,
|
||||
0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x29, 0x2e,
|
||||
0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e,
|
||||
0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x50, 0x61, 0x72,
|
||||
0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e,
|
||||
0x74, 0x68, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72,
|
||||
0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12,
|
||||
0x15, 0x0a, 0x06, 0x6b, 0x79, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x05, 0x6b, 0x79, 0x63, 0x49, 0x64, 0x3a, 0x10, 0x82, 0xe7, 0xb0, 0x2a, 0x0b, 0x70, 0x61, 0x72,
|
||||
0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x22, 0x1f, 0x0a, 0x1d, 0x4d, 0x73, 0x67, 0x4f,
|
||||
0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e,
|
||||
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb2, 0x01, 0x0a, 0x03, 0x4d, 0x73,
|
||||
0x67, 0x12, 0xa3, 0x01, 0x0a, 0x12, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x50, 0x61, 0x72,
|
||||
0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x29, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e,
|
||||
0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73,
|
||||
0x67, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70,
|
||||
0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2f, 0x82, 0xd3, 0xe4,
|
||||
0x93, 0x02, 0x29, 0x22, 0x27, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61,
|
||||
0x72, 0x64, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64,
|
||||
0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x1a, 0x05, 0x80, 0xe7,
|
||||
0xb0, 0x2a, 0x01, 0x42, 0xcc, 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, 0x07,
|
||||
0x54, 0x78, 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,
|
||||
0x61, 0x6e, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x6f, 0x6e, 0x62, 0x6f, 0x61,
|
||||
0x72, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4f, 0x6e, 0x62, 0x6f,
|
||||
0x61, 0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x22, 0x27,
|
||||
0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67,
|
||||
0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x74,
|
||||
0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xcc,
|
||||
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, 0x07, 0x54, 0x78, 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 (
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,14 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
md_Module protoreflect.MessageDescriptor
|
||||
md_Module protoreflect.MessageDescriptor
|
||||
fd_Module_authority protoreflect.FieldDescriptor
|
||||
)
|
||||
|
||||
func init() {
|
||||
file_cerc_registry_module_v1_module_proto_init()
|
||||
md_Module = File_cerc_registry_module_v1_module_proto.Messages().ByName("Module")
|
||||
fd_Module_authority = md_Module.Fields().ByName("authority")
|
||||
}
|
||||
|
||||
var _ protoreflect.Message = (*fastReflection_Module)(nil)
|
||||
@@ -87,6 +89,12 @@ func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage {
|
||||
// While iterating, mutating operations may only be performed
|
||||
// on the current field descriptor.
|
||||
func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
if x.Authority != "" {
|
||||
value := protoreflect.ValueOfString(x.Authority)
|
||||
if !f(fd_Module_authority, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Has reports whether a field is populated.
|
||||
@@ -102,6 +110,8 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto
|
||||
// a repeated field is populated if it is non-empty.
|
||||
func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
switch fd.FullName() {
|
||||
case "cerc.registry.module.v1.Module.authority":
|
||||
return x.Authority != ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.module.v1.Module"))
|
||||
@@ -118,6 +128,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
// Clear is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.registry.module.v1.Module.authority":
|
||||
x.Authority = ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.module.v1.Module"))
|
||||
@@ -134,6 +146,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
||||
// of the value; to obtain a mutable reference, use Mutable.
|
||||
func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch descriptor.FullName() {
|
||||
case "cerc.registry.module.v1.Module.authority":
|
||||
value := x.Authority
|
||||
return protoreflect.ValueOfString(value)
|
||||
default:
|
||||
if descriptor.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.module.v1.Module"))
|
||||
@@ -154,6 +169,8 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro
|
||||
// Set is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.registry.module.v1.Module.authority":
|
||||
x.Authority = value.Interface().(string)
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.module.v1.Module"))
|
||||
@@ -174,6 +191,8 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto
|
||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.registry.module.v1.Module.authority":
|
||||
panic(fmt.Errorf("field authority of message cerc.registry.module.v1.Module is not mutable"))
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.module.v1.Module"))
|
||||
@@ -187,6 +206,8 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore
|
||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
||||
func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.registry.module.v1.Module.authority":
|
||||
return protoreflect.ValueOfString("")
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.registry.module.v1.Module"))
|
||||
@@ -256,6 +277,10 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
var n int
|
||||
var l int
|
||||
_ = l
|
||||
l = len(x.Authority)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
if x.unknownFields != nil {
|
||||
n += len(x.unknownFields)
|
||||
}
|
||||
@@ -285,6 +310,13 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
i -= len(x.unknownFields)
|
||||
copy(dAtA[i:], x.unknownFields)
|
||||
}
|
||||
if len(x.Authority) > 0 {
|
||||
i -= len(x.Authority)
|
||||
copy(dAtA[i:], x.Authority)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if input.Buf != nil {
|
||||
input.Buf = append(input.Buf, dAtA...)
|
||||
} else {
|
||||
@@ -334,6 +366,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
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.Authority = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := runtime.Skip(dAtA[iNdEx:])
|
||||
@@ -388,6 +452,10 @@ type Module struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// authority defines the custom module authority. If not set, defaults to the
|
||||
// governance module.
|
||||
Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Module) Reset() {
|
||||
@@ -410,6 +478,13 @@ func (*Module) Descriptor() ([]byte, []int) {
|
||||
return file_cerc_registry_module_v1_module_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Module) GetAuthority() string {
|
||||
if x != nil {
|
||||
return x.Authority
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_cerc_registry_module_v1_module_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_cerc_registry_module_v1_module_proto_rawDesc = []byte{
|
||||
@@ -419,26 +494,27 @@ var file_cerc_registry_module_v1_module_proto_rawDesc = []byte{
|
||||
0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a,
|
||||
0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x22, 0x38, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x2e, 0xba, 0xc0, 0x96,
|
||||
0xda, 0x01, 0x28, 0x0a, 0x26, 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, 0x78, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x42, 0xeb, 0x01, 0x0a, 0x1b,
|
||||
0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72,
|
||||
0x79, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 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, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
|
||||
0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43,
|
||||
0x52, 0x4d, 0xaa, 0x02, 0x17, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,
|
||||
0x72, 0x79, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43,
|
||||
0x65, 0x72, 0x63, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x4d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x52, 0x65,
|
||||
0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31,
|
||||
0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43,
|
||||
0x65, 0x72, 0x63, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x4d,
|
||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
0x6f, 0x22, 0x56, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61,
|
||||
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||
0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3a, 0x2e, 0xba, 0xc0, 0x96, 0xda, 0x01,
|
||||
0x28, 0x0a, 0x26, 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, 0x78,
|
||||
0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x42, 0xeb, 0x01, 0x0a, 0x1b, 0x63, 0x6f,
|
||||
0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e,
|
||||
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c,
|
||||
0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 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, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76,
|
||||
0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x52, 0x4d,
|
||||
0xaa, 0x02, 0x17, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79,
|
||||
0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43, 0x65, 0x72,
|
||||
0x63, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c,
|
||||
0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x52, 0x65, 0x67, 0x69,
|
||||
0x73, 0x74, 0x72, 0x79, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47,
|
||||
0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, 0x65, 0x72,
|
||||
0x63, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x4d, 0x6f, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
+1363
-235
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
@@ -28,11 +28,14 @@ const (
|
||||
Query_LookupLrn_FullMethodName = "/cerc.registry.v1.Query/LookupLrn"
|
||||
Query_ResolveLrn_FullMethodName = "/cerc.registry.v1.Query/ResolveLrn"
|
||||
Query_GetRegistryModuleBalance_FullMethodName = "/cerc.registry.v1.Query/GetRegistryModuleBalance"
|
||||
Query_Authorities_FullMethodName = "/cerc.registry.v1.Query/Authorities"
|
||||
)
|
||||
|
||||
// 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)
|
||||
@@ -52,6 +55,8 @@ type QueryClient interface {
|
||||
ResolveLrn(ctx context.Context, in *QueryResolveLrnRequest, opts ...grpc.CallOption) (*QueryResolveLrnResponse, error)
|
||||
// Get registry module balance
|
||||
GetRegistryModuleBalance(ctx context.Context, in *QueryGetRegistryModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetRegistryModuleBalanceResponse, error)
|
||||
// Authorities queries all authorities
|
||||
Authorities(ctx context.Context, in *QueryAuthoritiesRequest, opts ...grpc.CallOption) (*QueryAuthoritiesResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
@@ -63,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
|
||||
}
|
||||
@@ -72,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
|
||||
}
|
||||
@@ -81,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
|
||||
}
|
||||
@@ -90,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
|
||||
}
|
||||
@@ -99,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
|
||||
}
|
||||
@@ -108,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
|
||||
}
|
||||
@@ -117,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
|
||||
}
|
||||
@@ -126,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
|
||||
}
|
||||
@@ -135,8 +148,19 @@ 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
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
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, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -145,7 +169,9 @@ func (c *queryClient) GetRegistryModuleBalance(ctx context.Context, in *QueryGet
|
||||
|
||||
// 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)
|
||||
@@ -165,12 +191,17 @@ type QueryServer interface {
|
||||
ResolveLrn(context.Context, *QueryResolveLrnRequest) (*QueryResolveLrnResponse, error)
|
||||
// Get registry module balance
|
||||
GetRegistryModuleBalance(context.Context, *QueryGetRegistryModuleBalanceRequest) (*QueryGetRegistryModuleBalanceResponse, error)
|
||||
// Authorities queries all authorities
|
||||
Authorities(context.Context, *QueryAuthoritiesRequest) (*QueryAuthoritiesResponse, error)
|
||||
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")
|
||||
@@ -199,7 +230,11 @@ func (UnimplementedQueryServer) ResolveLrn(context.Context, *QueryResolveLrnRequ
|
||||
func (UnimplementedQueryServer) GetRegistryModuleBalance(context.Context, *QueryGetRegistryModuleBalanceRequest) (*QueryGetRegistryModuleBalanceResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetRegistryModuleBalance not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) Authorities(context.Context, *QueryAuthoritiesRequest) (*QueryAuthoritiesResponse, error) {
|
||||
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
|
||||
@@ -209,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)
|
||||
}
|
||||
|
||||
@@ -374,6 +416,24 @@ func _Query_GetRegistryModuleBalance_Handler(srv interface{}, ctx context.Contex
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_Authorities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryAuthoritiesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).Authorities(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_Authorities_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).Authorities(ctx, req.(*QueryAuthoritiesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -417,6 +477,10 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetRegistryModuleBalance",
|
||||
Handler: _Query_GetRegistryModuleBalance_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Authorities",
|
||||
Handler: _Query_Authorities_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/registry/v1/query.proto",
|
||||
|
||||
@@ -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 (
|
||||
|
||||
+1222
-240
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
@@ -29,11 +29,14 @@ const (
|
||||
Msg_DeleteName_FullMethodName = "/cerc.registry.v1.Msg/DeleteName"
|
||||
Msg_ReserveAuthority_FullMethodName = "/cerc.registry.v1.Msg/ReserveAuthority"
|
||||
Msg_SetAuthorityBond_FullMethodName = "/cerc.registry.v1.Msg/SetAuthorityBond"
|
||||
Msg_UpdateParams_FullMethodName = "/cerc.registry.v1.Msg/UpdateParams"
|
||||
)
|
||||
|
||||
// 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)
|
||||
@@ -55,6 +58,9 @@ type MsgClient interface {
|
||||
ReserveAuthority(ctx context.Context, in *MsgReserveAuthority, opts ...grpc.CallOption) (*MsgReserveAuthorityResponse, error)
|
||||
// SetAuthorityBond
|
||||
SetAuthorityBond(ctx context.Context, in *MsgSetAuthorityBond, opts ...grpc.CallOption) (*MsgSetAuthorityBondResponse, error)
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@@ -66,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
|
||||
}
|
||||
@@ -75,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
|
||||
}
|
||||
@@ -84,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
|
||||
}
|
||||
@@ -93,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
|
||||
}
|
||||
@@ -102,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
|
||||
}
|
||||
@@ -111,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
|
||||
}
|
||||
@@ -120,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
|
||||
}
|
||||
@@ -129,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
|
||||
}
|
||||
@@ -138,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
|
||||
}
|
||||
@@ -147,8 +162,19 @@ 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
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
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, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -157,7 +183,9 @@ func (c *msgClient) SetAuthorityBond(ctx context.Context, in *MsgSetAuthorityBon
|
||||
|
||||
// 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)
|
||||
@@ -179,12 +207,18 @@ type MsgServer interface {
|
||||
ReserveAuthority(context.Context, *MsgReserveAuthority) (*MsgReserveAuthorityResponse, error)
|
||||
// SetAuthorityBond
|
||||
SetAuthorityBond(context.Context, *MsgSetAuthorityBond) (*MsgSetAuthorityBondResponse, error)
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, 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) SetRecord(context.Context, *MsgSetRecord) (*MsgSetRecordResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetRecord not implemented")
|
||||
@@ -216,7 +250,11 @@ func (UnimplementedMsgServer) ReserveAuthority(context.Context, *MsgReserveAutho
|
||||
func (UnimplementedMsgServer) SetAuthorityBond(context.Context, *MsgSetAuthorityBond) (*MsgSetAuthorityBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetAuthorityBond not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
||||
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
|
||||
@@ -226,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)
|
||||
}
|
||||
|
||||
@@ -409,6 +454,24 @@ func _Msg_SetAuthorityBond_Handler(srv interface{}, ctx context.Context, dec fun
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgUpdateParams)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).UpdateParams(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_UpdateParams_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -456,6 +519,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "SetAuthorityBond",
|
||||
Handler: _Msg_SetAuthorityBond_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/registry/v1/tx.proto",
|
||||
|
||||
@@ -0,0 +1,755 @@
|
||||
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
|
||||
package typesv1
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
runtime "github.com/cosmos/cosmos-proto/runtime"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
||||
types "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoiface "google.golang.org/protobuf/runtime/protoiface"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
io "io"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
var (
|
||||
md_LockupAccount protoreflect.MessageDescriptor
|
||||
fd_LockupAccount_base_account protoreflect.FieldDescriptor
|
||||
fd_LockupAccount_name protoreflect.FieldDescriptor
|
||||
fd_LockupAccount_distribution protoreflect.FieldDescriptor
|
||||
)
|
||||
|
||||
func init() {
|
||||
file_cerc_types_v1_lockup_proto_init()
|
||||
md_LockupAccount = File_cerc_types_v1_lockup_proto.Messages().ByName("LockupAccount")
|
||||
fd_LockupAccount_base_account = md_LockupAccount.Fields().ByName("base_account")
|
||||
fd_LockupAccount_name = md_LockupAccount.Fields().ByName("name")
|
||||
fd_LockupAccount_distribution = md_LockupAccount.Fields().ByName("distribution")
|
||||
}
|
||||
|
||||
var _ protoreflect.Message = (*fastReflection_LockupAccount)(nil)
|
||||
|
||||
type fastReflection_LockupAccount LockupAccount
|
||||
|
||||
func (x *LockupAccount) ProtoReflect() protoreflect.Message {
|
||||
return (*fastReflection_LockupAccount)(x)
|
||||
}
|
||||
|
||||
func (x *LockupAccount) slowProtoReflect() protoreflect.Message {
|
||||
mi := &file_cerc_types_v1_lockup_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
var _fastReflection_LockupAccount_messageType fastReflection_LockupAccount_messageType
|
||||
var _ protoreflect.MessageType = fastReflection_LockupAccount_messageType{}
|
||||
|
||||
type fastReflection_LockupAccount_messageType struct{}
|
||||
|
||||
func (x fastReflection_LockupAccount_messageType) Zero() protoreflect.Message {
|
||||
return (*fastReflection_LockupAccount)(nil)
|
||||
}
|
||||
func (x fastReflection_LockupAccount_messageType) New() protoreflect.Message {
|
||||
return new(fastReflection_LockupAccount)
|
||||
}
|
||||
func (x fastReflection_LockupAccount_messageType) Descriptor() protoreflect.MessageDescriptor {
|
||||
return md_LockupAccount
|
||||
}
|
||||
|
||||
// Descriptor returns message descriptor, which contains only the protobuf
|
||||
// type information for the message.
|
||||
func (x *fastReflection_LockupAccount) Descriptor() protoreflect.MessageDescriptor {
|
||||
return md_LockupAccount
|
||||
}
|
||||
|
||||
// Type returns the message type, which encapsulates both Go and protobuf
|
||||
// type information. If the Go type information is not needed,
|
||||
// it is recommended that the message descriptor be used instead.
|
||||
func (x *fastReflection_LockupAccount) Type() protoreflect.MessageType {
|
||||
return _fastReflection_LockupAccount_messageType
|
||||
}
|
||||
|
||||
// New returns a newly allocated and mutable empty message.
|
||||
func (x *fastReflection_LockupAccount) New() protoreflect.Message {
|
||||
return new(fastReflection_LockupAccount)
|
||||
}
|
||||
|
||||
// Interface unwraps the message reflection interface and
|
||||
// returns the underlying ProtoMessage interface.
|
||||
func (x *fastReflection_LockupAccount) Interface() protoreflect.ProtoMessage {
|
||||
return (*LockupAccount)(x)
|
||||
}
|
||||
|
||||
// Range iterates over every populated field in an undefined order,
|
||||
// calling f for each field descriptor and value encountered.
|
||||
// Range returns immediately if f returns false.
|
||||
// While iterating, mutating operations may only be performed
|
||||
// on the current field descriptor.
|
||||
func (x *fastReflection_LockupAccount) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
if x.BaseAccount != nil {
|
||||
value := protoreflect.ValueOfMessage(x.BaseAccount.ProtoReflect())
|
||||
if !f(fd_LockupAccount_base_account, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if x.Name != "" {
|
||||
value := protoreflect.ValueOfString(x.Name)
|
||||
if !f(fd_LockupAccount_name, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if x.Distribution != "" {
|
||||
value := protoreflect.ValueOfString(x.Distribution)
|
||||
if !f(fd_LockupAccount_distribution, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Has reports whether a field is populated.
|
||||
//
|
||||
// Some fields have the property of nullability where it is possible to
|
||||
// distinguish between the default value of a field and whether the field
|
||||
// was explicitly populated with the default value. Singular message fields,
|
||||
// member fields of a oneof, and proto2 scalar fields are nullable. Such
|
||||
// fields are populated only if explicitly set.
|
||||
//
|
||||
// In other cases (aside from the nullable cases above),
|
||||
// a proto3 scalar field is populated if it contains a non-zero value, and
|
||||
// a repeated field is populated if it is non-empty.
|
||||
func (x *fastReflection_LockupAccount) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
return x.BaseAccount != nil
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
return x.Name != ""
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
return x.Distribution != ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount does not contain field %s", fd.FullName()))
|
||||
}
|
||||
}
|
||||
|
||||
// Clear clears the field such that a subsequent Has call reports false.
|
||||
//
|
||||
// Clearing an extension field clears both the extension type and value
|
||||
// associated with the given field number.
|
||||
//
|
||||
// Clear is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_LockupAccount) Clear(fd protoreflect.FieldDescriptor) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
x.BaseAccount = nil
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
x.Name = ""
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
x.Distribution = ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount does not contain field %s", fd.FullName()))
|
||||
}
|
||||
}
|
||||
|
||||
// Get retrieves the value for a field.
|
||||
//
|
||||
// For unpopulated scalars, it returns the default value, where
|
||||
// the default value of a bytes scalar is guaranteed to be a copy.
|
||||
// For unpopulated composite types, it returns an empty, read-only view
|
||||
// of the value; to obtain a mutable reference, use Mutable.
|
||||
func (x *fastReflection_LockupAccount) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch descriptor.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
value := x.BaseAccount
|
||||
return protoreflect.ValueOfMessage(value.ProtoReflect())
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
value := x.Name
|
||||
return protoreflect.ValueOfString(value)
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
value := x.Distribution
|
||||
return protoreflect.ValueOfString(value)
|
||||
default:
|
||||
if descriptor.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount does not contain field %s", descriptor.FullName()))
|
||||
}
|
||||
}
|
||||
|
||||
// Set stores the value for a field.
|
||||
//
|
||||
// For a field belonging to a oneof, it implicitly clears any other field
|
||||
// that may be currently set within the same oneof.
|
||||
// For extension fields, it implicitly stores the provided ExtensionType.
|
||||
// When setting a composite type, it is unspecified whether the stored value
|
||||
// aliases the source's memory in any way. If the composite value is an
|
||||
// empty, read-only value, then it panics.
|
||||
//
|
||||
// Set is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_LockupAccount) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
x.BaseAccount = value.Message().Interface().(*types.BaseAccount)
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
x.Name = value.Interface().(string)
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
x.Distribution = value.Interface().(string)
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount does not contain field %s", fd.FullName()))
|
||||
}
|
||||
}
|
||||
|
||||
// Mutable returns a mutable reference to a composite type.
|
||||
//
|
||||
// If the field is unpopulated, it may allocate a composite value.
|
||||
// For a field belonging to a oneof, it implicitly clears any other field
|
||||
// that may be currently set within the same oneof.
|
||||
// For extension fields, it implicitly stores the provided ExtensionType
|
||||
// if not already stored.
|
||||
// It panics if the field does not contain a composite type.
|
||||
//
|
||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_LockupAccount) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
if x.BaseAccount == nil {
|
||||
x.BaseAccount = new(types.BaseAccount)
|
||||
}
|
||||
return protoreflect.ValueOfMessage(x.BaseAccount.ProtoReflect())
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
panic(fmt.Errorf("field name of message cerc.types.v1.LockupAccount is not mutable"))
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
panic(fmt.Errorf("field distribution of message cerc.types.v1.LockupAccount is not mutable"))
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount does not contain field %s", fd.FullName()))
|
||||
}
|
||||
}
|
||||
|
||||
// NewField returns a new value that is assignable to the field
|
||||
// for the given descriptor. For scalars, this returns the default value.
|
||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
||||
func (x *fastReflection_LockupAccount) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
m := new(types.BaseAccount)
|
||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
return protoreflect.ValueOfString("")
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
return protoreflect.ValueOfString("")
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount does not contain field %s", fd.FullName()))
|
||||
}
|
||||
}
|
||||
|
||||
// WhichOneof reports which field within the oneof is populated,
|
||||
// returning nil if none are populated.
|
||||
// It panics if the oneof descriptor does not belong to this message.
|
||||
func (x *fastReflection_LockupAccount) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||
switch d.FullName() {
|
||||
default:
|
||||
panic(fmt.Errorf("%s is not a oneof field in cerc.types.v1.LockupAccount", d.FullName()))
|
||||
}
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
// GetUnknown retrieves the entire list of unknown fields.
|
||||
// The caller may only mutate the contents of the RawFields
|
||||
// if the mutated bytes are stored back into the message with SetUnknown.
|
||||
func (x *fastReflection_LockupAccount) GetUnknown() protoreflect.RawFields {
|
||||
return x.unknownFields
|
||||
}
|
||||
|
||||
// SetUnknown stores an entire list of unknown fields.
|
||||
// The raw fields must be syntactically valid according to the wire format.
|
||||
// An implementation may panic if this is not the case.
|
||||
// Once stored, the caller must not mutate the content of the RawFields.
|
||||
// An empty RawFields may be passed to clear the fields.
|
||||
//
|
||||
// SetUnknown is a mutating operation and unsafe for concurrent use.
|
||||
func (x *fastReflection_LockupAccount) SetUnknown(fields protoreflect.RawFields) {
|
||||
x.unknownFields = fields
|
||||
}
|
||||
|
||||
// IsValid reports whether the message is valid.
|
||||
//
|
||||
// An invalid message is an empty, read-only value.
|
||||
//
|
||||
// An invalid message often corresponds to a nil pointer of the concrete
|
||||
// message type, but the details are implementation dependent.
|
||||
// Validity is not part of the protobuf data model, and may not
|
||||
// be preserved in marshaling or other operations.
|
||||
func (x *fastReflection_LockupAccount) IsValid() bool {
|
||||
return x != nil
|
||||
}
|
||||
|
||||
// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations.
|
||||
// This method may return nil.
|
||||
//
|
||||
// The returned methods type is identical to
|
||||
// "google.golang.org/protobuf/runtime/protoiface".Methods.
|
||||
// Consult the protoiface package documentation for details.
|
||||
func (x *fastReflection_LockupAccount) ProtoMethods() *protoiface.Methods {
|
||||
size := func(input protoiface.SizeInput) protoiface.SizeOutput {
|
||||
x := input.Message.Interface().(*LockupAccount)
|
||||
if x == nil {
|
||||
return protoiface.SizeOutput{
|
||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
||||
Size: 0,
|
||||
}
|
||||
}
|
||||
options := runtime.SizeInputToOptions(input)
|
||||
_ = options
|
||||
var n int
|
||||
var l int
|
||||
_ = l
|
||||
if x.BaseAccount != nil {
|
||||
l = options.Size(x.BaseAccount)
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
l = len(x.Name)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
l = len(x.Distribution)
|
||||
if l > 0 {
|
||||
n += 1 + l + runtime.Sov(uint64(l))
|
||||
}
|
||||
if x.unknownFields != nil {
|
||||
n += len(x.unknownFields)
|
||||
}
|
||||
return protoiface.SizeOutput{
|
||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
||||
Size: n,
|
||||
}
|
||||
}
|
||||
|
||||
marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) {
|
||||
x := input.Message.Interface().(*LockupAccount)
|
||||
if x == nil {
|
||||
return protoiface.MarshalOutput{
|
||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
||||
Buf: input.Buf,
|
||||
}, nil
|
||||
}
|
||||
options := runtime.MarshalInputToOptions(input)
|
||||
_ = options
|
||||
size := options.Size(x)
|
||||
dAtA := make([]byte, size)
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if x.unknownFields != nil {
|
||||
i -= len(x.unknownFields)
|
||||
copy(dAtA[i:], x.unknownFields)
|
||||
}
|
||||
if len(x.Distribution) > 0 {
|
||||
i -= len(x.Distribution)
|
||||
copy(dAtA[i:], x.Distribution)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Distribution)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if len(x.Name) > 0 {
|
||||
i -= len(x.Name)
|
||||
copy(dAtA[i:], x.Name)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if x.BaseAccount != nil {
|
||||
encoded, err := options.Marshal(x.BaseAccount)
|
||||
if err != nil {
|
||||
return protoiface.MarshalOutput{
|
||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
||||
Buf: input.Buf,
|
||||
}, err
|
||||
}
|
||||
i -= len(encoded)
|
||||
copy(dAtA[i:], encoded)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
if input.Buf != nil {
|
||||
input.Buf = append(input.Buf, dAtA...)
|
||||
} else {
|
||||
input.Buf = dAtA
|
||||
}
|
||||
return protoiface.MarshalOutput{
|
||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
||||
Buf: input.Buf,
|
||||
}, nil
|
||||
}
|
||||
unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) {
|
||||
x := input.Message.Interface().(*LockupAccount)
|
||||
if x == nil {
|
||||
return protoiface.UnmarshalOutput{
|
||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
||||
Flags: input.Flags,
|
||||
}, nil
|
||||
}
|
||||
options := runtime.UnmarshalInputToOptions(input)
|
||||
_ = options
|
||||
dAtA := input.Buf
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: LockupAccount: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: LockupAccount: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
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
|
||||
}
|
||||
if x.BaseAccount == nil {
|
||||
x.BaseAccount = &types.BaseAccount{}
|
||||
}
|
||||
if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.BaseAccount); err != nil {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
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.Name = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Distribution", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
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.Distribution = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := runtime.Skip(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
if !options.DiscardUnknown {
|
||||
x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...)
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
||||
}
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil
|
||||
}
|
||||
return &protoiface.Methods{
|
||||
NoUnkeyedLiterals: struct{}{},
|
||||
Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown,
|
||||
Size: size,
|
||||
Marshal: marshal,
|
||||
Unmarshal: unmarshal,
|
||||
Merge: nil,
|
||||
CheckInitialized: nil,
|
||||
}
|
||||
}
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.0
|
||||
// protoc (unknown)
|
||||
// source: cerc/types/v1/lockup.proto
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// LockupAccount extends the Cosmos SDK BaseAccount with a name and distribution
|
||||
// field. It satisfies the ModuleAccountI interface to allow querying it as a
|
||||
// module account.
|
||||
type LockupAccount struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
BaseAccount *types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3" json:"base_account,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Distribution string `protobuf:"bytes,3,opt,name=distribution,proto3" json:"distribution,omitempty"`
|
||||
}
|
||||
|
||||
func (x *LockupAccount) Reset() {
|
||||
*x = LockupAccount{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_cerc_types_v1_lockup_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *LockupAccount) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LockupAccount) ProtoMessage() {}
|
||||
|
||||
// Deprecated: Use LockupAccount.ProtoReflect.Descriptor instead.
|
||||
func (*LockupAccount) Descriptor() ([]byte, []int) {
|
||||
return file_cerc_types_v1_lockup_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *LockupAccount) GetBaseAccount() *types.BaseAccount {
|
||||
if x != nil {
|
||||
return x.BaseAccount
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *LockupAccount) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *LockupAccount) GetDistribution() string {
|
||||
if x != nil {
|
||||
return x.Distribution
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_cerc_types_v1_lockup_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_cerc_types_v1_lockup_proto_rawDesc = []byte{
|
||||
0x0a, 0x1a, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x63, 0x65,
|
||||
0x72, 0x63, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x11, 0x61, 0x6d, 0x69,
|
||||
0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19,
|
||||
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73,
|
||||
0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f,
|
||||
0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61,
|
||||
0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x8b, 0x02, 0x0a, 0x0d, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x12, 0x49, 0x0a, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73,
|
||||
0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x42, 0x61,
|
||||
0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x04, 0xd0, 0xde, 0x1f, 0x01, 0x52,
|
||||
0x0b, 0x62, 0x61, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x77, 0x88, 0xa0, 0x1f, 0x00, 0xca, 0xb4, 0x2d, 0x22, 0x63, 0x6f,
|
||||
0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61,
|
||||
0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49,
|
||||
0xca, 0xb4, 0x2d, 0x1c, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49,
|
||||
0x8a, 0xe7, 0xb0, 0x2a, 0x15, 0x6c, 0x61, 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x2f, 0x4c, 0x6f, 0x63,
|
||||
0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x92, 0xe7, 0xb0, 0x2a, 0x0e, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0xad, 0x01,
|
||||
0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73,
|
||||
0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x50, 0x01, 0x5a, 0x35, 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, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x76,
|
||||
0x31, 0x3b, 0x74, 0x79, 0x70, 0x65, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa,
|
||||
0x02, 0x0d, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x56, 0x31, 0xca,
|
||||
0x02, 0x0d, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x54, 0x79, 0x70, 0x65, 0x73, 0x5c, 0x56, 0x31, 0xe2,
|
||||
0x02, 0x19, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x54, 0x79, 0x70, 0x65, 0x73, 0x5c, 0x56, 0x31, 0x5c,
|
||||
0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, 0x43, 0x65,
|
||||
0x72, 0x63, 0x3a, 0x3a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_cerc_types_v1_lockup_proto_rawDescOnce sync.Once
|
||||
file_cerc_types_v1_lockup_proto_rawDescData = file_cerc_types_v1_lockup_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_cerc_types_v1_lockup_proto_rawDescGZIP() []byte {
|
||||
file_cerc_types_v1_lockup_proto_rawDescOnce.Do(func() {
|
||||
file_cerc_types_v1_lockup_proto_rawDescData = protoimpl.X.CompressGZIP(file_cerc_types_v1_lockup_proto_rawDescData)
|
||||
})
|
||||
return file_cerc_types_v1_lockup_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_cerc_types_v1_lockup_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_cerc_types_v1_lockup_proto_goTypes = []interface{}{
|
||||
(*LockupAccount)(nil), // 0: cerc.types.v1.LockupAccount
|
||||
(*types.BaseAccount)(nil), // 1: cosmos.auth.v1beta1.BaseAccount
|
||||
}
|
||||
var file_cerc_types_v1_lockup_proto_depIdxs = []int32{
|
||||
1, // 0: cerc.types.v1.LockupAccount.base_account:type_name -> cosmos.auth.v1beta1.BaseAccount
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_cerc_types_v1_lockup_proto_init() }
|
||||
func file_cerc_types_v1_lockup_proto_init() {
|
||||
if File_cerc_types_v1_lockup_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_cerc_types_v1_lockup_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*LockupAccount); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_cerc_types_v1_lockup_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_cerc_types_v1_lockup_proto_goTypes,
|
||||
DependencyIndexes: file_cerc_types_v1_lockup_proto_depIdxs,
|
||||
MessageInfos: file_cerc_types_v1_lockup_proto_msgTypes,
|
||||
}.Build()
|
||||
File_cerc_types_v1_lockup_proto = out.File
|
||||
file_cerc_types_v1_lockup_proto_rawDesc = nil
|
||||
file_cerc_types_v1_lockup_proto_goTypes = nil
|
||||
file_cerc_types_v1_lockup_proto_depIdxs = nil
|
||||
}
|
||||
+180
@@ -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
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"math"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
)
|
||||
|
||||
// Reference: https://github.com/cosmos/cosmos-sdk/blob/v0.50.10/x/auth/ante/validator_tx_fee.go#L15
|
||||
|
||||
// checkTxFeeWithValidatorMinGasPrices implements the default fee logic, where the minimum price per
|
||||
// unit of gas is fixed and set by each validator, can the tx priority is computed from the gas price.
|
||||
func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) {
|
||||
feeTx, ok := tx.(sdk.FeeTx)
|
||||
if !ok {
|
||||
return nil, 0, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
|
||||
}
|
||||
|
||||
feeCoins := feeTx.GetFee()
|
||||
gas := feeTx.GetGas()
|
||||
|
||||
// Only allow alnt as a fee token
|
||||
for _, coin := range feeCoins {
|
||||
if coin.Denom != params.CoinUnit {
|
||||
return nil, 0, errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "invalid fee denom %s, only %s is accepted", coin.Denom, params.CoinUnit)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that the provided fees meet a minimum threshold for the validator,
|
||||
// if this is a CheckTx. This is only for local mempool purposes, and thus
|
||||
// is only ran on check tx.
|
||||
if ctx.IsCheckTx() {
|
||||
minGasPrices := ctx.MinGasPrices()
|
||||
if !minGasPrices.IsZero() {
|
||||
requiredFees := make(sdk.Coins, len(minGasPrices))
|
||||
|
||||
// Determine the required fees by multiplying each required minimum gas
|
||||
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
|
||||
glDec := sdkmath.LegacyNewDec(int64(gas))
|
||||
for i, gp := range minGasPrices {
|
||||
fee := gp.Amount.Mul(glDec)
|
||||
requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
|
||||
}
|
||||
|
||||
if !feeCoins.IsAnyGTE(requiredFees) {
|
||||
return nil, 0, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
priority := getTxPriority(feeCoins, int64(gas))
|
||||
return feeCoins, priority, nil
|
||||
}
|
||||
|
||||
// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price
|
||||
// provided in a transaction.
|
||||
// NOTE: This implementation should be used with a great consideration as it opens potential attack vectors
|
||||
// where txs with multiple coins could not be prioritize as expected.
|
||||
func getTxPriority(fee sdk.Coins, gas int64) int64 {
|
||||
var priority int64
|
||||
for _, c := range fee {
|
||||
p := int64(math.MaxInt64)
|
||||
gasPrice := c.Amount.QuoRaw(gas)
|
||||
if gasPrice.IsInt64() {
|
||||
p = gasPrice.Int64()
|
||||
}
|
||||
if priority == 0 || p < priority {
|
||||
priority = p
|
||||
}
|
||||
}
|
||||
|
||||
return priority
|
||||
}
|
||||
+167
-50
@@ -3,20 +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"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@@ -26,37 +21,47 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server/api"
|
||||
"github.com/cosmos/cosmos-sdk/server/config"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
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"
|
||||
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
||||
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
|
||||
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/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)
|
||||
@@ -72,44 +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
|
||||
CrisisKeeper *crisiskeeper.Keeper
|
||||
GovKeeper *govkeeper.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),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// NewLaconicApp returns a reference to an initialized LaconicApp.
|
||||
@@ -124,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,
|
||||
@@ -142,17 +143,32 @@ func NewLaconicApp(
|
||||
&app.AccountKeeper,
|
||||
&app.BankKeeper,
|
||||
&app.StakingKeeper,
|
||||
&app.SlashingKeeper,
|
||||
&app.DistrKeeper,
|
||||
&app.CrisisKeeper,
|
||||
&app.GovKeeper,
|
||||
&app.ConsensusParamsKeeper,
|
||||
&app.EvidenceKeeper,
|
||||
&app.ProtocolPoolKeeper,
|
||||
&app.AuctionKeeper,
|
||||
&app.BondKeeper,
|
||||
&app.RegistryKeeper,
|
||||
&app.OnboardingKeeper,
|
||||
&app.NitroKeeper,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Register custom interfaces
|
||||
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
|
||||
@@ -162,13 +178,14 @@ 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 handler
|
||||
app.setAnteHandler()
|
||||
|
||||
if err := app.Load(loadLatest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -176,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)
|
||||
@@ -216,3 +277,59 @@ func (app *LaconicApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.AP
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterCustomInterfaces(interfaceRegistry codectypes.InterfaceRegistry) {
|
||||
// Custom LockupAccount type needs to be registered to be able to use it as a genesis account
|
||||
interfaceRegistry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &types.LockupAccount{})
|
||||
|
||||
// LockupAccount extends auth Account
|
||||
interfaceRegistry.RegisterInterface(
|
||||
"cosmos.auth.v1beta1.AccountI",
|
||||
(*sdk.AccountI)(nil),
|
||||
&types.LockupAccount{},
|
||||
)
|
||||
|
||||
// LockupAccount extends auth ModuleAccount
|
||||
interfaceRegistry.RegisterInterface(
|
||||
"cosmos.auth.v1beta1.ModuleAccountI",
|
||||
(*sdk.ModuleAccountI)(nil),
|
||||
&types.LockupAccount{},
|
||||
)
|
||||
|
||||
interfaceRegistry.RegisterInterface(
|
||||
"cosmos.auth.v1beta1.GenesisAccount",
|
||||
(*authtypes.GenesisAccount)(nil),
|
||||
&types.LockupAccount{},
|
||||
)
|
||||
|
||||
interfaceRegistry.RegisterInterface(
|
||||
"cerc.types.v1.LockupAccountI",
|
||||
(*types.LockupAccountI)(nil),
|
||||
&types.LockupAccount{},
|
||||
)
|
||||
}
|
||||
|
||||
func RegisterCustomLegacyAminoCodec(registrar *codec.LegacyAmino) {
|
||||
registrar.RegisterInterface((*types.LockupAccountI)(nil), nil)
|
||||
registrar.RegisterConcrete(&types.LockupAccount{}, "laconic/LockupAccount", 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) setCustomAnteHandler() {
|
||||
anteHandler, err := ante.NewAnteHandler(
|
||||
ante.HandlerOptions{
|
||||
AccountKeeper: app.AccountKeeper,
|
||||
BankKeeper: app.BankKeeper,
|
||||
SignModeHandler: app.txConfig.SignModeHandler(),
|
||||
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
|
||||
TxFeeChecker: checkTxFeeWithValidatorMinGasPrices,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Set the AnteHandler for the app
|
||||
app.SetAnteHandler(anteHandler)
|
||||
}
|
||||
|
||||
+45
-6
@@ -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, staking]
|
||||
end_blockers: [crisis, 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, crisis, genutil, 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
|
||||
@@ -25,20 +46,29 @@ modules:
|
||||
permissions: [burner, staking]
|
||||
- account: not_bonded_tokens_pool
|
||||
permissions: [burner, staking]
|
||||
- account: gov
|
||||
permissions: [burner]
|
||||
- account: protocolpool
|
||||
- account: protocolpool_escrow
|
||||
- account: auction
|
||||
- account: auction_burn
|
||||
- account: bond
|
||||
- account: registry
|
||||
- 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
|
||||
- name: slashing
|
||||
config:
|
||||
"@type": cosmos.slashing.module.v1.Module
|
||||
- name: distribution
|
||||
config:
|
||||
"@type": cosmos.distribution.module.v1.Module
|
||||
@@ -51,9 +81,15 @@ modules:
|
||||
- name: tx
|
||||
config:
|
||||
"@type": cosmos.tx.config.v1.Config
|
||||
- name: crisis
|
||||
- name: gov
|
||||
config:
|
||||
"@type": cosmos.crisis.module.v1.Module
|
||||
"@type": cosmos.gov.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
|
||||
@@ -66,3 +102,6 @@ modules:
|
||||
- name: onboarding
|
||||
config:
|
||||
"@type": cerc.onboarding.module.v1.Module
|
||||
- name: nitro
|
||||
config:
|
||||
"@type": cerc.nitro.module.v1.Module
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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{},
|
||||
),
|
||||
},
|
||||
),
|
||||
)
|
||||
)
|
||||
@@ -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
|
||||
}
|
||||
+61
-42
@@ -2,26 +2,25 @@ 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"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
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.
|
||||
@@ -31,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, "", " ")
|
||||
@@ -46,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)
|
||||
|
||||
@@ -73,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)
|
||||
@@ -95,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)
|
||||
}
|
||||
@@ -114,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)
|
||||
@@ -148,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
|
||||
@@ -171,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
|
||||
@@ -208,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 {
|
||||
@@ -221,4 +222,22 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
/* Handle slashing state. */
|
||||
|
||||
// reset start height on signing infos
|
||||
err = app.SlashingKeeper.IterateValidatorSigningInfos(
|
||||
ctx,
|
||||
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
|
||||
info.StartHeight = 0
|
||||
err = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
|
||||
if err != nil {
|
||||
panic("unable to set validator signing info")
|
||||
}
|
||||
return false
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("error while iterating validator signing info: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
+13
-3
@@ -10,9 +10,14 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
CoinUnit = "photon"
|
||||
// Registered token
|
||||
LpsCoinUnit = "lps"
|
||||
LpsBaseCoinUnit = "alps"
|
||||
LpsExponent = 18
|
||||
|
||||
DefaultBondDenom = CoinUnit
|
||||
// Native token, only denominated in alnt
|
||||
// Used for staking, fees and laconic module ops
|
||||
CoinUnit = "alnt"
|
||||
|
||||
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address.
|
||||
Bech32PrefixAccAddr = "laconic"
|
||||
@@ -34,10 +39,15 @@ var (
|
||||
func init() {
|
||||
SetAddressPrefixes()
|
||||
RegisterDenoms()
|
||||
sdk.DefaultBondDenom = CoinUnit
|
||||
}
|
||||
|
||||
func RegisterDenoms() {
|
||||
err := sdk.RegisterDenom(CoinUnit, math.LegacyOneDec())
|
||||
err := sdk.RegisterDenom(LpsCoinUnit, math.LegacyOneDec())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = sdk.RegisterDenom(LpsBaseCoinUnit, math.LegacyNewDecWithPrec(1, LpsExponent))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
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"
|
||||
|
||||
types "git.vdb.to/cerc-io/laconicd/x/types/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
flagAppendMode = "append"
|
||||
)
|
||||
|
||||
// AddGenesisLockupAccountCmd returns add-genesis-lockup-account cobra Command.
|
||||
func AddGenesisLockupAccountCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "add-genesis-lockup-account <account_name> <distribution-json-file> <coin>[,<coin>...]",
|
||||
Short: "Add genesis lockup account with give name",
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
serverCtx := server.GetServerContextFromCmd(cmd)
|
||||
config := serverCtx.Config
|
||||
|
||||
config.SetRoot(clientCtx.HomeDir)
|
||||
|
||||
moduleName := args[0]
|
||||
distributionFilePath := args[1]
|
||||
|
||||
var distribution []interface{}
|
||||
distributionBytes, err := os.ReadFile(distributionFilePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read %s file: %w", distributionFilePath, err)
|
||||
}
|
||||
if err = json.Unmarshal(distributionBytes, &distribution); err != nil {
|
||||
return fmt.Errorf("distribution is invalid json: %v", err)
|
||||
}
|
||||
|
||||
appendflag, _ := cmd.Flags().GetBool(flagAppendMode)
|
||||
|
||||
return AddGenesisLockupAccount(clientCtx.Codec, moduleName, string(distributionBytes), appendflag, config.GenesisFile(), args[2])
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Bool(flagAppendMode, false, "append the coins to an account already in the genesis.json file")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func AddGenesisLockupAccount(
|
||||
cdc codec.Codec,
|
||||
moduleName string,
|
||||
distribution string,
|
||||
appendAcct bool,
|
||||
genesisFileURL, amountStr string,
|
||||
) error {
|
||||
coins, err := sdk.ParseCoinsNormalized(amountStr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse coins: %w", err)
|
||||
}
|
||||
|
||||
// create concrete account type based on input parameters
|
||||
moduleAccount := authtypes.NewEmptyModuleAccount(moduleName)
|
||||
accAddr := moduleAccount.GetAddress()
|
||||
balances := banktypes.Balance{Address: accAddr.String(), Coins: coins.Sort()}
|
||||
|
||||
genAccount := &types.LockupAccount{
|
||||
BaseAccount: moduleAccount.BaseAccount,
|
||||
Name: moduleAccount.Name,
|
||||
Distribution: distribution,
|
||||
}
|
||||
|
||||
if err := genAccount.Validate(); err != nil {
|
||||
return fmt.Errorf("failed to validate new genesis account: %w", err)
|
||||
}
|
||||
|
||||
appState, appGenesis, err := genutiltypes.GenesisStateFromGenFile(genesisFileURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
|
||||
}
|
||||
|
||||
authGenState := authtypes.GetGenesisStateFromAppState(cdc, appState)
|
||||
|
||||
accs, err := authtypes.UnpackAccounts(authGenState.Accounts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get accounts from any: %w", err)
|
||||
}
|
||||
|
||||
bankGenState := banktypes.GetGenesisStateFromAppState(cdc, appState)
|
||||
if accs.Contains(accAddr) {
|
||||
if !appendAcct {
|
||||
return fmt.Errorf(" Account %s already exists\nUse `append` flag to append account at existing address", accAddr)
|
||||
}
|
||||
|
||||
genesisB := banktypes.GetGenesisStateFromAppState(cdc, appState)
|
||||
for idx, acc := range genesisB.Balances {
|
||||
if acc.Address != accAddr.String() {
|
||||
continue
|
||||
}
|
||||
|
||||
updatedCoins := acc.Coins.Add(coins...)
|
||||
bankGenState.Balances[idx] = banktypes.Balance{Address: accAddr.String(), Coins: updatedCoins.Sort()}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
// Add the new account to the set of genesis accounts and sanitize the accounts afterwards.
|
||||
accs = append(accs, genAccount)
|
||||
accs = authtypes.SanitizeGenesisAccounts(accs)
|
||||
|
||||
genAccs, err := authtypes.PackAccounts(accs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to convert accounts into any's: %w", err)
|
||||
}
|
||||
authGenState.Accounts = genAccs
|
||||
|
||||
authGenStateBz, err := cdc.MarshalJSON(&authGenState)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal auth genesis state: %w", err)
|
||||
}
|
||||
appState[authtypes.ModuleName] = authGenStateBz
|
||||
|
||||
bankGenState.Balances = append(bankGenState.Balances, balances)
|
||||
}
|
||||
|
||||
bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances)
|
||||
|
||||
bankGenState.Supply = bankGenState.Supply.Add(balances.Coins...)
|
||||
|
||||
bankGenStateBz, err := cdc.MarshalJSON(bankGenState)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal bank genesis state: %w", err)
|
||||
}
|
||||
appState[banktypes.ModuleName] = bankGenStateBz
|
||||
|
||||
appStateJSON, err := json.Marshal(appState)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal application genesis state: %w", err)
|
||||
}
|
||||
|
||||
appGenesis.AppState = appStateJSON
|
||||
return genutil.ExportGenesisFile(appGenesis, genesisFileURL)
|
||||
}
|
||||
@@ -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,47 +22,104 @@ 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
|
||||
genesisCmd := genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome)
|
||||
genesisCmd.AddCommand(AddGenesisLockupAccountCmd())
|
||||
|
||||
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
server.StatusCommand(),
|
||||
genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome),
|
||||
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 {
|
||||
@@ -79,7 +133,7 @@ func queryCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
rpc.ValidatorCommand(),
|
||||
rpc.WaitTxCmd(),
|
||||
server.QueryBlockCmd(),
|
||||
authcmd.QueryTxsByEventsCmd(),
|
||||
server.QueryBlocksCmd(),
|
||||
@@ -114,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,
|
||||
@@ -136,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")
|
||||
@@ -157,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 '*:<level>,<key>:<level>')
|
||||
// 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)
|
||||
}
|
||||
+99
-68
@@ -2,39 +2,42 @@ package cmd
|
||||
|
||||
import (
|
||||
"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"
|
||||
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app"
|
||||
"git.vdb.to/cerc-io/laconicd/gql"
|
||||
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
|
||||
@@ -43,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,
|
||||
@@ -57,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 = "0photon"
|
||||
|
||||
// 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(
|
||||
@@ -133,12 +101,12 @@ func ProvideClientContext(
|
||||
WithTxConfig(txConfig).
|
||||
WithLegacyAmino(legacyAmino).
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(types.AccountRetriever{}).
|
||||
WithAccountRetriever(authtypes.AccountRetriever{}).
|
||||
WithHomeDir(app.DefaultNodeHome).
|
||||
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
|
||||
@@ -146,6 +114,11 @@ 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{})
|
||||
|
||||
return clientCtx
|
||||
}
|
||||
|
||||
@@ -157,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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:")
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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())
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
+16
-6
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,135 +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.2
|
||||
cosmossdk.io/client/v2 v2.0.0-beta.1
|
||||
cosmossdk.io/collections v0.4.0
|
||||
cosmossdk.io/core v0.11.0
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4
|
||||
cosmossdk.io/errors v1.0.1
|
||||
cosmossdk.io/log v1.3.0
|
||||
cosmossdk.io/math v1.2.0
|
||||
cosmossdk.io/store v1.0.2
|
||||
cosmossdk.io/tools/confix v0.1.0
|
||||
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.2
|
||||
github.com/cosmos/cosmos-db v1.0.0
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.3
|
||||
github.com/cosmos/cosmos-sdk v0.50.3
|
||||
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.53.0
|
||||
github.com/cosmos/go-bip39 v1.0.0
|
||||
github.com/cosmos/gogoproto v1.4.11
|
||||
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/rs/cors v1.8.3
|
||||
github.com/spf13/cobra v1.8.0
|
||||
github.com/spf13/viper v1.17.0
|
||||
github.com/statechannels/go-nitro v0.1.2
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/vektah/gqlparser/v2 v2.5.11
|
||||
golang.org/x/sync v0.7.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f
|
||||
google.golang.org/grpc v1.60.1
|
||||
google.golang.org/protobuf v1.33.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.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.0 // 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/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
github.com/btcsuite/btcd/btcutil v1.1.5 // 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/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/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.1 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
||||
github.com/cockroachdb/pebble v1.1.0 // 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.9.1 // 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.0.0 // indirect
|
||||
github.com/cosmos/ics23/go v0.10.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/iavl v1.2.2 // indirect
|
||||
github.com/cosmos/ics23/go v0.11.0 // 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.5.0 // indirect
|
||||
github.com/emicklei/dot v1.6.0 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.25.0 // indirect
|
||||
github.com/go-kit/kit v0.12.0 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.6.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/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/gorilla/websocket v1.5.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.1 // 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/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/golang-lru/v2 v2.0.7 // 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.4 // 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/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/linxGnu/grocksdb v1.8.6 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // 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.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // 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
|
||||
@@ -148,52 +205,78 @@ require (
|
||||
github.com/multiformats/go-multibase v0.2.0 // indirect
|
||||
github.com/multiformats/go-multihash v0.2.3 // indirect
|
||||
github.com/multiformats/go-varint v0.0.7 // indirect
|
||||
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.1.0 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // 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.17.0 // indirect
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.45.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
github.com/prometheus/client_golang v1.22.0 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // 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.11.0 // indirect
|
||||
github.com/rs/zerolog v1.31.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.3.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.10.0 // indirect
|
||||
github.com/spf13/cast v1.5.1 // 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.8 // 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.22.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/term v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // 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.1 // indirect
|
||||
lukechampine.com/blake3 v1.2.1 // 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.3.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
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
# cerc-io laconic gql
|
||||
|
||||
> Browser : http://localhost:9473 for gql
|
||||
> Browser : <http://localhost:9473> for gql
|
||||
|
||||
## Run gqlgen
|
||||
|
||||
@@ -13,7 +13,7 @@ On having some change in the GQL schema (for example: adding a new query) update
|
||||
go get github.com/99designs/gqlgen@v0.17.22
|
||||
|
||||
# Generate bindings
|
||||
# In gql
|
||||
cd gql
|
||||
go run github.com/99designs/gqlgen generate
|
||||
```
|
||||
|
||||
@@ -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:
|
||||
@@ -385,4 +385,4 @@ Query participants:
|
||||
nitroAddress
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
@@ -33,6 +33,8 @@ type Account {
|
||||
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.
|
||||
@@ -166,10 +168,14 @@ type Auction {
|
||||
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.
|
||||
winnerAddress: String! # Winner address.
|
||||
winnerBid: Coin! # The winning bid amount.
|
||||
winnerAddresses: [String!]! # Winner address.
|
||||
winnerBids: [Coin!]! # The winning bid amount.
|
||||
winnerPrice: Coin! # The price that the winner actually pays (2nd highest bid).
|
||||
bids: [AuctionBid] # Bids make in the auction.
|
||||
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.
|
||||
@@ -195,6 +201,11 @@ type AuthorityRecord {
|
||||
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.
|
||||
@@ -220,7 +231,7 @@ type Query {
|
||||
getBondsByIds(ids: [String!]): [Bond]
|
||||
|
||||
# Query bonds.
|
||||
queryBonds(attributes: [KeyValueInput!]): [Bond]
|
||||
queryBonds: [Bond]
|
||||
|
||||
# Query bonds by owner.
|
||||
queryBondsByOwner(ownerAddresses: [String!]): [OwnerBonds]
|
||||
@@ -239,12 +250,21 @@ type Query {
|
||||
|
||||
# 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]!
|
||||
|
||||
@@ -263,4 +283,6 @@ type Query {
|
||||
|
||||
# Query participants.
|
||||
getParticipants: [Participant]!
|
||||
getParticipantByAddress(address: String!): Participant!
|
||||
getParticipantByNitroAddress(nitroAddress: String!): Participant!
|
||||
}
|
||||
|
||||
@@ -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."`
|
||||
}
|
||||
+19
-10
@@ -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
|
||||
}
|
||||
|
||||
+3
-3
@@ -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
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@ func PlaygroundHandler(apiURL string) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/graphql/graphiql/blob/main/examples/graphiql-cdn/index.html
|
||||
// https://github.com/graphql/graphiql/blob/graphiql%402.4.7/examples/graphiql-cdn/index.html
|
||||
var page = template.Must(template.New("graphiql").Parse(`
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -68,17 +68,17 @@ var page = template.Must(template.New("graphiql").Parse(`
|
||||
copy them directly into your environment, or perhaps include them in your
|
||||
favored resource bundler.
|
||||
-->
|
||||
<link rel="stylesheet" href="https://unpkg.com/graphiql/graphiql.min.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/graphiql@2.4.7/graphiql.min.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="graphiql">Loading...</div>
|
||||
<script
|
||||
src="https://unpkg.com/graphiql/graphiql.min.js"
|
||||
src="https://unpkg.com/graphiql@2.4.7/graphiql.min.js"
|
||||
type="application/javascript"
|
||||
></script>
|
||||
<script>
|
||||
// https://github.com/graphql/graphiql/blob/main/packages/graphiql/resources/renderExample.js
|
||||
// https://github.com/graphql/graphiql/blob/graphiql%402.4.7/packages/graphiql/resources/renderExample.js
|
||||
|
||||
// Parse the search string to get url parameters.
|
||||
var search = window.location.search;
|
||||
|
||||
+141
-52
@@ -8,9 +8,12 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
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"
|
||||
@@ -23,22 +26,55 @@ const DefaultLogNumLines = 50
|
||||
// MaxLogNumLines is the max number of log lines that can be tailed.
|
||||
const MaxLogNumLines = 1000
|
||||
|
||||
// Whether to use default page limit when pagination args are not passed.
|
||||
const UseDefaultPagination = false
|
||||
|
||||
type Resolver struct {
|
||||
ctx client.Context
|
||||
logFile string
|
||||
}
|
||||
|
||||
// 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) LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error) {
|
||||
func (q queryResolver) GetAuthorities(ctx context.Context, owner *string) ([]*schema.Authority, error) {
|
||||
nsQueryClient := registrytypes.NewQueryClient(q.ctx)
|
||||
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
|
||||
gqlResponse := []*AuthorityRecord{}
|
||||
|
||||
authoritiesReq := ®istrytypes.QueryAuthoritiesRequest{}
|
||||
if owner != nil {
|
||||
authoritiesReq.Owner = *owner
|
||||
}
|
||||
|
||||
authoritiesResp, err := nsQueryClient.Authorities(ctx, authoritiesReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
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] = &schema.Authority{
|
||||
Name: a.Name,
|
||||
Entry: entry,
|
||||
}
|
||||
}
|
||||
|
||||
return authorities, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([]*schema.AuthorityRecord, error) {
|
||||
nsQueryClient := registrytypes.NewQueryClient(q.ctx)
|
||||
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
|
||||
gqlResponse := []*schema.AuthorityRecord{}
|
||||
|
||||
for _, name := range names {
|
||||
res, err := nsQueryClient.Whois(context.Background(), ®istrytypes.QueryWhoisRequest{Name: name})
|
||||
@@ -52,38 +88,20 @@ func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([
|
||||
}
|
||||
|
||||
nameAuthority := res.GetNameAuthority()
|
||||
gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority)
|
||||
gqlNameAuthorityRecord, err := getAuthorityRecord(nameAuthority, auctionQueryClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if nameAuthority.AuctionId != "" {
|
||||
auctionResp, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.QueryGetAuctionRequest{Id: nameAuthority.GetAuctionId()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bidsResp, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.QueryGetBidsRequest{AuctionId: nameAuthority.GetAuctionId()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlAuctionRecord, err := GetGQLAuction(auctionResp.GetAuction(), bidsResp.GetBids())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlNameAuthorityRecord.Auction = gqlAuctionRecord
|
||||
}
|
||||
|
||||
gqlResponse = append(gqlResponse, gqlNameAuthorityRecord)
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -102,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})
|
||||
@@ -124,14 +142,34 @@ func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*Name
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*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
|
||||
|
||||
// Use defaults only if limit and offset not provided
|
||||
// and UseDefaultPagination is true
|
||||
if limit == nil && offset == nil {
|
||||
if UseDefaultPagination {
|
||||
pagination = &query.PageRequest{}
|
||||
}
|
||||
} else {
|
||||
pagination = &query.PageRequest{}
|
||||
|
||||
if limit != nil {
|
||||
pagination.Limit = uint64(*limit)
|
||||
}
|
||||
if offset != nil {
|
||||
pagination.Offset = uint64(*offset)
|
||||
}
|
||||
}
|
||||
|
||||
res, err := nsQueryClient.Records(
|
||||
context.Background(),
|
||||
®istrytypes.QueryRecordsRequest{
|
||||
Attributes: toRPCAttributes(attributes),
|
||||
All: (all != nil && *all),
|
||||
Pagination: pagination,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -139,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)
|
||||
@@ -152,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})
|
||||
@@ -173,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
|
||||
@@ -194,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,
|
||||
@@ -206,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 {
|
||||
@@ -218,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 {
|
||||
@@ -244,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,
|
||||
@@ -253,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 {
|
||||
@@ -266,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 {
|
||||
@@ -284,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, attributes []*KeyValueInput) ([]*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 {
|
||||
@@ -304,8 +342,8 @@ func (q queryResolver) QueryBonds(ctx context.Context, attributes []*KeyValueInp
|
||||
}
|
||||
|
||||
// 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 {
|
||||
@@ -317,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
|
||||
@@ -334,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 {
|
||||
@@ -361,20 +399,71 @@ 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,
|
||||
}
|
||||
}
|
||||
|
||||
return participants, nil
|
||||
}
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := participantResp.Participant
|
||||
nitroAddress, err := utils.EthAddressFromPubKey(p.PublicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
participant := &schema.Participant{
|
||||
CosmosAddress: p.CosmosAddress,
|
||||
NitroAddress: nitroAddress.String(),
|
||||
Role: p.Role,
|
||||
KycID: p.KycId,
|
||||
}
|
||||
|
||||
return participant, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetParticipantByNitroAddress(ctx context.Context, nitroAddress string) (*schema.Participant, error) {
|
||||
onboardingQueryClient := onboardingTypes.NewQueryClient(q.ctx)
|
||||
participantResp, err := onboardingQueryClient.GetParticipantByNitroAddress(
|
||||
ctx,
|
||||
&onboardingTypes.QueryGetParticipantByNitroAddressRequest{
|
||||
NitroAddress: nitroAddress,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := participantResp.Participant
|
||||
participant := &schema.Participant{
|
||||
CosmosAddress: p.CosmosAddress,
|
||||
NitroAddress: nitroAddress,
|
||||
Role: p.Role,
|
||||
KycID: p.KycId,
|
||||
}
|
||||
|
||||
return participant, nil
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
package gql
|
||||
package schema
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
|
||||
|
||||
package gql
|
||||
package schema
|
||||
|
||||
type Value interface {
|
||||
IsValue()
|
||||
@@ -26,19 +26,23 @@ type Attribute struct {
|
||||
}
|
||||
|
||||
type Auction struct {
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
OwnerAddress string `json:"ownerAddress"`
|
||||
CreateTime string `json:"createTime"`
|
||||
CommitsEndTime string `json:"commitsEndTime"`
|
||||
RevealsEndTime string `json:"revealsEndTime"`
|
||||
CommitFee *Coin `json:"commitFee"`
|
||||
RevealFee *Coin `json:"revealFee"`
|
||||
MinimumBid *Coin `json:"minimumBid"`
|
||||
WinnerAddress string `json:"winnerAddress"`
|
||||
WinnerBid *Coin `json:"winnerBid"`
|
||||
WinnerPrice *Coin `json:"winnerPrice"`
|
||||
Bids []*AuctionBid `json:"bids"`
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
OwnerAddress string `json:"ownerAddress"`
|
||||
CreateTime string `json:"createTime"`
|
||||
CommitsEndTime string `json:"commitsEndTime"`
|
||||
RevealsEndTime string `json:"revealsEndTime"`
|
||||
CommitFee *Coin `json:"commitFee"`
|
||||
RevealFee *Coin `json:"revealFee"`
|
||||
MinimumBid *Coin `json:"minimumBid"`
|
||||
WinnerAddresses []string `json:"winnerAddresses"`
|
||||
WinnerBids []*Coin `json:"winnerBids"`
|
||||
WinnerPrice *Coin `json:"winnerPrice"`
|
||||
MaxPrice *Coin `json:"maxPrice"`
|
||||
Kind string `json:"kind"`
|
||||
NumProviders *int `json:"numProviders"`
|
||||
FundsReleased bool `json:"fundsReleased"`
|
||||
Bids []*AuctionBid `json:"bids"`
|
||||
}
|
||||
|
||||
type AuctionBid struct {
|
||||
@@ -52,6 +56,11 @@ type AuctionBid struct {
|
||||
BidAmount *Coin `json:"bidAmount"`
|
||||
}
|
||||
|
||||
type Authority struct {
|
||||
Name string `json:"name"`
|
||||
Entry *AuthorityRecord `json:"entry"`
|
||||
}
|
||||
|
||||
type AuthorityRecord struct {
|
||||
OwnerAddress string `json:"ownerAddress"`
|
||||
OwnerPublicKey string `json:"ownerPublicKey"`
|
||||
@@ -138,6 +147,8 @@ type OwnerBonds struct {
|
||||
type Participant struct {
|
||||
CosmosAddress string `json:"cosmosAddress"`
|
||||
NitroAddress string `json:"nitroAddress"`
|
||||
Role string `json:"role"`
|
||||
KycID string `json:"kycId"`
|
||||
}
|
||||
|
||||
type PeerInfo struct {
|
||||
+83
-40
@@ -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
|
||||
}
|
||||
|
||||
+10
-9
@@ -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,
|
||||
|
||||
+81
-47
@@ -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,27 +228,33 @@ 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
|
||||
}
|
||||
|
||||
gqlAuction := Auction{
|
||||
ID: auction.Id,
|
||||
Status: auction.Status,
|
||||
OwnerAddress: auction.OwnerAddress,
|
||||
CreateTime: auction.GetCreateTime(),
|
||||
CommitsEndTime: auction.GetCommitsEndTime(),
|
||||
RevealsEndTime: auction.GetRevealsEndTime(),
|
||||
CommitFee: getGQLCoin(auction.CommitFee),
|
||||
RevealFee: getGQLCoin(auction.RevealFee),
|
||||
MinimumBid: getGQLCoin(auction.MinimumBid),
|
||||
WinnerAddress: auction.WinnerAddress,
|
||||
WinnerBid: getGQLCoin(auction.WinningBid),
|
||||
WinnerPrice: getGQLCoin(auction.WinningPrice),
|
||||
numProviders := int(auction.NumProviders)
|
||||
|
||||
gqlAuction := schema.Auction{
|
||||
ID: auction.Id,
|
||||
Status: auction.Status,
|
||||
OwnerAddress: auction.OwnerAddress,
|
||||
CreateTime: auction.GetCreateTime(),
|
||||
CommitsEndTime: auction.GetCommitsEndTime(),
|
||||
RevealsEndTime: auction.GetRevealsEndTime(),
|
||||
CommitFee: getGQLCoin(auction.CommitFee),
|
||||
RevealFee: getGQLCoin(auction.RevealFee),
|
||||
MinimumBid: getGQLCoin(auction.MinimumBid),
|
||||
WinnerAddresses: auction.WinnerAddresses,
|
||||
WinnerBids: getGQLCoins(auction.WinningBids),
|
||||
WinnerPrice: getGQLCoin(auction.WinningPrice),
|
||||
MaxPrice: getGQLCoin(auction.MaxPrice),
|
||||
Kind: auction.Kind,
|
||||
NumProviders: &numProviders,
|
||||
FundsReleased: auction.FundsReleased,
|
||||
}
|
||||
|
||||
auctionBids := make([]*AuctionBid, len(bids))
|
||||
auctionBids := make([]*schema.AuctionBid, len(bids))
|
||||
for index, entry := range bids {
|
||||
auctionBids[index] = getAuctionBid(entry)
|
||||
}
|
||||
@@ -257,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 {
|
||||
@@ -289,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 {
|
||||
@@ -303,3 +310,30 @@ func toRPCAttributes(attrs []*KeyValueInput) []*registrytypes.QueryRecordsReques
|
||||
|
||||
return kvPairs
|
||||
}
|
||||
|
||||
func getAuthorityRecord(nameAuthority registrytypes.NameAuthority, auctionQueryClient auctiontypes.QueryClient) (*schema.AuthorityRecord, error) {
|
||||
gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if nameAuthority.AuctionId != "" {
|
||||
auctionResp, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.QueryGetAuctionRequest{Id: nameAuthority.GetAuctionId()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bidsResp, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.QueryGetBidsRequest{AuctionId: nameAuthority.GetAuctionId()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlAuctionRecord, err := GetGQLAuction(auctionResp.GetAuction(), bidsResp.GetBids())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlNameAuthorityRecord.Auction = gqlAuctionRecord
|
||||
}
|
||||
|
||||
return gqlNameAuthorityRecord, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Lockup Account Usage
|
||||
|
||||
* Add a genesis lockup account:
|
||||
|
||||
```bash
|
||||
laconicd genesis add-genesis-lockup-account <account_name> <distribution-json-file> <coin>[,<coin>...]
|
||||
|
||||
# Example
|
||||
# laconicd genesis add-genesis-lockup-account lps_lockup distribution.json 1000alps
|
||||
```
|
||||
|
||||
* This adds a `LockupAccount` with given name and balance in the genesis file
|
||||
|
||||
* The lockup account can be queried as shown below once the chain starts
|
||||
|
||||
* Query a lockup account:
|
||||
|
||||
```bash
|
||||
laconicd query auth module-account <account_name>
|
||||
|
||||
# Example
|
||||
# laconicd query auth module-account lps_lockup
|
||||
# account:
|
||||
# type: laconic/LockupAccount
|
||||
# value:
|
||||
# base_account:
|
||||
# account_number: "1"
|
||||
# address: laconic1mprsxp9jqe0d0lp88fxuccthwgy7tqgt5x9y65
|
||||
# distribution: |-
|
||||
# {
|
||||
# ...
|
||||
```
|
||||
|
||||
* Query a lockup account's balance:
|
||||
|
||||
```bash
|
||||
laconicd query bank balances <address>
|
||||
|
||||
# Example
|
||||
lockup_account_address=$(laconicd query auth module-account lps_lockup -o json | jq -r '.account.value.base_account.address')
|
||||
laconicd query bank balances $lockup_account_address
|
||||
balances:
|
||||
- amount: "1000"
|
||||
denom: alps
|
||||
pagination:
|
||||
total: "1"
|
||||
```
|
||||
@@ -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
|
||||
|
||||
@@ -10,4 +10,8 @@ message Module {
|
||||
option (cosmos.app.v1alpha1.module) = {
|
||||
go_import : "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||
};
|
||||
|
||||
// authority defines the custom module authority. If not set, defaults to the
|
||||
// governance module.
|
||||
string authority = 2;
|
||||
}
|
||||
|
||||
@@ -3,76 +3,44 @@ syntax = "proto3";
|
||||
package cerc.auction.v1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/auction";
|
||||
|
||||
// Params defines the auction module parameters
|
||||
message Params {
|
||||
// Write custom stringer method
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
// Duration of the commits phase in seconds
|
||||
google.protobuf.Duration commits_duration = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
|
||||
];
|
||||
|
||||
// Duration of the reveals phase in seconds
|
||||
google.protobuf.Duration reveals_duration = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
|
||||
];
|
||||
|
||||
// Commit fees
|
||||
cosmos.base.v1beta1.Coin commit_fee = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||
];
|
||||
|
||||
// Reveal fees
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 4 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||
];
|
||||
|
||||
// Minimum acceptable bid amount
|
||||
cosmos.base.v1beta1.Coin minimum_bid = 5 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
||||
];
|
||||
}
|
||||
message Params {}
|
||||
|
||||
// Auction represents a sealed-bid on-chain auction
|
||||
message Auction {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
string id = 1;
|
||||
string status = 2;
|
||||
|
||||
// Auction kind (vickrey | provider)
|
||||
string kind = 2 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ];
|
||||
|
||||
string status = 3;
|
||||
|
||||
// Address of the creator of the auction
|
||||
string owner_address = 3;
|
||||
string owner_address = 4;
|
||||
|
||||
// Timestamp at which the auction was created
|
||||
google.protobuf.Timestamp create_time = 4 [
|
||||
google.protobuf.Timestamp create_time = 5 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"create_time\" yaml:\"create_time\""
|
||||
];
|
||||
|
||||
// Timestamp at which the commits phase concluded
|
||||
google.protobuf.Timestamp commits_end_time = 5 [
|
||||
google.protobuf.Timestamp commits_end_time = 6 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commits_end_time\" yaml:\"commits_end_time\""
|
||||
];
|
||||
|
||||
// Timestamp at which the reveals phase concluded
|
||||
google.protobuf.Timestamp reveals_end_time = 6 [
|
||||
google.protobuf.Timestamp reveals_end_time = 7 [
|
||||
(gogoproto.stdtime) = true,
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveals_end_time\" yaml:\"reveals_end_time\""
|
||||
@@ -80,35 +48,58 @@ message Auction {
|
||||
|
||||
// Commit and reveal fees must both be paid when committing a bid
|
||||
// Reveal fee is returned only if the bid is revealed
|
||||
cosmos.base.v1beta1.Coin commit_fee = 7 [
|
||||
cosmos.base.v1beta1.Coin commit_fee = 8 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||
];
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 8 [
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 9 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||
];
|
||||
|
||||
// Minimum acceptable bid amount for a valid commit
|
||||
cosmos.base.v1beta1.Coin minimum_bid = 9 [
|
||||
// Only applicable in vickrey auctions
|
||||
cosmos.base.v1beta1.Coin minimum_bid = 10 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
||||
];
|
||||
|
||||
// Address of the winner
|
||||
string winner_address = 10;
|
||||
// Addresses of the winners
|
||||
// (single winner for vickrey auction)
|
||||
// (multiple winners for provider auctions)
|
||||
repeated string winner_addresses = 11;
|
||||
|
||||
// Winning bid, i.e., the highest bid
|
||||
cosmos.base.v1beta1.Coin winning_bid = 11 [
|
||||
// Winning bids, i.e. the best bids
|
||||
repeated cosmos.base.v1beta1.Coin winning_bids = 12 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"winning_bid\" yaml:\"winning_bid\""
|
||||
(gogoproto.moretags) = "json:\"winning_bids\" yaml:\"winning_bids\""
|
||||
];
|
||||
|
||||
// Amount the winner pays, i.e. the second highest auction
|
||||
cosmos.base.v1beta1.Coin winning_price = 12 [
|
||||
// Auction winning price
|
||||
// vickrey auction: second highest bid, paid by the winner
|
||||
// provider auction: higest bid amongst winning_bids, paid by auction creator
|
||||
// to each winner
|
||||
cosmos.base.v1beta1.Coin winning_price = 13 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"winning_price\" yaml:\"winning_price\""
|
||||
];
|
||||
|
||||
// Maximum acceptable bid amount for a valid commit
|
||||
// Only applicable in provider auctions
|
||||
cosmos.base.v1beta1.Coin max_price = 14 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"max_price\" yaml:\"max_price\""
|
||||
];
|
||||
|
||||
// Number of desired providers (num of auction winners)
|
||||
// Only applicable in provider auctions
|
||||
int32 num_providers = 15;
|
||||
|
||||
// Whether funds have been released to providers
|
||||
// Only applicable in provider auctions
|
||||
bool funds_released = 16
|
||||
[ (gogoproto.moretags) =
|
||||
"json:\"funds_released\" yaml:\"funds_released\"" ];
|
||||
}
|
||||
|
||||
// Auctions represent all the auctions in the module
|
||||
|
||||
@@ -7,6 +7,7 @@ import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "cerc/auction/v1/auction.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/auction";
|
||||
@@ -29,6 +30,15 @@ service Msg {
|
||||
rpc RevealBid(MsgRevealBid) returns (MsgRevealBidResponse) {
|
||||
option (google.api.http).post = "/cerc/auction/v1/reveal_bid";
|
||||
};
|
||||
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
|
||||
|
||||
// ReleaseFunds is the command for paying the winners of provider auctions
|
||||
rpc ReleaseFunds(MsgReleaseFunds) returns (MsgReleaseFundsResponse) {
|
||||
option (google.api.http).post = "/cerc/auction/v1/release_funds";
|
||||
};
|
||||
}
|
||||
|
||||
// MsgCreateAuction defines a create auction message
|
||||
@@ -36,41 +46,56 @@ message MsgCreateAuction {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
option (cosmos.msg.v1.signer) = "signer";
|
||||
|
||||
// Address of the signer
|
||||
string signer = 1
|
||||
[ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ];
|
||||
|
||||
// Auction kind (vickrey | provider)
|
||||
string kind = 2 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ];
|
||||
|
||||
// Duration of the commits phase in seconds
|
||||
google.protobuf.Duration commits_duration = 1 [
|
||||
google.protobuf.Duration commits_duration = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
|
||||
];
|
||||
|
||||
// Duration of the reveals phase in seconds
|
||||
google.protobuf.Duration reveals_duration = 2 [
|
||||
google.protobuf.Duration reveals_duration = 4 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
|
||||
];
|
||||
|
||||
// Commit fees
|
||||
cosmos.base.v1beta1.Coin commit_fee = 3 [
|
||||
cosmos.base.v1beta1.Coin commit_fee = 5 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||
];
|
||||
|
||||
// Reveal fees
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 4 [
|
||||
cosmos.base.v1beta1.Coin reveal_fee = 6 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||
];
|
||||
|
||||
// Minimum acceptable bid amount
|
||||
cosmos.base.v1beta1.Coin minimum_bid = 5 [
|
||||
// Only applicable in vickrey auctions
|
||||
cosmos.base.v1beta1.Coin minimum_bid = 7 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
||||
];
|
||||
|
||||
// Address of the signer
|
||||
string signer = 6
|
||||
[ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ];
|
||||
// Maximum acceptable bid amount
|
||||
// Only applicable in provider auctions
|
||||
cosmos.base.v1beta1.Coin max_price = 8 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"max_price\" yaml:\"max_price\""
|
||||
];
|
||||
|
||||
// Number of desired providers (num of auction winners)
|
||||
// Only applicable in provider auctions
|
||||
int32 num_providers = 9;
|
||||
}
|
||||
|
||||
// MsgCreateAuctionResponse returns the details of the created auction
|
||||
@@ -134,3 +159,45 @@ message MsgRevealBidResponse {
|
||||
Auction auction = 1
|
||||
[ (gogoproto.moretags) = "json:\"auction\" yaml:\"auction\"" ];
|
||||
}
|
||||
|
||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
||||
message MsgUpdateParams {
|
||||
option (cosmos.msg.v1.signer) = "authority";
|
||||
|
||||
// authority is the address that controls the module (defaults to x/gov unless
|
||||
// overwritten).
|
||||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
|
||||
|
||||
// params defines the x/auction parameters to update.
|
||||
//
|
||||
// NOTE: All parameters must be supplied.
|
||||
Params params = 2 [ (gogoproto.nullable) = false ];
|
||||
}
|
||||
|
||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
||||
// MsgUpdateParams message.
|
||||
message MsgUpdateParamsResponse {};
|
||||
|
||||
// ReleaseFunds defines the message to pay the winners of provider auctions
|
||||
message MsgReleaseFunds {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
option (cosmos.msg.v1.signer) = "signer";
|
||||
|
||||
// Auction id
|
||||
string auction_id = 1
|
||||
[ (gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\"" ];
|
||||
|
||||
// Address of the signer
|
||||
string signer = 2
|
||||
[ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ];
|
||||
}
|
||||
|
||||
// MsgReleaseFundsResponse returns the state of the auction after releasing the
|
||||
// funds
|
||||
message MsgReleaseFundsResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Auction details
|
||||
Auction auction = 1
|
||||
[ (gogoproto.moretags) = "json:\"auction\" yaml:\"auction\"" ];
|
||||
}
|
||||
|
||||
@@ -10,4 +10,8 @@ message Module {
|
||||
option (cosmos.app.v1alpha1.module) = {
|
||||
go_import : "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||
};
|
||||
|
||||
// authority defines the custom module authority. If not set, defaults to the
|
||||
// governance module.
|
||||
string authority = 2;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import "cosmos/msg/v1/msg.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "cerc/bond/v1/bond.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/bond";
|
||||
|
||||
@@ -32,6 +34,10 @@ service Msg {
|
||||
rpc CancelBond(MsgCancelBond) returns (MsgCancelBondResponse) {
|
||||
option (google.api.http).post = "/cerc/bond/v1/cancel_bond";
|
||||
};
|
||||
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
|
||||
}
|
||||
|
||||
// MsgCreateBond defines a SDK message for creating a new bond.
|
||||
@@ -91,3 +97,21 @@ message MsgCancelBond {
|
||||
|
||||
// MsgCancelBondResponse defines the Msg/CancelBond response type.
|
||||
message MsgCancelBondResponse {}
|
||||
|
||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
||||
message MsgUpdateParams {
|
||||
option (cosmos.msg.v1.signer) = "authority";
|
||||
|
||||
// authority is the address that controls the module (defaults to x/gov unless
|
||||
// overwritten).
|
||||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
|
||||
|
||||
// params defines the x/bond parameters to update.
|
||||
//
|
||||
// NOTE: All parameters must be supplied.
|
||||
Params params = 2 [ (gogoproto.nullable) = false ];
|
||||
}
|
||||
|
||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
||||
// MsgUpdateParams message.
|
||||
message MsgUpdateParamsResponse {};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
];
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -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 {}
|
||||
@@ -16,14 +16,22 @@ message Params {
|
||||
// Participant defines the data that will be stored for each enrolled
|
||||
// participant
|
||||
message Participant {
|
||||
// participant's cosmos (laconic) address
|
||||
string cosmos_address = 1
|
||||
[ (gogoproto.moretags) =
|
||||
"json:\"cosmos_address\" yaml:\"cosmos_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\"" ];
|
||||
|
||||
// participant's KYC receipt ID
|
||||
string kyc_id = 4
|
||||
[ (gogoproto.moretags) = "json:\"kyc_id\" yaml:\"kyc_id\"" ];
|
||||
}
|
||||
|
||||
// EthPayload defines the payload that is signed by the ethereum private key
|
||||
message EthPayload {
|
||||
string address = 1
|
||||
|
||||
@@ -16,6 +16,19 @@ service Query {
|
||||
returns (QueryParticipantsResponse) {
|
||||
option (google.api.http).get = "/cerc/onboarding/v1/participants";
|
||||
}
|
||||
|
||||
// GetParticipantByAddress queries a participant by cosmos (laconic) address
|
||||
rpc GetParticipantByAddress(QueryGetParticipantByAddressRequest)
|
||||
returns (QueryGetParticipantByAddressResponse) {
|
||||
option (google.api.http).get = "/cerc/onboarding/v1/participants/{address}";
|
||||
}
|
||||
|
||||
// GetParticipantByNitroAddress queries a participant by nitro address
|
||||
rpc GetParticipantByNitroAddress(QueryGetParticipantByNitroAddressRequest)
|
||||
returns (QueryGetParticipantByNitroAddressResponse) {
|
||||
option (google.api.http).get =
|
||||
"/cerc/onboarding/v1/participants-by-nitro/{nitro_address}";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryParticipantsRequest queries participants
|
||||
@@ -24,7 +37,7 @@ message QueryParticipantsRequest {
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// QueryParticipantsResponse is response type for get the participants
|
||||
// QueryParticipantsResponse is response type for querying the participants
|
||||
message QueryParticipantsResponse {
|
||||
repeated Participant participants = 1
|
||||
[ (gogoproto.moretags) = "json:\"participants\" yaml:\"participants\"" ];
|
||||
@@ -32,3 +45,31 @@ message QueryParticipantsResponse {
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryGetParticipantByAddressRequest queries participant by the laconic
|
||||
// address
|
||||
message QueryGetParticipantByAddressRequest {
|
||||
// Laconic address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
// QueryGetParticipantByAddressResponse is response type for querying
|
||||
// participant by the laconic address
|
||||
message QueryGetParticipantByAddressResponse {
|
||||
// Participant details
|
||||
Participant participant = 1;
|
||||
}
|
||||
|
||||
// QueryGetParticipantByNitroAddressRequest queries participant by the nitro
|
||||
// address
|
||||
message QueryGetParticipantByNitroAddressRequest {
|
||||
// Nitro address
|
||||
string nitro_address = 1;
|
||||
}
|
||||
|
||||
// QueryGetParticipantByNitroAddressResponse is response type for querying
|
||||
// participant by the nitro address
|
||||
message QueryGetParticipantByNitroAddressResponse {
|
||||
// Participant details
|
||||
Participant participant = 1;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ message MsgOnboardParticipant {
|
||||
string participant = 1;
|
||||
EthPayload eth_payload = 2 [ (gogoproto.nullable) = false ];
|
||||
string eth_signature = 3;
|
||||
string role = 4;
|
||||
string kyc_id = 5;
|
||||
}
|
||||
|
||||
// MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response
|
||||
|
||||
@@ -10,4 +10,8 @@ message Module {
|
||||
option (cosmos.app.v1alpha1.module) = {
|
||||
go_import : "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||
};
|
||||
|
||||
// authority defines the custom module authority. If not set, defaults to the
|
||||
// governance module.
|
||||
string authority = 2;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ service Query {
|
||||
returns (QueryGetRegistryModuleBalanceResponse) {
|
||||
option (google.api.http).get = "/cerc/registry/v1/balance";
|
||||
}
|
||||
|
||||
// Authorities queries all authorities
|
||||
rpc Authorities(QueryAuthoritiesRequest) returns (QueryAuthoritiesResponse) {
|
||||
option (google.api.http).get = "/cerc/registry/v1/authorities";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryParamsRequest is request type for registry params
|
||||
@@ -152,6 +157,16 @@ message QueryWhoisResponse {
|
||||
];
|
||||
}
|
||||
|
||||
// QueryAuthoritiesRequest is request type to get all authorities
|
||||
message QueryAuthoritiesRequest { string owner = 1; }
|
||||
|
||||
// QueryAuthoritiesResponse is response type for authorities request
|
||||
message QueryAuthoritiesResponse {
|
||||
repeated AuthorityEntry authorities = 1 [ (gogoproto.nullable) = false ];
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryLookupLrnRequest is request type for LookupLrn
|
||||
message QueryLookupLrnRequest { string lrn = 1; }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,6 +6,7 @@ import "google/api/annotations.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/msg/v1/msg.proto";
|
||||
import "cerc/registry/v1/registry.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/registry";
|
||||
|
||||
@@ -66,6 +67,10 @@ service Msg {
|
||||
returns (MsgSetAuthorityBondResponse) {
|
||||
option (google.api.http).post = "/cerc/registry/v1/set_authority_bond";
|
||||
}
|
||||
|
||||
// UpdateParams defines an operation for updating the x/staking module
|
||||
// parameters.
|
||||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
|
||||
}
|
||||
|
||||
// MsgSetRecord
|
||||
@@ -203,3 +208,21 @@ message MsgReassociateRecords {
|
||||
|
||||
// MsgReassociateRecordsResponse
|
||||
message MsgReassociateRecordsResponse {}
|
||||
|
||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
||||
message MsgUpdateParams {
|
||||
option (cosmos.msg.v1.signer) = "authority";
|
||||
|
||||
// authority is the address that controls the module (defaults to x/gov unless
|
||||
// overwritten).
|
||||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
|
||||
|
||||
// params defines the x/registry parameters to update.
|
||||
//
|
||||
// NOTE: All parameters must be supplied.
|
||||
Params params = 2 [ (gogoproto.nullable) = false ];
|
||||
}
|
||||
|
||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
||||
// MsgUpdateParams message.
|
||||
message MsgUpdateParamsResponse {}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
syntax = "proto3";
|
||||
package cerc.types.v1;
|
||||
|
||||
import "amino/amino.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "cosmos/auth/v1beta1/auth.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/types/v1";
|
||||
|
||||
// LockupAccount extends the Cosmos SDK BaseAccount with a name and distribution
|
||||
// field. It satisfies the ModuleAccountI interface to allow querying it as a
|
||||
// module account.
|
||||
message LockupAccount {
|
||||
option (amino.name) = "laconic/LockupAccount";
|
||||
option (amino.message_encoding) = "lockup_account";
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
option (cosmos_proto.implements_interface) =
|
||||
"cosmos.auth.v1beta1.ModuleAccountI";
|
||||
option (cosmos_proto.implements_interface) = "cerc.types.v1.LockupAccountI";
|
||||
|
||||
cosmos.auth.v1beta1.BaseAccount base_account = 1 [ (gogoproto.embed) = true ];
|
||||
string name = 2;
|
||||
string distribution = 3;
|
||||
}
|
||||
+89
-94
@@ -1,110 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
KEY="alice"
|
||||
CHAINID="laconic_9000-1"
|
||||
MONIKER="localtestnet"
|
||||
KEYRING="test"
|
||||
LOGLEVEL="${LOGLEVEL:-info}"
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; 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
|
||||
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"}
|
||||
STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"} # 10^15 alnt
|
||||
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}
|
||||
|
||||
laconicd="$LACONIC_BIN --home=$LACONIC_HOME --log_level=$LOGLEVEL"
|
||||
|
||||
set -e
|
||||
|
||||
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
|
||||
|
||||
# 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 [[ ! -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 $LACONIC_HOME/config/genesis.json
|
||||
fi
|
||||
|
||||
$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"
|
||||
}
|
||||
|
||||
# remove existing daemon and client
|
||||
rm -rf $HOME/.laconicd/*
|
||||
# disable empty blocks
|
||||
update_comet_config consensus.create_empty_blocks 'false'
|
||||
|
||||
if [ -n "`which make`" ]; then
|
||||
make install
|
||||
fi
|
||||
# Allow requests from any origin
|
||||
update_comet_config rpc.cors_allowed_origins '["*"]'
|
||||
|
||||
laconicd config set client chain-id $CHAINID
|
||||
laconicd config set client keyring-backend $KEYRING
|
||||
|
||||
# if $KEY exists it should be deleted
|
||||
laconicd keys add $KEY --keyring-backend $KEYRING
|
||||
|
||||
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
||||
laconicd init $MONIKER --chain-id $CHAINID --default-denom photon
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then
|
||||
echo "Setting timers for expiry tests."
|
||||
|
||||
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
|
||||
|
||||
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 validator onboarding."
|
||||
|
||||
update_genesis '.app_state["onboarding"]["params"]["onboarding_enabled"]=true'
|
||||
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"'
|
||||
|
||||
# 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 100000000000000000000000000photon --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 1000000000000000000000photon --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=0.0001photon \
|
||||
--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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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))
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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 }
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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")
|
||||
)
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 <channel-id>",
|
||||
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 <ledger-channel-id>",
|
||||
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
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user