forked from cerc-io/laconicd
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb9aa00816 | |||
| a8ebc0aceb | |||
| e02d221dea | |||
| 59236e5ce6 | |||
| 7af9e9d496 | |||
| 31ef3afb9a | |||
| f4cf8ac744 | |||
| c14f1d3b00 |
127
AGENTS.md
Normal file
127
AGENTS.md
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
# Agents: read this before touching laconicd-backed state
|
||||||
|
|
||||||
|
Written for AI coding agents (Claude, Codex, Copilot, etc.) working
|
||||||
|
on laconicd itself or on applications that persist data through
|
||||||
|
it. Humans can read it too — the content is the same — but the
|
||||||
|
tone addresses a specific failure mode that agents exhibit more
|
||||||
|
consistently than humans.
|
||||||
|
|
||||||
|
## The failure mode this document exists to prevent
|
||||||
|
|
||||||
|
Agents extending an existing laconicd-backed codebase pattern-match
|
||||||
|
the visible API calls and treat them as canonical. If a codebase
|
||||||
|
uses `queryRecords` with attribute filtering for everything —
|
||||||
|
including where it's wrong — an agent will extend that usage
|
||||||
|
rather than discover the Naming API.
|
||||||
|
|
||||||
|
When the wrong pattern eventually scales badly (latency grows with
|
||||||
|
accumulated record versions), agents reach for **workarounds
|
||||||
|
within the chosen pattern** — pagination, caches, compaction —
|
||||||
|
rather than re-evaluating the primitive choice. That drift
|
||||||
|
compounds: each workaround entrenches the wrong design.
|
||||||
|
|
||||||
|
This has happened repeatedly on real projects. The architectural
|
||||||
|
cost is high, because laconicd is append-only: wrong versions
|
||||||
|
persist on chain as permanent garbage that you can't silently
|
||||||
|
delete.
|
||||||
|
|
||||||
|
## Concrete rules for agents
|
||||||
|
|
||||||
|
### 1. Before designing any laconicd-backed state, read `docs/PATTERNS.md`
|
||||||
|
|
||||||
|
Not after a first implementation. Not when you hit a scaling
|
||||||
|
wall. **Before.** The decision tree there is the only reliable
|
||||||
|
way to pick the right primitive.
|
||||||
|
|
||||||
|
### 2. Do not pattern-match from existing client code as if it were canon
|
||||||
|
|
||||||
|
A gateway, SDK, or service that already uses laconicd is an
|
||||||
|
existing code sample. It is not evidence that the patterns it
|
||||||
|
uses are correct. Check:
|
||||||
|
|
||||||
|
- Does the client use `setName` / `lookupNames` / `resolveNames`
|
||||||
|
at all? If not, the chances it's modelling mutable identity
|
||||||
|
with `queryRecords`+attribute scan are high — that's almost
|
||||||
|
always a latent latency bug.
|
||||||
|
- Does `save_*` in the client write only a Record, never a name?
|
||||||
|
If your new feature has the same shape, you're about to extend
|
||||||
|
the bug.
|
||||||
|
- Does the client have "pick the latest" / "sort desc and take
|
||||||
|
first" logic after a `queryRecords` call? That is exactly what
|
||||||
|
`resolveName` does at the chain level — the client is
|
||||||
|
re-implementing it badly.
|
||||||
|
|
||||||
|
### 3. Questions an agent should ask itself before writing `queryRecords`
|
||||||
|
|
||||||
|
- "Am I looking up the current state of a logical entity?" If yes,
|
||||||
|
you want the Naming API, not `queryRecords`.
|
||||||
|
- "Will this query return more records as the same entity gets
|
||||||
|
modified over time?" If yes, you want the Naming API.
|
||||||
|
- "Am I about to write client-side code that picks the latest of
|
||||||
|
the returned list?" If yes, you want the Naming API.
|
||||||
|
|
||||||
|
If any answer is yes and you still want `queryRecords`, stop and
|
||||||
|
write a comment explaining why the Naming API doesn't fit. If you
|
||||||
|
can't, the Naming API does fit.
|
||||||
|
|
||||||
|
### 4. Do not propose caches, pagination, or compaction as the first fix for slow reads
|
||||||
|
|
||||||
|
Slow `queryRecords` on a mutable-identity use case is a design
|
||||||
|
smell, not a performance problem. The fixes agents reach for
|
||||||
|
first are all wrong:
|
||||||
|
|
||||||
|
- **TTL caches** hide the latency rather than fix it. First read
|
||||||
|
per window still pays the full cost.
|
||||||
|
- **`limit` / `offset` pagination** caps per-request fetch cost
|
||||||
|
but doesn't reduce the version-per-entity multiplier.
|
||||||
|
- **`delete_records` compaction** destroys the audit trail that
|
||||||
|
the immutable-Record design was supposed to provide.
|
||||||
|
|
||||||
|
If you're reaching for these, you are almost certainly on the
|
||||||
|
wrong side of the decision tree in `docs/PATTERNS.md`. Go back
|
||||||
|
and re-pick the primitive.
|
||||||
|
|
||||||
|
### 5. If you find a codebase already on the wrong side
|
||||||
|
|
||||||
|
Do not compound the mistake. Options in order of preference:
|
||||||
|
|
||||||
|
1. Migrate the specific feature you're touching to the Naming
|
||||||
|
API. You can usually do this incrementally — start writing
|
||||||
|
names on new writes, keep reading via attribute-scan until
|
||||||
|
the name index is populated, then flip the read path.
|
||||||
|
2. Write an ADR documenting the debt and which class of
|
||||||
|
regression will appear (latency grows with history; first
|
||||||
|
timeout hit around ~N records).
|
||||||
|
3. Ship the feature on the Naming API even if the rest of the
|
||||||
|
codebase doesn't — a single correct example in the codebase
|
||||||
|
is worth more than consistency with a wrong pattern.
|
||||||
|
|
||||||
|
### 6. Read laconicd's schema and keeper source, not just the client
|
||||||
|
|
||||||
|
Before proposing a fix that involves "laconicd doesn't support
|
||||||
|
X":
|
||||||
|
|
||||||
|
- `gql/cerc-io/laconicd/schema.graphql` — the actual read API.
|
||||||
|
- `x/registry/keeper/` — the write and index path.
|
||||||
|
- `proto/cerc/registry/v1/tx.proto` — the mutation messages.
|
||||||
|
|
||||||
|
Many "laconicd limitations" agents assume are actually client
|
||||||
|
limitations. `queryRecords` supports `limit` and `offset`;
|
||||||
|
`setName` and `lookupNames` exist and work; `NameRecord.history`
|
||||||
|
returns block-height-tagged prior bindings. Verify capabilities
|
||||||
|
against source before recommending workarounds or upstream
|
||||||
|
changes.
|
||||||
|
|
||||||
|
## Why this is in its own file
|
||||||
|
|
||||||
|
A `PATTERNS.md` on its own is a reference document humans browse.
|
||||||
|
An `AGENTS.md` is loaded into context and read top-to-bottom at
|
||||||
|
the start of agent sessions. Calling out the failure mode
|
||||||
|
explicitly — "agents tend to overlook the Naming API" — is load-
|
||||||
|
bearing because the people most likely to hit the failure are
|
||||||
|
the ones who wouldn't naturally pattern-match to a document
|
||||||
|
titled "Patterns."
|
||||||
|
|
||||||
|
If you are reading this and you are about to write your first
|
||||||
|
`queryRecords` call: stop. Read `docs/PATTERNS.md`. Then come
|
||||||
|
back.
|
||||||
@ -25,7 +25,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
# Copy over binary from the builder
|
# Copy over binary from the builder
|
||||||
COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/build/laconicd /usr/bin/laconicd
|
COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/build/laconicd /usr/bin/laconicd
|
||||||
|
|
||||||
# Copy over init script from builder
|
# Copy over init script from builder
|
||||||
COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/scripts/init.sh scripts/init.sh
|
COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/scripts/init.sh scripts/init.sh
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
|||||||
2
Makefile
2
Makefile
@ -43,7 +43,7 @@ build-linux:
|
|||||||
|
|
||||||
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
|
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
|
||||||
@echo "--> installing laconicd"
|
@echo "--> installing laconicd"
|
||||||
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...
|
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/laconicd
|
||||||
|
|
||||||
$(BUILDDIR)/:
|
$(BUILDDIR)/:
|
||||||
mkdir -p $(BUILDDIR)/
|
mkdir -p $(BUILDDIR)/
|
||||||
|
|||||||
22
README.md
22
README.md
@ -27,6 +27,28 @@ Run with a single node fixture:
|
|||||||
./scripts/init.sh clean
|
./scripts/init.sh clean
|
||||||
```
|
```
|
||||||
|
|
||||||
|
See [lockup.md](./lockup.md) for lockup account usage.
|
||||||
|
|
||||||
|
## Designing state that lives on laconicd
|
||||||
|
|
||||||
|
**Before** writing a client library, service, or migration that
|
||||||
|
persists data through laconicd, read:
|
||||||
|
|
||||||
|
- [`docs/PATTERNS.md`](./docs/PATTERNS.md) — the primitive
|
||||||
|
decision tree. Explains when to use the Naming API
|
||||||
|
(`setName` / `lookupNames` / `resolveNames`) vs. the Record
|
||||||
|
API (`setRecord` / `queryRecords` / `getRecordsByIds`), with
|
||||||
|
worked examples and the common anti-patterns.
|
||||||
|
- [`AGENTS.md`](./AGENTS.md) — written for AI coding agents, but
|
||||||
|
the failure mode it describes (extending the wrong primitive
|
||||||
|
rather than re-evaluating it) applies to human contributors
|
||||||
|
under deadline pressure too.
|
||||||
|
|
||||||
|
Picking the wrong primitive is expensive to unwind: laconicd is
|
||||||
|
append-only, so mistakes persist as on-chain data you cannot
|
||||||
|
silently remove. Spend the 10 minutes to read the pattern guide
|
||||||
|
before the first commit.
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
Run tests:
|
Run tests:
|
||||||
|
|||||||
755
api/cerc/types/v1/lockup.pulsar.go
Normal file
755
api/cerc/types/v1/lockup.pulsar.go
Normal file
@ -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
|
||||||
|
}
|
||||||
79
app/ante.go
Normal file
79
app/ante.go
Normal file
@ -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
|
||||||
|
}
|
||||||
71
app/app.go
71
app/app.go
@ -12,11 +12,13 @@ import (
|
|||||||
"cosmossdk.io/depinject"
|
"cosmossdk.io/depinject"
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
storetypes "cosmossdk.io/store/types"
|
storetypes "cosmossdk.io/store/types"
|
||||||
|
evidencekeeper "cosmossdk.io/x/evidence/keeper"
|
||||||
|
|
||||||
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
||||||
bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
||||||
onboardingkeeper "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
|
onboardingkeeper "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
|
||||||
registrykeeper "git.vdb.to/cerc-io/laconicd/x/registry/keeper"
|
registrykeeper "git.vdb.to/cerc-io/laconicd/x/registry/keeper"
|
||||||
|
types "git.vdb.to/cerc-io/laconicd/x/types/v1"
|
||||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
@ -26,8 +28,11 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/server/api"
|
"github.com/cosmos/cosmos-sdk/server/api"
|
||||||
"github.com/cosmos/cosmos-sdk/server/config"
|
"github.com/cosmos/cosmos-sdk/server/config"
|
||||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
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/types/module"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
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"
|
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||||
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
|
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
|
||||||
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
||||||
@ -43,6 +48,7 @@ import (
|
|||||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||||
|
|
||||||
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/evidence" // import for side-effects
|
||||||
_ "git.vdb.to/cerc-io/laconicd/x/auction/module" // 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/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/onboarding/module" // import for side-effects
|
||||||
@ -88,6 +94,7 @@ type LaconicApp struct {
|
|||||||
GovKeeper *govkeeper.Keeper
|
GovKeeper *govkeeper.Keeper
|
||||||
CrisisKeeper *crisiskeeper.Keeper
|
CrisisKeeper *crisiskeeper.Keeper
|
||||||
ConsensusParamsKeeper consensuskeeper.Keeper
|
ConsensusParamsKeeper consensuskeeper.Keeper
|
||||||
|
EvidenceKeeper evidencekeeper.Keeper
|
||||||
|
|
||||||
// laconic keepers
|
// laconic keepers
|
||||||
AuctionKeeper *auctionkeeper.Keeper // (Use * as per ProvideModule implementation)
|
AuctionKeeper *auctionkeeper.Keeper // (Use * as per ProvideModule implementation)
|
||||||
@ -161,6 +168,7 @@ func NewLaconicApp(
|
|||||||
&app.GovKeeper,
|
&app.GovKeeper,
|
||||||
&app.CrisisKeeper,
|
&app.CrisisKeeper,
|
||||||
&app.ConsensusParamsKeeper,
|
&app.ConsensusParamsKeeper,
|
||||||
|
&app.EvidenceKeeper,
|
||||||
&app.AuctionKeeper,
|
&app.AuctionKeeper,
|
||||||
&app.BondKeeper,
|
&app.BondKeeper,
|
||||||
&app.RegistryKeeper,
|
&app.RegistryKeeper,
|
||||||
@ -169,6 +177,10 @@ func NewLaconicApp(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register custom interfaces
|
||||||
|
RegisterCustomInterfaces(app.interfaceRegistry)
|
||||||
|
RegisterCustomLegacyAminoCodec(app.legacyAmino)
|
||||||
|
|
||||||
app.App = appBuilder.Build(db, traceStore, baseAppOptions...)
|
app.App = appBuilder.Build(db, traceStore, baseAppOptions...)
|
||||||
|
|
||||||
// register streaming services
|
// register streaming services
|
||||||
@ -185,6 +197,9 @@ func NewLaconicApp(
|
|||||||
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, make(map[string]module.AppModuleSimulation, 0))
|
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, make(map[string]module.AppModuleSimulation, 0))
|
||||||
app.sm.RegisterStoreDecoders()
|
app.sm.RegisterStoreDecoders()
|
||||||
|
|
||||||
|
// set custom ante handlers
|
||||||
|
app.setCustomAnteHandler()
|
||||||
|
|
||||||
if err := app.Load(loadLatest); err != nil {
|
if err := app.Load(loadLatest); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -232,3 +247,59 @@ func (app *LaconicApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.AP
|
|||||||
panic(err)
|
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)
|
||||||
|
}
|
||||||
|
|||||||
@ -6,11 +6,11 @@ modules:
|
|||||||
# During begin block slashing happens after distr.BeginBlocker so that
|
# 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.
|
# 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
|
# NOTE: staking module is required if HistoricalEntries param > 0
|
||||||
begin_blockers: [distribution, slashing, staking]
|
begin_blockers: [distribution, slashing, evidence, staking]
|
||||||
end_blockers: [crisis, gov, staking, auction, registry]
|
end_blockers: [crisis, gov, staking, 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 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.
|
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
|
||||||
init_genesis: [auth, bank, distribution, staking, slashing, gov, crisis, genutil, auction, bond, registry, onboarding]
|
init_genesis: [auth, bank, distribution, staking, slashing, gov, crisis, genutil, evidence, auction, bond, registry, onboarding]
|
||||||
override_store_keys:
|
override_store_keys:
|
||||||
- module_name: auth
|
- module_name: auth
|
||||||
kv_store_key: acc
|
kv_store_key: acc
|
||||||
@ -33,6 +33,7 @@ modules:
|
|||||||
- account: registry
|
- account: registry
|
||||||
- account: record_rent
|
- account: record_rent
|
||||||
- account: authority_rent
|
- account: authority_rent
|
||||||
|
- account: lps_lockup
|
||||||
- name: bank
|
- name: bank
|
||||||
config:
|
config:
|
||||||
"@type": cosmos.bank.module.v1.Module
|
"@type": cosmos.bank.module.v1.Module
|
||||||
@ -62,6 +63,9 @@ modules:
|
|||||||
- name: crisis
|
- name: crisis
|
||||||
config:
|
config:
|
||||||
"@type": cosmos.crisis.module.v1.Module
|
"@type": cosmos.crisis.module.v1.Module
|
||||||
|
- name: evidence
|
||||||
|
config:
|
||||||
|
"@type": cosmos.evidence.module.v1.Module
|
||||||
- name: bond
|
- name: bond
|
||||||
config:
|
config:
|
||||||
"@type": cerc.bond.module.v1.Module
|
"@type": cerc.bond.module.v1.Module
|
||||||
|
|||||||
@ -10,11 +10,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CoinUnit = "lnt"
|
// Registered token
|
||||||
BaseCoinUnit = "alnt"
|
LpsCoinUnit = "lps"
|
||||||
LntExponent = 18
|
LpsBaseCoinUnit = "alps"
|
||||||
|
LpsExponent = 18
|
||||||
|
|
||||||
DefaultBondDenom = BaseCoinUnit
|
// 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 defines the Bech32 prefix of an account's address.
|
||||||
Bech32PrefixAccAddr = "laconic"
|
Bech32PrefixAccAddr = "laconic"
|
||||||
@ -39,12 +42,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RegisterDenoms() {
|
func RegisterDenoms() {
|
||||||
err := sdk.RegisterDenom(CoinUnit, math.LegacyOneDec())
|
err := sdk.RegisterDenom(LpsCoinUnit, math.LegacyOneDec())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
err = sdk.RegisterDenom(LpsBaseCoinUnit, math.LegacyNewDecWithPrec(1, LpsExponent))
|
||||||
err = sdk.RegisterDenom(BaseCoinUnit, math.LegacyNewDecWithPrec(1, LntExponent))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
154
cmd/laconicd/cmd/add_genesis_lockup_account.go
Normal file
154
cmd/laconicd/cmd/add_genesis_lockup_account.go
Normal file
@ -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)
|
||||||
|
}
|
||||||
@ -58,10 +58,14 @@ func initRootCmd(rootCmd *cobra.Command, txConfig client.TxConfig, basicManager
|
|||||||
startCmd.RunE = newStartCmd.RunE
|
startCmd.RunE = newStartCmd.RunE
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 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
|
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
server.StatusCommand(),
|
server.StatusCommand(),
|
||||||
genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome),
|
genesisCmd,
|
||||||
queryCommand(),
|
queryCommand(),
|
||||||
txCommand(),
|
txCommand(),
|
||||||
keys.Commands(),
|
keys.Commands(),
|
||||||
|
|||||||
@ -21,15 +21,16 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||||
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
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/app"
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
"git.vdb.to/cerc-io/laconicd/gql"
|
"git.vdb.to/cerc-io/laconicd/gql"
|
||||||
|
types "git.vdb.to/cerc-io/laconicd/x/types/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const EnvPrefix = "LACONIC"
|
const EnvPrefix = "LACONIC"
|
||||||
@ -100,7 +101,7 @@ func NewRootCmd() *cobra.Command {
|
|||||||
|
|
||||||
// overwrite the minimum gas price from the app configuration
|
// overwrite the minimum gas price from the app configuration
|
||||||
srvCfg := serverconfig.DefaultConfig()
|
srvCfg := serverconfig.DefaultConfig()
|
||||||
srvCfg.MinGasPrices = fmt.Sprintf("0%s", sdk.DefaultBondDenom)
|
srvCfg.MinGasPrices = fmt.Sprintf("0%s", params.CoinUnit)
|
||||||
|
|
||||||
// overwrite the block timeout
|
// overwrite the block timeout
|
||||||
cmtCfg := cmtcfg.DefaultConfig()
|
cmtCfg := cmtcfg.DefaultConfig()
|
||||||
@ -135,7 +136,7 @@ func ProvideClientContext(
|
|||||||
WithTxConfig(txConfig).
|
WithTxConfig(txConfig).
|
||||||
WithLegacyAmino(legacyAmino).
|
WithLegacyAmino(legacyAmino).
|
||||||
WithInput(os.Stdin).
|
WithInput(os.Stdin).
|
||||||
WithAccountRetriever(types.AccountRetriever{}).
|
WithAccountRetriever(authtypes.AccountRetriever{}).
|
||||||
WithHomeDir(app.DefaultNodeHome).
|
WithHomeDir(app.DefaultNodeHome).
|
||||||
WithViper(EnvPrefix) // env variable prefix
|
WithViper(EnvPrefix) // env variable prefix
|
||||||
|
|
||||||
@ -148,6 +149,10 @@ func ProvideClientContext(
|
|||||||
clientCtx.HomeDir = ""
|
clientCtx.HomeDir = ""
|
||||||
clientCtx.KeyringDir = ""
|
clientCtx.KeyringDir = ""
|
||||||
|
|
||||||
|
// Custom LockupAccount type needs to be registered
|
||||||
|
interfaceRegistry.RegisterImplementations((*types.LockupAccountI)(nil), &types.LockupAccount{})
|
||||||
|
interfaceRegistry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &types.LockupAccount{})
|
||||||
|
|
||||||
return clientCtx
|
return clientCtx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
220
docs/PATTERNS.md
Normal file
220
docs/PATTERNS.md
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
# Laconicd design patterns
|
||||||
|
|
||||||
|
**Read this before designing any state that lives on laconicd.**
|
||||||
|
Not after. Writing a client library, a service that persists user
|
||||||
|
data, or a migration from another store — start here.
|
||||||
|
|
||||||
|
This document exists because the wrong primitive choice in an
|
||||||
|
application is expensive to unwind after production traffic
|
||||||
|
accumulates. The chain is append-only; mistakes persist as
|
||||||
|
on-chain garbage you cannot delete retroactively. Most of the
|
||||||
|
architectural regret in the laconicd ecosystem so far has come
|
||||||
|
from picking `queryRecords` as the default read path when a
|
||||||
|
different primitive was the right tool.
|
||||||
|
|
||||||
|
## The primitives, honestly
|
||||||
|
|
||||||
|
Laconicd exposes three distinct storage and lookup primitives. They
|
||||||
|
look similar on first glance and have VERY different semantics.
|
||||||
|
|
||||||
|
| Primitive | Identity | Mutability | Lookup cost | Audit trail |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| **Record** (`setRecord` / `queryRecords` / `getRecordsByIds`) | Content hash (CID) | Immutable. Every change is a NEW record with a new CID. | Attribute-indexed, but returns EVERY version matching | Implicit — all versions persist forever |
|
||||||
|
| **Name** (`setName` / `lookupNames` / `resolveNames`) | Caller-chosen string (`"mtm/lootboxes/<wallet>/<id>"`) | Pointer. Re-setting updates which CID the name resolves to. | Direct name → latest CID lookup (single record) | Explicit — `NameRecord.history` returns prior bindings with block heights |
|
||||||
|
| **Authority / Bond / Auction** | Purpose-specific | Varies | Purpose-specific | Varies |
|
||||||
|
|
||||||
|
**The trap:** `Record` looks like the universal "put this thing on
|
||||||
|
chain" primitive because its API surface is biggest and most
|
||||||
|
obvious. If you treat it as such, every mutable-state use case
|
||||||
|
(game state, user profiles, inventories, counters) ends up re-
|
||||||
|
implementing the Naming API badly — appending version after
|
||||||
|
version, then filtering client-side for "the latest."
|
||||||
|
|
||||||
|
## Decision tree
|
||||||
|
|
||||||
|
```
|
||||||
|
Does the thing you're storing have a mutable logical identity?
|
||||||
|
(i.e., "the current state of thing X" is a meaningful question)
|
||||||
|
|
||||||
|
├── YES → Use the Naming API.
|
||||||
|
│ setName("mtm/lootboxes/<wallet>/<box_id>", cid) on every write.
|
||||||
|
│ lookupNames(...) or resolveNames(...) returns the one
|
||||||
|
│ current record. Audit trail via NameRecord.history.
|
||||||
|
│
|
||||||
|
└── NO → Is it a point-lookup by CID?
|
||||||
|
│
|
||||||
|
├── YES → getRecordsByIds([cid])
|
||||||
|
│
|
||||||
|
└── NO → It's an append-only event stream with
|
||||||
|
queryable attributes. Use setRecord +
|
||||||
|
queryRecords. Expect every historical record
|
||||||
|
to come back; plan pagination accordingly.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Anti-pattern: "queryRecords-as-key-value-store"
|
||||||
|
|
||||||
|
This is the mistake real laconicd codebases keep making. It looks
|
||||||
|
like this:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# BAD — reimplementing names via attribute scan
|
||||||
|
|
||||||
|
async def save_state(user_id: str, state: dict):
|
||||||
|
await set_record(
|
||||||
|
record_type="UserState",
|
||||||
|
attributes={"user_id": user_id}, # logical ID as attribute
|
||||||
|
data=state,
|
||||||
|
)
|
||||||
|
|
||||||
|
async def get_state(user_id: str) -> dict:
|
||||||
|
records = await query_records(
|
||||||
|
record_type="UserState",
|
||||||
|
attributes={"user_id": user_id},
|
||||||
|
)
|
||||||
|
# Client-side "pick the latest" — smell
|
||||||
|
records.sort(key=lambda r: r["created_at"], reverse=True)
|
||||||
|
return records[0]
|
||||||
|
```
|
||||||
|
|
||||||
|
Why it's wrong:
|
||||||
|
|
||||||
|
1. Every call to `save_state` writes a NEW content-addressed record.
|
||||||
|
Old records stay on chain forever.
|
||||||
|
2. `query_records` returns all of them every time. Per-record fetch
|
||||||
|
cost scales linearly with save count.
|
||||||
|
3. The client-side `sort + [0]` is "I wanted the latest" — exactly
|
||||||
|
what `lookupNames` does at the index level.
|
||||||
|
4. Latency degrades silently as users accumulate history. The
|
||||||
|
query eventually breaches whatever timeout the caller has.
|
||||||
|
|
||||||
|
The correct pattern:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# GOOD — names for mutable identity
|
||||||
|
|
||||||
|
async def save_state(user_id: str, state: dict):
|
||||||
|
cid = await set_record(
|
||||||
|
record_type="UserState",
|
||||||
|
attributes={"user_id": user_id},
|
||||||
|
data=state,
|
||||||
|
)
|
||||||
|
await set_name(
|
||||||
|
name=f"my-app/user-state/{user_id}",
|
||||||
|
cid=cid,
|
||||||
|
)
|
||||||
|
|
||||||
|
async def get_state(user_id: str) -> dict:
|
||||||
|
record = await resolve_name(f"my-app/user-state/{user_id}")
|
||||||
|
return record
|
||||||
|
```
|
||||||
|
|
||||||
|
Properties of the correct pattern:
|
||||||
|
|
||||||
|
- One name → one current CID. Latency doesn't scale with save count.
|
||||||
|
- Historical versions still exist on chain (immutable Record CIDs
|
||||||
|
aren't deleted), and are reachable via `NameRecord.history`.
|
||||||
|
- Audit trail is explicit rather than implicit — you can ask "what
|
||||||
|
was the state at block N?" rather than scanning every version.
|
||||||
|
- Client code has no "pick the latest" step; the chain already
|
||||||
|
answered that.
|
||||||
|
|
||||||
|
## Anti-pattern: "compaction via `delete_records`"
|
||||||
|
|
||||||
|
The `delete_records` primitive exists and is tempting to use for
|
||||||
|
"prune old versions of logical entity X to keep queries fast." Do
|
||||||
|
not use it for that unless you have signed off on dropping the
|
||||||
|
audit trail.
|
||||||
|
|
||||||
|
- `delete_records` physically removes a CID from the index.
|
||||||
|
- If your design relies on every version being recoverable (audit
|
||||||
|
trails, chain-of-custody, dispute resolution), compaction
|
||||||
|
destroys exactly that property.
|
||||||
|
- If your design doesn't need every version, you were never in
|
||||||
|
the Record + attribute-scan pattern to begin with — you wanted
|
||||||
|
the Naming API from the start.
|
||||||
|
|
||||||
|
`delete_records` is appropriate for **user-intent-driven
|
||||||
|
permanent deletion** (unregistering a device, unfollowing,
|
||||||
|
revoking a credential). Not for database-compaction-style
|
||||||
|
version pruning.
|
||||||
|
|
||||||
|
## Anti-pattern: "cache the slow query"
|
||||||
|
|
||||||
|
Caching a `queryRecords` result (TTL, LRU, whatever) at the client
|
||||||
|
layer is attractive because it appears to fix latency without
|
||||||
|
touching storage design. It doesn't — it hides the fact that you
|
||||||
|
chose the wrong primitive. The first read per cache window still
|
||||||
|
pays the growing-with-history cost, and the design drifts further
|
||||||
|
from correct as the caching surface calcifies.
|
||||||
|
|
||||||
|
Cache is acceptable for genuinely external-service latency (price
|
||||||
|
oracles, Solana RPC balance checks). It is not acceptable as a
|
||||||
|
substitute for using the Naming API.
|
||||||
|
|
||||||
|
## Pagination (`limit` / `offset`)
|
||||||
|
|
||||||
|
`queryRecords` accepts `limit` and `offset`. Use them when you
|
||||||
|
genuinely want an append-only event stream with cursor-style
|
||||||
|
paging (e.g., "the last 100 events matching filter X"). Do NOT
|
||||||
|
use pagination to patch over "my mutable-identity query is slow" —
|
||||||
|
pagination doesn't reduce the per-entity version multiplier,
|
||||||
|
only the per-request fetch budget.
|
||||||
|
|
||||||
|
## Mutations go through Cosmos tx, not GraphQL
|
||||||
|
|
||||||
|
Writes (`setRecord`, `setName`, `deleteRecord`, `reserveAuthority`,
|
||||||
|
etc.) are Cosmos SDK `Msg`s, submitted via Tendermint RPC. The
|
||||||
|
GraphQL endpoint is read-only. Client libraries usually wrap this
|
||||||
|
behind a "registry writer" sidecar or equivalent — check how your
|
||||||
|
SDK / service is structured before wiring writes.
|
||||||
|
|
||||||
|
## Worked example: mutable game state
|
||||||
|
|
||||||
|
Game records a user's loot box that transitions
|
||||||
|
`PENDING → ACTIVE → RESOLVED`.
|
||||||
|
|
||||||
|
Correct shape:
|
||||||
|
|
||||||
|
- **Record writes** (one per state transition; each gets a new CID):
|
||||||
|
- `setRecord(type="LootBox", attributes={wallet, id, status}, data={...})`
|
||||||
|
- Preserves complete history as immutable records. Needed for
|
||||||
|
audit: "what did this box look like when the user picked?"
|
||||||
|
- **Name write** (on every transition, pointing at the new CID):
|
||||||
|
- `setName(name=f"mygame/lootboxes/{wallet}/{box_id}", cid=<new_cid>)`
|
||||||
|
- **Read: current state of one box**:
|
||||||
|
- `resolveName(f"mygame/lootboxes/{wallet}/{box_id}")` → one record.
|
||||||
|
- **Read: all current boxes for a wallet**:
|
||||||
|
- Enumerate names by prefix, resolve each. Or maintain an
|
||||||
|
index name `mygame/lootboxes/{wallet}/_index` whose pointed
|
||||||
|
record lists active box ids.
|
||||||
|
- **Read: audit trail of one box**:
|
||||||
|
- `lookupNames([f"mygame/lootboxes/{wallet}/{box_id}"])` returns
|
||||||
|
`NameRecord.history`, one entry per state transition, each with
|
||||||
|
its block height. Resolve each entry's CID to get the full
|
||||||
|
historical state.
|
||||||
|
|
||||||
|
This shape works with any number of boxes per wallet. Per-wallet
|
||||||
|
latency is bounded by active-box count, not lifetime
|
||||||
|
transition-count.
|
||||||
|
|
||||||
|
## When you find an existing codebase doing it wrong
|
||||||
|
|
||||||
|
Appending a fix on top of the wrong primitive is usually the
|
||||||
|
wrong move. Options in order of preference:
|
||||||
|
|
||||||
|
1. **Migrate to Naming API.** The data already on chain as Records
|
||||||
|
is still valid — you just need to start writing names and
|
||||||
|
reading via names. Existing consumers of the attribute-scan
|
||||||
|
path can keep working until they're moved.
|
||||||
|
2. **Document the debt.** If the migration is deferred, write an
|
||||||
|
ADR saying so and naming the specific class of regression
|
||||||
|
this creates (latency as history accumulates).
|
||||||
|
3. **Do NOT reach for caches or compaction first.** Those hide
|
||||||
|
the design mistake and make the eventual migration harder.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- `AGENTS.md` (repo root) — why AI agents particularly mis-pick
|
||||||
|
primitives here, and what context they need.
|
||||||
|
- `gql/cerc-io/laconicd/schema.graphql` — inline anti-pattern
|
||||||
|
warnings on `queryRecords` and `getRecordsByIds`.
|
||||||
1
go.mod
1
go.mod
@ -23,6 +23,7 @@ require (
|
|||||||
cosmossdk.io/math v1.3.0
|
cosmossdk.io/math v1.3.0
|
||||||
cosmossdk.io/store v1.1.1
|
cosmossdk.io/store v1.1.1
|
||||||
cosmossdk.io/tools/confix v0.1.0
|
cosmossdk.io/tools/confix v0.1.0
|
||||||
|
cosmossdk.io/x/evidence v0.1.1
|
||||||
github.com/99designs/gqlgen v0.17.22
|
github.com/99designs/gqlgen v0.17.22
|
||||||
github.com/cometbft/cometbft v0.38.12
|
github.com/cometbft/cometbft v0.38.12
|
||||||
github.com/cosmos/cosmos-db v1.0.2
|
github.com/cosmos/cosmos-db v1.0.2
|
||||||
|
|||||||
2
go.sum
2
go.sum
@ -20,6 +20,8 @@ cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y=
|
|||||||
cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
|
cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
|
||||||
cosmossdk.io/tools/confix v0.1.0 h1:2OOZTtQsDT5e7P3FM5xqM0bPfluAxZlAwxqaDmYBE+E=
|
cosmossdk.io/tools/confix v0.1.0 h1:2OOZTtQsDT5e7P3FM5xqM0bPfluAxZlAwxqaDmYBE+E=
|
||||||
cosmossdk.io/tools/confix v0.1.0/go.mod h1:TdXKVYs4gEayav5wM+JHT+kTU2J7fozFNqoVaN+8CdY=
|
cosmossdk.io/tools/confix v0.1.0/go.mod h1:TdXKVYs4gEayav5wM+JHT+kTU2J7fozFNqoVaN+8CdY=
|
||||||
|
cosmossdk.io/x/evidence v0.1.1 h1:Ks+BLTa3uftFpElLTDp9L76t2b58htjVbSZ86aoK/E4=
|
||||||
|
cosmossdk.io/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc=
|
||||||
cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw=
|
cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw=
|
||||||
cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
|
cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
|
|||||||
@ -240,10 +240,30 @@ type Query {
|
|||||||
# GraphDB API.
|
# GraphDB API.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Get records by IDs.
|
# Point-lookup of records by content-hash CID.
|
||||||
|
#
|
||||||
|
# Returns one record per id. CIDs are immutable — a record's
|
||||||
|
# content never changes, so this API answers "what was at this
|
||||||
|
# CID?" If you want "what is the current state of logical
|
||||||
|
# thing X?", use resolveNames / lookupNames instead (below).
|
||||||
getRecordsByIds(ids: [String!]): [Record]
|
getRecordsByIds(ids: [String!]): [Record]
|
||||||
|
|
||||||
# Query records.
|
# Attribute-filtered query over records.
|
||||||
|
#
|
||||||
|
# WARNING — pick the right primitive before using this.
|
||||||
|
# Records are content-addressed and immutable; every state
|
||||||
|
# change writes a NEW record with a new CID. queryRecords
|
||||||
|
# returns EVERY version matching the filter, not "the latest."
|
||||||
|
# If you find yourself filtering by a logical id attribute
|
||||||
|
# (wallet, user_id, entity_id, etc.) and then picking the
|
||||||
|
# "latest" version client-side, you are reimplementing the
|
||||||
|
# Naming API (resolveNames / lookupNames) at the client layer.
|
||||||
|
# That is the correct primitive for mutable logical identity.
|
||||||
|
#
|
||||||
|
# Use queryRecords for: append-only event streams, list-all-
|
||||||
|
# events-matching-filter, cursor-paged audit scans.
|
||||||
|
# DO NOT use queryRecords for: "get the current state of X".
|
||||||
|
# See docs/PATTERNS.md and AGENTS.md for the decision tree.
|
||||||
queryRecords(
|
queryRecords(
|
||||||
# Multiple attribute conditions are in a logical AND.
|
# Multiple attribute conditions are in a logical AND.
|
||||||
attributes: [KeyValueInput!]
|
attributes: [KeyValueInput!]
|
||||||
@ -261,6 +281,17 @@ type Query {
|
|||||||
#
|
#
|
||||||
# Naming API.
|
# Naming API.
|
||||||
#
|
#
|
||||||
|
# USE THIS for any "current state of logical thing X" lookup.
|
||||||
|
# setName binds a caller-chosen name to a content-addressed
|
||||||
|
# record CID. Re-calling setName with a new CID updates which
|
||||||
|
# CID the name resolves to, without losing the prior binding
|
||||||
|
# (NameRecord.history preserves it with block heights).
|
||||||
|
#
|
||||||
|
# Names eliminate the "scan all versions, pick latest" client-
|
||||||
|
# side pattern that queryRecords invites. They are the
|
||||||
|
# correct primitive for mutable logical identity.
|
||||||
|
# See docs/PATTERNS.md for the decision tree and worked examples.
|
||||||
|
#
|
||||||
|
|
||||||
# Get authorities list.
|
# Get authorities list.
|
||||||
getAuthorities(owner: String): [Authority]!
|
getAuthorities(owner: String): [Authority]!
|
||||||
@ -269,6 +300,12 @@ type Query {
|
|||||||
lookupAuthorities(names: [String!]): [AuthorityRecord]!
|
lookupAuthorities(names: [String!]): [AuthorityRecord]!
|
||||||
|
|
||||||
# Lookup name to record mapping information.
|
# Lookup name to record mapping information.
|
||||||
|
#
|
||||||
|
# Returns a NameRecord per queried name, each containing the
|
||||||
|
# `latest` binding (the current CID) and `history` (all prior
|
||||||
|
# bindings with their block heights). Use this when you want
|
||||||
|
# both the current state and its audit trail. If you only want
|
||||||
|
# the current Record, resolveNames is more direct.
|
||||||
lookupNames(names: [String!]): [NameRecord]!
|
lookupNames(names: [String!]): [NameRecord]!
|
||||||
|
|
||||||
# Resolve names to records.
|
# Resolve names to records.
|
||||||
|
|||||||
@ -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(`
|
var page = template.Must(template.New("graphiql").Parse(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<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
|
copy them directly into your environment, or perhaps include them in your
|
||||||
favored resource bundler.
|
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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="graphiql">Loading...</div>
|
<div id="graphiql">Loading...</div>
|
||||||
<script
|
<script
|
||||||
src="https://unpkg.com/graphiql/graphiql.min.js"
|
src="https://unpkg.com/graphiql@2.4.7/graphiql.min.js"
|
||||||
type="application/javascript"
|
type="application/javascript"
|
||||||
></script>
|
></script>
|
||||||
<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.
|
// Parse the search string to get url parameters.
|
||||||
var search = window.location.search;
|
var search = window.location.search;
|
||||||
|
|||||||
47
lockup.md
Normal file
47
lockup.md
Normal file
@ -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"
|
||||||
|
```
|
||||||
26
proto/cerc/types/v1/lockup.proto
Normal file
26
proto/cerc/types/v1/lockup.proto
Normal file
@ -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;
|
||||||
|
}
|
||||||
@ -1,11 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
KEY="alice"
|
KEY="alice"
|
||||||
CHAINID=${CHAINID:-"laconic_9000-1"}
|
CHAINID=${CHAINID:-"laconic_9000-1"}
|
||||||
MONIKER=${MONIKER:-"localtestnet"}
|
MONIKER=${MONIKER:-"localtestnet"}
|
||||||
KEYRING=${KEYRING:-"test"}
|
KEYRING=${KEYRING:-"test"}
|
||||||
DENOM=${DENOM:-"alnt"}
|
DENOM=${DENOM:-"alnt"}
|
||||||
STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"}
|
BALANCE=${BALANCE:-"1000000000000000000000000000000"} # 10^32 alnt
|
||||||
|
STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"} # 10^15 alnt
|
||||||
MIN_GAS_PRICE=${MIN_GAS_PRICE:-"0.001"}
|
MIN_GAS_PRICE=${MIN_GAS_PRICE:-"0.001"}
|
||||||
LOGLEVEL=${LOGLEVEL:-"info"}
|
LOGLEVEL=${LOGLEVEL:-"info"}
|
||||||
|
|
||||||
@ -94,6 +97,16 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data" ]; then
|
|||||||
# Set gas limit in genesis
|
# Set gas limit in genesis
|
||||||
update_genesis '.consensus["params"]["block"]["max_gas"]="10000000"'
|
update_genesis '.consensus["params"]["block"]["max_gas"]="10000000"'
|
||||||
|
|
||||||
|
# Set distribution community tax to 1 for disabling staking rewards
|
||||||
|
update_genesis '.app_state["distribution"]["params"]["community_tax"]="1.000000000000000000"'
|
||||||
|
|
||||||
|
echo "Setting high threshold for accepting governance proposal"
|
||||||
|
update_genesis '.app_state["gov"]["params"]["quorum"]="1.000000000000000000"'
|
||||||
|
# Set expedited threshold to 100%
|
||||||
|
update_genesis '.app_state["gov"]["params"]["expedited_threshold"]="1.000000000000000000"'
|
||||||
|
# Set normal threshold to 99% since it needs to be lesser than expedited threshold
|
||||||
|
update_genesis '.app_state["gov"]["params"]["threshold"]="0.990000000000000000"'
|
||||||
|
|
||||||
# disable produce empty block
|
# disable produce empty block
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||||
@ -116,11 +129,9 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Allocate genesis accounts (cosmos formatted addresses)
|
# Allocate genesis accounts (cosmos formatted addresses)
|
||||||
# 10^30 alnt | 10^12 lnt
|
laconicd genesis add-genesis-account $KEY ${BALANCE}${DENOM} --keyring-backend $KEYRING
|
||||||
laconicd genesis add-genesis-account $KEY 1000000000000000000000000000000$DENOM --keyring-backend $KEYRING
|
|
||||||
|
|
||||||
# Sign genesis transaction
|
# Sign genesis transaction
|
||||||
# 10^15 alnt
|
|
||||||
laconicd genesis gentx $KEY $STAKING_AMOUNT$DENOM --keyring-backend $KEYRING --chain-id $CHAINID
|
laconicd genesis gentx $KEY $STAKING_AMOUNT$DENOM --keyring-backend $KEYRING --chain-id $CHAINID
|
||||||
|
|
||||||
# Collect genesis tx
|
# Collect genesis tx
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
package e2e
|
package e2e
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
|
||||||
dbm "github.com/cosmos/cosmos-db"
|
dbm "github.com/cosmos/cosmos-db"
|
||||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
@ -16,12 +18,14 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||||
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
|
|
||||||
laconicApp "git.vdb.to/cerc-io/laconicd/app"
|
laconicApp "git.vdb.to/cerc-io/laconicd/app"
|
||||||
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
||||||
bondmodule "git.vdb.to/cerc-io/laconicd/x/bond/module"
|
bondmodule "git.vdb.to/cerc-io/laconicd/x/bond/module"
|
||||||
registrymodule "git.vdb.to/cerc-io/laconicd/x/registry/module"
|
registrymodule "git.vdb.to/cerc-io/laconicd/x/registry/module"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
_ "git.vdb.to/cerc-io/laconicd/app/params" // import for side-effects (see init)
|
_ "git.vdb.to/cerc-io/laconicd/app/params" // import for side-effects (see init)
|
||||||
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
||||||
)
|
)
|
||||||
@ -54,16 +58,40 @@ func NewTestNetworkFixture() network.TestFixture {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
encodingConfig := testutil.MakeTestEncodingConfig(
|
||||||
|
auth.AppModuleBasic{},
|
||||||
|
bank.AppModuleBasic{},
|
||||||
|
staking.AppModuleBasic{},
|
||||||
|
auctionmodule.AppModule{},
|
||||||
|
bondmodule.AppModule{},
|
||||||
|
registrymodule.AppModule{},
|
||||||
|
)
|
||||||
|
|
||||||
|
genesisState := app.DefaultGenesis()
|
||||||
|
genesisState, err = updateStakingGenesisBondDenom(genesisState, encodingConfig.Codec)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("failed to update genesis state: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
return network.TestFixture{
|
return network.TestFixture{
|
||||||
AppConstructor: appCtr,
|
AppConstructor: appCtr,
|
||||||
GenesisState: app.DefaultGenesis(),
|
GenesisState: genesisState,
|
||||||
EncodingConfig: testutil.MakeTestEncodingConfig(
|
EncodingConfig: encodingConfig,
|
||||||
auth.AppModuleBasic{},
|
|
||||||
bank.AppModuleBasic{},
|
|
||||||
staking.AppModuleBasic{},
|
|
||||||
auctionmodule.AppModule{},
|
|
||||||
bondmodule.AppModule{},
|
|
||||||
registrymodule.AppModule{},
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateStakingGenesisBondDenom(genesisState map[string]json.RawMessage, codec codec.Codec) (map[string]json.RawMessage, error) {
|
||||||
|
var stakingGenesis stakingtypes.GenesisState
|
||||||
|
if err := codec.UnmarshalJSON(genesisState[stakingtypes.ModuleName], &stakingGenesis); err != nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
stakingGenesis.Params.BondDenom = params.CoinUnit
|
||||||
|
|
||||||
|
stakingGenesisBz, err := codec.MarshalJSON(&stakingGenesis)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
genesisState[stakingtypes.ModuleName] = stakingGenesisBz
|
||||||
|
|
||||||
|
return genesisState, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import (
|
|||||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
||||||
types "git.vdb.to/cerc-io/laconicd/x/auction"
|
types "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
)
|
)
|
||||||
@ -337,9 +338,9 @@ func (kts *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.Au
|
|||||||
Signer: accounts[0].String(),
|
Signer: accounts[0].String(),
|
||||||
CommitsDuration: 5 * time.Minute,
|
CommitsDuration: 5 * time.Minute,
|
||||||
RevealsDuration: 5 * time.Minute,
|
RevealsDuration: 5 * time.Minute,
|
||||||
CommitFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)),
|
CommitFee: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000)),
|
||||||
RevealFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)),
|
RevealFee: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000)),
|
||||||
MinimumBid: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000000)),
|
MinimumBid: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000000)),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
||||||
types "git.vdb.to/cerc-io/laconicd/x/bond"
|
types "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
)
|
)
|
||||||
@ -185,7 +186,7 @@ func (kts *KeeperTestSuite) TestGrpcGetModuleBalance() {
|
|||||||
if !test.errResponse {
|
if !test.errResponse {
|
||||||
kts.Require().Nil(err)
|
kts.Require().Nil(err)
|
||||||
kts.Require().NotNil(resp.GetBalance())
|
kts.Require().NotNil(resp.GetBalance())
|
||||||
kts.Require().Equal(resp.GetBalance(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))))
|
kts.Require().Equal(resp.GetBalance(), sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(10))))
|
||||||
} else {
|
} else {
|
||||||
kts.Require().NotNil(err)
|
kts.Require().NotNil(err)
|
||||||
kts.Require().Error(err)
|
kts.Require().Error(err)
|
||||||
@ -201,7 +202,7 @@ func (kts *KeeperTestSuite) createBond() (*types.Bond, error) {
|
|||||||
// Create funded account(s)
|
// Create funded account(s)
|
||||||
accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(1000))
|
accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(1000))
|
||||||
|
|
||||||
bond, err := k.CreateBond(ctx, accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))))
|
bond, err := k.CreateBond(ctx, accounts[0], sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(10))))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import (
|
|||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
||||||
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
||||||
@ -82,8 +83,8 @@ func (tf *TestFixture) Setup() error {
|
|||||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||||
authtypes.ProtoBaseAccount,
|
authtypes.ProtoBaseAccount,
|
||||||
maccPerms,
|
maccPerms,
|
||||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
addresscodec.NewBech32Codec(params.Bech32PrefixAccAddr),
|
||||||
sdk.Bech32MainPrefix,
|
params.Bech32PrefixAccAddr,
|
||||||
authority.String(),
|
authority.String(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -161,5 +162,5 @@ func (tf *TestFixture) Setup() error {
|
|||||||
type BondDenomProvider struct{}
|
type BondDenomProvider struct{}
|
||||||
|
|
||||||
func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) {
|
func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) {
|
||||||
return sdk.DefaultBondDenom, nil
|
return params.CoinUnit, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
||||||
bondTypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
bondTypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
types "git.vdb.to/cerc-io/laconicd/x/registry"
|
types "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
@ -51,7 +52,7 @@ func (kts *KeeperTestSuite) createBond() (*bondTypes.Bond, error) {
|
|||||||
// Create a funded account
|
// Create a funded account
|
||||||
kts.accounts = simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, 1, math.NewInt(1000000000000))
|
kts.accounts = simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, 1, math.NewInt(1000000000000))
|
||||||
|
|
||||||
bond, err := kts.BondKeeper.CreateBond(ctx, kts.accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000000))))
|
bond, err := kts.BondKeeper.CreateBond(ctx, kts.accounts[0], sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(1000000000))))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,6 +60,8 @@ import (
|
|||||||
_ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank
|
_ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank
|
_ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
// package-wide network lock to only allow one test network at a time
|
// package-wide network lock to only allow one test network at a time
|
||||||
@ -148,8 +150,8 @@ func DefaultConfig(factory TestFixtureFactory) Config {
|
|||||||
TimeoutCommit: 2 * time.Second,
|
TimeoutCommit: 2 * time.Second,
|
||||||
ChainID: "chain-" + unsafe.Str(6),
|
ChainID: "chain-" + unsafe.Str(6),
|
||||||
NumValidators: 4,
|
NumValidators: 4,
|
||||||
BondDenom: sdk.DefaultBondDenom,
|
BondDenom: params.CoinUnit,
|
||||||
MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom),
|
MinGasPrices: fmt.Sprintf("0.000006%s", params.CoinUnit),
|
||||||
AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction),
|
AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction),
|
||||||
StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction),
|
StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction),
|
||||||
BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction),
|
BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction),
|
||||||
|
|||||||
@ -5,11 +5,12 @@ import (
|
|||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
|
|
||||||
sdkmath "cosmossdk.io/math"
|
sdkmath "cosmossdk.io/math"
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultMaxBondAmountTokens are the default parameter values.
|
// DefaultMaxBondAmountTokens are the default parameter values.
|
||||||
var DefaultMaxBondAmountTokens = sdkmath.NewInt(1000000000000) // 10^12 alnt
|
var DefaultMaxBondAmountTokens = sdkmath.NewInt(1000000000000) // 10^12
|
||||||
|
|
||||||
func NewParams(maxBondAmount sdk.Coin) Params {
|
func NewParams(maxBondAmount sdk.Coin) Params {
|
||||||
return Params{MaxBondAmount: maxBondAmount}
|
return Params{MaxBondAmount: maxBondAmount}
|
||||||
@ -17,7 +18,7 @@ func NewParams(maxBondAmount sdk.Coin) Params {
|
|||||||
|
|
||||||
// DefaultParams returns default module parameters
|
// DefaultParams returns default module parameters
|
||||||
func DefaultParams() Params {
|
func DefaultParams() Params {
|
||||||
return NewParams(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMaxBondAmountTokens))
|
return NewParams(sdk.NewCoin(params.CoinUnit, DefaultMaxBondAmountTokens))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate checks that the parameters have valid values
|
// Validate checks that the parameters have valid values
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/registry/helpers"
|
"git.vdb.to/cerc-io/laconicd/x/registry/helpers"
|
||||||
@ -295,7 +296,7 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo
|
|||||||
moduleParams.AuthorityAuctionCommitFee,
|
moduleParams.AuthorityAuctionCommitFee,
|
||||||
moduleParams.AuthorityAuctionRevealFee,
|
moduleParams.AuthorityAuctionRevealFee,
|
||||||
moduleParams.AuthorityAuctionMinimumBid,
|
moduleParams.AuthorityAuctionMinimumBid,
|
||||||
sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(0)),
|
sdk.NewCoin(params.CoinUnit, math.NewInt(0)),
|
||||||
0,
|
0,
|
||||||
ownerAddress,
|
ownerAddress,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -6,26 +6,28 @@ import (
|
|||||||
|
|
||||||
sdkmath "cosmossdk.io/math"
|
sdkmath "cosmossdk.io/math"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Default parameter values.
|
// Default parameter values.
|
||||||
var (
|
var (
|
||||||
// DefaultRecordRent is the default record rent for 1 time period (see expiry time).
|
// DefaultRecordRent is the default record rent for 1 time period (see expiry time).
|
||||||
DefaultRecordRent = sdkmath.NewInt(1000000) // 10^6 alnt
|
DefaultRecordRent = sdkmath.NewInt(1000000) // 10^6
|
||||||
|
|
||||||
// DefaultRecordExpiryTime is the default record expiry time (1 year).
|
// DefaultRecordExpiryTime is the default record expiry time (1 year).
|
||||||
DefaultRecordExpiryTime = time.Hour * 24 * 365
|
DefaultRecordExpiryTime = time.Hour * 24 * 365
|
||||||
|
|
||||||
DefaultAuthorityRent = sdkmath.NewInt(1000000) // 10^6 alnt
|
DefaultAuthorityRent = sdkmath.NewInt(1000000) // 10^6
|
||||||
DefaultAuthorityExpiryTime = time.Hour * 24 * 365
|
DefaultAuthorityExpiryTime = time.Hour * 24 * 365
|
||||||
DefaultAuthorityGracePeriod = time.Hour * 24 * 2
|
DefaultAuthorityGracePeriod = time.Hour * 24 * 2
|
||||||
|
|
||||||
DefaultAuthorityAuctionEnabled = false
|
DefaultAuthorityAuctionEnabled = false
|
||||||
DefaultCommitsDuration = time.Hour * 24
|
DefaultCommitsDuration = time.Hour * 24
|
||||||
DefaultRevealsDuration = time.Hour * 24
|
DefaultRevealsDuration = time.Hour * 24
|
||||||
DefaultCommitFee = sdkmath.NewInt(1000000) // 10^6 alnt
|
DefaultCommitFee = sdkmath.NewInt(1000000) // 10^6
|
||||||
DefaultRevealFee = sdkmath.NewInt(1000000) // 10^6 alnt
|
DefaultRevealFee = sdkmath.NewInt(1000000) // 10^6
|
||||||
DefaultMinimumBid = sdkmath.NewInt(5000000) // 5 * 10^6 alnt
|
DefaultMinimumBid = sdkmath.NewInt(5000000) // 5 * 10^6
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewParams creates a new Params instance
|
// NewParams creates a new Params instance
|
||||||
@ -60,13 +62,13 @@ func NewParams(
|
|||||||
// DefaultParams returns a default set of parameters.
|
// DefaultParams returns a default set of parameters.
|
||||||
func DefaultParams() Params {
|
func DefaultParams() Params {
|
||||||
return NewParams(
|
return NewParams(
|
||||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultRecordRent), DefaultRecordExpiryTime,
|
sdk.NewCoin(params.CoinUnit, DefaultRecordRent), DefaultRecordExpiryTime,
|
||||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultAuthorityRent),
|
sdk.NewCoin(params.CoinUnit, DefaultAuthorityRent),
|
||||||
DefaultAuthorityExpiryTime, DefaultAuthorityGracePeriod, DefaultAuthorityAuctionEnabled, DefaultCommitsDuration,
|
DefaultAuthorityExpiryTime, DefaultAuthorityGracePeriod, DefaultAuthorityAuctionEnabled, DefaultCommitsDuration,
|
||||||
DefaultRevealsDuration,
|
DefaultRevealsDuration,
|
||||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultCommitFee),
|
sdk.NewCoin(params.CoinUnit, DefaultCommitFee),
|
||||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultRevealFee),
|
sdk.NewCoin(params.CoinUnit, DefaultRevealFee),
|
||||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinimumBid),
|
sdk.NewCoin(params.CoinUnit, DefaultMinimumBid),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
51
x/types/v1/lockup.go
Normal file
51
x/types/v1/lockup.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ authtypes.GenesisAccount = (*LockupAccount)(nil)
|
||||||
|
_ LockupAccountI = (*LockupAccount)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
// LockupAccountI defines an account interface for lockup account with token distribution
|
||||||
|
type LockupAccountI interface {
|
||||||
|
sdk.ModuleAccountI
|
||||||
|
|
||||||
|
GetDistribution() string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate checks for errors on the account fields
|
||||||
|
func (la LockupAccount) Validate() error {
|
||||||
|
if la.BaseAccount == nil {
|
||||||
|
return errors.New("uninitialized LockupAccount: BaseAccount is nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
return la.BaseAccount.Validate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasPermission returns whether or not the account has permission.
|
||||||
|
// Return false as the lockup account doesn't have any permissions
|
||||||
|
func (la LockupAccount) HasPermission(permission string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetName returns the name of the holder's module
|
||||||
|
func (la LockupAccount) GetName() string {
|
||||||
|
return la.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPermissions returns permissions granted to the module account
|
||||||
|
// Return empty as the lockup account doesn't have any permissions
|
||||||
|
func (la LockupAccount) GetPermissions() []string {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDistribution returns the total token distribution
|
||||||
|
func (la LockupAccount) GetDistribution() string {
|
||||||
|
return la.Distribution
|
||||||
|
}
|
||||||
422
x/types/v1/lockup.pb.go
Normal file
422
x/types/v1/lockup.pb.go
Normal file
@ -0,0 +1,422 @@
|
|||||||
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
|
// source: cerc/types/v1/lockup.proto
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
fmt "fmt"
|
||||||
|
_ "github.com/cosmos/cosmos-proto"
|
||||||
|
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
||||||
|
types "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||||
|
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
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
*types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3,embedded=base_account" 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 (m *LockupAccount) Reset() { *m = LockupAccount{} }
|
||||||
|
func (m *LockupAccount) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*LockupAccount) ProtoMessage() {}
|
||||||
|
func (*LockupAccount) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_8fa58dc19f6348bf, []int{0}
|
||||||
|
}
|
||||||
|
func (m *LockupAccount) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *LockupAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_LockupAccount.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 *LockupAccount) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_LockupAccount.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *LockupAccount) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *LockupAccount) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_LockupAccount.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_LockupAccount proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*LockupAccount)(nil), "cerc.types.v1.LockupAccount")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("cerc/types/v1/lockup.proto", fileDescriptor_8fa58dc19f6348bf) }
|
||||||
|
|
||||||
|
var fileDescriptor_8fa58dc19f6348bf = []byte{
|
||||||
|
// 335 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0x4e, 0x2d, 0x4a,
|
||||||
|
0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0xcf, 0xc9, 0x4f, 0xce, 0x2e, 0x2d,
|
||||||
|
0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0xc9, 0xe9, 0x81, 0xe5, 0xf4, 0xca, 0x0c,
|
||||||
|
0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x85, 0x94, 0x64, 0x72, 0x7e,
|
||||||
|
0x71, 0x6e, 0x7e, 0x71, 0x3c, 0x98, 0xa7, 0x0f, 0xe1, 0x40, 0xa5, 0xe4, 0x20, 0x3c, 0xfd, 0xc4,
|
||||||
|
0xd2, 0x92, 0x0c, 0xfd, 0x32, 0xc3, 0xa4, 0xd4, 0x92, 0x44, 0x43, 0x30, 0x07, 0x2a, 0x2f, 0x92,
|
||||||
|
0x9e, 0x9f, 0x9e, 0x0f, 0xd1, 0x07, 0x62, 0x41, 0x44, 0x95, 0xba, 0x99, 0xb8, 0x78, 0x7d, 0xc0,
|
||||||
|
0x6e, 0x70, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x11, 0xf2, 0xe4, 0xe2, 0x49, 0x4a, 0x2c, 0x4e,
|
||||||
|
0x8d, 0x4f, 0x84, 0xf0, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x14, 0xf4, 0xa0, 0x96, 0x81,
|
||||||
|
0x4d, 0x84, 0x1a, 0xaf, 0xe7, 0x94, 0x58, 0x9c, 0x0a, 0xd5, 0xe7, 0xc4, 0x72, 0xe1, 0x9e, 0x3c,
|
||||||
|
0x63, 0x10, 0x77, 0x12, 0x42, 0x48, 0x48, 0x88, 0x8b, 0x25, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x49,
|
||||||
|
0x81, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x16, 0x52, 0xe2, 0xe2, 0x49, 0xc9, 0x2c, 0x2e, 0x29, 0xca,
|
||||||
|
0x4c, 0x2a, 0x2d, 0xc9, 0xcc, 0xcf, 0x93, 0x60, 0x06, 0xcb, 0xa1, 0x88, 0x59, 0x95, 0x77, 0x2c,
|
||||||
|
0x90, 0x67, 0x38, 0xb5, 0x45, 0x57, 0x09, 0x9b, 0x9d, 0xbe, 0xf9, 0x29, 0xa5, 0x39, 0x30, 0x2b,
|
||||||
|
0x3c, 0x4f, 0x6d, 0xd1, 0x95, 0x41, 0x09, 0x35, 0x3d, 0x14, 0xdf, 0x78, 0x76, 0x3d, 0xdf, 0xa0,
|
||||||
|
0x25, 0x9a, 0x93, 0x98, 0x9c, 0x9f, 0x97, 0x99, 0xac, 0x8f, 0x22, 0x35, 0xe9, 0xf9, 0x06, 0x2d,
|
||||||
|
0x3e, 0x48, 0xf0, 0xc3, 0xfc, 0xea, 0xe4, 0x70, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c,
|
||||||
|
0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72,
|
||||||
|
0x0c, 0x51, 0x6a, 0xe9, 0x99, 0x25, 0x7a, 0x65, 0x29, 0x49, 0x7a, 0xa0, 0x60, 0x4f, 0x2d, 0x4a,
|
||||||
|
0xd6, 0xcd, 0xcc, 0xd7, 0x87, 0x1a, 0x9b, 0xa2, 0x5f, 0x01, 0x8f, 0xcf, 0x24, 0x36, 0x70, 0xb0,
|
||||||
|
0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x89, 0x9d, 0x6b, 0xe7, 0x01, 0x00, 0x00,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LockupAccount) 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 *LockupAccount) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LockupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.Distribution) > 0 {
|
||||||
|
i -= len(m.Distribution)
|
||||||
|
copy(dAtA[i:], m.Distribution)
|
||||||
|
i = encodeVarintLockup(dAtA, i, uint64(len(m.Distribution)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x1a
|
||||||
|
}
|
||||||
|
if len(m.Name) > 0 {
|
||||||
|
i -= len(m.Name)
|
||||||
|
copy(dAtA[i:], m.Name)
|
||||||
|
i = encodeVarintLockup(dAtA, i, uint64(len(m.Name)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
|
}
|
||||||
|
if m.BaseAccount != nil {
|
||||||
|
{
|
||||||
|
size, err := m.BaseAccount.MarshalToSizedBuffer(dAtA[:i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintLockup(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func encodeVarintLockup(dAtA []byte, offset int, v uint64) int {
|
||||||
|
offset -= sovLockup(v)
|
||||||
|
base := offset
|
||||||
|
for v >= 1<<7 {
|
||||||
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
|
v >>= 7
|
||||||
|
offset++
|
||||||
|
}
|
||||||
|
dAtA[offset] = uint8(v)
|
||||||
|
return base
|
||||||
|
}
|
||||||
|
func (m *LockupAccount) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if m.BaseAccount != nil {
|
||||||
|
l = m.BaseAccount.Size()
|
||||||
|
n += 1 + l + sovLockup(uint64(l))
|
||||||
|
}
|
||||||
|
l = len(m.Name)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovLockup(uint64(l))
|
||||||
|
}
|
||||||
|
l = len(m.Distribution)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovLockup(uint64(l))
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func sovLockup(x uint64) (n int) {
|
||||||
|
return (math_bits.Len64(x|1) + 6) / 7
|
||||||
|
}
|
||||||
|
func sozLockup(x uint64) (n int) {
|
||||||
|
return sovLockup(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||||
|
}
|
||||||
|
func (m *LockupAccount) 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 ErrIntOverflowLockup
|
||||||
|
}
|
||||||
|
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: LockupAccount: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: LockupAccount: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowLockup
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if m.BaseAccount == nil {
|
||||||
|
m.BaseAccount = &types.BaseAccount{}
|
||||||
|
}
|
||||||
|
if err := m.BaseAccount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 2:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowLockup
|
||||||
|
}
|
||||||
|
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 ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Name = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 3:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Distribution", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowLockup
|
||||||
|
}
|
||||||
|
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 ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Distribution = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipLockup(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func skipLockup(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, ErrIntOverflowLockup
|
||||||
|
}
|
||||||
|
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, ErrIntOverflowLockup
|
||||||
|
}
|
||||||
|
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, ErrIntOverflowLockup
|
||||||
|
}
|
||||||
|
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, ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
iNdEx += length
|
||||||
|
case 3:
|
||||||
|
depth++
|
||||||
|
case 4:
|
||||||
|
if depth == 0 {
|
||||||
|
return 0, ErrUnexpectedEndOfGroupLockup
|
||||||
|
}
|
||||||
|
depth--
|
||||||
|
case 5:
|
||||||
|
iNdEx += 4
|
||||||
|
default:
|
||||||
|
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||||
|
}
|
||||||
|
if iNdEx < 0 {
|
||||||
|
return 0, ErrInvalidLengthLockup
|
||||||
|
}
|
||||||
|
if depth == 0 {
|
||||||
|
return iNdEx, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrInvalidLengthLockup = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||||
|
ErrIntOverflowLockup = fmt.Errorf("proto: integer overflow")
|
||||||
|
ErrUnexpectedEndOfGroupLockup = fmt.Errorf("proto: unexpected end of group")
|
||||||
|
)
|
||||||
Loading…
Reference in New Issue
Block a user