mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
Compare commits
67 Commits
e3b7446a05
...
be505a4c58
Author | SHA1 | Date | |
---|---|---|---|
|
be505a4c58 | ||
|
a8f86c0323 | ||
|
8ddc417cdd | ||
|
3bf0284b7b | ||
|
ffba5f7dda | ||
|
853475212d | ||
|
5a809d89ec | ||
|
9850e9f84b | ||
|
22bcf1f42f | ||
|
1adfdbbc65 | ||
|
97c3288fd3 | ||
|
468fe2921e | ||
|
f7a161fe2f | ||
|
ac3615dec3 | ||
|
131ffdd5b0 | ||
|
d988008147 | ||
|
76dcb302f9 | ||
|
abfc340038 | ||
|
00793ac89d | ||
|
8060c74e83 | ||
|
d3c5892b23 | ||
|
afb82c30d4 | ||
|
446766c46c | ||
|
481dec4d5c | ||
|
625f5e3c13 | ||
|
0eccd071a0 | ||
|
2468ab5c31 | ||
|
86cfde7e71 | ||
|
e65b8b083a | ||
|
379fd4824b | ||
|
845bbd07be | ||
|
86e2ff6009 | ||
|
1b5006798e | ||
|
74cf381b7d | ||
|
1e9019bc99 | ||
|
d47ecbca2e | ||
|
75d64b62ce | ||
|
4e1fad319b | ||
|
c3f48c00e0 | ||
|
1f4070f487 | ||
|
8999139ddf | ||
|
73668e408a | ||
|
6156a90b39 | ||
|
3d047f3d79 | ||
|
c91033bc90 | ||
|
06fd616af5 | ||
|
fde0ac7ef1 | ||
|
03c068a883 | ||
|
30af237cf8 | ||
|
23e99d5335 | ||
|
4b46d8da1b | ||
|
0f66d8bcc3 | ||
|
4297939e0b | ||
|
78d1f13a93 | ||
|
4de4b68869 | ||
|
a373109916 | ||
|
ed275dcdae | ||
|
ea01bc63be | ||
|
4113a57a36 | ||
|
84921d5c99 | ||
|
782558468f | ||
|
58f852b36c | ||
|
319c2ce3ae | ||
|
ad13c849bd | ||
|
4efd6c0b19 | ||
|
3d3eef4cbc | ||
|
d4faca5f99 |
@ -80,7 +80,7 @@ printf "original evm util module params\n %s" , "$originalEvmUtilParams"
|
||||
# change the params of the chain like a god - make it so 🖖🏽
|
||||
# make sure to update god committee member permissions for the module
|
||||
# and params being updated (see below for example)
|
||||
# https://github.com/Kava-Labs/kava/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903
|
||||
# https://github.com/0glabs/0g-chain/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903
|
||||
kava tx committee submit-proposal 1 "$proposalFileName" --gas 2000000 --gas-prices 0.01ukava --from god -y
|
||||
|
||||
# fetch current module params
|
||||
|
2
.github/scripts/seed-internal-testnet.sh
vendored
2
.github/scripts/seed-internal-testnet.sh
vendored
@ -155,7 +155,7 @@ printf "original evm util module params\n %s" , "$originalEvmUtilParams"
|
||||
# change the params of the chain like a god - make it so 🖖🏽
|
||||
# make sure to update god committee member permissions for the module
|
||||
# and params being updated (see below for example)
|
||||
# https://github.com/Kava-Labs/kava/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903
|
||||
# https://github.com/0glabs/0g-chain/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903
|
||||
# committee 1 is the stability committee. on internal testnet, this has only one member.
|
||||
kava tx committee submit-proposal 1 "$proposalFileName" --gas 2000000 --gas-prices 0.01ukava --from god -y
|
||||
|
||||
|
2
.github/scripts/seed-protonet.sh
vendored
2
.github/scripts/seed-protonet.sh
vendored
@ -147,7 +147,7 @@ printf "original evm util module params\n %s" , "$originalEvmUtilParams"
|
||||
# change the params of the chain like a god - make it so 🖖🏽
|
||||
# make sure to update god committee member permissions for the module
|
||||
# and params being updated (see below for example)
|
||||
# https://github.com/Kava-Labs/kava/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903
|
||||
# https://github.com/0glabs/0g-chain/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903
|
||||
kava tx committee submit-proposal 1 "$proposalFileName" --gas 2000000 --gas-prices 0.01ukava --from god -y
|
||||
|
||||
# vote on the proposal. this assumes no other committee proposal has ever been submitted (id=1)
|
||||
|
25
.github/workflows/upload-release-assets.yml
vendored
Normal file
25
.github/workflows/upload-release-assets.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: Upload Release Assets
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20'
|
||||
- name: Build
|
||||
run: make build
|
||||
- name: Rename file
|
||||
run: mv ./out/linux/0gchaind ./out/linux/0gchaind-linux-${{ github.ref_name }}
|
||||
- name: Upload Release Asset
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: ./out/linux/0gchaind-linux-${{ github.ref_name }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ZG_UPLOAD_ASSET }}
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -41,3 +41,8 @@ build/linux
|
||||
# Go workspace files
|
||||
go.work
|
||||
go.work.sum
|
||||
.build/0gchaind
|
||||
.build/da
|
||||
|
||||
# runtime
|
||||
run
|
||||
|
12
CHANGELOG.md
12
CHANGELOG.md
@ -36,6 +36,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v0.25.0]
|
||||
|
||||
### Features
|
||||
|
||||
- (community) [#1704] Add module params
|
||||
@ -59,7 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
- (community) [#1755] Keep funds in `x/community` in `CommunityPoolLendWithdrawProposal` handler
|
||||
- (staking) [#1761] Set validator minimum commission to 5% for all validators under 5%
|
||||
|
||||
## [v0.24.1](https://github.com/Kava-Labs/kava/releases/tag/v0.24.1)
|
||||
## [v0.24.1]
|
||||
|
||||
### Features
|
||||
- (metrics) [#1668] Adds non-state breaking x/metrics module for custom telemetry.
|
||||
@ -359,8 +361,12 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md).
|
||||
[#750]: https://github.com/Kava-Labs/kava/pull/750
|
||||
[#751]: https://github.com/Kava-Labs/kava/pull/751
|
||||
[#780]: https://github.com/Kava-Labs/kava/pull/780
|
||||
[unreleased]: https://github.com/Kava-Labs/kava/compare/v0.24.0...HEAD
|
||||
[v0.24.0]: https://github.com/Kava-Labs/kava/compare/v0.24.0...v0.23.2
|
||||
|
||||
[unreleased]: https://github.com/Kava-Labs/kava/compare/v0.25.0...HEAD
|
||||
|
||||
[v0.25.0]: https://github.com/Kava-Labs/kava/compare/v0.24.1...v0.25.0
|
||||
[v0.24.1]: https://github.com/Kava-Labs/kava/compare/v0.24.0...v0.24.1
|
||||
[v0.24.0]: https://github.com/Kava-Labs/kava/compare/v0.23.2...v0.24.0
|
||||
[v0.23.2]: https://github.com/Kava-Labs/kava/compare/v0.23.1...v0.23.2
|
||||
[v0.23.1]: https://github.com/Kava-Labs/kava/compare/v0.23.0...v0.23.1
|
||||
[v0.23.0]: https://github.com/Kava-Labs/kava/compare/v0.21.1...v0.23.0
|
||||
|
@ -7,7 +7,7 @@ FROM golang:1.20-alpine AS build-env
|
||||
RUN apk add bash git make libc-dev gcc linux-headers eudev-dev jq curl
|
||||
|
||||
# Set working directory for the build
|
||||
WORKDIR /root/kava
|
||||
WORKDIR /root/0g-chain
|
||||
# default home directory is /root
|
||||
|
||||
# Copy dependency files first to facilitate dependency caching
|
||||
@ -32,6 +32,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
FROM alpine:3.15
|
||||
|
||||
RUN apk add bash jq curl
|
||||
COPY --from=build-env /go/bin/kava /bin/kava
|
||||
COPY --from=build-env /go/bin/0gchaind /bin/0gchaind
|
||||
|
||||
CMD ["kava"]
|
||||
CMD ["0gchaind"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM golang:1.20-bullseye AS kava-builder
|
||||
FROM golang:1.20-bullseye AS chain-builder
|
||||
|
||||
# Set up dependencies
|
||||
RUN apt-get update \
|
||||
@ -19,7 +19,7 @@ RUN git clone https://github.com/facebook/rocksdb.git \
|
||||
&& make -j$(nproc) install-shared \
|
||||
&& ldconfig
|
||||
|
||||
WORKDIR /root/kava
|
||||
WORKDIR /root/0gchain
|
||||
# Copy dependency files first to facilitate dependency caching
|
||||
COPY ./go.mod ./
|
||||
COPY ./go.sum ./
|
||||
@ -32,13 +32,13 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
# Add source files
|
||||
COPY . .
|
||||
|
||||
ARG kava_database_backend=rocksdb
|
||||
ENV KAVA_DATABASE_BACKEND=$kava_database_backend
|
||||
ARG 0gchain_database_backend=rocksdb
|
||||
ENV 0GCHAIN_DATABASE_BACKEND=$0gchain_database_backend
|
||||
|
||||
# Mount go build and mod caches as container caches, persisted between builder invocations
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
make install COSMOS_BUILD_OPTIONS=$KAVA_DATABASE_BACKEND
|
||||
make install COSMOS_BUILD_OPTIONS=$0GCHAIN_DATABASE_BACKEND
|
||||
|
||||
|
||||
FROM ubuntu:22.04
|
||||
@ -48,10 +48,10 @@ RUN apt-get update \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# copy rocksdb shared objects
|
||||
COPY --from=kava-builder /usr/local/lib/ /usr/local/lib/
|
||||
COPY --from=chain-builder /usr/local/lib/ /usr/local/lib/
|
||||
RUN ldconfig
|
||||
|
||||
# copy kava binary
|
||||
COPY --from=kava-builder /go/bin/kava /bin/kava
|
||||
# copy 0g-chain binary
|
||||
COPY --from=chain-builder /go/bin/0gchaind /bin/0gchaind
|
||||
|
||||
CMD ["kava"]
|
||||
CMD ["0gchaind"]
|
||||
|
45
Makefile
45
Makefile
@ -1,8 +1,10 @@
|
||||
################################################################################
|
||||
### Project Info ###
|
||||
################################################################################
|
||||
PROJECT_NAME := kava# unique namespace for project
|
||||
|
||||
PROJECT_NAME := 0g-chain# unique namespace for project
|
||||
BINARY_NAME := 0gchaind
|
||||
MAIN_ENTRY := ./cmd/$(BINARY_NAME)
|
||||
DOCKER_IMAGE_NAME := 0glabs/$(PROJECT_NAME)
|
||||
GO_BIN ?= go
|
||||
|
||||
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||
@ -37,7 +39,7 @@ print-git-info:
|
||||
|
||||
.PHONY: print-version
|
||||
print-version:
|
||||
@echo "kava $(VERSION)\ntendermint $(TENDERMINT_VERSION)\ncosmos $(COSMOS_SDK_VERSION)"
|
||||
@echo "$(BINARY_NAME) $(VERSION)\ntendermint $(TENDERMINT_VERSION)\ncosmos $(COSMOS_SDK_VERSION)"
|
||||
|
||||
################################################################################
|
||||
### Project Settings ###
|
||||
@ -45,7 +47,7 @@ print-version:
|
||||
LEDGER_ENABLED ?= true
|
||||
DOCKER:=docker
|
||||
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
|
||||
HTTPS_GIT := https://github.com/Kava-Labs/kava.git
|
||||
HTTPS_GIT := https://github.com/0glabs/0g-chain.git
|
||||
|
||||
################################################################################
|
||||
### Machine Info ###
|
||||
@ -76,7 +78,7 @@ print-machine-info:
|
||||
BUILD_DIR := build# build files
|
||||
BIN_DIR := $(BUILD_DIR)/bin# for binary dev dependencies
|
||||
BUILD_CACHE_DIR := $(BUILD_DIR)/.cache# caching for non-artifact outputs
|
||||
OUT_DIR := out# for artifact intermediates and outputs
|
||||
OUT_DIR := ./.build# for artifact intermediates and outputs
|
||||
|
||||
ROOT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))# absolute path to root
|
||||
export PATH := $(ROOT_DIR)/$(BIN_DIR):$(PATH)# add local bin first in path
|
||||
@ -142,8 +144,8 @@ build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
|
||||
|
||||
# process linker flags
|
||||
|
||||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=kava \
|
||||
-X github.com/cosmos/cosmos-sdk/version.AppName=kava \
|
||||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(PROJECT_NAME) \
|
||||
-X github.com/cosmos/cosmos-sdk/version.AppName=$(PROJECT_NAME) \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION_NUMBER) \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_COMMIT) \
|
||||
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
|
||||
@ -188,16 +190,16 @@ all: install
|
||||
|
||||
build: go.sum
|
||||
ifeq ($(OS), Windows_NT)
|
||||
$(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava.exe ./cmd/kava
|
||||
$(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/$(BINARY_NAME).exe $(MAIN_ENTRY)
|
||||
else
|
||||
$(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava ./cmd/kava
|
||||
$(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/$(BINARY_NAME) $(MAIN_ENTRY)
|
||||
endif
|
||||
|
||||
build-linux: go.sum
|
||||
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
|
||||
|
||||
install: go.sum
|
||||
$(GO_BIN) install -mod=readonly $(BUILD_FLAGS) ./cmd/kava
|
||||
$(GO_BIN) install -mod=readonly $(BUILD_FLAGS) $(MAIN_ENTRY)
|
||||
|
||||
########################################
|
||||
### Tools & dependencies
|
||||
@ -219,6 +221,7 @@ go.sum: go.mod
|
||||
# Set to exclude riot links as they trigger false positives
|
||||
link-check:
|
||||
@$(GO_BIN) get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3
|
||||
# TODO: replace kava in following line with project name
|
||||
liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*|^https://kava3.data.kava.io*|^https://ipfs.io*|^https://apps.apple.com*|^https://kava.quicksync.io*"
|
||||
|
||||
|
||||
@ -233,26 +236,26 @@ format:
|
||||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs misspell -w
|
||||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/tendermint
|
||||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk
|
||||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/kava-labs/kava
|
||||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/0glabs/0g-chain
|
||||
.PHONY: format
|
||||
|
||||
###############################################################################
|
||||
### Localnet ###
|
||||
###############################################################################
|
||||
|
||||
# Build docker image and tag as kava/kava:local
|
||||
# Build docker image and tag as 0glabs/0g-chain:local
|
||||
docker-build:
|
||||
DOCKER_BUILDKIT=1 $(DOCKER) build -t kava/kava:local .
|
||||
DOCKER_BUILDKIT=1 $(DOCKER) build -t $(DOCKER_IMAGE_NAME):local .
|
||||
|
||||
docker-build-rocksdb:
|
||||
DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile-rocksdb -t kava/kava:local .
|
||||
DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile-rocksdb -t $(DOCKER_IMAGE_NAME):local .
|
||||
|
||||
build-docker-local-kava:
|
||||
build-docker-local-0gchain:
|
||||
@$(MAKE) -C networks/local
|
||||
|
||||
# Run a 4-node testnet locally
|
||||
localnet-start: build-linux localnet-stop
|
||||
@if ! [ -f build/node0/kvd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/kvd:Z kava/kavanode testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
|
||||
@if ! [ -f build/node0/kvd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/kvd:Z $(DOCKER_IMAGE_NAME)-node testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
|
||||
docker-compose up -d
|
||||
|
||||
localnet-stop:
|
||||
@ -261,7 +264,7 @@ localnet-stop:
|
||||
# Launch a new single validator chain
|
||||
start:
|
||||
./contrib/devnet/init-new-chain.sh
|
||||
kava start
|
||||
$(BINARY_NAME) start
|
||||
|
||||
#proto-format:
|
||||
#@echo "Formatting Protobuf files"
|
||||
@ -302,7 +305,7 @@ test:
|
||||
@$(GO_BIN) test $$($(GO_BIN) list ./... | grep -v 'contrib' | grep -v 'tests/e2e')
|
||||
|
||||
test-rocksdb:
|
||||
@go test -tags=rocksdb ./cmd/kava/opendb
|
||||
@go test -tags=rocksdb $(MAIN_ENTRY)/opendb
|
||||
|
||||
# Run cli integration tests
|
||||
# `-p 4` to use 4 cores, `-tags cli_test` to tell $(GO_BIN) not to ignore the cli package
|
||||
@ -318,15 +321,15 @@ test-migrate:
|
||||
# This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3
|
||||
start-remote-sims:
|
||||
# build the image used for running sims in, and tag it
|
||||
docker build -f simulations/Dockerfile -t kava/kava-sim:master .
|
||||
docker build -f simulations/Dockerfile -t $(DOCKER_IMAGE_NAME)-sim:master .
|
||||
# push that image to the hub
|
||||
docker push kava/kava-sim:master
|
||||
docker push $(DOCKER_IMAGE_NAME)-sim:master
|
||||
# submit an array job on AWS Batch, using 1000 seeds, spot instances
|
||||
aws batch submit-job \
|
||||
-—job-name "master-$(VERSION)" \
|
||||
-—job-queue “simulation-1-queue-spot" \
|
||||
-—array-properties size=1000 \
|
||||
-—job-definition kava-sim-master \
|
||||
-—job-definition $(BINARY_NAME)-sim-master \
|
||||
-—container-override environment=[{SIM_NAME=master-$(VERSION)}]
|
||||
|
||||
update-kvtool:
|
||||
|
28
README.md
28
README.md
@ -1,36 +1,29 @@
|
||||
<!---
|
||||
<p align="center">
|
||||
<img src="./kava-logo.svg" width="300">
|
||||
<img src="./0g-logo.svg" width="300">
|
||||
</p>
|
||||
--->
|
||||
|
||||
# 0G Chain
|
||||
|
||||
<div align="center">
|
||||
|
||||
[![version](https://img.shields.io/github/tag/kava-labs/kava.svg)](https://github.com/kava-labs/kava/releases/latest)
|
||||
[![CircleCI](https://circleci.com/gh/Kava-Labs/kava/tree/master.svg?style=shield)](https://circleci.com/gh/Kava-Labs/kava/tree/master)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/kava-labs/kava)](https://goreportcard.com/report/github.com/kava-labs/kava)
|
||||
[![API Reference](https://godoc.org/github.com/Kava-Labs/kava?status.svg)](https://godoc.org/github.com/Kava-Labs/kava)
|
||||
[![GitHub](https://img.shields.io/github/license/kava-labs/kava.svg)](https://github.com/Kava-Labs/kava/blob/master/LICENSE.md)
|
||||
[![Twitter Follow](https://img.shields.io/twitter/follow/KAVA_CHAIN.svg?label=Follow&style=social)](https://twitter.com/KAVA_CHAIN)
|
||||
[![Discord Chat](https://img.shields.io/discord/704389840614981673.svg)](https://discord.com/invite/kQzh3Uv)
|
||||
### [Telegram](https://t.me/web3_0glabs) | [Discord](https://discord.com/invite/0glabs)
|
||||
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
|
||||
### [Telegram](https://t.me/kavalabs) | [Medium](https://medium.com/kava-labs) | [Discord](https://discord.gg/JJYnuCx)
|
||||
|
||||
</div>
|
||||
|
||||
Reference implementation of Kava, a blockchain for cross-chain DeFi. Built using the [cosmos-sdk](https://github.com/cosmos/cosmos-sdk).
|
||||
Reference implementation of 0G Chain, the first modular AI chain. Built using the [cosmos-sdk](https://github.com/cosmos/cosmos-sdk).
|
||||
|
||||
<!---
|
||||
## Mainnet
|
||||
|
||||
The current recommended version of the software for mainnet is [v0.24.1](https://github.com/Kava-Labs/kava/releases/tag/v0.24.1). The master branch of this repository often contains considerable development work since the last mainnet release and is __not__ runnable on mainnet.
|
||||
The current recommended version of the software for mainnet is [v0.25.0](https://github.com/Kava-Labs/kava/releases/tag/v0.25.0) The master branch of this repository often contains considerable development work since the last mainnet release and is __not__ runnable on mainnet.
|
||||
|
||||
### Installation and Setup
|
||||
For detailed instructions see [the Kava docs](https://docs.kava.io/docs/participate/validator-node).
|
||||
|
||||
```bash
|
||||
git checkout v0.24.1
|
||||
git checkout v0.25.0
|
||||
make install
|
||||
```
|
||||
|
||||
@ -63,3 +56,4 @@ If you find a security issue, please report it to security [at] kava.io. Dependi
|
||||
Copyright © Kava Labs, Inc. All rights reserved.
|
||||
|
||||
Licensed under the [Apache v2 License](LICENSE.md).
|
||||
--->
|
@ -32,15 +32,10 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
|
||||
"github.com/kava-labs/kava/x/auction"
|
||||
"github.com/kava-labs/kava/x/bep3"
|
||||
"github.com/kava-labs/kava/x/cdp"
|
||||
"github.com/kava-labs/kava/x/committee"
|
||||
"github.com/kava-labs/kava/x/incentive"
|
||||
"github.com/kava-labs/kava/x/kavadist"
|
||||
"github.com/kava-labs/kava/x/pricefeed"
|
||||
"github.com/kava-labs/kava/x/swap"
|
||||
validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
|
||||
"github.com/0glabs/0g-chain/x/bep3"
|
||||
"github.com/0glabs/0g-chain/x/committee"
|
||||
"github.com/0glabs/0g-chain/x/pricefeed"
|
||||
validatorvesting "github.com/0glabs/0g-chain/x/validator-vesting"
|
||||
)
|
||||
|
||||
type StoreKeysPrefixes struct {
|
||||
|
@ -8,7 +8,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -51,9 +52,9 @@ func (suite *SimulateRequestTestSuite) TearDownTest() {
|
||||
}
|
||||
|
||||
func (suite *SimulateRequestTestSuite) TestSimulateRequest() {
|
||||
fromAddr, err := sdk.AccAddressFromBech32("kava1esagqd83rhqdtpy5sxhklaxgn58k2m3s3mnpea")
|
||||
fromAddr, err := sdk.AccAddressFromBech32("0g1esagqd83rhqdtpy5sxhklaxgn58k2m3s3mnpea")
|
||||
suite.Require().NoError(err)
|
||||
toAddr, err := sdk.AccAddressFromBech32("kava1mq9qxlhze029lm0frzw2xr6hem8c3k9ts54w0w")
|
||||
toAddr, err := sdk.AccAddressFromBech32("0g1mq9qxlhze029lm0frzw2xr6hem8c3k9ts54w0w")
|
||||
suite.Require().NoError(err)
|
||||
|
||||
simRequest := app.SimulateRequest{
|
||||
@ -61,11 +62,11 @@ func (suite *SimulateRequestTestSuite) TestSimulateRequest() {
|
||||
bank.MsgSend{
|
||||
FromAddress: fromAddr,
|
||||
ToAddress: toAddr,
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e6)),
|
||||
},
|
||||
},
|
||||
Fee: auth.StdFee{
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(5e4))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(5e4)),
|
||||
Gas: 1e6,
|
||||
},
|
||||
Memo: "test memo",
|
||||
|
@ -21,13 +21,14 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmdb "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
bep3types "github.com/kava-labs/kava/x/bep3/types"
|
||||
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
bep3types "github.com/0glabs/0g-chain/x/bep3/types"
|
||||
pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
app.SetSDKConfig()
|
||||
chaincfg.SetSDKConfig()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
@ -52,7 +53,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
App: *app.NewApp(
|
||||
log.NewNopLogger(),
|
||||
tmdb.NewMemDB(),
|
||||
app.DefaultNodeHome,
|
||||
chaincfg.DefaultNodeHome,
|
||||
nil,
|
||||
encodingConfig,
|
||||
opts,
|
||||
@ -65,7 +66,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
chainID,
|
||||
app.NewFundedGenStateWithSameCoins(
|
||||
tApp.AppCodec(),
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 1e9)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e9)),
|
||||
testAddresses,
|
||||
),
|
||||
newBep3GenStateMulti(tApp.AppCodec(), deputy),
|
||||
@ -113,7 +114,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
tc.address,
|
||||
testAddresses[0],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 1_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1_000_000)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
|
@ -10,8 +10,9 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/app/ante"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
var _ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle
|
||||
@ -45,7 +46,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_NotCheckTx(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100_000_000)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
@ -80,12 +81,12 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Pass(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[2],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
@ -121,7 +122,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Reject(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
|
@ -14,8 +14,9 @@ import (
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/app/ante"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
func newMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a authz.Authorization, expiration time.Time) *authz.MsgGrant {
|
||||
@ -58,7 +59,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
),
|
||||
},
|
||||
checkTx: false,
|
||||
@ -128,7 +129,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
[]sdk.Msg{banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[3],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
)}),
|
||||
},
|
||||
checkTx: false,
|
||||
@ -161,7 +162,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[3],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
),
|
||||
&evmtypes.MsgEthereumTx{},
|
||||
},
|
||||
|
@ -33,13 +33,12 @@ import (
|
||||
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
cdptypes "github.com/kava-labs/kava/x/cdp/types"
|
||||
evmutilkeeper "github.com/kava-labs/kava/x/evmutil/keeper"
|
||||
evmutiltestutil "github.com/kava-labs/kava/x/evmutil/testutil"
|
||||
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
|
||||
hardtypes "github.com/kava-labs/kava/x/hard/types"
|
||||
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper"
|
||||
evmutiltestutil "github.com/0glabs/0g-chain/x/evmutil/testutil"
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -157,7 +156,7 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
// Genesis states
|
||||
evmGs := evmtypes.NewGenesisState(
|
||||
evmtypes.NewParams(
|
||||
"akava", // evmDenom
|
||||
chaincfg.EvmDenom, // evmDenom
|
||||
false, // allowedUnprotectedTxs
|
||||
true, // enableCreate
|
||||
true, // enableCall
|
||||
@ -172,47 +171,6 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
feemarketGenesis.Params.EnableHeight = 1
|
||||
feemarketGenesis.Params.NoBaseFee = false
|
||||
|
||||
cdpGenState := cdptypes.DefaultGenesisState()
|
||||
cdpGenState.Params.GlobalDebtLimit = sdk.NewInt64Coin("usdx", 53000000000000)
|
||||
cdpGenState.Params.CollateralParams = cdptypes.CollateralParams{
|
||||
{
|
||||
Denom: USDCCoinDenom,
|
||||
Type: USDCCDPType,
|
||||
LiquidationRatio: sdk.MustNewDecFromStr("1.01"),
|
||||
DebtLimit: sdk.NewInt64Coin("usdx", 500000000000),
|
||||
StabilityFee: sdk.OneDec(),
|
||||
AuctionSize: sdkmath.NewIntFromUint64(10000000000),
|
||||
LiquidationPenalty: sdk.MustNewDecFromStr("0.05"),
|
||||
CheckCollateralizationIndexCount: sdkmath.NewInt(10),
|
||||
KeeperRewardPercentage: sdk.MustNewDecFromStr("0.01"),
|
||||
SpotMarketID: "usdc:usd",
|
||||
LiquidationMarketID: "usdc:usd:30",
|
||||
ConversionFactor: sdkmath.NewInt(18),
|
||||
},
|
||||
}
|
||||
|
||||
hardGenState := hardtypes.DefaultGenesisState()
|
||||
hardGenState.Params.MoneyMarkets = []hardtypes.MoneyMarket{
|
||||
{
|
||||
Denom: "usdx",
|
||||
BorrowLimit: hardtypes.BorrowLimit{
|
||||
HasMaxLimit: true,
|
||||
MaximumLimit: sdk.MustNewDecFromStr("100000000000"),
|
||||
LoanToValue: sdk.MustNewDecFromStr("1"),
|
||||
},
|
||||
SpotMarketID: "usdx:usd",
|
||||
ConversionFactor: sdkmath.NewInt(1_000_000),
|
||||
InterestRateModel: hardtypes.InterestRateModel{
|
||||
BaseRateAPY: sdk.MustNewDecFromStr("0.05"),
|
||||
BaseMultiplier: sdk.MustNewDecFromStr("2"),
|
||||
Kink: sdk.MustNewDecFromStr("0.8"),
|
||||
JumpMultiplier: sdk.MustNewDecFromStr("10"),
|
||||
},
|
||||
ReserveFactor: sdk.MustNewDecFromStr("0.05"),
|
||||
KeeperRewardPercentage: sdk.ZeroDec(),
|
||||
},
|
||||
}
|
||||
|
||||
pricefeedGenState := pricefeedtypes.DefaultGenesisState()
|
||||
pricefeedGenState.Params.Markets = []pricefeedtypes.Market{
|
||||
{
|
||||
@ -261,15 +219,13 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
genState := app.GenesisState{
|
||||
evmtypes.ModuleName: cdc.MustMarshalJSON(evmGs),
|
||||
feemarkettypes.ModuleName: cdc.MustMarshalJSON(feemarketGenesis),
|
||||
cdptypes.ModuleName: cdc.MustMarshalJSON(&cdpGenState),
|
||||
hardtypes.ModuleName: cdc.MustMarshalJSON(&hardGenState),
|
||||
pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pricefeedGenState),
|
||||
}
|
||||
|
||||
// funds our test accounts with some ukava
|
||||
// funds our test accounts with some gas denom
|
||||
coinsGenState := app.NewFundedGenStateWithSameCoins(
|
||||
tApp.AppCodec(),
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 1e9)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e9)),
|
||||
[]sdk.AccAddress{suite.testAddr, suite.testAddr2},
|
||||
)
|
||||
|
||||
@ -351,45 +307,17 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
params := evmKeeper.GetParams(suite.ctx)
|
||||
params.EIP712AllowedMsgs = []evmtypes.EIP712AllowedMsg{
|
||||
{
|
||||
MsgTypeUrl: "/kava.evmutil.v1beta1.MsgConvertERC20ToCoin",
|
||||
MsgTypeUrl: "/zgc.evmutil.v1beta1.MsgConvertERC20ToCoin",
|
||||
MsgValueTypeName: "MsgValueEVMConvertERC20ToCoin",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "initiator", Type: "string"},
|
||||
{Name: "receiver", Type: "string"},
|
||||
{Name: "kava_erc20_address", Type: "string"},
|
||||
{Name: "zgchain_erc20_address", Type: "string"},
|
||||
{Name: "amount", Type: "string"},
|
||||
},
|
||||
},
|
||||
{
|
||||
MsgTypeUrl: "/kava.cdp.v1beta1.MsgCreateCDP",
|
||||
MsgValueTypeName: "MsgValueCDPCreate",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "sender", Type: "string"},
|
||||
{Name: "collateral", Type: "Coin"},
|
||||
{Name: "principal", Type: "Coin"},
|
||||
{Name: "collateral_type", Type: "string"},
|
||||
},
|
||||
},
|
||||
{
|
||||
MsgTypeUrl: "/kava.cdp.v1beta1.MsgDeposit",
|
||||
MsgValueTypeName: "MsgValueCDPDeposit",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "depositor", Type: "string"},
|
||||
{Name: "owner", Type: "string"},
|
||||
{Name: "collateral", Type: "Coin"},
|
||||
{Name: "collateral_type", Type: "string"},
|
||||
},
|
||||
},
|
||||
{
|
||||
MsgTypeUrl: "/kava.hard.v1beta1.MsgDeposit",
|
||||
MsgValueTypeName: "MsgValueHardDeposit",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "depositor", Type: "string"},
|
||||
{Name: "amount", Type: "Coin[]"},
|
||||
},
|
||||
},
|
||||
{
|
||||
MsgTypeUrl: "/kava.evmutil.v1beta1.MsgConvertCoinToERC20",
|
||||
MsgTypeUrl: "/zgc.evmutil.v1beta1.MsgConvertCoinToERC20",
|
||||
MsgValueTypeName: "MsgValueEVMConvertCoinToERC20",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "initiator", Type: "string"},
|
||||
@ -397,23 +325,6 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
{Name: "amount", Type: "Coin"},
|
||||
},
|
||||
},
|
||||
{
|
||||
MsgTypeUrl: "/kava.cdp.v1beta1.MsgRepayDebt",
|
||||
MsgValueTypeName: "MsgValueCDPRepayDebt",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "sender", Type: "string"},
|
||||
{Name: "collateral_type", Type: "string"},
|
||||
{Name: "payment", Type: "Coin"},
|
||||
},
|
||||
},
|
||||
{
|
||||
MsgTypeUrl: "/kava.hard.v1beta1.MsgWithdraw",
|
||||
MsgValueTypeName: "MsgValueHardWithdraw",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "depositor", Type: "string"},
|
||||
{Name: "amount", Type: "Coin[]"},
|
||||
},
|
||||
},
|
||||
}
|
||||
evmKeeper.SetParams(suite.ctx, params)
|
||||
|
||||
@ -459,7 +370,7 @@ func (suite *EIP712TestSuite) deployUSDCERC20(app app.TestApp, ctx sdk.Context)
|
||||
suite.tApp.FundModuleAccount(
|
||||
suite.ctx,
|
||||
evmutiltypes.ModuleName,
|
||||
sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(0))),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(0)),
|
||||
)
|
||||
|
||||
contractAddr, err := suite.evmutilKeeper.DeployTestMintableERC20Contract(suite.ctx, "USDC", "USDC", uint8(18))
|
||||
@ -481,40 +392,43 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
failCheckTx bool
|
||||
errMsg string
|
||||
}{
|
||||
{
|
||||
name: "processes deposit eip712 messages successfully",
|
||||
usdcDepositAmt: 100,
|
||||
usdxToMintAmt: 99,
|
||||
},
|
||||
// TODO: need fix
|
||||
// {
|
||||
// name: "processes deposit eip712 messages successfully",
|
||||
// usdcDepositAmt: 100,
|
||||
// usdxToMintAmt: 99,
|
||||
// },
|
||||
{
|
||||
name: "fails when convertion more erc20 usdc than balance",
|
||||
usdcDepositAmt: 51_000,
|
||||
usdxToMintAmt: 100,
|
||||
errMsg: "transfer amount exceeds balance",
|
||||
},
|
||||
{
|
||||
name: "fails when minting more usdx than allowed",
|
||||
usdcDepositAmt: 100,
|
||||
usdxToMintAmt: 100,
|
||||
errMsg: "proposed collateral ratio is below liquidation ratio",
|
||||
},
|
||||
{
|
||||
name: "fails when trying to convert usdc for another address",
|
||||
usdcDepositAmt: 100,
|
||||
usdxToMintAmt: 90,
|
||||
errMsg: "unauthorized",
|
||||
failCheckTx: true,
|
||||
updateMsgs: func(msgs []sdk.Msg) []sdk.Msg {
|
||||
convertMsg := evmutiltypes.NewMsgConvertERC20ToCoin(
|
||||
suite.testEVMAddr2,
|
||||
suite.testAddr,
|
||||
suite.usdcEVMAddr,
|
||||
suite.getEVMAmount(100),
|
||||
)
|
||||
msgs[0] = &convertMsg
|
||||
return msgs
|
||||
},
|
||||
},
|
||||
// TODO: need fix
|
||||
// {
|
||||
// name: "fails when minting more usdx than allowed",
|
||||
// usdcDepositAmt: 100,
|
||||
// usdxToMintAmt: 100,
|
||||
// errMsg: "proposed collateral ratio is below liquidation ratio",
|
||||
// },
|
||||
// TODO: need fix
|
||||
// {
|
||||
// name: "fails when trying to convert usdc for another address",
|
||||
// usdcDepositAmt: 100,
|
||||
// usdxToMintAmt: 90,
|
||||
// errMsg: "unauthorized",
|
||||
// failCheckTx: true,
|
||||
// updateMsgs: func(msgs []sdk.Msg) []sdk.Msg {
|
||||
// convertMsg := evmutiltypes.NewMsgConvertERC20ToCoin(
|
||||
// suite.testEVMAddr2,
|
||||
// suite.testAddr,
|
||||
// suite.usdcEVMAddr,
|
||||
// suite.getEVMAmount(100),
|
||||
// )
|
||||
// msgs[0] = &convertMsg
|
||||
// return msgs
|
||||
// },
|
||||
// },
|
||||
{
|
||||
name: "fails when trying to convert erc20 for non-whitelisted contract",
|
||||
usdcDepositAmt: 100,
|
||||
@ -556,7 +470,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
errMsg: "insufficient funds",
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
bk := suite.tApp.GetBankKeeper()
|
||||
gasCoins := bk.GetBalance(suite.ctx, suite.testAddr, "ukava")
|
||||
gasCoins := bk.GetBalance(suite.ctx, suite.testAddr, chaincfg.GasDenom)
|
||||
suite.tApp.GetBankKeeper().SendCoins(suite.ctx, suite.testAddr, suite.testAddr2, sdk.NewCoins(gasCoins))
|
||||
return txBuilder
|
||||
},
|
||||
@ -568,7 +482,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
failCheckTx: true,
|
||||
errMsg: "invalid chain-id",
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
gasAmt := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(20)))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
return suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, "kavatest_12-1", uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -581,7 +495,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
failCheckTx: true,
|
||||
errMsg: "invalid pubkey",
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
gasAmt := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(20)))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
return suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr2, suite.testPrivKey2, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -601,27 +515,15 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
suite.usdcEVMAddr,
|
||||
usdcAmt,
|
||||
)
|
||||
usdxAmt := sdkmath.NewInt(1_000_000).Mul(sdkmath.NewInt(tc.usdxToMintAmt))
|
||||
mintMsg := cdptypes.NewMsgCreateCDP(
|
||||
suite.testAddr,
|
||||
sdk.NewCoin(USDCCoinDenom, usdcAmt),
|
||||
sdk.NewCoin(cdptypes.DefaultStableDenom, usdxAmt),
|
||||
USDCCDPType,
|
||||
)
|
||||
lendMsg := hardtypes.NewMsgDeposit(
|
||||
suite.testAddr,
|
||||
sdk.NewCoins(sdk.NewCoin(cdptypes.DefaultStableDenom, usdxAmt)),
|
||||
)
|
||||
|
||||
msgs := []sdk.Msg{
|
||||
&convertMsg,
|
||||
&mintMsg,
|
||||
&lendMsg,
|
||||
}
|
||||
if tc.updateMsgs != nil {
|
||||
msgs = tc.updateMsgs(msgs)
|
||||
}
|
||||
|
||||
gasAmt := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(20)))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
txBuilder := suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -659,17 +561,17 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
suite.Require().Equal(sdk.ZeroInt(), amt.Amount)
|
||||
|
||||
// validate cdp
|
||||
cdp, found := suite.tApp.GetCDPKeeper().GetCdpByOwnerAndCollateralType(suite.ctx, suite.testAddr, USDCCDPType)
|
||||
suite.Require().True(found)
|
||||
suite.Require().Equal(suite.testAddr, cdp.Owner)
|
||||
suite.Require().Equal(sdk.NewCoin(USDCCoinDenom, suite.getEVMAmount(100)), cdp.Collateral)
|
||||
suite.Require().Equal(sdk.NewCoin("usdx", sdkmath.NewInt(99_000_000)), cdp.Principal)
|
||||
// cdp, found := suite.tApp.GetCDPKeeper().GetCdpByOwnerAndCollateralType(suite.ctx, suite.testAddr, USDCCDPType)
|
||||
// suite.Require().True(found)
|
||||
// suite.Require().Equal(suite.testAddr, cdp.Owner)
|
||||
// suite.Require().Equal(sdk.NewCoin(USDCCoinDenom, suite.getEVMAmount(100)), cdp.Collateral)
|
||||
// suite.Require().Equal(sdk.NewCoin("usdx", sdkmath.NewInt(99_000_000)), cdp.Principal)
|
||||
|
||||
// validate hard
|
||||
hardDeposit, found := suite.tApp.GetHardKeeper().GetDeposit(suite.ctx, suite.testAddr)
|
||||
suite.Require().True(found)
|
||||
suite.Require().Equal(suite.testAddr, hardDeposit.Depositor)
|
||||
suite.Require().Equal(sdk.NewCoins(sdk.NewCoin("usdx", sdkmath.NewInt(99_000_000))), hardDeposit.Amount)
|
||||
// hardDeposit, found := suite.tApp.GetHardKeeper().GetDeposit(suite.ctx, suite.testAddr)
|
||||
// suite.Require().True(found)
|
||||
// suite.Require().Equal(suite.testAddr, hardDeposit.Depositor)
|
||||
// suite.Require().Equal(sdk.NewCoins(sdk.NewCoin("usdx", sdkmath.NewInt(99_000_000))), hardDeposit.Amount)
|
||||
} else {
|
||||
suite.Require().NotEqual(resDeliverTx.Code, uint32(0), resCheckTx.Log)
|
||||
suite.Require().Contains(resDeliverTx.Log, tc.errMsg)
|
||||
@ -689,25 +591,13 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
|
||||
suite.usdcEVMAddr,
|
||||
usdcAmt,
|
||||
)
|
||||
usdxAmt := sdkmath.NewInt(1_000_000).Mul(sdkmath.NewInt(99))
|
||||
mintMsg := cdptypes.NewMsgCreateCDP(
|
||||
suite.testAddr,
|
||||
sdk.NewCoin(USDCCoinDenom, usdcAmt),
|
||||
sdk.NewCoin(cdptypes.DefaultStableDenom, usdxAmt),
|
||||
USDCCDPType,
|
||||
)
|
||||
lendMsg := hardtypes.NewMsgDeposit(
|
||||
suite.testAddr,
|
||||
sdk.NewCoins(sdk.NewCoin(cdptypes.DefaultStableDenom, usdxAmt)),
|
||||
)
|
||||
|
||||
depositMsgs := []sdk.Msg{
|
||||
&convertMsg,
|
||||
&mintMsg,
|
||||
&lendMsg,
|
||||
}
|
||||
|
||||
// deliver deposit msg
|
||||
gasAmt := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(20)))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
txBuilder := suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, depositMsgs,
|
||||
)
|
||||
@ -721,10 +611,10 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
|
||||
suite.Require().Equal(resDeliverTx.Code, uint32(0), resDeliverTx.Log)
|
||||
|
||||
// validate hard
|
||||
hardDeposit, found := suite.tApp.GetHardKeeper().GetDeposit(suite.ctx, suite.testAddr)
|
||||
suite.Require().True(found)
|
||||
suite.Require().Equal(suite.testAddr, hardDeposit.Depositor)
|
||||
suite.Require().Equal(sdk.NewCoins(sdk.NewCoin("usdx", sdkmath.NewInt(99_000_000))), hardDeposit.Amount)
|
||||
// hardDeposit, found := suite.tApp.GetHardKeeper().GetDeposit(suite.ctx, suite.testAddr)
|
||||
// suite.Require().True(found)
|
||||
// suite.Require().Equal(suite.testAddr, hardDeposit.Depositor)
|
||||
// suite.Require().Equal(sdk.NewCoins(sdk.NewCoin("usdx", sdkmath.NewInt(99_000_000))), hardDeposit.Amount)
|
||||
|
||||
// validate erc20 balance
|
||||
coinBal, err := suite.evmutilKeeper.QueryERC20BalanceOf(suite.ctx, suite.usdcEVMAddr, suite.testEVMAddr)
|
||||
@ -737,18 +627,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
|
||||
suite.testEVMAddr.String(),
|
||||
sdk.NewCoin(USDCCoinDenom, usdcAmt),
|
||||
)
|
||||
cdpWithdrawMsg := cdptypes.NewMsgRepayDebt(
|
||||
suite.testAddr,
|
||||
USDCCDPType,
|
||||
sdk.NewCoin(cdptypes.DefaultStableDenom, usdxAmt),
|
||||
)
|
||||
hardWithdrawMsg := hardtypes.NewMsgWithdraw(
|
||||
suite.testAddr,
|
||||
sdk.NewCoins(sdk.NewCoin(cdptypes.DefaultStableDenom, usdxAmt)),
|
||||
)
|
||||
withdrawMsgs := []sdk.Msg{
|
||||
&hardWithdrawMsg,
|
||||
&cdpWithdrawMsg,
|
||||
&withdrawConvertMsg,
|
||||
}
|
||||
|
||||
@ -766,10 +645,10 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
|
||||
suite.Require().Equal(resDeliverTx.Code, uint32(0), resDeliverTx.Log)
|
||||
|
||||
// validate hard & cdp should be repayed
|
||||
_, found = suite.tApp.GetHardKeeper().GetDeposit(suite.ctx, suite.testAddr)
|
||||
suite.Require().False(found)
|
||||
_, found = suite.tApp.GetCDPKeeper().GetCdpByOwnerAndCollateralType(suite.ctx, suite.testAddr, USDCCDPType)
|
||||
suite.Require().False(found)
|
||||
// _, found = suite.tApp.GetHardKeeper().GetDeposit(suite.ctx, suite.testAddr)
|
||||
// suite.Require().False(found)
|
||||
// _, found = suite.tApp.GetCDPKeeper().GetCdpByOwnerAndCollateralType(suite.ctx, suite.testAddr, USDCCDPType)
|
||||
// suite.Require().False(found)
|
||||
|
||||
// validate user cosmos erc20/usd balance
|
||||
bk := suite.tApp.GetBankKeeper()
|
||||
|
@ -11,8 +11,9 @@ import (
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/app/ante"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
func mustParseDecCoins(value string) sdk.DecCoins {
|
||||
@ -30,7 +31,7 @@ func TestEvmMinGasFilter(t *testing.T) {
|
||||
|
||||
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
||||
tApp.GetEvmKeeper().SetParams(ctx, evmtypes.Params{
|
||||
EvmDenom: "akava",
|
||||
EvmDenom: chaincfg.EvmDenom,
|
||||
})
|
||||
|
||||
testCases := []struct {
|
||||
@ -44,29 +45,29 @@ func TestEvmMinGasFilter(t *testing.T) {
|
||||
mustParseDecCoins(""),
|
||||
},
|
||||
{
|
||||
"zero ukava gas price",
|
||||
mustParseDecCoins("0ukava"),
|
||||
mustParseDecCoins("0ukava"),
|
||||
"zero ua0gi gas price",
|
||||
mustParseDecCoins("0ua0gi"),
|
||||
mustParseDecCoins("0ua0gi"),
|
||||
},
|
||||
{
|
||||
"non-zero ukava gas price",
|
||||
mustParseDecCoins("0.001ukava"),
|
||||
mustParseDecCoins("0.001ukava"),
|
||||
"non-zero ua0gi gas price",
|
||||
mustParseDecCoins("0.001ua0gi"),
|
||||
mustParseDecCoins("0.001ua0gi"),
|
||||
},
|
||||
{
|
||||
"zero ukava gas price, min akava price",
|
||||
mustParseDecCoins("0ukava;100000akava"),
|
||||
mustParseDecCoins("0ukava"), // akava is removed
|
||||
"zero ua0gi gas price, min neuron price",
|
||||
mustParseDecCoins("0ua0gi;100000neuron"),
|
||||
mustParseDecCoins("0ua0gi"), // neuron is removed
|
||||
},
|
||||
{
|
||||
"zero ukava gas price, min akava price, other token",
|
||||
mustParseDecCoins("0ukava;100000akava;0.001other"),
|
||||
mustParseDecCoins("0ukava;0.001other"), // akava is removed
|
||||
"zero ua0gi gas price, min neuron price, other token",
|
||||
mustParseDecCoins("0ua0gi;100000neuron;0.001other"),
|
||||
mustParseDecCoins("0ua0gi;0.001other"), // neuron is removed
|
||||
},
|
||||
{
|
||||
"non-zero ukava gas price, min akava price",
|
||||
mustParseDecCoins("0.25ukava;100000akava;0.001other"),
|
||||
mustParseDecCoins("0.25ukava;0.001other"), // akava is removed
|
||||
"non-zero ua0gi gas price, min neuron price",
|
||||
mustParseDecCoins("0.25ua0gi;100000neuron;0.001other"),
|
||||
mustParseDecCoins("0.25ua0gi;0.001other"), // neuron is removed
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
)
|
||||
|
||||
var _ sdk.AnteDecorator = VestingAccountDecorator{}
|
||||
@ -17,9 +16,9 @@ type VestingAccountDecorator struct {
|
||||
func NewVestingAccountDecorator() VestingAccountDecorator {
|
||||
return VestingAccountDecorator{
|
||||
disabledMsgTypeUrls: []string{
|
||||
sdk.MsgTypeURL(&vesting.MsgCreateVestingAccount{}),
|
||||
sdk.MsgTypeURL(&vesting.MsgCreatePermanentLockedAccount{}),
|
||||
sdk.MsgTypeURL(&vesting.MsgCreatePeriodicVestingAccount{}),
|
||||
// sdk.MsgTypeURL(&vesting.MsgCreateVestingAccount{}),
|
||||
// sdk.MsgTypeURL(&vesting.MsgCreatePermanentLockedAccount{}),
|
||||
// sdk.MsgTypeURL(&vesting.MsgCreatePeriodicVestingAccount{}),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,9 @@ import (
|
||||
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/app/ante"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing.T) {
|
||||
@ -33,7 +34,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"MsgCreateVestingAccount",
|
||||
vesting.NewMsgCreateVestingAccount(
|
||||
testAddresses[0], testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC).Unix(),
|
||||
false,
|
||||
),
|
||||
@ -44,7 +45,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"MsgCreateVestingAccount",
|
||||
vesting.NewMsgCreatePermanentLockedAccount(
|
||||
testAddresses[0], testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
true,
|
||||
"MsgTypeURL /cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount not supported",
|
||||
@ -63,7 +64,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"other messages not affected",
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0], testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ukava", 100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
false,
|
||||
"",
|
||||
|
393
app/app.go
393
app/app.go
@ -3,10 +3,7 @@ package app
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
stdlog "log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -26,6 +23,7 @@ import (
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
||||
vestingkeeper "github.com/cosmos/cosmos-sdk/x/auth/vesting/keeper"
|
||||
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
|
||||
@ -87,85 +85,51 @@ import (
|
||||
"github.com/evmos/ethermint/x/evm"
|
||||
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/evmos/ethermint/x/evm/vm/geth"
|
||||
"github.com/evmos/ethermint/x/feemarket"
|
||||
feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
|
||||
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
tmlog "github.com/tendermint/tendermint/libs/log"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/kava-labs/kava/app/ante"
|
||||
kavaparams "github.com/kava-labs/kava/app/params"
|
||||
"github.com/kava-labs/kava/x/auction"
|
||||
auctionkeeper "github.com/kava-labs/kava/x/auction/keeper"
|
||||
auctiontypes "github.com/kava-labs/kava/x/auction/types"
|
||||
"github.com/kava-labs/kava/x/bep3"
|
||||
bep3keeper "github.com/kava-labs/kava/x/bep3/keeper"
|
||||
bep3types "github.com/kava-labs/kava/x/bep3/types"
|
||||
"github.com/kava-labs/kava/x/cdp"
|
||||
cdpkeeper "github.com/kava-labs/kava/x/cdp/keeper"
|
||||
cdptypes "github.com/kava-labs/kava/x/cdp/types"
|
||||
"github.com/kava-labs/kava/x/committee"
|
||||
committeeclient "github.com/kava-labs/kava/x/committee/client"
|
||||
committeekeeper "github.com/kava-labs/kava/x/committee/keeper"
|
||||
committeetypes "github.com/kava-labs/kava/x/committee/types"
|
||||
"github.com/kava-labs/kava/x/community"
|
||||
communityclient "github.com/kava-labs/kava/x/community/client"
|
||||
communitykeeper "github.com/kava-labs/kava/x/community/keeper"
|
||||
communitytypes "github.com/kava-labs/kava/x/community/types"
|
||||
earn "github.com/kava-labs/kava/x/earn"
|
||||
earnclient "github.com/kava-labs/kava/x/earn/client"
|
||||
earnkeeper "github.com/kava-labs/kava/x/earn/keeper"
|
||||
earntypes "github.com/kava-labs/kava/x/earn/types"
|
||||
evmutil "github.com/kava-labs/kava/x/evmutil"
|
||||
evmutilkeeper "github.com/kava-labs/kava/x/evmutil/keeper"
|
||||
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
|
||||
"github.com/kava-labs/kava/x/hard"
|
||||
hardkeeper "github.com/kava-labs/kava/x/hard/keeper"
|
||||
hardtypes "github.com/kava-labs/kava/x/hard/types"
|
||||
"github.com/kava-labs/kava/x/incentive"
|
||||
incentivekeeper "github.com/kava-labs/kava/x/incentive/keeper"
|
||||
incentivetypes "github.com/kava-labs/kava/x/incentive/types"
|
||||
issuance "github.com/kava-labs/kava/x/issuance"
|
||||
issuancekeeper "github.com/kava-labs/kava/x/issuance/keeper"
|
||||
issuancetypes "github.com/kava-labs/kava/x/issuance/types"
|
||||
"github.com/kava-labs/kava/x/kavadist"
|
||||
kavadistclient "github.com/kava-labs/kava/x/kavadist/client"
|
||||
kavadistkeeper "github.com/kava-labs/kava/x/kavadist/keeper"
|
||||
kavadisttypes "github.com/kava-labs/kava/x/kavadist/types"
|
||||
"github.com/kava-labs/kava/x/liquid"
|
||||
liquidkeeper "github.com/kava-labs/kava/x/liquid/keeper"
|
||||
liquidtypes "github.com/kava-labs/kava/x/liquid/types"
|
||||
metrics "github.com/kava-labs/kava/x/metrics"
|
||||
metricstypes "github.com/kava-labs/kava/x/metrics/types"
|
||||
pricefeed "github.com/kava-labs/kava/x/pricefeed"
|
||||
pricefeedkeeper "github.com/kava-labs/kava/x/pricefeed/keeper"
|
||||
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
|
||||
"github.com/kava-labs/kava/x/router"
|
||||
routerkeeper "github.com/kava-labs/kava/x/router/keeper"
|
||||
routertypes "github.com/kava-labs/kava/x/router/types"
|
||||
savings "github.com/kava-labs/kava/x/savings"
|
||||
savingskeeper "github.com/kava-labs/kava/x/savings/keeper"
|
||||
savingstypes "github.com/kava-labs/kava/x/savings/types"
|
||||
"github.com/kava-labs/kava/x/swap"
|
||||
swapkeeper "github.com/kava-labs/kava/x/swap/keeper"
|
||||
swaptypes "github.com/kava-labs/kava/x/swap/types"
|
||||
validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
|
||||
validatorvestingrest "github.com/kava-labs/kava/x/validator-vesting/client/rest"
|
||||
validatorvestingtypes "github.com/kava-labs/kava/x/validator-vesting/types"
|
||||
)
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
chainparams "github.com/0glabs/0g-chain/app/params"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
dasignersprecompile "github.com/0glabs/0g-chain/precompiles/dasigners"
|
||||
|
||||
const (
|
||||
appName = "kava"
|
||||
"github.com/0glabs/0g-chain/x/bep3"
|
||||
bep3keeper "github.com/0glabs/0g-chain/x/bep3/keeper"
|
||||
bep3types "github.com/0glabs/0g-chain/x/bep3/types"
|
||||
"github.com/0glabs/0g-chain/x/committee"
|
||||
committeeclient "github.com/0glabs/0g-chain/x/committee/client"
|
||||
committeekeeper "github.com/0glabs/0g-chain/x/committee/keeper"
|
||||
committeetypes "github.com/0glabs/0g-chain/x/committee/types"
|
||||
council "github.com/0glabs/0g-chain/x/council/v1"
|
||||
councilkeeper "github.com/0glabs/0g-chain/x/council/v1/keeper"
|
||||
counciltypes "github.com/0glabs/0g-chain/x/council/v1/types"
|
||||
dasigners "github.com/0glabs/0g-chain/x/dasigners/v1"
|
||||
dasignerskeeper "github.com/0glabs/0g-chain/x/dasigners/v1/keeper"
|
||||
dasignerstypes "github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
evmutil "github.com/0glabs/0g-chain/x/evmutil"
|
||||
evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper"
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
issuance "github.com/0glabs/0g-chain/x/issuance"
|
||||
issuancekeeper "github.com/0glabs/0g-chain/x/issuance/keeper"
|
||||
issuancetypes "github.com/0glabs/0g-chain/x/issuance/types"
|
||||
pricefeed "github.com/0glabs/0g-chain/x/pricefeed"
|
||||
pricefeedkeeper "github.com/0glabs/0g-chain/x/pricefeed/keeper"
|
||||
pricefeedtypes "github.com/0glabs/0g-chain/x/pricefeed/types"
|
||||
validatorvesting "github.com/0glabs/0g-chain/x/validator-vesting"
|
||||
validatorvestingrest "github.com/0glabs/0g-chain/x/validator-vesting/client/rest"
|
||||
validatorvestingtypes "github.com/0glabs/0g-chain/x/validator-vesting/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
var (
|
||||
// DefaultNodeHome default home directories for the application daemon
|
||||
DefaultNodeHome string
|
||||
|
||||
// ModuleBasics manages simple versions of full app modules.
|
||||
// It's used for things such as codec registration and genesis file verification.
|
||||
ModuleBasics = module.NewBasicManager(
|
||||
@ -182,12 +146,7 @@ var (
|
||||
upgradeclient.LegacyCancelProposalHandler,
|
||||
ibcclientclient.UpdateClientProposalHandler,
|
||||
ibcclientclient.UpgradeProposalHandler,
|
||||
kavadistclient.ProposalHandler,
|
||||
committeeclient.ProposalHandler,
|
||||
earnclient.DepositProposalHandler,
|
||||
earnclient.WithdrawProposalHandler,
|
||||
communityclient.LendDepositProposalHandler,
|
||||
communityclient.LendWithdrawProposalHandler,
|
||||
}),
|
||||
params.AppModuleBasic{},
|
||||
crisis.AppModuleBasic{},
|
||||
@ -200,25 +159,15 @@ var (
|
||||
vesting.AppModuleBasic{},
|
||||
evm.AppModuleBasic{},
|
||||
feemarket.AppModuleBasic{},
|
||||
kavadist.AppModuleBasic{},
|
||||
auction.AppModuleBasic{},
|
||||
issuance.AppModuleBasic{},
|
||||
bep3.AppModuleBasic{},
|
||||
pricefeed.AppModuleBasic{},
|
||||
swap.AppModuleBasic{},
|
||||
cdp.AppModuleBasic{},
|
||||
hard.AppModuleBasic{},
|
||||
committee.AppModuleBasic{},
|
||||
incentive.AppModuleBasic{},
|
||||
savings.AppModuleBasic{},
|
||||
validatorvesting.AppModuleBasic{},
|
||||
evmutil.AppModuleBasic{},
|
||||
liquid.AppModuleBasic{},
|
||||
earn.AppModuleBasic{},
|
||||
router.AppModuleBasic{},
|
||||
mint.AppModuleBasic{},
|
||||
community.AppModuleBasic{},
|
||||
metrics.AppModuleBasic{},
|
||||
council.AppModuleBasic{},
|
||||
dasigners.AppModuleBasic{},
|
||||
)
|
||||
|
||||
// module account permissions
|
||||
@ -233,20 +182,9 @@ var (
|
||||
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
||||
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
|
||||
evmutiltypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
||||
kavadisttypes.KavaDistMacc: {authtypes.Minter},
|
||||
auctiontypes.ModuleName: nil,
|
||||
issuancetypes.ModuleAccountName: {authtypes.Minter, authtypes.Burner},
|
||||
bep3types.ModuleName: {authtypes.Burner, authtypes.Minter},
|
||||
swaptypes.ModuleName: nil,
|
||||
cdptypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
||||
cdptypes.LiquidatorMacc: {authtypes.Minter, authtypes.Burner},
|
||||
hardtypes.ModuleAccountName: {authtypes.Minter},
|
||||
savingstypes.ModuleAccountName: nil,
|
||||
liquidtypes.ModuleAccountName: {authtypes.Minter, authtypes.Burner},
|
||||
earntypes.ModuleAccountName: nil,
|
||||
kavadisttypes.FundModuleAccount: nil,
|
||||
minttypes.ModuleName: {authtypes.Minter},
|
||||
communitytypes.ModuleName: nil,
|
||||
}
|
||||
)
|
||||
|
||||
@ -266,7 +204,6 @@ type Options struct {
|
||||
MempoolAuthAddresses []sdk.AccAddress
|
||||
EVMTrace string
|
||||
EVMMaxGasWanted uint64
|
||||
TelemetryOptions metricstypes.TelemetryOptions
|
||||
}
|
||||
|
||||
// DefaultOptions is a sensible default Options value.
|
||||
@ -275,7 +212,7 @@ var DefaultOptions = Options{
|
||||
EVMMaxGasWanted: ethermintconfig.DefaultMaxTxGasWanted,
|
||||
}
|
||||
|
||||
// App is the Kava ABCI application.
|
||||
// App is the 0gChain ABCI application.
|
||||
type App struct {
|
||||
*baseapp.BaseApp
|
||||
|
||||
@ -307,22 +244,14 @@ type App struct {
|
||||
upgradeKeeper upgradekeeper.Keeper
|
||||
evidenceKeeper evidencekeeper.Keeper
|
||||
transferKeeper ibctransferkeeper.Keeper
|
||||
kavadistKeeper kavadistkeeper.Keeper
|
||||
auctionKeeper auctionkeeper.Keeper
|
||||
CouncilKeeper councilkeeper.Keeper
|
||||
issuanceKeeper issuancekeeper.Keeper
|
||||
bep3Keeper bep3keeper.Keeper
|
||||
pricefeedKeeper pricefeedkeeper.Keeper
|
||||
swapKeeper swapkeeper.Keeper
|
||||
cdpKeeper cdpkeeper.Keeper
|
||||
hardKeeper hardkeeper.Keeper
|
||||
committeeKeeper committeekeeper.Keeper
|
||||
incentiveKeeper incentivekeeper.Keeper
|
||||
savingsKeeper savingskeeper.Keeper
|
||||
liquidKeeper liquidkeeper.Keeper
|
||||
earnKeeper earnkeeper.Keeper
|
||||
routerKeeper routerkeeper.Keeper
|
||||
vestingKeeper vestingkeeper.VestingKeeper
|
||||
mintKeeper mintkeeper.Keeper
|
||||
communityKeeper communitykeeper.Keeper
|
||||
dasignersKeeper dasignerskeeper.Keeper
|
||||
|
||||
// make scoped keepers public for test purposes
|
||||
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
|
||||
@ -339,12 +268,6 @@ type App struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
userHomeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
stdlog.Printf("Failed to get home dir %v", err)
|
||||
}
|
||||
|
||||
DefaultNodeHome = filepath.Join(userHomeDir, ".kava")
|
||||
}
|
||||
|
||||
// NewApp returns a reference to an initialized App.
|
||||
@ -353,7 +276,7 @@ func NewApp(
|
||||
db dbm.DB,
|
||||
homePath string,
|
||||
traceStore io.Writer,
|
||||
encodingConfig kavaparams.EncodingConfig,
|
||||
encodingConfig chainparams.EncodingConfig,
|
||||
options Options,
|
||||
baseAppOptions ...func(*baseapp.BaseApp),
|
||||
) *App {
|
||||
@ -361,7 +284,7 @@ func NewApp(
|
||||
legacyAmino := encodingConfig.Amino
|
||||
interfaceRegistry := encodingConfig.InterfaceRegistry
|
||||
|
||||
bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)
|
||||
bApp := baseapp.NewBaseApp(chaincfg.AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)
|
||||
bApp.SetCommitMultiStoreTracer(traceStore)
|
||||
bApp.SetVersion(version.Version)
|
||||
bApp.SetInterfaceRegistry(interfaceRegistry)
|
||||
@ -372,11 +295,13 @@ func NewApp(
|
||||
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey,
|
||||
upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey,
|
||||
evmtypes.StoreKey, feemarkettypes.StoreKey, authzkeeper.StoreKey,
|
||||
capabilitytypes.StoreKey, kavadisttypes.StoreKey, auctiontypes.StoreKey,
|
||||
capabilitytypes.StoreKey,
|
||||
issuancetypes.StoreKey, bep3types.StoreKey, pricefeedtypes.StoreKey,
|
||||
swaptypes.StoreKey, cdptypes.StoreKey, hardtypes.StoreKey, communitytypes.StoreKey,
|
||||
committeetypes.StoreKey, incentivetypes.StoreKey, evmutiltypes.StoreKey,
|
||||
savingstypes.StoreKey, earntypes.StoreKey, minttypes.StoreKey,
|
||||
committeetypes.StoreKey, evmutiltypes.StoreKey,
|
||||
minttypes.StoreKey,
|
||||
counciltypes.StoreKey,
|
||||
dasignerstypes.StoreKey,
|
||||
vestingtypes.StoreKey,
|
||||
)
|
||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
|
||||
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
||||
@ -408,22 +333,14 @@ func NewApp(
|
||||
slashingSubspace := app.paramsKeeper.Subspace(slashingtypes.ModuleName)
|
||||
govSubspace := app.paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
|
||||
crisisSubspace := app.paramsKeeper.Subspace(crisistypes.ModuleName)
|
||||
kavadistSubspace := app.paramsKeeper.Subspace(kavadisttypes.ModuleName)
|
||||
auctionSubspace := app.paramsKeeper.Subspace(auctiontypes.ModuleName)
|
||||
issuanceSubspace := app.paramsKeeper.Subspace(issuancetypes.ModuleName)
|
||||
bep3Subspace := app.paramsKeeper.Subspace(bep3types.ModuleName)
|
||||
pricefeedSubspace := app.paramsKeeper.Subspace(pricefeedtypes.ModuleName)
|
||||
swapSubspace := app.paramsKeeper.Subspace(swaptypes.ModuleName)
|
||||
cdpSubspace := app.paramsKeeper.Subspace(cdptypes.ModuleName)
|
||||
hardSubspace := app.paramsKeeper.Subspace(hardtypes.ModuleName)
|
||||
incentiveSubspace := app.paramsKeeper.Subspace(incentivetypes.ModuleName)
|
||||
savingsSubspace := app.paramsKeeper.Subspace(savingstypes.ModuleName)
|
||||
ibcSubspace := app.paramsKeeper.Subspace(ibchost.ModuleName)
|
||||
ibctransferSubspace := app.paramsKeeper.Subspace(ibctransfertypes.ModuleName)
|
||||
feemarketSubspace := app.paramsKeeper.Subspace(feemarkettypes.ModuleName)
|
||||
evmSubspace := app.paramsKeeper.Subspace(evmtypes.ModuleName)
|
||||
evmutilSubspace := app.paramsKeeper.Subspace(evmutiltypes.ModuleName)
|
||||
earnSubspace := app.paramsKeeper.Subspace(earntypes.ModuleName)
|
||||
mintSubspace := app.paramsKeeper.Subspace(minttypes.ModuleName)
|
||||
|
||||
bApp.SetParamStore(
|
||||
@ -450,11 +367,14 @@ func NewApp(
|
||||
bankSubspace,
|
||||
app.loadBlockedMaccAddrs(),
|
||||
)
|
||||
app.vestingKeeper = vestingkeeper.NewVestingKeeper(app.accountKeeper, app.bankKeeper, keys[vestingtypes.StoreKey])
|
||||
|
||||
app.stakingKeeper = stakingkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[stakingtypes.StoreKey],
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.vestingKeeper,
|
||||
stakingSubspace,
|
||||
)
|
||||
app.authzKeeper = authzkeeper.NewKeeper(
|
||||
@ -526,14 +446,23 @@ func NewApp(
|
||||
)
|
||||
|
||||
evmBankKeeper := evmutilkeeper.NewEvmBankKeeper(app.evmutilKeeper, app.bankKeeper, app.accountKeeper)
|
||||
// dasigners keeper
|
||||
app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper)
|
||||
// precopmiles
|
||||
precompiles := make(map[common.Address]vm.PrecompiledContract)
|
||||
daSignersPrecompile, err := dasignersprecompile.NewDASignersPrecompile(app.dasignersKeeper)
|
||||
if err != nil {
|
||||
panic("initialize precompile failed")
|
||||
}
|
||||
precompiles[daSignersPrecompile.Address()] = daSignersPrecompile
|
||||
// evm keeper
|
||||
app.evmKeeper = evmkeeper.NewKeeper(
|
||||
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
|
||||
govAuthorityAddr,
|
||||
app.accountKeeper, evmBankKeeper, app.stakingKeeper, app.feeMarketKeeper,
|
||||
nil, // precompiled contracts
|
||||
geth.NewEVM,
|
||||
options.EVMTrace,
|
||||
evmSubspace,
|
||||
precompiles,
|
||||
)
|
||||
|
||||
app.evmutilKeeper.SetEvmKeeper(app.evmKeeper)
|
||||
@ -557,13 +486,6 @@ func NewApp(
|
||||
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
|
||||
app.ibcKeeper.SetRouter(ibcRouter)
|
||||
|
||||
app.auctionKeeper = auctionkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[auctiontypes.StoreKey],
|
||||
auctionSubspace,
|
||||
app.bankKeeper,
|
||||
app.accountKeeper,
|
||||
)
|
||||
app.issuanceKeeper = issuancekeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[issuancetypes.StoreKey],
|
||||
@ -584,68 +506,6 @@ func NewApp(
|
||||
keys[pricefeedtypes.StoreKey],
|
||||
pricefeedSubspace,
|
||||
)
|
||||
swapKeeper := swapkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[swaptypes.StoreKey],
|
||||
swapSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
)
|
||||
cdpKeeper := cdpkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[cdptypes.StoreKey],
|
||||
cdpSubspace,
|
||||
app.pricefeedKeeper,
|
||||
app.auctionKeeper,
|
||||
app.bankKeeper,
|
||||
app.accountKeeper,
|
||||
mAccPerms,
|
||||
)
|
||||
hardKeeper := hardkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[hardtypes.StoreKey],
|
||||
hardSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.pricefeedKeeper,
|
||||
app.auctionKeeper,
|
||||
)
|
||||
app.liquidKeeper = liquidkeeper.NewDefaultKeeper(
|
||||
appCodec,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
&app.stakingKeeper,
|
||||
&app.distrKeeper,
|
||||
)
|
||||
savingsKeeper := savingskeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[savingstypes.StoreKey],
|
||||
savingsSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
app.liquidKeeper,
|
||||
)
|
||||
earnKeeper := earnkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[earntypes.StoreKey],
|
||||
earnSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
&app.liquidKeeper,
|
||||
&hardKeeper,
|
||||
&savingsKeeper,
|
||||
&app.distrKeeper,
|
||||
)
|
||||
|
||||
app.kavadistKeeper = kavadistkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[kavadisttypes.StoreKey],
|
||||
kavadistSubspace,
|
||||
app.bankKeeper,
|
||||
app.accountKeeper,
|
||||
app.distrKeeper,
|
||||
app.loadBlockedMaccAddrs(),
|
||||
)
|
||||
|
||||
app.mintKeeper = mintkeeper.NewKeeper(
|
||||
appCodec,
|
||||
@ -657,49 +517,10 @@ func NewApp(
|
||||
authtypes.FeeCollectorName,
|
||||
)
|
||||
|
||||
// x/community's deposit/withdraw to lend proposals depend on hard keeper.
|
||||
app.communityKeeper = communitykeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[communitytypes.StoreKey],
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
&cdpKeeper,
|
||||
app.distrKeeper,
|
||||
&hardKeeper,
|
||||
&app.mintKeeper,
|
||||
&app.kavadistKeeper,
|
||||
app.stakingKeeper,
|
||||
govAuthorityAddr,
|
||||
)
|
||||
|
||||
app.incentiveKeeper = incentivekeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[incentivetypes.StoreKey],
|
||||
incentiveSubspace,
|
||||
app.bankKeeper,
|
||||
&cdpKeeper,
|
||||
&hardKeeper,
|
||||
app.accountKeeper,
|
||||
app.stakingKeeper,
|
||||
&swapKeeper,
|
||||
&savingsKeeper,
|
||||
&app.liquidKeeper,
|
||||
&earnKeeper,
|
||||
app.mintKeeper,
|
||||
app.distrKeeper,
|
||||
app.pricefeedKeeper,
|
||||
)
|
||||
app.routerKeeper = routerkeeper.NewKeeper(
|
||||
&app.earnKeeper,
|
||||
app.liquidKeeper,
|
||||
&app.stakingKeeper,
|
||||
)
|
||||
|
||||
// create committee keeper with router
|
||||
committeeGovRouter := govv1beta1.NewRouter()
|
||||
committeeGovRouter.
|
||||
AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
|
||||
AddRoute(communitytypes.RouterKey, community.NewCommunityPoolProposalHandler(app.communityKeeper)).
|
||||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
|
||||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper))
|
||||
@ -720,15 +541,8 @@ func NewApp(
|
||||
stakingtypes.NewMultiStakingHooks(
|
||||
app.distrKeeper.Hooks(),
|
||||
app.slashingKeeper.Hooks(),
|
||||
app.incentiveKeeper.Hooks(),
|
||||
)))
|
||||
|
||||
app.swapKeeper = *swapKeeper.SetHooks(app.incentiveKeeper.Hooks())
|
||||
app.cdpKeeper = *cdpKeeper.SetHooks(cdptypes.NewMultiCDPHooks(app.incentiveKeeper.Hooks()))
|
||||
app.hardKeeper = *hardKeeper.SetHooks(hardtypes.NewMultiHARDHooks(app.incentiveKeeper.Hooks()))
|
||||
app.savingsKeeper = savingsKeeper // savings incentive hooks disabled
|
||||
app.earnKeeper = *earnKeeper.SetHooks(app.incentiveKeeper.Hooks())
|
||||
|
||||
// create gov keeper with router
|
||||
// NOTE this must be done after any keepers referenced in the gov router (ie committee) are defined
|
||||
govRouter := govv1beta1.NewRouter()
|
||||
@ -738,9 +552,6 @@ func NewApp(
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper)).
|
||||
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper)).
|
||||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
|
||||
AddRoute(kavadisttypes.RouterKey, kavadist.NewCommunityPoolMultiSpendProposalHandler(app.kavadistKeeper)).
|
||||
AddRoute(earntypes.RouterKey, earn.NewCommunityPoolProposalHandler(app.earnKeeper)).
|
||||
AddRoute(communitytypes.RouterKey, community.NewCommunityPoolProposalHandler(app.communityKeeper)).
|
||||
AddRoute(committeetypes.RouterKey, committee.NewProposalHandler(app.committeeKeeper))
|
||||
|
||||
govConfig := govtypes.DefaultConfig()
|
||||
@ -758,11 +569,14 @@ func NewApp(
|
||||
|
||||
// override x/gov tally handler with custom implementation
|
||||
tallyHandler := NewTallyHandler(
|
||||
app.govKeeper, app.stakingKeeper, app.savingsKeeper, app.earnKeeper,
|
||||
app.liquidKeeper, app.bankKeeper,
|
||||
app.govKeeper, app.stakingKeeper, app.bankKeeper,
|
||||
)
|
||||
app.govKeeper.SetTallyHandler(tallyHandler)
|
||||
|
||||
app.CouncilKeeper = councilkeeper.NewKeeper(
|
||||
keys[counciltypes.StoreKey], appCodec, app.stakingKeeper,
|
||||
)
|
||||
|
||||
// create the module manager (Note: Any module instantiated in the module manager that is later modified
|
||||
// must be passed by reference here.)
|
||||
app.mm = module.NewManager(
|
||||
@ -782,33 +596,22 @@ func NewApp(
|
||||
upgrade.NewAppModule(app.upgradeKeeper),
|
||||
evidence.NewAppModule(app.evidenceKeeper),
|
||||
transferModule,
|
||||
vesting.NewAppModule(app.accountKeeper, app.bankKeeper),
|
||||
vesting.NewAppModule(app.accountKeeper, app.vestingKeeper),
|
||||
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
|
||||
kavadist.NewAppModule(app.kavadistKeeper, app.accountKeeper),
|
||||
auction.NewAppModule(app.auctionKeeper, app.accountKeeper, app.bankKeeper),
|
||||
issuance.NewAppModule(app.issuanceKeeper, app.accountKeeper, app.bankKeeper),
|
||||
bep3.NewAppModule(app.bep3Keeper, app.accountKeeper, app.bankKeeper),
|
||||
pricefeed.NewAppModule(app.pricefeedKeeper, app.accountKeeper),
|
||||
validatorvesting.NewAppModule(app.bankKeeper),
|
||||
swap.NewAppModule(app.swapKeeper, app.accountKeeper),
|
||||
cdp.NewAppModule(app.cdpKeeper, app.accountKeeper, app.pricefeedKeeper, app.bankKeeper),
|
||||
hard.NewAppModule(app.hardKeeper, app.accountKeeper, app.bankKeeper, app.pricefeedKeeper),
|
||||
committee.NewAppModule(app.committeeKeeper, app.accountKeeper),
|
||||
incentive.NewAppModule(app.incentiveKeeper, app.accountKeeper, app.bankKeeper, app.cdpKeeper),
|
||||
evmutil.NewAppModule(app.evmutilKeeper, app.bankKeeper, app.accountKeeper),
|
||||
savings.NewAppModule(app.savingsKeeper, app.accountKeeper, app.bankKeeper),
|
||||
liquid.NewAppModule(app.liquidKeeper),
|
||||
earn.NewAppModule(app.earnKeeper, app.accountKeeper, app.bankKeeper),
|
||||
router.NewAppModule(app.routerKeeper),
|
||||
// nil InflationCalculationFn, use SDK's default inflation function
|
||||
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, nil),
|
||||
community.NewAppModule(app.communityKeeper, app.accountKeeper),
|
||||
metrics.NewAppModule(options.TelemetryOptions),
|
||||
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, chaincfg.NextInflationRate),
|
||||
council.NewAppModule(app.CouncilKeeper, app.stakingKeeper),
|
||||
dasigners.NewAppModule(app.dasignersKeeper, app.stakingKeeper),
|
||||
)
|
||||
|
||||
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
app.mm.SetOrderBeginBlockers(
|
||||
metricstypes.ModuleName,
|
||||
// Upgrade begin blocker runs migrations on the first block after an upgrade. It should run before any other module.
|
||||
upgradetypes.ModuleName,
|
||||
// Capability begin blocker runs non state changing initialization.
|
||||
@ -818,7 +621,6 @@ func NewApp(
|
||||
committeetypes.ModuleName,
|
||||
// Community begin blocker should run before x/mint and x/kavadist since
|
||||
// the disable inflation upgrade will update those modules' params.
|
||||
communitytypes.ModuleName,
|
||||
minttypes.ModuleName,
|
||||
distrtypes.ModuleName,
|
||||
// During begin block slashing happens after distr.BeginBlocker so that
|
||||
@ -829,18 +631,12 @@ func NewApp(
|
||||
stakingtypes.ModuleName,
|
||||
feemarkettypes.ModuleName,
|
||||
evmtypes.ModuleName,
|
||||
kavadisttypes.ModuleName,
|
||||
// Auction begin blocker will close out expired auctions and pay debt back to cdp.
|
||||
// It should be run before cdp begin blocker which cancels out debt with stable and starts more auctions.
|
||||
auctiontypes.ModuleName,
|
||||
cdptypes.ModuleName,
|
||||
bep3types.ModuleName,
|
||||
hardtypes.ModuleName,
|
||||
issuancetypes.ModuleName,
|
||||
incentivetypes.ModuleName,
|
||||
ibchost.ModuleName,
|
||||
// Add all remaining modules with an empty begin blocker below since cosmos 0.45.0 requires it
|
||||
swaptypes.ModuleName,
|
||||
vestingtypes.ModuleName,
|
||||
pricefeedtypes.ModuleName,
|
||||
validatorvestingtypes.ModuleName,
|
||||
@ -853,10 +649,9 @@ func NewApp(
|
||||
paramstypes.ModuleName,
|
||||
authz.ModuleName,
|
||||
evmutiltypes.ModuleName,
|
||||
savingstypes.ModuleName,
|
||||
liquidtypes.ModuleName,
|
||||
earntypes.ModuleName,
|
||||
routertypes.ModuleName,
|
||||
|
||||
counciltypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -870,19 +665,13 @@ func NewApp(
|
||||
pricefeedtypes.ModuleName,
|
||||
// Add all remaining modules with an empty end blocker below since cosmos 0.45.0 requires it
|
||||
capabilitytypes.ModuleName,
|
||||
incentivetypes.ModuleName,
|
||||
issuancetypes.ModuleName,
|
||||
slashingtypes.ModuleName,
|
||||
distrtypes.ModuleName,
|
||||
auctiontypes.ModuleName,
|
||||
bep3types.ModuleName,
|
||||
cdptypes.ModuleName,
|
||||
hardtypes.ModuleName,
|
||||
committeetypes.ModuleName,
|
||||
upgradetypes.ModuleName,
|
||||
evidencetypes.ModuleName,
|
||||
kavadisttypes.ModuleName,
|
||||
swaptypes.ModuleName,
|
||||
vestingtypes.ModuleName,
|
||||
ibchost.ModuleName,
|
||||
validatorvestingtypes.ModuleName,
|
||||
@ -893,13 +682,9 @@ func NewApp(
|
||||
paramstypes.ModuleName,
|
||||
authz.ModuleName,
|
||||
evmutiltypes.ModuleName,
|
||||
savingstypes.ModuleName,
|
||||
liquidtypes.ModuleName,
|
||||
earntypes.ModuleName,
|
||||
routertypes.ModuleName,
|
||||
minttypes.ModuleName,
|
||||
communitytypes.ModuleName,
|
||||
metricstypes.ModuleName,
|
||||
counciltypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list
|
||||
@ -918,20 +703,11 @@ func NewApp(
|
||||
ibctransfertypes.ModuleName,
|
||||
evmtypes.ModuleName,
|
||||
feemarkettypes.ModuleName,
|
||||
kavadisttypes.ModuleName,
|
||||
auctiontypes.ModuleName,
|
||||
issuancetypes.ModuleName,
|
||||
savingstypes.ModuleName,
|
||||
bep3types.ModuleName,
|
||||
pricefeedtypes.ModuleName,
|
||||
swaptypes.ModuleName,
|
||||
cdptypes.ModuleName, // reads market prices, so must run after pricefeed genesis
|
||||
hardtypes.ModuleName,
|
||||
incentivetypes.ModuleName, // reads cdp params, so must run after cdp genesis
|
||||
committeetypes.ModuleName,
|
||||
evmutiltypes.ModuleName,
|
||||
earntypes.ModuleName,
|
||||
communitytypes.ModuleName,
|
||||
genutiltypes.ModuleName, // runs arbitrary txs included in genisis state, so run after modules have been initialized
|
||||
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
|
||||
// Add all remaining modules with an empty InitGenesis below since cosmos 0.45.0 requires it
|
||||
@ -939,9 +715,8 @@ func NewApp(
|
||||
paramstypes.ModuleName,
|
||||
upgradetypes.ModuleName,
|
||||
validatorvestingtypes.ModuleName,
|
||||
liquidtypes.ModuleName,
|
||||
routertypes.ModuleName,
|
||||
metricstypes.ModuleName,
|
||||
counciltypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
app.mm.RegisterInvariants(&app.crisisKeeper)
|
||||
@ -1044,7 +819,7 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Store current module versions in kava-10 to setup future in-place upgrades.
|
||||
// Store current module versions in 0gChain-10 to setup future in-place upgrades.
|
||||
// During in-place migrations, the old module versions in the store will be referenced to determine which migrations to run.
|
||||
app.upgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
|
||||
|
||||
@ -1106,7 +881,7 @@ func RegisterAPIRouteRewrites(router *mux.Router) {
|
||||
// Eg: querying /cosmos/distribution/v1beta1/community_pool will return
|
||||
// the same response as querying /kava/community/v1beta1/total_balance
|
||||
routeMap := map[string]string{
|
||||
"/cosmos/distribution/v1beta1/community_pool": "/kava/community/v1beta1/total_balance",
|
||||
"/cosmos/distribution/v1beta1/community_pool": "/0g/community/v1beta1/total_balance",
|
||||
}
|
||||
|
||||
for clientPath, backendPath := range routeMap {
|
||||
@ -1147,16 +922,6 @@ func (app *App) RegisterNodeService(clientCtx client.Context) {
|
||||
func (app *App) loadBlockedMaccAddrs() map[string]bool {
|
||||
modAccAddrs := app.ModuleAccountAddrs()
|
||||
allowedMaccs := map[string]bool{
|
||||
// kavadist
|
||||
app.accountKeeper.GetModuleAddress(kavadisttypes.ModuleName).String(): true,
|
||||
// earn
|
||||
app.accountKeeper.GetModuleAddress(earntypes.ModuleName).String(): true,
|
||||
// liquid
|
||||
app.accountKeeper.GetModuleAddress(liquidtypes.ModuleName).String(): true,
|
||||
// kavadist fund
|
||||
app.accountKeeper.GetModuleAddress(kavadisttypes.FundModuleAccount).String(): true,
|
||||
// community
|
||||
app.accountKeeper.GetModuleAddress(communitytypes.ModuleAccountName).String(): true,
|
||||
// NOTE: if adding evmutil, adjust the cosmos-coins-fully-backed-invariant accordingly.
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,7 @@ package app
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
|
||||
@ -19,14 +15,18 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
db "github.com/tendermint/tm-db"
|
||||
"os"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestNewApp(t *testing.T) {
|
||||
SetSDKConfig()
|
||||
chaincfg.SetSDKConfig()
|
||||
NewApp(
|
||||
log.NewTMLogger(log.NewSyncWriter(os.Stdout)),
|
||||
db.NewMemDB(),
|
||||
DefaultNodeHome,
|
||||
chaincfg.DefaultNodeHome,
|
||||
nil,
|
||||
MakeEncodingConfig(),
|
||||
DefaultOptions,
|
||||
@ -34,9 +34,9 @@ func TestNewApp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExport(t *testing.T) {
|
||||
SetSDKConfig()
|
||||
chaincfg.SetSDKConfig()
|
||||
db := db.NewMemDB()
|
||||
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, DefaultNodeHome, nil, MakeEncodingConfig(), DefaultOptions)
|
||||
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, chaincfg.DefaultNodeHome, nil, MakeEncodingConfig(), DefaultOptions)
|
||||
|
||||
genesisState := GenesisStateWithSingleValidator(&TestApp{App: *app}, NewDefaultGenesisState())
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
package app
|
||||
|
||||
import sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
const (
|
||||
// Bech32MainPrefix defines the Bech32 prefix for account addresses
|
||||
Bech32MainPrefix = "kava"
|
||||
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
|
||||
Bech32PrefixAccPub = Bech32MainPrefix + "pub"
|
||||
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
|
||||
Bech32PrefixValAddr = Bech32MainPrefix + "val" + "oper"
|
||||
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
|
||||
Bech32PrefixValPub = Bech32MainPrefix + "val" + "oper" + "pub"
|
||||
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
|
||||
Bech32PrefixConsAddr = Bech32MainPrefix + "val" + "cons"
|
||||
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
|
||||
Bech32PrefixConsPub = Bech32MainPrefix + "val" + "cons" + "pub"
|
||||
|
||||
Bip44CoinType = 459 // see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
|
||||
)
|
||||
|
||||
// SetSDKConfig configures the global config with kava app specific parameters.
|
||||
// It does not seal the config to allow modification in tests.
|
||||
func SetSDKConfig() *sdk.Config {
|
||||
config := sdk.GetConfig()
|
||||
SetBech32AddressPrefixes(config)
|
||||
SetBip44CoinType(config)
|
||||
return config
|
||||
}
|
||||
|
||||
// SetBech32AddressPrefixes sets the global prefix to be used when serializing addresses to bech32 strings.
|
||||
func SetBech32AddressPrefixes(config *sdk.Config) {
|
||||
config.SetBech32PrefixForAccount(Bech32MainPrefix, Bech32PrefixAccPub)
|
||||
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
|
||||
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
|
||||
}
|
||||
|
||||
// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets.
|
||||
func SetBip44CoinType(config *sdk.Config) {
|
||||
config.SetCoinType(Bip44CoinType)
|
||||
}
|
@ -3,7 +3,7 @@ package app
|
||||
import (
|
||||
enccodec "github.com/evmos/ethermint/encoding/codec"
|
||||
|
||||
"github.com/kava-labs/kava/app/params"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
)
|
||||
|
||||
// MakeEncodingConfig creates an EncodingConfig and registers the app's types on it.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Package params defines the simulation parameters for the Kava app.
|
||||
Package params defines the simulation parameters for the 0gChain app.
|
||||
|
||||
It contains the default weights used for each transaction used on the module's
|
||||
simulation. These weights define the chance for a transaction to be simulated at
|
||||
|
@ -8,10 +8,6 @@ import (
|
||||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
earnkeeper "github.com/kava-labs/kava/x/earn/keeper"
|
||||
liquidkeeper "github.com/kava-labs/kava/x/liquid/keeper"
|
||||
liquidtypes "github.com/kava-labs/kava/x/liquid/types"
|
||||
savingskeeper "github.com/kava-labs/kava/x/savings/keeper"
|
||||
)
|
||||
|
||||
var _ govv1.TallyHandler = TallyHandler{}
|
||||
@ -20,23 +16,16 @@ var _ govv1.TallyHandler = TallyHandler{}
|
||||
type TallyHandler struct {
|
||||
gk govkeeper.Keeper
|
||||
stk stakingkeeper.Keeper
|
||||
svk savingskeeper.Keeper
|
||||
ek earnkeeper.Keeper
|
||||
lk liquidkeeper.Keeper
|
||||
bk bankkeeper.Keeper
|
||||
}
|
||||
|
||||
// NewTallyHandler creates a new tally handler.
|
||||
func NewTallyHandler(
|
||||
gk govkeeper.Keeper, stk stakingkeeper.Keeper, svk savingskeeper.Keeper,
|
||||
ek earnkeeper.Keeper, lk liquidkeeper.Keeper, bk bankkeeper.Keeper,
|
||||
gk govkeeper.Keeper, stk stakingkeeper.Keeper, bk bankkeeper.Keeper,
|
||||
) TallyHandler {
|
||||
return TallyHandler{
|
||||
gk: gk,
|
||||
stk: stk,
|
||||
svk: svk,
|
||||
ek: ek,
|
||||
lk: lk,
|
||||
bk: bk,
|
||||
}
|
||||
}
|
||||
@ -105,34 +94,34 @@ func (th TallyHandler) Tally(
|
||||
})
|
||||
|
||||
// get voter bkava and update total voting power and results
|
||||
addrBkava := th.getAddrBkava(ctx, voter).toCoins()
|
||||
for _, coin := range addrBkava {
|
||||
valAddr, err := liquidtypes.ParseLiquidStakingTokenDenom(coin.Denom)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
// addrBkava := th.getAddrBkava(ctx, voter).toCoins()
|
||||
// for _, coin := range addrBkava {
|
||||
// valAddr, err := liquidtypes.ParseLiquidStakingTokenDenom(coin.Denom)
|
||||
// if err != nil {
|
||||
// break
|
||||
// }
|
||||
|
||||
// reduce delegator shares by the amount of voter bkava for the validator
|
||||
valAddrStr := valAddr.String()
|
||||
if val, ok := currValidators[valAddrStr]; ok {
|
||||
val.DelegatorDeductions = val.DelegatorDeductions.Add(sdk.NewDecFromInt(coin.Amount))
|
||||
currValidators[valAddrStr] = val
|
||||
}
|
||||
// // reduce delegator shares by the amount of voter bkava for the validator
|
||||
// valAddrStr := valAddr.String()
|
||||
// if val, ok := currValidators[valAddrStr]; ok {
|
||||
// val.DelegatorDeductions = val.DelegatorDeductions.Add(sdk.NewDecFromInt(coin.Amount))
|
||||
// currValidators[valAddrStr] = val
|
||||
// }
|
||||
|
||||
// votingPower = amount of ukava coin
|
||||
stakedCoins, err := th.lk.GetStakedTokensForDerivatives(ctx, sdk.NewCoins(coin))
|
||||
if err != nil {
|
||||
// error is returned only if the bkava denom is incorrect, which should never happen here.
|
||||
panic(err)
|
||||
}
|
||||
votingPower := sdk.NewDecFromInt(stakedCoins.Amount)
|
||||
// // votingPower = amount of ukava coin
|
||||
// stakedCoins, err := th.lk.GetStakedTokensForDerivatives(ctx, sdk.NewCoins(coin))
|
||||
// if err != nil {
|
||||
// // error is returned only if the bkava denom is incorrect, which should never happen here.
|
||||
// panic(err)
|
||||
// }
|
||||
// votingPower := sdk.NewDecFromInt(stakedCoins.Amount)
|
||||
|
||||
for _, option := range vote.Options {
|
||||
subPower := votingPower.Mul(sdk.MustNewDecFromStr(option.Weight))
|
||||
results[option.Option] = results[option.Option].Add(subPower)
|
||||
}
|
||||
totalVotingPower = totalVotingPower.Add(votingPower)
|
||||
}
|
||||
// for _, option := range vote.Options {
|
||||
// subPower := votingPower.Mul(sdk.MustNewDecFromStr(option.Weight))
|
||||
// results[option.Option] = results[option.Option].Add(subPower)
|
||||
// }
|
||||
// totalVotingPower = totalVotingPower.Add(votingPower)
|
||||
// }
|
||||
|
||||
th.gk.DeleteVote(ctx, vote.ProposalId, voter)
|
||||
return false
|
||||
@ -219,38 +208,38 @@ func (th TallyHandler) getAddrBkava(ctx sdk.Context, addr sdk.AccAddress) bkavaB
|
||||
|
||||
// addBkavaFromWallet adds all addr balances of bkava in x/bank.
|
||||
func (th TallyHandler) addBkavaFromWallet(ctx sdk.Context, addr sdk.AccAddress, bkava bkavaByDenom) {
|
||||
coins := th.bk.GetAllBalances(ctx, addr)
|
||||
for _, coin := range coins {
|
||||
if th.lk.IsDerivativeDenom(ctx, coin.Denom) {
|
||||
bkava.add(coin)
|
||||
}
|
||||
}
|
||||
// coins := th.bk.GetAllBalances(ctx, addr)
|
||||
// for _, coin := range coins {
|
||||
// if th.lk.IsDerivativeDenom(ctx, coin.Denom) {
|
||||
// bkava.add(coin)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// addBkavaFromSavings adds all addr deposits of bkava in x/savings.
|
||||
func (th TallyHandler) addBkavaFromSavings(ctx sdk.Context, addr sdk.AccAddress, bkava bkavaByDenom) {
|
||||
deposit, found := th.svk.GetDeposit(ctx, addr)
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
for _, coin := range deposit.Amount {
|
||||
if th.lk.IsDerivativeDenom(ctx, coin.Denom) {
|
||||
bkava.add(coin)
|
||||
}
|
||||
}
|
||||
// deposit, found := th.svk.GetDeposit(ctx, addr)
|
||||
// if !found {
|
||||
// return
|
||||
// }
|
||||
// for _, coin := range deposit.Amount {
|
||||
// if th.lk.IsDerivativeDenom(ctx, coin.Denom) {
|
||||
// bkava.add(coin)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// addBkavaFromEarn adds all addr deposits of bkava in x/earn.
|
||||
func (th TallyHandler) addBkavaFromEarn(ctx sdk.Context, addr sdk.AccAddress, bkava bkavaByDenom) {
|
||||
shares, found := th.ek.GetVaultAccountShares(ctx, addr)
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
for _, share := range shares {
|
||||
if th.lk.IsDerivativeDenom(ctx, share.Denom) {
|
||||
if coin, err := th.ek.ConvertToAssets(ctx, share); err == nil {
|
||||
bkava.add(coin)
|
||||
}
|
||||
}
|
||||
}
|
||||
// shares, found := th.ek.GetVaultAccountShares(ctx, addr)
|
||||
// if !found {
|
||||
// return
|
||||
// }
|
||||
// for _, share := range shares {
|
||||
// if th.lk.IsDerivativeDenom(ctx, share.Denom) {
|
||||
// if coin, err := th.ek.ConvertToAssets(ctx, share); err == nil {
|
||||
// bkava.add(coin)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -16,9 +16,6 @@ import (
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
earntypes "github.com/kava-labs/kava/x/earn/types"
|
||||
liquidtypes "github.com/kava-labs/kava/x/liquid/types"
|
||||
)
|
||||
|
||||
// d is an alias for sdk.MustNewDecFromStr
|
||||
@ -50,9 +47,6 @@ func (suite *tallyHandlerSuite) SetupTest() {
|
||||
suite.tallier = NewTallyHandler(
|
||||
suite.app.GetGovKeeper(),
|
||||
suite.app.GetStakingKeeper(),
|
||||
suite.app.GetSavingsKeeper(),
|
||||
suite.app.GetEarnKeeper(),
|
||||
suite.app.GetLiquidKeeper(),
|
||||
suite.app.GetBankKeeper(),
|
||||
)
|
||||
}
|
||||
@ -269,39 +263,40 @@ func (suite *tallyHandlerSuite) newBondCoin(amount sdkmath.Int) sdk.Coin {
|
||||
}
|
||||
|
||||
func (suite *tallyHandlerSuite) allowBKavaEarnDeposits() {
|
||||
ek := suite.app.GetEarnKeeper()
|
||||
earnParams := ek.GetParams(suite.ctx)
|
||||
// ek := suite.app.GetEarnKeeper()
|
||||
// earnParams := ek.GetParams(suite.ctx)
|
||||
|
||||
vault := earntypes.NewAllowedVault(
|
||||
liquidtypes.DefaultDerivativeDenom,
|
||||
earntypes.StrategyTypes{earntypes.STRATEGY_TYPE_SAVINGS},
|
||||
false,
|
||||
nil,
|
||||
)
|
||||
// vault := earntypes.NewAllowedVault(
|
||||
// liquidtypes.DefaultDerivativeDenom,
|
||||
// earntypes.StrategyTypes{earntypes.STRATEGY_TYPE_SAVINGS},
|
||||
// false,
|
||||
// nil,
|
||||
// )
|
||||
|
||||
earnParams.AllowedVaults = append(earnParams.AllowedVaults, vault)
|
||||
ek.SetParams(suite.ctx, earnParams)
|
||||
// earnParams.AllowedVaults = append(earnParams.AllowedVaults, vault)
|
||||
// ek.SetParams(suite.ctx, earnParams)
|
||||
|
||||
sk := suite.app.GetSavingsKeeper()
|
||||
savingsParams := sk.GetParams(suite.ctx)
|
||||
savingsParams.SupportedDenoms = append(savingsParams.SupportedDenoms, liquidtypes.DefaultDerivativeDenom)
|
||||
sk.SetParams(suite.ctx, savingsParams)
|
||||
// sk := suite.app.GetSavingsKeeper()
|
||||
// savingsParams := sk.GetParams(suite.ctx)
|
||||
// savingsParams.SupportedDenoms = append(savingsParams.SupportedDenoms, liquidtypes.DefaultDerivativeDenom)
|
||||
// sk.SetParams(suite.ctx, savingsParams)
|
||||
}
|
||||
|
||||
func (suite *tallyHandlerSuite) earnDeposit(owner sdk.AccAddress, derivative sdk.Coin) {
|
||||
ek := suite.app.GetEarnKeeper()
|
||||
// ek := suite.app.GetEarnKeeper()
|
||||
|
||||
err := ek.Deposit(suite.ctx, owner, derivative, earntypes.STRATEGY_TYPE_SAVINGS)
|
||||
suite.Require().NoError(err)
|
||||
// err := ek.Deposit(suite.ctx, owner, derivative, earntypes.STRATEGY_TYPE_SAVINGS)
|
||||
// suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
func (suite *tallyHandlerSuite) mintDerivative(owner sdk.AccAddress, validator sdk.ValAddress, amount sdkmath.Int) sdk.Coin {
|
||||
lk := suite.app.GetLiquidKeeper()
|
||||
// lk := suite.app.GetLiquidKeeper()
|
||||
|
||||
minted, err := lk.MintDerivative(suite.ctx, owner, validator, suite.newBondCoin(amount))
|
||||
suite.Require().NoError(err)
|
||||
// minted, err := lk.MintDerivative(suite.ctx, owner, validator, suite.newBondCoin(amount))
|
||||
// suite.Require().NoError(err)
|
||||
|
||||
return minted
|
||||
// return minted
|
||||
return sdk.NewCoin("ukava", amount)
|
||||
}
|
||||
|
||||
func (suite *tallyHandlerSuite) delegateToNewBondedValidator(delegator sdk.AccAddress, amount sdkmath.Int) stakingtypes.ValidatorI {
|
||||
|
@ -41,22 +41,12 @@ import (
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
tmdb "github.com/tendermint/tm-db"
|
||||
|
||||
auctionkeeper "github.com/kava-labs/kava/x/auction/keeper"
|
||||
bep3keeper "github.com/kava-labs/kava/x/bep3/keeper"
|
||||
cdpkeeper "github.com/kava-labs/kava/x/cdp/keeper"
|
||||
committeekeeper "github.com/kava-labs/kava/x/committee/keeper"
|
||||
communitykeeper "github.com/kava-labs/kava/x/community/keeper"
|
||||
earnkeeper "github.com/kava-labs/kava/x/earn/keeper"
|
||||
evmutilkeeper "github.com/kava-labs/kava/x/evmutil/keeper"
|
||||
hardkeeper "github.com/kava-labs/kava/x/hard/keeper"
|
||||
incentivekeeper "github.com/kava-labs/kava/x/incentive/keeper"
|
||||
issuancekeeper "github.com/kava-labs/kava/x/issuance/keeper"
|
||||
kavadistkeeper "github.com/kava-labs/kava/x/kavadist/keeper"
|
||||
liquidkeeper "github.com/kava-labs/kava/x/liquid/keeper"
|
||||
pricefeedkeeper "github.com/kava-labs/kava/x/pricefeed/keeper"
|
||||
routerkeeper "github.com/kava-labs/kava/x/router/keeper"
|
||||
savingskeeper "github.com/kava-labs/kava/x/savings/keeper"
|
||||
swapkeeper "github.com/kava-labs/kava/x/swap/keeper"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
bep3keeper "github.com/0glabs/0g-chain/x/bep3/keeper"
|
||||
committeekeeper "github.com/0glabs/0g-chain/x/committee/keeper"
|
||||
evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper"
|
||||
issuancekeeper "github.com/0glabs/0g-chain/x/issuance/keeper"
|
||||
pricefeedkeeper "github.com/0glabs/0g-chain/x/pricefeed/keeper"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -88,7 +78,7 @@ type TestApp struct {
|
||||
//
|
||||
// Note, it also sets the sdk config with the app's address prefix, coin type, etc.
|
||||
func NewTestApp() TestApp {
|
||||
SetSDKConfig()
|
||||
chaincfg.SetSDKConfig()
|
||||
|
||||
return NewTestAppFromSealed()
|
||||
}
|
||||
@ -99,7 +89,7 @@ func NewTestAppFromSealed() TestApp {
|
||||
|
||||
encCfg := MakeEncodingConfig()
|
||||
|
||||
app := NewApp(log.NewNopLogger(), db, DefaultNodeHome, nil, encCfg, DefaultOptions)
|
||||
app := NewApp(log.NewNopLogger(), db, chaincfg.DefaultNodeHome, nil, encCfg, DefaultOptions)
|
||||
return TestApp{App: *app}
|
||||
}
|
||||
|
||||
@ -113,24 +103,13 @@ func (tApp TestApp) GetDistrKeeper() distkeeper.Keeper { return tApp.di
|
||||
func (tApp TestApp) GetGovKeeper() govkeeper.Keeper { return tApp.govKeeper }
|
||||
func (tApp TestApp) GetCrisisKeeper() crisiskeeper.Keeper { return tApp.crisisKeeper }
|
||||
func (tApp TestApp) GetParamsKeeper() paramskeeper.Keeper { return tApp.paramsKeeper }
|
||||
func (tApp TestApp) GetKavadistKeeper() kavadistkeeper.Keeper { return tApp.kavadistKeeper }
|
||||
func (tApp TestApp) GetAuctionKeeper() auctionkeeper.Keeper { return tApp.auctionKeeper }
|
||||
func (tApp TestApp) GetIssuanceKeeper() issuancekeeper.Keeper { return tApp.issuanceKeeper }
|
||||
func (tApp TestApp) GetBep3Keeper() bep3keeper.Keeper { return tApp.bep3Keeper }
|
||||
func (tApp TestApp) GetPriceFeedKeeper() pricefeedkeeper.Keeper { return tApp.pricefeedKeeper }
|
||||
func (tApp TestApp) GetSwapKeeper() swapkeeper.Keeper { return tApp.swapKeeper }
|
||||
func (tApp TestApp) GetCDPKeeper() cdpkeeper.Keeper { return tApp.cdpKeeper }
|
||||
func (tApp TestApp) GetHardKeeper() hardkeeper.Keeper { return tApp.hardKeeper }
|
||||
func (tApp TestApp) GetCommitteeKeeper() committeekeeper.Keeper { return tApp.committeeKeeper }
|
||||
func (tApp TestApp) GetIncentiveKeeper() incentivekeeper.Keeper { return tApp.incentiveKeeper }
|
||||
func (tApp TestApp) GetEvmutilKeeper() evmutilkeeper.Keeper { return tApp.evmutilKeeper }
|
||||
func (tApp TestApp) GetEvmKeeper() *evmkeeper.Keeper { return tApp.evmKeeper }
|
||||
func (tApp TestApp) GetSavingsKeeper() savingskeeper.Keeper { return tApp.savingsKeeper }
|
||||
func (tApp TestApp) GetFeeMarketKeeper() feemarketkeeper.Keeper { return tApp.feeMarketKeeper }
|
||||
func (tApp TestApp) GetLiquidKeeper() liquidkeeper.Keeper { return tApp.liquidKeeper }
|
||||
func (tApp TestApp) GetEarnKeeper() earnkeeper.Keeper { return tApp.earnKeeper }
|
||||
func (tApp TestApp) GetRouterKeeper() routerkeeper.Keeper { return tApp.routerKeeper }
|
||||
func (tApp TestApp) GetCommunityKeeper() communitykeeper.Keeper { return tApp.communityKeeper }
|
||||
|
||||
func (tApp TestApp) GetKVStoreKey(key string) *storetypes.KVStoreKey {
|
||||
return tApp.keys[key]
|
||||
@ -170,7 +149,7 @@ func GenesisStateWithSingleValidator(
|
||||
balances := []banktypes.Balance{
|
||||
{
|
||||
Address: acc.GetAddress().String(),
|
||||
Coins: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(100000000000000))),
|
||||
Coins: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100000000000000)),
|
||||
},
|
||||
}
|
||||
|
||||
@ -233,7 +212,7 @@ func genesisStateWithValSet(
|
||||
}
|
||||
// set validators and delegations
|
||||
currentStakingGenesis := stakingtypes.GetGenesisStateFromAppState(app.appCodec, genesisState)
|
||||
currentStakingGenesis.Params.BondDenom = "ukava"
|
||||
currentStakingGenesis.Params.BondDenom = chaincfg.GasDenom // TODO:
|
||||
|
||||
stakingGenesis := stakingtypes.NewGenesisState(
|
||||
currentStakingGenesis.Params,
|
||||
@ -253,13 +232,13 @@ func genesisStateWithValSet(
|
||||
|
||||
for range delegations {
|
||||
// add delegated tokens to total supply
|
||||
totalSupply = totalSupply.Add(sdk.NewCoin("ukava", bondAmt))
|
||||
totalSupply = totalSupply.Add(chaincfg.MakeCoinForGasDenom(bondAmt))
|
||||
}
|
||||
|
||||
// add bonded amount to bonded pool module account
|
||||
balances = append(balances, banktypes.Balance{
|
||||
Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(),
|
||||
Coins: sdk.Coins{sdk.NewCoin("ukava", bondAmt)},
|
||||
Coins: sdk.Coins{chaincfg.MakeCoinForGasDenom(bondAmt)},
|
||||
})
|
||||
|
||||
bankGenesis := banktypes.NewGenesisState(
|
||||
|
257
app/upgrades.go
257
app/upgrades.go
@ -1,3 +1,258 @@
|
||||
package app
|
||||
|
||||
func (app App) RegisterUpgradeHandlers() {}
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||
)
|
||||
|
||||
const (
|
||||
UpgradeName_Mainnet = "v0.25.0"
|
||||
UpgradeName_Testnet = "v0.25.0-alpha.0"
|
||||
UpgradeName_E2ETest = "v0.25.0-testing"
|
||||
)
|
||||
|
||||
var (
|
||||
// KAVA to ukava - 6 decimals
|
||||
kavaConversionFactor = sdk.NewInt(1000_000)
|
||||
secondsPerYear = sdk.NewInt(365 * 24 * 60 * 60)
|
||||
|
||||
// 10 Million KAVA per year in staking rewards, inflation disable time 2024-01-01T00:00:00 UTC
|
||||
// CommunityParams_Mainnet = communitytypes.NewParams(
|
||||
// time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
// // before switchover
|
||||
// sdkmath.LegacyZeroDec(),
|
||||
// // after switchover - 10M KAVA to ukava per year / seconds per year
|
||||
// sdkmath.LegacyNewDec(10_000_000).
|
||||
// MulInt(kavaConversionFactor).
|
||||
// QuoInt(secondsPerYear),
|
||||
// )
|
||||
|
||||
// Testnet -- 15 Trillion KAVA per year in staking rewards, inflation disable time 2023-11-16T00:00:00 UTC
|
||||
// CommunityParams_Testnet = communitytypes.NewParams(
|
||||
// time.Date(2023, 11, 16, 0, 0, 0, 0, time.UTC),
|
||||
// // before switchover
|
||||
// sdkmath.LegacyZeroDec(),
|
||||
// // after switchover
|
||||
// sdkmath.LegacyNewDec(15_000_000).
|
||||
// MulInt64(1_000_000). // 15M * 1M = 15T
|
||||
// MulInt(kavaConversionFactor).
|
||||
// QuoInt(secondsPerYear),
|
||||
// )
|
||||
|
||||
// CommunityParams_E2E = communitytypes.NewParams(
|
||||
// time.Now().Add(10*time.Second).UTC(), // relative time for testing
|
||||
// sdkmath.LegacyNewDec(0), // stakingRewardsPerSecond
|
||||
// sdkmath.LegacyNewDec(1000), // upgradeTimeSetstakingRewardsPerSecond
|
||||
// )
|
||||
|
||||
// ValidatorMinimumCommission is the new 5% minimum commission rate for validators
|
||||
ValidatorMinimumCommission = sdk.NewDecWithPrec(5, 2)
|
||||
)
|
||||
|
||||
// RegisterUpgradeHandlers registers the upgrade handlers for the app.
|
||||
func (app App) RegisterUpgradeHandlers() {
|
||||
// app.upgradeKeeper.SetUpgradeHandler(
|
||||
// UpgradeName_Mainnet,
|
||||
// upgradeHandler(app, UpgradeName_Mainnet, CommunityParams_Mainnet),
|
||||
// )
|
||||
// app.upgradeKeeper.SetUpgradeHandler(
|
||||
// UpgradeName_Testnet,
|
||||
// upgradeHandler(app, UpgradeName_Testnet, CommunityParams_Testnet),
|
||||
// )
|
||||
// app.upgradeKeeper.SetUpgradeHandler(
|
||||
// UpgradeName_E2ETest,
|
||||
// upgradeHandler(app, UpgradeName_Testnet, CommunityParams_E2E),
|
||||
// )
|
||||
|
||||
upgradeInfo, err := app.upgradeKeeper.ReadUpgradeInfoFromDisk()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
doUpgrade := upgradeInfo.Name == UpgradeName_Mainnet ||
|
||||
upgradeInfo.Name == UpgradeName_Testnet ||
|
||||
upgradeInfo.Name == UpgradeName_E2ETest
|
||||
|
||||
if doUpgrade && !app.upgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
|
||||
storeUpgrades := storetypes.StoreUpgrades{
|
||||
Added: []string{
|
||||
// x/community added store
|
||||
// communitytypes.ModuleName,
|
||||
},
|
||||
}
|
||||
|
||||
// configure store loader that checks if version == upgradeHeight and applies store upgrades
|
||||
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
|
||||
}
|
||||
}
|
||||
|
||||
// upgradeHandler returns an UpgradeHandler for the given upgrade parameters.
|
||||
func upgradeHandler(
|
||||
app App,
|
||||
name string,
|
||||
// communityParams communitytypes.Params,
|
||||
) upgradetypes.UpgradeHandler {
|
||||
return func(
|
||||
ctx sdk.Context,
|
||||
plan upgradetypes.Plan,
|
||||
fromVM module.VersionMap,
|
||||
) (module.VersionMap, error) {
|
||||
app.Logger().Info(fmt.Sprintf("running %s upgrade handler", name))
|
||||
|
||||
toVM, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
|
||||
if err != nil {
|
||||
return toVM, err
|
||||
}
|
||||
|
||||
//
|
||||
// Staking validator minimum commission
|
||||
//
|
||||
UpdateValidatorMinimumCommission(ctx, app)
|
||||
|
||||
//
|
||||
// Community Params
|
||||
//
|
||||
// app.communityKeeper.SetParams(ctx, communityParams)
|
||||
// app.Logger().Info(
|
||||
// "initialized x/community params",
|
||||
// "UpgradeTimeDisableInflation", communityParams.UpgradeTimeDisableInflation,
|
||||
// "StakingRewardsPerSecond", communityParams.StakingRewardsPerSecond,
|
||||
// "UpgradeTimeSetStakingRewardsPerSecond", communityParams.UpgradeTimeSetStakingRewardsPerSecond,
|
||||
// )
|
||||
|
||||
//
|
||||
// Kavadist gov grant
|
||||
//
|
||||
// msgGrant, err := authz.NewMsgGrant(
|
||||
// app.accountKeeper.GetModuleAddress(kavadisttypes.ModuleName), // granter
|
||||
// app.accountKeeper.GetModuleAddress(govtypes.ModuleName), // grantee
|
||||
// authz.NewGenericAuthorization(sdk.MsgTypeURL(&banktypes.MsgSend{})), // authorization
|
||||
// nil, // expiration
|
||||
// )
|
||||
// if err != nil {
|
||||
// return toVM, err
|
||||
// }
|
||||
// _, err = app.authzKeeper.Grant(ctx, msgGrant)
|
||||
// if err != nil {
|
||||
// return toVM, err
|
||||
// }
|
||||
// app.Logger().Info("created gov grant for kavadist funds")
|
||||
|
||||
//
|
||||
// Gov Quorum
|
||||
//
|
||||
govTallyParams := app.govKeeper.GetTallyParams(ctx)
|
||||
oldQuorum := govTallyParams.Quorum
|
||||
govTallyParams.Quorum = sdkmath.LegacyMustNewDecFromStr("0.2").String()
|
||||
app.govKeeper.SetTallyParams(ctx, govTallyParams)
|
||||
app.Logger().Info(fmt.Sprintf("updated tally quorum from %s to %s", oldQuorum, govTallyParams.Quorum))
|
||||
|
||||
//
|
||||
// Incentive Params
|
||||
//
|
||||
UpdateIncentiveParams(ctx, app)
|
||||
|
||||
return toVM, nil
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateValidatorMinimumCommission updates the commission rate for all
|
||||
// validators to be at least the new min commission rate, and sets the minimum
|
||||
// commission rate in the staking params.
|
||||
func UpdateValidatorMinimumCommission(
|
||||
ctx sdk.Context,
|
||||
app App,
|
||||
) {
|
||||
resultCount := make(map[stakingtypes.BondStatus]int)
|
||||
|
||||
// Iterate over *all* validators including inactive
|
||||
app.stakingKeeper.IterateValidators(
|
||||
ctx,
|
||||
func(index int64, validator stakingtypes.ValidatorI) (stop bool) {
|
||||
// Skip if validator commission is already >= 5%
|
||||
if validator.GetCommission().GTE(ValidatorMinimumCommission) {
|
||||
return false
|
||||
}
|
||||
|
||||
val, ok := validator.(stakingtypes.Validator)
|
||||
if !ok {
|
||||
panic("expected stakingtypes.Validator")
|
||||
}
|
||||
|
||||
// Set minimum commission rate to 5%, when commission is < 5%
|
||||
val.Commission.Rate = ValidatorMinimumCommission
|
||||
val.Commission.UpdateTime = ctx.BlockTime()
|
||||
|
||||
// Update MaxRate if necessary
|
||||
if val.Commission.MaxRate.LT(ValidatorMinimumCommission) {
|
||||
val.Commission.MaxRate = ValidatorMinimumCommission
|
||||
}
|
||||
|
||||
if err := app.stakingKeeper.BeforeValidatorModified(ctx, val.GetOperator()); err != nil {
|
||||
panic(fmt.Sprintf("failed to call BeforeValidatorModified: %s", err))
|
||||
}
|
||||
app.stakingKeeper.SetValidator(ctx, val)
|
||||
|
||||
// Keep track of counts just for logging purposes
|
||||
switch val.GetStatus() {
|
||||
case stakingtypes.Bonded:
|
||||
resultCount[stakingtypes.Bonded]++
|
||||
case stakingtypes.Unbonded:
|
||||
resultCount[stakingtypes.Unbonded]++
|
||||
case stakingtypes.Unbonding:
|
||||
resultCount[stakingtypes.Unbonding]++
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
)
|
||||
|
||||
app.Logger().Info(
|
||||
"updated validator minimum commission rate for all existing validators",
|
||||
stakingtypes.BondStatusBonded, resultCount[stakingtypes.Bonded],
|
||||
stakingtypes.BondStatusUnbonded, resultCount[stakingtypes.Unbonded],
|
||||
stakingtypes.BondStatusUnbonding, resultCount[stakingtypes.Unbonding],
|
||||
)
|
||||
|
||||
stakingParams := app.stakingKeeper.GetParams(ctx)
|
||||
stakingParams.MinCommissionRate = ValidatorMinimumCommission
|
||||
app.stakingKeeper.SetParams(ctx, stakingParams)
|
||||
|
||||
app.Logger().Info(
|
||||
"updated x/staking params minimum commission rate",
|
||||
"MinCommissionRate", stakingParams.MinCommissionRate,
|
||||
)
|
||||
}
|
||||
|
||||
// UpdateIncentiveParams modifies the earn rewards period for bkava to be 600K KAVA per year.
|
||||
func UpdateIncentiveParams(
|
||||
ctx sdk.Context,
|
||||
app App,
|
||||
) {
|
||||
// incentiveParams := app.incentiveKeeper.GetParams(ctx)
|
||||
|
||||
// bkava annualized rewards: 600K KAVA
|
||||
// newAmount := sdkmath.LegacyNewDec(600_000).
|
||||
// MulInt(kavaConversionFactor).
|
||||
// QuoInt(secondsPerYear).
|
||||
// TruncateInt()
|
||||
|
||||
// for i := range incentiveParams.EarnRewardPeriods {
|
||||
// if incentiveParams.EarnRewardPeriods[i].CollateralType != "bkava" {
|
||||
// continue
|
||||
// }
|
||||
|
||||
// // Update rewards per second via index
|
||||
// incentiveParams.EarnRewardPeriods[i].RewardsPerSecond = sdk.NewCoins(
|
||||
// sdk.NewCoin("ukava", newAmount),
|
||||
// )
|
||||
// }
|
||||
|
||||
// app.incentiveKeeper.SetParams(ctx, incentiveParams)
|
||||
}
|
||||
|
239
app/upgrades_test.go
Normal file
239
app/upgrades_test.go
Normal file
@ -0,0 +1,239 @@
|
||||
package app_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/evmos/ethermint/crypto/ethsecp256k1"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
)
|
||||
|
||||
// func TestUpgradeCommunityParams_Mainnet(t *testing.T) {
|
||||
// require.Equal(
|
||||
// t,
|
||||
// sdkmath.LegacyZeroDec().String(),
|
||||
// app.CommunityParams_Mainnet.StakingRewardsPerSecond.String(),
|
||||
// )
|
||||
|
||||
// require.Equal(
|
||||
// t,
|
||||
// // Manually confirmed
|
||||
// "317097.919837645865043125",
|
||||
// app.CommunityParams_Mainnet.UpgradeTimeSetStakingRewardsPerSecond.String(),
|
||||
// "mainnet kava per second should be correct",
|
||||
// )
|
||||
// }
|
||||
|
||||
// func TestUpgradeCommunityParams_Testnet(t *testing.T) {
|
||||
// require.Equal(
|
||||
// t,
|
||||
// sdkmath.LegacyZeroDec().String(),
|
||||
// app.CommunityParams_Testnet.StakingRewardsPerSecond.String(),
|
||||
// )
|
||||
|
||||
// require.Equal(
|
||||
// t,
|
||||
// // Manually confirmed
|
||||
// "475646879756.468797564687975646",
|
||||
// app.CommunityParams_Testnet.UpgradeTimeSetStakingRewardsPerSecond.String(),
|
||||
// "testnet kava per second should be correct",
|
||||
// )
|
||||
// }
|
||||
|
||||
func TestUpdateValidatorMinimumCommission(t *testing.T) {
|
||||
tApp := app.NewTestApp()
|
||||
tApp.InitializeFromGenesisStates()
|
||||
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
||||
|
||||
sk := tApp.GetStakingKeeper()
|
||||
stakingParams := sk.GetParams(ctx)
|
||||
stakingParams.MinCommissionRate = sdk.ZeroDec()
|
||||
sk.SetParams(ctx, stakingParams)
|
||||
|
||||
// Set some validators with varying commission rates
|
||||
|
||||
vals := []struct {
|
||||
name string
|
||||
operatorAddr sdk.ValAddress
|
||||
consPriv *ethsecp256k1.PrivKey
|
||||
commissionRateMin sdk.Dec
|
||||
commissionRateMax sdk.Dec
|
||||
shouldBeUpdated bool
|
||||
}{
|
||||
{
|
||||
name: "zero commission rate",
|
||||
operatorAddr: sdk.ValAddress("val0"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.ZeroDec(),
|
||||
commissionRateMax: sdk.ZeroDec(),
|
||||
shouldBeUpdated: true,
|
||||
},
|
||||
{
|
||||
name: "0.01 commission rate",
|
||||
operatorAddr: sdk.ValAddress("val1"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.MustNewDecFromStr("0.01"),
|
||||
commissionRateMax: sdk.MustNewDecFromStr("0.01"),
|
||||
shouldBeUpdated: true,
|
||||
},
|
||||
{
|
||||
name: "0.05 commission rate",
|
||||
operatorAddr: sdk.ValAddress("val2"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.MustNewDecFromStr("0.05"),
|
||||
commissionRateMax: sdk.MustNewDecFromStr("0.05"),
|
||||
shouldBeUpdated: false,
|
||||
},
|
||||
{
|
||||
name: "0.06 commission rate",
|
||||
operatorAddr: sdk.ValAddress("val3"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.MustNewDecFromStr("0.06"),
|
||||
commissionRateMax: sdk.MustNewDecFromStr("0.06"),
|
||||
shouldBeUpdated: false,
|
||||
},
|
||||
{
|
||||
name: "0.5 commission rate",
|
||||
operatorAddr: sdk.ValAddress("val4"),
|
||||
consPriv: generateConsKey(t),
|
||||
commissionRateMin: sdk.MustNewDecFromStr("0.5"),
|
||||
commissionRateMax: sdk.MustNewDecFromStr("0.5"),
|
||||
shouldBeUpdated: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, v := range vals {
|
||||
val, err := stakingtypes.NewValidator(
|
||||
v.operatorAddr,
|
||||
v.consPriv.PubKey(),
|
||||
stakingtypes.Description{},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
val.Commission.Rate = v.commissionRateMin
|
||||
val.Commission.MaxRate = v.commissionRateMax
|
||||
|
||||
err = sk.SetValidatorByConsAddr(ctx, val)
|
||||
require.NoError(t, err)
|
||||
sk.SetValidator(ctx, val)
|
||||
}
|
||||
|
||||
require.NotPanics(
|
||||
t, func() {
|
||||
app.UpdateValidatorMinimumCommission(ctx, tApp.App)
|
||||
},
|
||||
)
|
||||
|
||||
stakingParamsAfter := sk.GetParams(ctx)
|
||||
require.Equal(t, stakingParamsAfter.MinCommissionRate, app.ValidatorMinimumCommission)
|
||||
|
||||
// Check that all validators have a commission rate >= 5%
|
||||
for _, val := range vals {
|
||||
t.Run(val.name, func(t *testing.T) {
|
||||
validator, found := sk.GetValidator(ctx, val.operatorAddr)
|
||||
require.True(t, found, "validator should be found")
|
||||
|
||||
require.True(
|
||||
t,
|
||||
validator.GetCommission().GTE(app.ValidatorMinimumCommission),
|
||||
"commission rate should be >= 5%",
|
||||
)
|
||||
|
||||
require.True(
|
||||
t,
|
||||
validator.Commission.MaxRate.GTE(app.ValidatorMinimumCommission),
|
||||
"commission rate max should be >= 5%, got %s",
|
||||
validator.Commission.MaxRate,
|
||||
)
|
||||
|
||||
if val.shouldBeUpdated {
|
||||
require.Equal(
|
||||
t,
|
||||
ctx.BlockTime(),
|
||||
validator.Commission.UpdateTime,
|
||||
"commission update time should be set to block time",
|
||||
)
|
||||
} else {
|
||||
require.Equal(
|
||||
t,
|
||||
time.Unix(0, 0).UTC(),
|
||||
validator.Commission.UpdateTime,
|
||||
"commission update time should not be changed -- default value is 0",
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// func TestUpdateIncentiveParams(t *testing.T) {
|
||||
// tApp := app.NewTestApp()
|
||||
// tApp.InitializeFromGenesisStates()
|
||||
// ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
||||
|
||||
// ik := tApp.GetIncentiveKeeper()
|
||||
// params := ik.GetParams(ctx)
|
||||
|
||||
// startPeriod := time.Date(2021, 10, 26, 15, 0, 0, 0, time.UTC)
|
||||
// endPeriod := time.Date(2022, 10, 26, 15, 0, 0, 0, time.UTC)
|
||||
|
||||
// params.EarnRewardPeriods = incentivetypes.MultiRewardPeriods{
|
||||
// incentivetypes.NewMultiRewardPeriod(
|
||||
// true,
|
||||
// "bkava",
|
||||
// startPeriod,
|
||||
// endPeriod,
|
||||
// sdk.NewCoins(
|
||||
// sdk.NewCoin("ukava", sdk.NewInt(159459)),
|
||||
// ),
|
||||
// ),
|
||||
// }
|
||||
// ik.SetParams(ctx, params)
|
||||
|
||||
// beforeParams := ik.GetParams(ctx)
|
||||
// require.Equal(t, params, beforeParams, "initial incentive params should be set")
|
||||
|
||||
// // -- UPGRADE
|
||||
// app.UpdateIncentiveParams(ctx, tApp.App)
|
||||
|
||||
// // -- After
|
||||
// afterParams := ik.GetParams(ctx)
|
||||
|
||||
// require.Len(
|
||||
// t,
|
||||
// afterParams.EarnRewardPeriods[0].RewardsPerSecond,
|
||||
// 1,
|
||||
// "bkava earn reward period should only contain 1 coin",
|
||||
// )
|
||||
// require.Equal(
|
||||
// t,
|
||||
// // Manual calculation of
|
||||
// // 600,000 * 1000,000 / (365 * 24 * 60 * 60)
|
||||
// sdk.NewCoin("ukava", sdkmath.NewInt(19025)),
|
||||
// afterParams.EarnRewardPeriods[0].RewardsPerSecond[0],
|
||||
// "bkava earn reward period should be updated",
|
||||
// )
|
||||
|
||||
// // Check that other params are not changed
|
||||
// afterParams.EarnRewardPeriods[0].RewardsPerSecond[0] = beforeParams.EarnRewardPeriods[0].RewardsPerSecond[0]
|
||||
// require.Equal(
|
||||
// t,
|
||||
// beforeParams,
|
||||
// afterParams,
|
||||
// "other param values should not be changed",
|
||||
// )
|
||||
// }
|
||||
|
||||
func generateConsKey(
|
||||
t *testing.T,
|
||||
) *ethsecp256k1.PrivKey {
|
||||
t.Helper()
|
||||
|
||||
key, err := ethsecp256k1.GenerateKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
return key
|
||||
}
|
@ -7,7 +7,7 @@ proto-lint check-proto-lint: install-build-deps
|
||||
proto-gen: install-build-deps
|
||||
@echo "Generating go proto files"
|
||||
@$(BUF) generate --template proto/buf.gen.gogo.yaml proto
|
||||
@cp -r out/github.com/kava-labs/kava/* ./
|
||||
@cp -r out/github.com/0glabs/0g-chain/* ./
|
||||
@rm -rf out/github.com
|
||||
|
||||
.PHONY: check-proto-gen
|
||||
|
22
chaincfg/coin.go
Normal file
22
chaincfg/coin.go
Normal file
@ -0,0 +1,22 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
var (
|
||||
// Bip44CoinType satisfies EIP84. See https://github.com/ethereum/EIPs/issues/84 for more info.
|
||||
Bip44CoinType uint32 = 459 // TODO: need new coin type for 0g-chain (a0gi)
|
||||
// eth = 60
|
||||
// kava = 459 // see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
|
||||
// BIP44HDPath is the default BIP44 HD path used on Ethereum.
|
||||
//BIP44HDPath = ethaccounts.DefaultBaseDerivationPath.String()
|
||||
)
|
||||
|
||||
// TODO: Implement BIP44CoinType and BIP44HDPath
|
||||
// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets.
|
||||
func setBip44CoinType(config *sdk.Config) {
|
||||
config.SetCoinType(Bip44CoinType)
|
||||
//config.SetPurpose(sdk.Purpose) // Shared
|
||||
//config.SetFullFundraiserPath(BIP44HDPath) //nolint: staticcheck
|
||||
}
|
57
chaincfg/coin_helper.go
Normal file
57
chaincfg/coin_helper.go
Normal file
@ -0,0 +1,57 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
func toBigInt(amount any) *big.Int {
|
||||
if amount == nil {
|
||||
return big.NewInt(0)
|
||||
}
|
||||
var val *big.Int
|
||||
switch amount.(type) {
|
||||
case int:
|
||||
val = big.NewInt(int64(amount.(int)))
|
||||
case int32:
|
||||
val = big.NewInt(int64(amount.(int32)))
|
||||
case int64:
|
||||
val = big.NewInt(amount.(int64))
|
||||
case string:
|
||||
var ok bool
|
||||
val, ok = new(big.Int).SetString(amount.(string), 0)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("invalid amount string: %s", amount.(string)))
|
||||
}
|
||||
case math.Int:
|
||||
val = amount.(math.Int).BigInt()
|
||||
case *big.Int:
|
||||
val = amount.(*big.Int)
|
||||
case float64:
|
||||
val = decimal.NewFromFloat(amount.(float64)).BigInt()
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid amount type: %T", amount))
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func MakeCoinForStandardDenom(amount any) sdk.Coin {
|
||||
return makeCoin(StandardDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func MakeCoinForGasDenom(amount any) sdk.Coin {
|
||||
return makeCoin(GasDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func MakeCoinForEvmDenom(amount any) sdk.Coin {
|
||||
return makeCoin(EvmDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func makeCoin(denom string, amount *big.Int) sdk.Coin {
|
||||
return sdk.NewCoin(denom, math.NewIntFromBigInt(amount))
|
||||
}
|
15
chaincfg/config.go
Normal file
15
chaincfg/config.go
Normal file
@ -0,0 +1,15 @@
|
||||
package chaincfg
|
||||
|
||||
import sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
const (
|
||||
AppName = "0gchaind"
|
||||
EnvPrefix = "0GCHAIN"
|
||||
)
|
||||
|
||||
func SetSDKConfig() *sdk.Config {
|
||||
config := sdk.GetConfig()
|
||||
setBech32Prefixes(config)
|
||||
setBip44CoinType(config)
|
||||
return config
|
||||
}
|
37
chaincfg/denoms.go
Normal file
37
chaincfg/denoms.go
Normal file
@ -0,0 +1,37 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
const (
|
||||
StandardDenom = "a0gi"
|
||||
|
||||
GasDenom = "ua0gi"
|
||||
|
||||
EvmDenom = "neuron"
|
||||
|
||||
BondDenom = EvmDenom
|
||||
|
||||
GasDenomUnit = 6
|
||||
|
||||
EvmDenomUnit = 18
|
||||
|
||||
GasDenomConversionMultiplier = 1e12
|
||||
EvmDenomConversionMultiplier = 1e18
|
||||
)
|
||||
|
||||
// RegisterDenoms registers the base and gas denominations to the SDK.
|
||||
func RegisterDenoms() {
|
||||
if err := sdk.RegisterDenom(StandardDenom, sdk.OneDec()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := sdk.RegisterDenom(GasDenom, sdk.NewDecWithPrec(1, GasDenomUnit)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := sdk.RegisterDenom(EvmDenom, sdk.NewDecWithPrec(1, EvmDenomUnit)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
80
chaincfg/denoms_test.go
Normal file
80
chaincfg/denoms_test.go
Normal file
@ -0,0 +1,80 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRegisterDenoms(t *testing.T) {
|
||||
RegisterDenoms()
|
||||
tests := []struct {
|
||||
name string
|
||||
from sdk.Coin
|
||||
targetDenom string
|
||||
expCoin sdk.Coin
|
||||
expErr error
|
||||
}{
|
||||
{
|
||||
"standard to gas",
|
||||
MakeCoinForStandardDenom(99),
|
||||
GasDenom,
|
||||
MakeCoinForGasDenom(99 * (EvmDenomConversionMultiplier / GasDenomConversionMultiplier)),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"gas to standard",
|
||||
MakeCoinForGasDenom(5e7),
|
||||
StandardDenom,
|
||||
MakeCoinForStandardDenom(50),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"standard to base",
|
||||
MakeCoinForStandardDenom(22),
|
||||
EvmDenom,
|
||||
MakeCoinForEvmDenom(22 * EvmDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"base to standard",
|
||||
MakeCoinForEvmDenom("97000000000000000000"),
|
||||
StandardDenom,
|
||||
MakeCoinForStandardDenom(97),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"gas to base",
|
||||
MakeCoinForGasDenom(33),
|
||||
EvmDenom,
|
||||
MakeCoinForEvmDenom(33 * GasDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"base to gas",
|
||||
MakeCoinForEvmDenom("770000000000000"),
|
||||
GasDenom,
|
||||
MakeCoinForGasDenom(770000000000000 / GasDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ret, err := sdk.ConvertCoin(tt.from, tt.targetDenom)
|
||||
if tt.expErr != nil {
|
||||
if err == nil {
|
||||
t.Errorf("expErr is not nil, but got nil")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
t.Errorf("expErr is nil, but got %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
assert.Equal(t, tt.expCoin, ret)
|
||||
})
|
||||
}
|
||||
}
|
25
chaincfg/homedir.go
Normal file
25
chaincfg/homedir.go
Normal file
@ -0,0 +1,25 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
stdlog "log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const (
|
||||
HomeDirName = ".0gchain"
|
||||
)
|
||||
|
||||
var (
|
||||
// DefaultNodeHome default home directories for the application daemon
|
||||
DefaultNodeHome string
|
||||
)
|
||||
|
||||
func init() {
|
||||
userHomeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
stdlog.Printf("Failed to get home dir %v", err)
|
||||
}
|
||||
|
||||
DefaultNodeHome = filepath.Join(userHomeDir, HomeDirName)
|
||||
}
|
76
chaincfg/mint.go
Normal file
76
chaincfg/mint.go
Normal file
@ -0,0 +1,76 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
"github.com/shopspring/decimal"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
var (
|
||||
Xmax, _ = sdk.NewDecFromStr("1.0") // upper limit on staked supply (as % of circ supply)
|
||||
Ymin, _ = sdk.NewDecFromStr("0.05") // target APY at upper limit
|
||||
|
||||
Xmin, _ = sdk.NewDecFromStr("0.2") // lower limit on staked supply (as % of circ supply)
|
||||
Ymax, _ = sdk.NewDecFromStr("0.15") // target APY at lower limit
|
||||
|
||||
decayRate, _ = sdk.NewDecFromStr("10")
|
||||
)
|
||||
|
||||
func decExp(x sdk.Dec) sdk.Dec {
|
||||
xDec := decimal.NewFromBigInt(x.BigInt(), -18)
|
||||
expDec, _ := xDec.ExpTaylor(18)
|
||||
expInt := expDec.Shift(18).BigInt()
|
||||
return sdk.NewDecFromBigIntWithPrec(expInt, 18)
|
||||
}
|
||||
|
||||
func NextInflationRate(ctx sdk.Context, minter minttypes.Minter, params minttypes.Params, bondedRatio sdk.Dec, circulatingRatio sdk.Dec) sdk.Dec {
|
||||
X := bondedRatio.Quo(circulatingRatio)
|
||||
|
||||
var apy sdk.Dec
|
||||
if X.LT(Xmin) {
|
||||
apy = Ymax
|
||||
} else {
|
||||
exp := decayRate.Neg().Mul(Xmax.Sub(Xmin))
|
||||
c := decExp(exp)
|
||||
d := Ymin.Sub(Ymax.Mul(c)).Quo(sdk.OneDec().Sub(c))
|
||||
expBonded := decayRate.Neg().Mul(X.Sub(Xmin))
|
||||
cBonded := decExp(expBonded)
|
||||
e := Ymax.Sub(d).Mul(cBonded)
|
||||
apy = d.Add(e)
|
||||
}
|
||||
|
||||
inflation := apy.Mul(bondedRatio)
|
||||
|
||||
// // The target annual inflation rate is recalculated for each previsions cycle. The
|
||||
// // inflation is also subject to a rate change (positive or negative) depending on
|
||||
// // the distance from the desired ratio (67%). The maximum rate change possible is
|
||||
// // defined to be 13% per year, however the annual inflation is capped as between
|
||||
// // 7% and 20%.
|
||||
|
||||
// // (1 - bondedRatio/GoalBonded) * InflationRateChange
|
||||
// inflationRateChangePerYear := sdk.OneDec().
|
||||
// Sub(bondedRatio.Quo(params.GoalBonded)).
|
||||
// Mul(params.InflationRateChange)
|
||||
// inflationRateChange := inflationRateChangePerYear.Quo(sdk.NewDec(int64(params.BlocksPerYear)))
|
||||
|
||||
// // adjust the new annual inflation for this next cycle
|
||||
// inflation := minter.Inflation.Add(inflationRateChange) // note inflationRateChange may be negative
|
||||
// if inflation.GT(params.InflationMax) {
|
||||
// inflation = params.InflationMax
|
||||
// }
|
||||
// if inflation.LT(params.InflationMin) {
|
||||
// inflation = params.InflationMin
|
||||
// }
|
||||
|
||||
ctx.Logger().Info(
|
||||
"nextInflationRate",
|
||||
"bondedRatio", bondedRatio,
|
||||
"circulatingRatio", circulatingRatio,
|
||||
"apy", apy,
|
||||
"inflation", inflation,
|
||||
"params", params,
|
||||
"minter", minter,
|
||||
)
|
||||
return inflation
|
||||
}
|
44
chaincfg/prefix.go
Normal file
44
chaincfg/prefix.go
Normal file
@ -0,0 +1,44 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
const (
|
||||
// Bech32Prefix defines the Bech32 prefix used for EthAccounts
|
||||
Bech32Prefix = "0g"
|
||||
|
||||
// PrefixAccount is the prefix for account keys
|
||||
PrefixAccount = "acc"
|
||||
// PrefixValidator is the prefix for validator keys
|
||||
PrefixValidator = "val"
|
||||
// PrefixConsensus is the prefix for consensus keys
|
||||
PrefixConsensus = "cons"
|
||||
// PrefixPublic is the prefix for public keys
|
||||
PrefixPublic = "pub"
|
||||
// PrefixOperator is the prefix for operator keys
|
||||
PrefixOperator = "oper"
|
||||
|
||||
// PrefixAddress is the prefix for addresses
|
||||
PrefixAddress = "addr"
|
||||
|
||||
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
|
||||
Bech32PrefixAccAddr = Bech32Prefix
|
||||
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
|
||||
Bech32PrefixAccPub = Bech32Prefix + PrefixPublic
|
||||
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
|
||||
Bech32PrefixValAddr = Bech32Prefix + PrefixValidator + PrefixOperator
|
||||
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
|
||||
Bech32PrefixValPub = Bech32Prefix + PrefixValidator + PrefixOperator + PrefixPublic
|
||||
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
|
||||
Bech32PrefixConsAddr = Bech32Prefix + PrefixValidator + PrefixConsensus
|
||||
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
|
||||
Bech32PrefixConsPub = Bech32Prefix + PrefixValidator + PrefixConsensus + PrefixPublic
|
||||
)
|
||||
|
||||
// setBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings.
|
||||
func setBech32Prefixes(config *sdk.Config) {
|
||||
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
|
||||
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
|
||||
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
|
||||
}
|
@ -62,36 +62,36 @@ func TestKvCLIKeysAddRecover(t *testing.T) {
|
||||
|
||||
exitSuccess, _, _ = f.KeysAddRecover("test-recover", "dentist task convince chimney quality leave banana trade firm crawl eternal easily")
|
||||
require.True(t, exitSuccess)
|
||||
require.Equal(t, "kava1rsjxn2e4dfl3a2qzuzzjvvgjmmate383g9q4cz", f.KeyAddress("test-recover").String())
|
||||
require.Equal(t, "0g1rsjxn2e4dfl3a2qzuzzjvvgjmmate383g9q4cz", f.KeyAddress("test-recover").String())
|
||||
|
||||
// test old bip44 coin type
|
||||
exitSuccess, _, _ = f.KeysAddRecover("test-recover-legacy", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", "--legacy-hd-path")
|
||||
require.True(t, exitSuccess)
|
||||
require.Equal(t, "kava1qcfdf69js922qrdr4yaww3ax7gjml6pd39p8lj", f.KeyAddress("test-recover-legacy").String())
|
||||
require.Equal(t, "0g1qcfdf69js922qrdr4yaww3ax7gjml6pd39p8lj", f.KeyAddress("test-recover-legacy").String())
|
||||
|
||||
// Cleanup testing directories
|
||||
f.Cleanup()
|
||||
}
|
||||
|
||||
func TestKavaCLIKeysAddRecoverHDPath(t *testing.T) {
|
||||
func TestZgChainCLIKeysAddRecoverHDPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
f := InitFixtures(t)
|
||||
|
||||
f.KeysAddRecoverHDPath("test-recoverHD1", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", 0, 0)
|
||||
require.Equal(t, "kava1rsjxn2e4dfl3a2qzuzzjvvgjmmate383g9q4cz", f.KeyAddress("test-recoverHD1").String())
|
||||
require.Equal(t, "0g1rsjxn2e4dfl3a2qzuzzjvvgjmmate383g9q4cz", f.KeyAddress("test-recoverHD1").String())
|
||||
|
||||
f.KeysAddRecoverHDPath("test-recoverH2", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", 1, 5)
|
||||
require.Equal(t, "kava1qpj6nstqn0n5gzcsaezspuhulje6msjq5t8cq5", f.KeyAddress("test-recoverH2").String())
|
||||
require.Equal(t, "0g1qpj6nstqn0n5gzcsaezspuhulje6msjq5t8cq5", f.KeyAddress("test-recoverH2").String())
|
||||
|
||||
f.KeysAddRecoverHDPath("test-recoverH3", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", 1, 17)
|
||||
require.Equal(t, "kava1vayfpstgapt7dmv7074kc3ll8xpf0rlzvh4k08", f.KeyAddress("test-recoverH3").String())
|
||||
require.Equal(t, "0g1vayfpstgapt7dmv7074kc3ll8xpf0rlzvh4k08", f.KeyAddress("test-recoverH3").String())
|
||||
|
||||
f.KeysAddRecoverHDPath("test-recoverH4", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", 2, 17)
|
||||
require.Equal(t, "kava1xvsfnksmhr887skcfrm4pe3va54tkmrtw7wyer", f.KeyAddress("test-recoverH4").String())
|
||||
require.Equal(t, "0g1xvsfnksmhr887skcfrm4pe3va54tkmrtw7wyer", f.KeyAddress("test-recoverH4").String())
|
||||
|
||||
// test old bip44 coin type
|
||||
f.KeysAddRecoverHDPath("test-recoverH5", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", 2, 17, "--legacy-hd-path")
|
||||
require.Equal(t, "kava1v9plmhvyhgxk3th9ydacm7j4z357s3nhhmy0tv", f.KeyAddress("test-recoverH5").String())
|
||||
require.Equal(t, "0g1v9plmhvyhgxk3th9ydacm7j4z357s3nhhmy0tv", f.KeyAddress("test-recoverH5").String())
|
||||
|
||||
exitSuccess, _, _ := f.KeysAddRecover("test-recover-fail", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", "--legacy-hd-path --hd-path 44'/459'/0'/0/0")
|
||||
require.False(t, exitSuccess)
|
||||
@ -99,11 +99,11 @@ func TestKavaCLIKeysAddRecoverHDPath(t *testing.T) {
|
||||
// test -hd-path flag
|
||||
exitSuccess, _, _ = f.KeysAddRecover("test-recoverH6", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", "--hd-path 44'/459'/0'/0/0")
|
||||
require.True(t, exitSuccess)
|
||||
require.Equal(t, "kava1rsjxn2e4dfl3a2qzuzzjvvgjmmate383g9q4cz", f.KeyAddress("test-recoverH6").String())
|
||||
require.Equal(t, "0g1rsjxn2e4dfl3a2qzuzzjvvgjmmate383g9q4cz", f.KeyAddress("test-recoverH6").String())
|
||||
|
||||
exitSuccess, _, _ = f.KeysAddRecover("test-recoverH7", "dentist task convince chimney quality leave banana trade firm crawl eternal easily", "--hd-path 44'/459'/2'/0/17")
|
||||
require.True(t, exitSuccess)
|
||||
require.Equal(t, "kava1xvsfnksmhr887skcfrm4pe3va54tkmrtw7wyer", f.KeyAddress("test-recoverH7").String())
|
||||
require.Equal(t, "0g1xvsfnksmhr887skcfrm4pe3va54tkmrtw7wyer", f.KeyAddress("test-recoverH7").String())
|
||||
|
||||
// Cleanup testing directories
|
||||
f.Cleanup()
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -65,8 +65,7 @@ var (
|
||||
|
||||
func init() {
|
||||
// set the address prefixes
|
||||
config := sdk.GetConfig()
|
||||
app.SetBech32AddressPrefixes(config)
|
||||
chaincfg.SetSDKConfig()
|
||||
// config.Seal()
|
||||
}
|
||||
|
||||
@ -92,7 +91,7 @@ type Fixtures struct {
|
||||
|
||||
// NewFixtures creates a new instance of Fixtures with many vars set
|
||||
func NewFixtures(t *testing.T) *Fixtures {
|
||||
tmpDir, err := ioutil.TempDir("", "kava_integration_"+t.Name()+"_")
|
||||
tmpDir, err := ioutil.TempDir("", "0gchain_integration_"+t.Name()+"_")
|
||||
require.NoError(t, err)
|
||||
|
||||
servAddr, port, err := server.FreeTCPAddr()
|
||||
@ -201,9 +200,9 @@ func (f *Fixtures) Flags() string {
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
// kavad
|
||||
// 0gchaind
|
||||
|
||||
// UnsafeResetAll is kavad unsafe-reset-all
|
||||
// UnsafeResetAll is 0gchaind unsafe-reset-all
|
||||
func (f *Fixtures) UnsafeResetAll(flags ...string) {
|
||||
cmd := fmt.Sprintf("%s --home=%s unsafe-reset-all", f.KvdBinary, f.KvdHome)
|
||||
executeWrite(f.T, addFlags(cmd, flags))
|
||||
@ -211,7 +210,7 @@ func (f *Fixtures) UnsafeResetAll(flags ...string) {
|
||||
require.NoError(f.T, err)
|
||||
}
|
||||
|
||||
// KvInit is kavad init
|
||||
// KvInit is 0gchaind init
|
||||
// NOTE: KvInit sets the ChainID for the Fixtures instance
|
||||
func (f *Fixtures) KvInit(moniker string, flags ...string) {
|
||||
cmd := fmt.Sprintf("%s init -o --home=%s %s", f.KvdBinary, f.KvdHome, moniker)
|
||||
@ -229,25 +228,25 @@ func (f *Fixtures) KvInit(moniker string, flags ...string) {
|
||||
f.ChainID = chainID
|
||||
}
|
||||
|
||||
// AddGenesisAccount is kavad add-genesis-account
|
||||
// AddGenesisAccount is 0gchaind add-genesis-account
|
||||
func (f *Fixtures) AddGenesisAccount(address sdk.AccAddress, coins sdk.Coins, flags ...string) {
|
||||
cmd := fmt.Sprintf("%s add-genesis-account %s %s --home=%s --keyring-backend=test", f.KvdBinary, address, coins, f.KvdHome)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags))
|
||||
}
|
||||
|
||||
// GenTx is kavad gentx
|
||||
// GenTx is 0gchaind gentx
|
||||
func (f *Fixtures) GenTx(name string, flags ...string) {
|
||||
cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s --keyring-backend=test", f.KvdBinary, name, f.KvdHome, f.KvcliHome)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags))
|
||||
}
|
||||
|
||||
// CollectGenTxs is kavad collect-gentxs
|
||||
// CollectGenTxs is 0gchaind collect-gentxs
|
||||
func (f *Fixtures) CollectGenTxs(flags ...string) {
|
||||
cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.KvdBinary, f.KvdHome)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags))
|
||||
}
|
||||
|
||||
// GDStart runs kavad start with the appropriate flags and returns a process
|
||||
// GDStart runs 0gchaind start with the appropriate flags and returns a process
|
||||
func (f *Fixtures) GDStart(flags ...string) *tests.Process {
|
||||
cmd := fmt.Sprintf("%s start --home=%s --rpc.laddr=%v --p2p.laddr=%v --pruning=everything", f.KvdBinary, f.KvdHome, f.RPCAddr, f.P2PAddr)
|
||||
proc := tests.GoExecuteTWithStdout(f.T, addFlags(cmd, flags))
|
||||
@ -256,7 +255,7 @@ func (f *Fixtures) GDStart(flags ...string) *tests.Process {
|
||||
return proc
|
||||
}
|
||||
|
||||
// GDTendermint returns the results of kavad tendermint [query]
|
||||
// GDTendermint returns the results of 0gchaind tendermint [query]
|
||||
func (f *Fixtures) GDTendermint(query string) string {
|
||||
cmd := fmt.Sprintf("%s tendermint %s --home=%s", f.KvdBinary, query, f.KvdHome)
|
||||
success, stdout, stderr := executeWriteRetStdStreams(f.T, cmd)
|
||||
@ -265,7 +264,7 @@ func (f *Fixtures) GDTendermint(query string) string {
|
||||
return strings.TrimSpace(stdout)
|
||||
}
|
||||
|
||||
// ValidateGenesis runs kavad validate-genesis
|
||||
// ValidateGenesis runs 0gchaind validate-genesis
|
||||
func (f *Fixtures) ValidateGenesis() {
|
||||
cmd := fmt.Sprintf("%s validate-genesis --home=%s", f.KvdBinary, f.KvdHome)
|
||||
executeWriteCheckErr(f.T, cmd)
|
||||
|
@ -7,7 +7,7 @@
|
||||
},
|
||||
"externalDocs": {
|
||||
"description": "GitHub",
|
||||
"url": "https://github.com/Kava-Labs/kava"
|
||||
"url": "https://github.com/0glabs/0g-chain"
|
||||
},
|
||||
"host": "api.data.kava.io",
|
||||
"schemes": ["https"],
|
||||
|
@ -5,7 +5,7 @@ info:
|
||||
version: 1.0.0
|
||||
externalDocs:
|
||||
description: GitHub
|
||||
url: https://github.com/Kava-Labs/kava
|
||||
url: https://github.com/0glabs/0g-chain
|
||||
host: api.data.kava.io
|
||||
schemes:
|
||||
- https
|
||||
|
@ -52,6 +52,13 @@ The pass backend requires GnuPG: https://gnupg.org/
|
||||
addCmd := keys.AddKeyCommand()
|
||||
addCmd.Flags().Bool(ethFlag, false, "use default evm coin-type (60) and key signing algorithm (\"eth_secp256k1\")")
|
||||
|
||||
algoFlag := addCmd.Flag(flags.FlagKeyAlgorithm)
|
||||
algoFlag.DefValue = string(hd.EthSecp256k1Type)
|
||||
err := algoFlag.Value.Set(string(hd.EthSecp256k1Type))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
addCmd.RunE = runAddCmd
|
||||
|
||||
cmd.AddCommand(
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/0glabs/0g-chain/client/rest"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -20,7 +21,6 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/kava-labs/kava/client/rest"
|
||||
)
|
||||
|
||||
func TestBaseReq_Sanitize(t *testing.T) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@ -22,9 +22,8 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
db "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/app/params"
|
||||
metricstypes "github.com/kava-labs/kava/x/metrics/types"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -32,7 +31,7 @@ const (
|
||||
flagMempoolAuthAddresses = "mempool.authorized-addresses"
|
||||
)
|
||||
|
||||
// appCreator holds functions used by the sdk server to control the kava app.
|
||||
// appCreator holds functions used by the sdk server to control the 0g-chain app.
|
||||
// The methods implement types in cosmos-sdk/server/types
|
||||
type appCreator struct {
|
||||
encodingConfig params.EncodingConfig
|
||||
@ -100,7 +99,6 @@ func (ac appCreator) newApp(
|
||||
MempoolAuthAddresses: mempoolAuthAddresses,
|
||||
EVMTrace: cast.ToString(appOpts.Get(ethermintflags.EVMTracer)),
|
||||
EVMMaxGasWanted: cast.ToUint64(appOpts.Get(ethermintflags.EVMMaxTxGasWanted)),
|
||||
TelemetryOptions: metricstypes.TelemetryOptionsFromAppOpts(appOpts),
|
||||
},
|
||||
baseapp.SetPruning(pruningOpts),
|
||||
baseapp.SetMinGasPrices(strings.Replace(cast.ToString(appOpts.Get(server.FlagMinGasPrices)), ";", ",", -1)),
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@ -9,8 +9,8 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/app/params"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
)
|
||||
|
||||
func AssertInvariantsCmd(config params.EncodingConfig) *cobra.Command {
|
@ -1,5 +1,5 @@
|
||||
// Sourced from https://github.com/evmos/ethermint/blob/main/cmd/ethermintd/genaccounts.go
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
@ -6,14 +6,15 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/cmd/kava/cmd"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rootCmd := cmd.NewRootCmd()
|
||||
chaincfg.SetSDKConfig().Seal()
|
||||
|
||||
if err := svrcmd.Execute(rootCmd, cmd.EnvPrefix, app.DefaultNodeHome); err != nil {
|
||||
rootCmd := NewRootCmd()
|
||||
|
||||
if err := svrcmd.Execute(rootCmd, chaincfg.EnvPrefix, chaincfg.DefaultNodeHome); err != nil {
|
||||
switch e := err.(type) {
|
||||
case server.ErrorCode:
|
||||
os.Exit(e.Code)
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -7,7 +7,7 @@ import (
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
)
|
||||
|
||||
// newQueryCmd creates all the commands for querying blockchain state.
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/config"
|
||||
"github.com/cosmos/cosmos-sdk/client/debug"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -20,21 +21,24 @@ import (
|
||||
tmcfg "github.com/tendermint/tendermint/config"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/app/params"
|
||||
kavaclient "github.com/kava-labs/kava/client"
|
||||
"github.com/kava-labs/kava/cmd/kava/opendb"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
kavaclient "github.com/0glabs/0g-chain/client"
|
||||
"github.com/0glabs/0g-chain/cmd/opendb"
|
||||
"github.com/0glabs/0g-chain/crypto/vrf"
|
||||
)
|
||||
|
||||
// EnvPrefix is the prefix environment variables must have to configure the app.
|
||||
const EnvPrefix = "KAVA"
|
||||
func customKeyringOptions() keyring.Option {
|
||||
return func(options *keyring.Options) {
|
||||
options.SupportedAlgos = append(hd.SupportedAlgorithms, vrf.VrfAlgo)
|
||||
options.SupportedAlgosLedger = append(hd.SupportedAlgorithmsLedger, vrf.VrfAlgo)
|
||||
}
|
||||
}
|
||||
|
||||
// NewRootCmd creates a new root command for the kava blockchain.
|
||||
// NewRootCmd creates a new root command for the 0g-chain blockchain.
|
||||
func NewRootCmd() *cobra.Command {
|
||||
app.SetSDKConfig().Seal()
|
||||
|
||||
encodingConfig := app.MakeEncodingConfig()
|
||||
|
||||
initClientCtx := client.Context{}.
|
||||
WithCodec(encodingConfig.Marshaler).
|
||||
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
||||
@ -43,13 +47,13 @@ func NewRootCmd() *cobra.Command {
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(types.AccountRetriever{}).
|
||||
WithBroadcastMode(flags.BroadcastBlock).
|
||||
WithHomeDir(app.DefaultNodeHome).
|
||||
WithKeyringOptions(hd.EthSecp256k1Option()).
|
||||
WithViper(EnvPrefix)
|
||||
WithHomeDir(chaincfg.DefaultNodeHome).
|
||||
WithKeyringOptions(customKeyringOptions()).
|
||||
WithViper(chaincfg.EnvPrefix)
|
||||
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "kava",
|
||||
Short: "Daemon and CLI for the Kava blockchain.",
|
||||
Use: chaincfg.AppName,
|
||||
Short: "Daemon and CLI for the 0g-chain blockchain.",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
||||
cmd.SetOut(cmd.OutOrStdout())
|
||||
cmd.SetErr(cmd.ErrOrStderr())
|
||||
@ -68,7 +72,7 @@ func NewRootCmd() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
customAppTemplate, customAppConfig := servercfg.AppConfig("ukava")
|
||||
customAppTemplate, customAppConfig := servercfg.AppConfig(chaincfg.GasDenom)
|
||||
|
||||
return server.InterceptConfigsPreRunHandler(
|
||||
cmd,
|
||||
@ -79,12 +83,12 @@ func NewRootCmd() *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
addSubCmds(rootCmd, encodingConfig, app.DefaultNodeHome)
|
||||
addSubCmds(rootCmd, encodingConfig, chaincfg.DefaultNodeHome)
|
||||
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
// addSubCmds registers all the sub commands used by kava.
|
||||
// addSubCmds registers all the sub commands used by 0g-chain.
|
||||
func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, defaultNodeHome string) {
|
||||
rootCmd.AddCommand(
|
||||
StatusCommand(),
|
||||
@ -108,7 +112,7 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de
|
||||
|
||||
opts := ethermintserver.StartOptions{
|
||||
AppCreator: ac.newApp,
|
||||
DefaultNodeHome: app.DefaultNodeHome,
|
||||
DefaultNodeHome: chaincfg.DefaultNodeHome,
|
||||
DBOpener: opendb.OpenDB,
|
||||
}
|
||||
// ethermintserver adds additional flags to start the JSON-RPC server for evm support
|
||||
@ -119,10 +123,10 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de
|
||||
ac.addStartCmdFlags,
|
||||
)
|
||||
|
||||
// add keybase, auxiliary RPC, query, and tx child commands
|
||||
// add keybase, gas RPC, query, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
newQueryCmd(),
|
||||
newTxCmd(),
|
||||
kavaclient.KeyCommands(app.DefaultNodeHome),
|
||||
kavaclient.KeyCommands(chaincfg.DefaultNodeHome),
|
||||
)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -6,7 +6,7 @@ import (
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
)
|
||||
|
||||
// newTxCmd creates all commands for submitting blockchain transactions.
|
@ -4,11 +4,11 @@ pragma solidity ^0.8.18;
|
||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
|
||||
/// @title An ERC20 token contract owned and deployed by the evmutil module of Kava.
|
||||
/// @title An ERC20 token contract owned and deployed by the evmutil module of 0g-chain.
|
||||
/// Tokens are backed one-for-one by cosmos-sdk coins held in the module account.
|
||||
/// @author Kava Labs, LLC
|
||||
/// @custom:security-contact security@kava.io
|
||||
contract ERC20KavaWrappedCosmosCoin is ERC20, Ownable {
|
||||
/// @author 0g Labs, LLC
|
||||
/// @custom:security-contact security@0g.ai
|
||||
contract ERC20ZgChainWrappedCosmosCoin is ERC20, Ownable {
|
||||
/// @notice The decimals places of the token. For display purposes only.
|
||||
uint8 private immutable _decimals;
|
||||
|
||||
|
@ -5,7 +5,7 @@ const config: HardhatUserConfig = {
|
||||
solidity: {
|
||||
version: "0.8.18",
|
||||
settings: {
|
||||
// istanbul upgrade occurred before the london hardfork, so is compatible with kava's evm
|
||||
// istanbul upgrade occurred before the london hardfork, so is compatible with 0g-chain's evm
|
||||
evmVersion: "istanbul",
|
||||
// optimize build for deployment to mainnet!
|
||||
optimizer: {
|
||||
@ -16,21 +16,21 @@ const config: HardhatUserConfig = {
|
||||
},
|
||||
networks: {
|
||||
// kvtool's local network
|
||||
kava: {
|
||||
chain: {
|
||||
url: "http://127.0.0.1:8545",
|
||||
accounts: [
|
||||
// kava keys unsafe-export-eth-key whale2
|
||||
// 0g-chain keys unsafe-export-eth-key whale2
|
||||
"AA50F4C6C15190D9E18BF8B14FC09BFBA0E7306331A4F232D10A77C2879E7966",
|
||||
],
|
||||
},
|
||||
protonet: {
|
||||
url: "https://evm.app.protonet.us-east.production.kava.io:443",
|
||||
url: "https://evm.app.protonet.us-east.production.0g-chain.io:443",
|
||||
accounts: [
|
||||
"247069F0BC3A5914CB2FD41E4133BBDAA6DBED9F47A01B9F110B5602C6E4CDD9",
|
||||
],
|
||||
},
|
||||
internal_testnet: {
|
||||
url: "https://evm.data.internal.testnet.us-east.production.kava.io:443",
|
||||
url: "https://evm.data.internal.testnet.us-east.production.0g-chain.io:443",
|
||||
accounts: [
|
||||
"247069F0BC3A5914CB2FD41E4133BBDAA6DBED9F47A01B9F110B5602C6E4CDD9",
|
||||
],
|
||||
|
4
contracts/package-lock.json
generated
4
contracts/package-lock.json
generated
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "kava-contracts",
|
||||
"name": "0g-chain-contracts",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "kava-contracts",
|
||||
"name": "0g-chain-contracts",
|
||||
"version": "0.0.1",
|
||||
"devDependencies": {
|
||||
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "kava-contracts",
|
||||
"name": "0g-chain-contracts",
|
||||
"version": "0.0.1",
|
||||
"author": "Kava Labs",
|
||||
"author": "0g Labs",
|
||||
"private": true,
|
||||
"description": "Solidity contracts for Kava Blockchain",
|
||||
"description": "Solidity contracts for 0g Blockchain",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
@ -12,7 +12,7 @@
|
||||
"clean": "hardhat clean",
|
||||
"compile": "hardhat compile",
|
||||
"coverage": "hardhat coverage",
|
||||
"ethermint-json": "jq '{ abi: .abi | tostring, bin: .bytecode | ltrimstr(\"0x\")}' artifacts/contracts/ERC20KavaWrappedCosmosCoin.sol/ERC20KavaWrappedCosmosCoin.json > ../x/evmutil/types/ethermint_json/ERC20KavaWrappedCosmosCoin.json",
|
||||
"ethermint-json": "jq '{ abi: .abi | tostring, bin: .bytecode | ltrimstr(\"0x\")}' artifacts/contracts/ERC20ZgChainWrappedCosmosCoin.sol/ERC20ZgChainWrappedCosmosCoin.json > ../x/evmutil/types/ethermint_json/ERC20ZgChainWrappedCosmosCoin.json",
|
||||
"gen-ts-types": "hardhat typechain",
|
||||
"lint": "eslint '**/*.{js,ts}'",
|
||||
"lint-fix": "eslint '**/*.{js,ts}' --fix",
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { ethers } from "hardhat";
|
||||
|
||||
async function main() {
|
||||
const tokenName = "Kava-wrapped ATOM";
|
||||
const tokenName = "0g-chain-wrapped ATOM";
|
||||
const tokenSymbol = "kATOM";
|
||||
const tokenDecimals = 6;
|
||||
|
||||
const ERC20KavaWrappedCosmosCoin = await ethers.getContractFactory(
|
||||
"ERC20KavaWrappedCosmosCoin"
|
||||
const ERC20ZgChainWrappedCosmosCoin = await ethers.getContractFactory(
|
||||
"ERC20ZgChainWrappedCosmosCoin"
|
||||
);
|
||||
const token = await ERC20KavaWrappedCosmosCoin.deploy(
|
||||
const token = await ERC20ZgChainWrappedCosmosCoin.deploy(
|
||||
tokenName,
|
||||
tokenSymbol,
|
||||
tokenDecimals
|
||||
|
@ -2,21 +2,21 @@ import { expect } from "chai";
|
||||
import { Signer } from "ethers";
|
||||
import { ethers } from "hardhat";
|
||||
import {
|
||||
ERC20KavaWrappedCosmosCoin,
|
||||
ERC20KavaWrappedCosmosCoin__factory as ERC20KavaWrappedCosmosCoinFactory,
|
||||
ERC20ZgChainWrappedCosmosCoin,
|
||||
ERC20ZgChainWrappedCosmosCoin__factory as ERC20ZgChainWrappedCosmosCoinFactory,
|
||||
} from "../typechain-types";
|
||||
|
||||
const decimals = 6n;
|
||||
|
||||
describe("ERC20KavaWrappedCosmosCoin", function () {
|
||||
let erc20: ERC20KavaWrappedCosmosCoin;
|
||||
let erc20Factory: ERC20KavaWrappedCosmosCoinFactory;
|
||||
describe("ERC20ZgChainWrappedCosmosCoin", function () {
|
||||
let erc20: ERC20ZgChainWrappedCosmosCoin;
|
||||
let erc20Factory: ERC20ZgChainWrappedCosmosCoinFactory;
|
||||
let owner: Signer;
|
||||
let sender: Signer;
|
||||
|
||||
beforeEach(async function () {
|
||||
erc20Factory = await ethers.getContractFactory(
|
||||
"ERC20KavaWrappedCosmosCoin"
|
||||
"ERC20ZgChainWrappedCosmosCoin"
|
||||
);
|
||||
erc20 = await erc20Factory.deploy("Wrapped ATOM", "ATOM", decimals);
|
||||
[owner, sender] = await ethers.getSigners();
|
||||
|
166
crypto/bn254util/bn254util.go
Normal file
166
crypto/bn254util/bn254util.go
Normal file
@ -0,0 +1,166 @@
|
||||
package bn254util
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254/fp"
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
const (
|
||||
G1PointSize = 32 * 2
|
||||
G2PointSize = 32 * 2 * 2
|
||||
)
|
||||
|
||||
var (
|
||||
FR_MODULUS, _ = new(big.Int).SetString("21888242871839275222246405745257275088548364400416034343698204186575808495617", 10)
|
||||
)
|
||||
|
||||
func VerifySig(sig *bn254.G1Affine, pubkey *bn254.G2Affine, msgBytes [32]byte) (bool, error) {
|
||||
|
||||
g2Gen := GetG2Generator()
|
||||
|
||||
msgPoint := MapToCurve(msgBytes)
|
||||
|
||||
var negSig bn254.G1Affine
|
||||
negSig.Neg((*bn254.G1Affine)(sig))
|
||||
|
||||
P := [2]bn254.G1Affine{*msgPoint, negSig}
|
||||
Q := [2]bn254.G2Affine{*pubkey, *g2Gen}
|
||||
|
||||
ok, err := bn254.PairingCheck(P[:], Q[:])
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
return ok, nil
|
||||
|
||||
}
|
||||
|
||||
func MapToCurve(digest [32]byte) *bn254.G1Affine {
|
||||
|
||||
one := new(big.Int).SetUint64(1)
|
||||
three := new(big.Int).SetUint64(3)
|
||||
x := new(big.Int)
|
||||
x.SetBytes(digest[:])
|
||||
for {
|
||||
// y = x^3 + 3
|
||||
xP3 := new(big.Int).Exp(x, big.NewInt(3), fp.Modulus())
|
||||
y := new(big.Int).Add(xP3, three)
|
||||
y.Mod(y, fp.Modulus())
|
||||
|
||||
if y.ModSqrt(y, fp.Modulus()) == nil {
|
||||
x.Add(x, one).Mod(x, fp.Modulus())
|
||||
} else {
|
||||
var fpX, fpY fp.Element
|
||||
fpX.SetBigInt(x)
|
||||
fpY.SetBigInt(y)
|
||||
return &bn254.G1Affine{
|
||||
X: fpX,
|
||||
Y: fpY,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CheckG1AndG2DiscreteLogEquality(pointG1 *bn254.G1Affine, pointG2 *bn254.G2Affine) (bool, error) {
|
||||
negGenG1 := new(bn254.G1Affine).Neg(GetG1Generator())
|
||||
return bn254.PairingCheck([]bn254.G1Affine{*pointG1, *negGenG1}, []bn254.G2Affine{*GetG2Generator(), *pointG2})
|
||||
}
|
||||
|
||||
func GetG1Generator() *bn254.G1Affine {
|
||||
g1Gen := new(bn254.G1Affine)
|
||||
_, err := g1Gen.X.SetString("1")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
_, err = g1Gen.Y.SetString("2")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return g1Gen
|
||||
}
|
||||
|
||||
func GetG2Generator() *bn254.G2Affine {
|
||||
g2Gen := new(bn254.G2Affine)
|
||||
g2Gen.X.SetString("10857046999023057135944570762232829481370756359578518086990519993285655852781",
|
||||
"11559732032986387107991004021392285783925812861821192530917403151452391805634")
|
||||
g2Gen.Y.SetString("8495653923123431417604973247489272438418190587263600148770280649306958101930",
|
||||
"4082367875863433681332203403145435568316851327593401208105741076214120093531")
|
||||
return g2Gen
|
||||
}
|
||||
|
||||
func MulByGeneratorG1(a *fr.Element) *bn254.G1Affine {
|
||||
g1Gen := GetG1Generator()
|
||||
return new(bn254.G1Affine).ScalarMultiplication(g1Gen, a.BigInt(new(big.Int)))
|
||||
}
|
||||
|
||||
func MulByGeneratorG2(a *fr.Element) *bn254.G2Affine {
|
||||
g2Gen := GetG2Generator()
|
||||
return new(bn254.G2Affine).ScalarMultiplication(g2Gen, a.BigInt(new(big.Int)))
|
||||
}
|
||||
|
||||
func SerializeG1(p *bn254.G1Affine) []byte {
|
||||
b := make([]byte, 0)
|
||||
tmp := p.X.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
tmp = p.Y.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func DeserializeG1(b []byte) *bn254.G1Affine {
|
||||
p := new(bn254.G1Affine)
|
||||
p.X.SetBytes(b[0:32])
|
||||
p.Y.SetBytes(b[32:64])
|
||||
return p
|
||||
}
|
||||
|
||||
func SerializeG2(p *bn254.G2Affine) []byte {
|
||||
b := make([]byte, 0)
|
||||
tmp := p.X.A0.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
tmp = p.X.A1.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
tmp = p.Y.A0.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
tmp = p.Y.A1.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func DeserializeG2(b []byte) *bn254.G2Affine {
|
||||
p := new(bn254.G2Affine)
|
||||
p.X.A0.SetBytes(b[0:32])
|
||||
p.X.A1.SetBytes(b[32:64])
|
||||
p.Y.A0.SetBytes(b[64:96])
|
||||
p.Y.A1.SetBytes(b[96:128])
|
||||
return p
|
||||
}
|
||||
|
||||
func Gamma(hash *bn254.G1Affine, signature *bn254.G1Affine, pkG1 *bn254.G1Affine, pkG2 *bn254.G2Affine) *big.Int {
|
||||
toHash := make([]byte, 0)
|
||||
toHash = append(toHash, SerializeG1(hash)...)
|
||||
toHash = append(toHash, SerializeG1(signature)...)
|
||||
toHash = append(toHash, SerializeG1(pkG1)...)
|
||||
toHash = append(toHash, SerializeG2(pkG2)...)
|
||||
|
||||
msgHash := crypto.Keccak256(toHash)
|
||||
gamma := new(big.Int)
|
||||
gamma.SetBytes(msgHash)
|
||||
gamma.Mod(gamma, FR_MODULUS)
|
||||
return gamma
|
||||
}
|
58
crypto/vrf/algorithm.go
Normal file
58
crypto/vrf/algorithm.go
Normal file
@ -0,0 +1,58 @@
|
||||
package vrf
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
)
|
||||
|
||||
var (
|
||||
// SupportedAlgorithms defines the list of signing algorithms used on Evmos:
|
||||
// - eth_secp256k1 (Ethereum)
|
||||
// - secp256k1 (Tendermint)
|
||||
SupportedAlgorithms = keyring.SigningAlgoList{VrfAlgo}
|
||||
// SupportedAlgorithmsLedger defines the list of signing algorithms used on Evmos for the Ledger device:
|
||||
// - eth_secp256k1 (Ethereum)
|
||||
// - secp256k1 (Tendermint)
|
||||
SupportedAlgorithmsLedger = keyring.SigningAlgoList{VrfAlgo}
|
||||
)
|
||||
|
||||
func VrfOption() keyring.Option {
|
||||
return func(options *keyring.Options) {
|
||||
options.SupportedAlgos = SupportedAlgorithms
|
||||
options.SupportedAlgosLedger = SupportedAlgorithmsLedger
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
VrfType = hd.PubKeyType(KeyType)
|
||||
)
|
||||
|
||||
var (
|
||||
_ keyring.SignatureAlgo = VrfAlgo
|
||||
VrfAlgo = vrfAlgo{}
|
||||
)
|
||||
|
||||
type vrfAlgo struct{}
|
||||
|
||||
func (s vrfAlgo) Name() hd.PubKeyType {
|
||||
return VrfType
|
||||
}
|
||||
|
||||
func (s vrfAlgo) Derive() hd.DeriveFn {
|
||||
return func(mnemonic, bip39Passphrase, path string) ([]byte, error) {
|
||||
key, err := GenerateKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return key.Bytes(), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s vrfAlgo) Generate() hd.GenerateFn {
|
||||
return func(bz []byte) cryptotypes.PrivKey {
|
||||
key, _ := GenerateKey()
|
||||
return key
|
||||
}
|
||||
}
|
496
crypto/vrf/keys.pb.go
Normal file
496
crypto/vrf/keys.pb.go
Normal file
@ -0,0 +1,496 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: crypto/vrf/keys.proto
|
||||
|
||||
package vrf
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/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
|
||||
|
||||
// PubKey defines a type alias for an vrf.PublicKey that implements
|
||||
// Vrf's PubKey interface. It represents the 32-byte compressed public
|
||||
// key format.
|
||||
type PubKey struct {
|
||||
// key is the public key in byte form
|
||||
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PubKey) Reset() { *m = PubKey{} }
|
||||
func (*PubKey) ProtoMessage() {}
|
||||
func (*PubKey) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_eae59d1af27f5957, []int{0}
|
||||
}
|
||||
func (m *PubKey) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_PubKey.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 *PubKey) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PubKey.Merge(m, src)
|
||||
}
|
||||
func (m *PubKey) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *PubKey) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PubKey.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PubKey proto.InternalMessageInfo
|
||||
|
||||
func (m *PubKey) GetKey() []byte {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PrivKey defines a type alias for an vrf.PrivateKey that implements
|
||||
// Vrf's PrivateKey interface.
|
||||
type PrivKey struct {
|
||||
// key is the private key in byte form
|
||||
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PrivKey) Reset() { *m = PrivKey{} }
|
||||
func (m *PrivKey) String() string { return proto.CompactTextString(m) }
|
||||
func (*PrivKey) ProtoMessage() {}
|
||||
func (*PrivKey) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_eae59d1af27f5957, []int{1}
|
||||
}
|
||||
func (m *PrivKey) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_PrivKey.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 *PrivKey) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PrivKey.Merge(m, src)
|
||||
}
|
||||
func (m *PrivKey) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *PrivKey) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PrivKey.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PrivKey proto.InternalMessageInfo
|
||||
|
||||
func (m *PrivKey) GetKey() []byte {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PubKey)(nil), "crypto.vrf.PubKey")
|
||||
proto.RegisterType((*PrivKey)(nil), "crypto.vrf.PrivKey")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("crypto/vrf/keys.proto", fileDescriptor_eae59d1af27f5957) }
|
||||
|
||||
var fileDescriptor_eae59d1af27f5957 = []byte{
|
||||
// 174 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x2e, 0xaa, 0x2c,
|
||||
0x28, 0xc9, 0xd7, 0x2f, 0x2b, 0x4a, 0xd3, 0xcf, 0x4e, 0xad, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0x17, 0xe2, 0x82, 0x08, 0xeb, 0x95, 0x15, 0xa5, 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83,
|
||||
0x85, 0xf5, 0x41, 0x2c, 0x88, 0x0a, 0x25, 0x05, 0x2e, 0xb6, 0x80, 0xd2, 0x24, 0xef, 0xd4, 0x4a,
|
||||
0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x9e, 0x20, 0x10, 0xd3,
|
||||
0x8a, 0x65, 0xc6, 0x02, 0x79, 0x06, 0x25, 0x69, 0x2e, 0xf6, 0x80, 0xa2, 0xcc, 0x32, 0xac, 0x4a,
|
||||
0x9c, 0xec, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09,
|
||||
0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x35, 0x3d, 0xb3,
|
||||
0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, 0x20, 0x3d, 0x27, 0x31, 0xa9, 0x58, 0xdf,
|
||||
0x20, 0x5d, 0x37, 0x39, 0x23, 0x31, 0x33, 0x4f, 0x1f, 0xe1, 0xd8, 0x24, 0x36, 0xb0, 0x33, 0x8c,
|
||||
0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdb, 0xb8, 0x32, 0x07, 0xc1, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *PubKey) 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 *PubKey) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Key) > 0 {
|
||||
i -= len(m.Key)
|
||||
copy(dAtA[i:], m.Key)
|
||||
i = encodeVarintKeys(dAtA, i, uint64(len(m.Key)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *PrivKey) 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 *PrivKey) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Key) > 0 {
|
||||
i -= len(m.Key)
|
||||
copy(dAtA[i:], m.Key)
|
||||
i = encodeVarintKeys(dAtA, i, uint64(len(m.Key)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintKeys(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovKeys(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *PubKey) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Key)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovKeys(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *PrivKey) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Key)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovKeys(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovKeys(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozKeys(x uint64) (n int) {
|
||||
return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *PubKey) 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 ErrIntOverflowKeys
|
||||
}
|
||||
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: PubKey: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: PubKey: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowKeys
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthKeys
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthKeys
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Key == nil {
|
||||
m.Key = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipKeys(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthKeys
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *PrivKey) 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 ErrIntOverflowKeys
|
||||
}
|
||||
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: PrivKey: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: PrivKey: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowKeys
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthKeys
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthKeys
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Key == nil {
|
||||
m.Key = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipKeys(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthKeys
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipKeys(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, ErrIntOverflowKeys
|
||||
}
|
||||
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, ErrIntOverflowKeys
|
||||
}
|
||||
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, ErrIntOverflowKeys
|
||||
}
|
||||
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, ErrInvalidLengthKeys
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupKeys
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthKeys
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
194
crypto/vrf/vrf.go
Normal file
194
crypto/vrf/vrf.go
Normal file
@ -0,0 +1,194 @@
|
||||
package vrf
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/subtle"
|
||||
"fmt"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
vrfalgo "github.com/coniks-sys/coniks-go/crypto/vrf"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
||||
)
|
||||
|
||||
const (
|
||||
// PrivKeySize defines the size of the PrivKey bytes
|
||||
PrivKeySize = 64
|
||||
// PubKeySize defines the size of the PubKey bytes
|
||||
PubKeySize = 32
|
||||
// KeyType is the string constant for the vrf algorithm
|
||||
KeyType = "vrf"
|
||||
)
|
||||
|
||||
// Amino encoding names
|
||||
const (
|
||||
// PrivKeyName defines the amino encoding name for the vrf private key
|
||||
PrivKeyName = "vrf/PrivKey"
|
||||
// PubKeyName defines the amino encoding name for the vrf public key
|
||||
PubKeyName = "vrf/PubKey"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// vrf Private Key
|
||||
|
||||
var (
|
||||
_ cryptotypes.PrivKey = &PrivKey{}
|
||||
_ codec.AminoMarshaler = &PrivKey{}
|
||||
)
|
||||
|
||||
// GenerateKey generates a new random private key. It returns an error upon
|
||||
// failure.
|
||||
func GenerateKey() (*PrivKey, error) {
|
||||
priv, err := vrfalgo.GenerateKey(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PrivKey{
|
||||
Key: priv,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (privKey PrivKey) getVrfPrivateKey() vrfalgo.PrivateKey {
|
||||
return vrfalgo.PrivateKey(privKey.Key)
|
||||
}
|
||||
|
||||
// Bytes returns the byte representation of the Private Key.
|
||||
func (privKey PrivKey) Bytes() []byte {
|
||||
bz := make([]byte, len(privKey.Key))
|
||||
copy(bz, privKey.Key)
|
||||
|
||||
return bz
|
||||
}
|
||||
|
||||
// PubKey returns the private key's public key. If the privkey is not valid
|
||||
// it returns a nil value.
|
||||
func (privKey PrivKey) PubKey() cryptotypes.PubKey {
|
||||
pk, _ := vrfalgo.PrivateKey(privKey.Key).Public()
|
||||
|
||||
return &PubKey{
|
||||
Key: pk,
|
||||
}
|
||||
}
|
||||
|
||||
// Equals returns true if two private keys are equal and false otherwise.
|
||||
func (privKey PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool {
|
||||
return privKey.Type() == other.Type() && subtle.ConstantTimeCompare(privKey.Bytes(), other.Bytes()) == 1
|
||||
}
|
||||
|
||||
// Type returns vrf
|
||||
func (privKey PrivKey) Type() string {
|
||||
return KeyType
|
||||
}
|
||||
|
||||
// Compute generates the vrf value for the byte slice m using the
|
||||
// underlying private key sk.
|
||||
func (privKey PrivKey) Sign(digestBz []byte) ([]byte, error) {
|
||||
sk := privKey.getVrfPrivateKey()
|
||||
|
||||
return sk.Compute(digestBz), nil
|
||||
}
|
||||
|
||||
// MarshalAmino overrides Amino binary marshaling.
|
||||
func (privKey PrivKey) MarshalAmino() ([]byte, error) {
|
||||
return privKey.Key, nil
|
||||
}
|
||||
|
||||
// UnmarshalAmino overrides Amino binary marshaling.
|
||||
func (privKey *PrivKey) UnmarshalAmino(bz []byte) error {
|
||||
if len(bz) != PrivKeySize {
|
||||
return fmt.Errorf("invalid privkey size, expected %d got %d", PrivKeySize, len(bz))
|
||||
}
|
||||
privKey.Key = bz
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalAminoJSON overrides Amino JSON marshaling.
|
||||
func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) {
|
||||
// When we marshal to Amino JSON, we don't marshal the "key" field itself,
|
||||
// just its contents (i.e. the key bytes).
|
||||
return privKey.MarshalAmino()
|
||||
}
|
||||
|
||||
// UnmarshalAminoJSON overrides Amino JSON marshaling.
|
||||
func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error {
|
||||
return privKey.UnmarshalAmino(bz)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// vrf Public Key
|
||||
|
||||
var (
|
||||
_ cryptotypes.PubKey = &PubKey{}
|
||||
_ codec.AminoMarshaler = &PubKey{}
|
||||
)
|
||||
|
||||
// func (pubKey PubKey) getVrfPublicKey() vrfalgo.PublicKey {
|
||||
// return vrfalgo.PublicKey(pubKey.Key)
|
||||
// }
|
||||
|
||||
// Address returns the address of the ECDSA public key.
|
||||
// The function will return an empty address if the public key is invalid.
|
||||
func (pubKey PubKey) Address() tmcrypto.Address {
|
||||
return tmcrypto.Address(common.BytesToAddress(pubKey.Key).Bytes())
|
||||
}
|
||||
|
||||
// Bytes returns the raw bytes of the ECDSA public key.
|
||||
func (pubKey PubKey) Bytes() []byte {
|
||||
bz := make([]byte, len(pubKey.Key))
|
||||
copy(bz, pubKey.Key)
|
||||
|
||||
return bz
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer interface.
|
||||
func (pubKey PubKey) String() string {
|
||||
return fmt.Sprintf("vrf{%X}", pubKey.Key)
|
||||
}
|
||||
|
||||
// Type returns vrf
|
||||
func (pubKey PubKey) Type() string {
|
||||
return KeyType
|
||||
}
|
||||
|
||||
// Equals returns true if the pubkey type is the same and their bytes are deeply equal.
|
||||
func (pubKey PubKey) Equals(other cryptotypes.PubKey) bool {
|
||||
return pubKey.Type() == other.Type() && bytes.Equal(pubKey.Bytes(), other.Bytes())
|
||||
}
|
||||
|
||||
// Verify returns true iff vrf=Compute(m) for the sk that
|
||||
// corresponds to pk.
|
||||
func (pubKey PubKey) VerifySignature(msg, sig []byte) bool {
|
||||
panic("not implement")
|
||||
}
|
||||
|
||||
// MarshalAmino overrides Amino binary marshaling.
|
||||
func (pubKey PubKey) MarshalAmino() ([]byte, error) {
|
||||
return pubKey.Key, nil
|
||||
}
|
||||
|
||||
// UnmarshalAmino overrides Amino binary marshaling.
|
||||
func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
|
||||
if len(bz) != PubKeySize {
|
||||
return errorsmod.Wrapf(errortypes.ErrInvalidPubKey, "invalid pubkey size, expected %d, got %d", PubKeySize, len(bz))
|
||||
}
|
||||
pubKey.Key = bz
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalAminoJSON overrides Amino JSON marshaling.
|
||||
func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) {
|
||||
// When we marshal to Amino JSON, we don't marshal the "key" field itself,
|
||||
// just its contents (i.e. the key bytes).
|
||||
return pubKey.MarshalAmino()
|
||||
}
|
||||
|
||||
// UnmarshalAminoJSON overrides Amino JSON marshaling.
|
||||
func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error {
|
||||
return pubKey.UnmarshalAmino(bz)
|
||||
}
|
96
crypto/vrf/vrf_test.go
Normal file
96
crypto/vrf/vrf_test.go
Normal file
@ -0,0 +1,96 @@
|
||||
package vrf
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
func TestPrivKey(t *testing.T) {
|
||||
// validate type and equality
|
||||
privKey, err := GenerateKey()
|
||||
require.NoError(t, err)
|
||||
require.Implements(t, (*cryptotypes.PrivKey)(nil), privKey)
|
||||
|
||||
// validate inequality
|
||||
privKey2, err := GenerateKey()
|
||||
require.NoError(t, err)
|
||||
require.False(t, privKey.Equals(privKey2))
|
||||
}
|
||||
|
||||
func TestPrivKey_PubKey(t *testing.T) {
|
||||
privKey, err := GenerateKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
// validate type and equality
|
||||
pubKey := &PubKey{
|
||||
Key: privKey.PubKey().Bytes(),
|
||||
}
|
||||
require.Implements(t, (*cryptotypes.PubKey)(nil), pubKey)
|
||||
|
||||
// validate inequality
|
||||
privKey2, err := GenerateKey()
|
||||
require.NoError(t, err)
|
||||
require.False(t, pubKey.Equals(privKey2.PubKey()))
|
||||
}
|
||||
|
||||
func TestMarshalAmino(t *testing.T) {
|
||||
aminoCdc := codec.NewLegacyAmino()
|
||||
privKey, err := GenerateKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
pubKey := privKey.PubKey().(*PubKey)
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
msg codec.AminoMarshaler
|
||||
typ interface{}
|
||||
expBinary []byte
|
||||
expJSON string
|
||||
}{
|
||||
{
|
||||
"vrf private key",
|
||||
privKey,
|
||||
&PrivKey{},
|
||||
append([]byte{64}, privKey.Bytes()...), // Length-prefixed.
|
||||
"\"" + base64.StdEncoding.EncodeToString(privKey.Bytes()) + "\"",
|
||||
},
|
||||
{
|
||||
"vrf public key",
|
||||
pubKey,
|
||||
&PubKey{},
|
||||
append([]byte{32}, pubKey.Bytes()...), // Length-prefixed.
|
||||
"\"" + base64.StdEncoding.EncodeToString(pubKey.Bytes()) + "\"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
// Do a round trip of encoding/decoding binary.
|
||||
bz, err := aminoCdc.Marshal(tc.msg)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.expBinary, bz)
|
||||
|
||||
err = aminoCdc.Unmarshal(bz, tc.typ)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, tc.msg, tc.typ)
|
||||
|
||||
// Do a round trip of encoding/decoding JSON.
|
||||
bz, err = aminoCdc.MarshalJSON(tc.msg)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.expJSON, string(bz))
|
||||
|
||||
err = aminoCdc.UnmarshalJSON(bz, tc.typ)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, tc.msg, tc.typ)
|
||||
})
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ version: '3'
|
||||
services:
|
||||
kvdnode0:
|
||||
container_name: kvdnode0
|
||||
image: "kava/kavanode"
|
||||
image: "0glabs/0g-chain-node"
|
||||
ports:
|
||||
- "26656-26657:26656-26657"
|
||||
environment:
|
||||
@ -17,7 +17,7 @@ services:
|
||||
|
||||
kvdnode1:
|
||||
container_name: kvdnode1
|
||||
image: "kava/kavanode"
|
||||
image: "0glabs/0g-chain-node"
|
||||
ports:
|
||||
- "26659-26660:26656-26657"
|
||||
environment:
|
||||
@ -31,7 +31,7 @@ services:
|
||||
|
||||
kvdnode2:
|
||||
container_name: kvdnode2
|
||||
image: "kava/kavanode"
|
||||
image: "0glabs/0g-chain-node"
|
||||
environment:
|
||||
- ID=2
|
||||
- LOG=${LOG:-kvd.log}
|
||||
@ -45,7 +45,7 @@ services:
|
||||
|
||||
kvdnode3:
|
||||
container_name: kvdnode3
|
||||
image: "kava/kavanode"
|
||||
image: "0glabs/0g-chain-node"
|
||||
environment:
|
||||
- ID=3
|
||||
- LOG=${LOG:-kvd.log}
|
||||
|
28
go.mod
28
go.mod
@ -1,4 +1,4 @@
|
||||
module github.com/kava-labs/kava
|
||||
module github.com/0glabs/0g-chain
|
||||
|
||||
go 1.20
|
||||
|
||||
@ -6,6 +6,8 @@ require (
|
||||
cosmossdk.io/errors v1.0.0-beta.7
|
||||
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4
|
||||
github.com/cenkalti/backoff/v4 v4.1.3
|
||||
github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71
|
||||
github.com/consensys/gnark-crypto v0.12.1
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.3
|
||||
github.com/cosmos/cosmos-sdk v0.46.11
|
||||
github.com/cosmos/go-bip39 v1.0.0
|
||||
@ -20,6 +22,7 @@ require (
|
||||
github.com/linxGnu/grocksdb v1.8.0
|
||||
github.com/pelletier/go-toml/v2 v2.0.6
|
||||
github.com/prometheus/client_golang v1.14.0
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/spf13/cast v1.5.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/spf13/viper v1.15.0
|
||||
@ -40,6 +43,7 @@ require (
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
cloud.google.com/go/iam v1.1.2 // indirect
|
||||
cloud.google.com/go/storage v1.30.1 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||
github.com/99designs/keyring v1.2.1 // indirect
|
||||
@ -53,6 +57,7 @@ require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.7.0 // indirect
|
||||
github.com/btcsuite/btcd v0.23.4 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
|
||||
@ -64,6 +69,7 @@ require (
|
||||
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
|
||||
github.com/cometbft/cometbft-db v0.7.0 // indirect
|
||||
github.com/confio/ics23/go v0.9.0 // indirect
|
||||
github.com/consensys/bavard v0.1.13 // indirect
|
||||
github.com/cosmos/btcutil v1.0.5 // indirect
|
||||
github.com/cosmos/gogoproto v1.4.6 // indirect
|
||||
github.com/cosmos/iavl v0.19.5 // indirect
|
||||
@ -100,7 +106,7 @@ require (
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/btree v1.1.2 // indirect
|
||||
github.com/google/flatbuffers v1.12.1 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/orderedcode v0.0.1 // indirect
|
||||
github.com/google/s2a-go v0.1.4 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
@ -135,7 +141,7 @@ require (
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/manifoldco/promptui v0.9.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
|
||||
@ -143,6 +149,7 @@ require (
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mmcloughlin/addchain v0.4.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/mtibben/percent v0.2.1 // indirect
|
||||
@ -160,14 +167,13 @@ require (
|
||||
github.com/rjeczalik/notify v0.9.1 // indirect
|
||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||
github.com/rs/cors v1.8.3 // indirect
|
||||
github.com/rs/zerolog v1.29.0 // indirect
|
||||
github.com/rs/zerolog v1.32.0 // indirect
|
||||
github.com/sasha-s/go-deadlock v0.3.1 // indirect
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
|
||||
github.com/spf13/afero v1.9.3 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/status-im/keycard-go v0.2.0 // indirect
|
||||
github.com/stretchr/objx v0.5.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||
github.com/tendermint/go-amino v0.16.0 // indirect
|
||||
github.com/tidwall/btree v1.5.0 // indirect
|
||||
@ -184,7 +190,7 @@ require (
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/oauth2 v0.10.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
golang.org/x/term v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
@ -193,10 +199,12 @@ require (
|
||||
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
nhooyr.io/websocket v1.8.6 // indirect
|
||||
rsc.io/tmplfunc v0.0.3 // indirect
|
||||
)
|
||||
|
||||
replace (
|
||||
@ -205,11 +213,13 @@ replace (
|
||||
// Use rocksdb 7.9.2
|
||||
github.com/cometbft/cometbft-db => github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-kava.1
|
||||
// Use cosmos-sdk fork with backported fix for unsafe-reset-all, staking transfer events, and custom tally handler support
|
||||
github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.46.11-kava.3
|
||||
github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.46.11-0glabs.8
|
||||
// See https://github.com/cosmos/cosmos-sdk/pull/13093
|
||||
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
|
||||
// Use go-ethereum fork with precompiles
|
||||
github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
|
||||
// Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support
|
||||
github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.21.0-kava-v23-1
|
||||
github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v2.0.4
|
||||
// See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320
|
||||
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
|
||||
// Use the cosmos modified protobufs
|
||||
@ -217,7 +227,7 @@ replace (
|
||||
// Downgraded to avoid bugs in following commits which causes "version does not exist" errors
|
||||
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
|
||||
// Use cometbft fork of tendermint
|
||||
github.com/tendermint/tendermint => github.com/kava-labs/cometbft v0.34.27-kava.0
|
||||
github.com/tendermint/tendermint => github.com/0glabs/cometbft v0.34.27-0glabs.0
|
||||
// Indirect dependencies still use tendermint/tm-db
|
||||
github.com/tendermint/tm-db => github.com/kava-labs/tm-db v0.6.7-kava.4
|
||||
)
|
||||
|
87
go.sum
87
go.sum
@ -193,6 +193,8 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS
|
||||
collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
|
||||
cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w=
|
||||
cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE=
|
||||
cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI=
|
||||
cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM=
|
||||
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA=
|
||||
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
@ -200,6 +202,12 @@ filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmG
|
||||
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
||||
git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw=
|
||||
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA=
|
||||
github.com/0glabs/cometbft v0.34.27-0glabs.0 h1:jErty8aVtp2RiU/59QTEhUCi3xCoc67NHHsmIqd7Xz4=
|
||||
github.com/0glabs/cometbft v0.34.27-0glabs.0/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw=
|
||||
github.com/0glabs/cosmos-sdk v0.46.11-0glabs.8 h1:zYkr1AaeyxIxrGyt/B/Xc4l/xWsdk71yo1CniPmrvuo=
|
||||
github.com/0glabs/cosmos-sdk v0.46.11-0glabs.8/go.mod h1:4uTpR8WwpNKawdsPj5uyUS8DvKilc2OyFKe4RBm4oso=
|
||||
github.com/0glabs/ethermint v0.21.0-0g.v2.0.4 h1:UFQflLvLk7uvJcKLvpKY6U3n5WU3Osphrf9VUSPgfBY=
|
||||
github.com/0glabs/ethermint v0.21.0-0g.v2.0.4/go.mod h1:o5lh9adPdMNNAweyDYleu3FRAJyRIy1drdMcSpo1qy8=
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM=
|
||||
@ -207,6 +215,7 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSu
|
||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
|
||||
@ -276,6 +285,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U
|
||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
|
||||
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo=
|
||||
github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
||||
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
|
||||
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||
github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8=
|
||||
@ -287,8 +298,8 @@ github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZg
|
||||
github.com/btcsuite/btcd v0.23.4 h1:IzV6qqkfwbItOS/sg/aDfPDsjPP8twrCOE2R93hxMlQ=
|
||||
github.com/btcsuite/btcd v0.23.4/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
|
||||
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
|
||||
@ -356,16 +367,22 @@ github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZ
|
||||
github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M=
|
||||
github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4=
|
||||
github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak=
|
||||
github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 h1:MFLTqgfJclmtaQ1SRUrWwmDX/1UBok3XWUethkJ2swQ=
|
||||
github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71/go.mod h1:TrHYHH4Wze7v7Hkwu1MH1W+mCPQKM+gs+PicdEV14o8=
|
||||
github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ=
|
||||
github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
|
||||
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
|
||||
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
|
||||
github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q=
|
||||
github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0=
|
||||
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
|
||||
github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
|
||||
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
|
||||
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
|
||||
@ -430,10 +447,9 @@ github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 h1:Izz0+t1Z5nI16
|
||||
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
|
||||
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
||||
github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker v1.6.2/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
|
||||
github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf h1:Yt+4K30SdjOkRoRRm3vYNQgR+/ZIy0RmeUDZo7Y8zeQ=
|
||||
github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
|
||||
github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y=
|
||||
@ -459,13 +475,13 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0=
|
||||
github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s=
|
||||
github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
|
||||
github.com/evmos/go-ethereum v1.10.26-evmos-rc2 h1:tYghk1ZZ8X4/OQ4YI9hvtm8aSN8OSqO0g9vo/sCMdBo=
|
||||
github.com/evmos/go-ethereum v1.10.26-evmos-rc2/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
|
||||
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
|
||||
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
|
||||
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
|
||||
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
|
||||
@ -477,6 +493,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
||||
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8=
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
|
||||
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
|
||||
@ -612,8 +629,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64=
|
||||
@ -645,6 +663,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc=
|
||||
github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
|
||||
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
@ -747,7 +766,6 @@ github.com/holiman/uint256 v1.2.1 h1:XRtyuda/zw2l+Bq/38n5XUoEF72aSOu/77Thd9pPp2o
|
||||
github.com/holiman/uint256 v1.2.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
|
||||
github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
|
||||
github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
|
||||
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
|
||||
@ -802,14 +820,8 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8
|
||||
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
|
||||
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
|
||||
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||
github.com/kava-labs/cometbft v0.34.27-kava.0 h1:FUEGRkF3xtrJH+h9A5G4eA2skf7QaNoOCPaoVqHkh8k=
|
||||
github.com/kava-labs/cometbft v0.34.27-kava.0/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw=
|
||||
github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-kava.1 h1:EZnZAkZ+dqK+1OM4AK+e6wYH8a5xuyg4yFTR4Ez3AXk=
|
||||
github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-kava.1/go.mod h1:mI/4J4IxRzPrXvMiwefrt0fucGwaQ5Hm9IKS7HnoJeI=
|
||||
github.com/kava-labs/cosmos-sdk v0.46.11-kava.3 h1:TOhyyW/xHso/9uIOgYdsrOWDIhXi6foORWZxVRe/wS0=
|
||||
github.com/kava-labs/cosmos-sdk v0.46.11-kava.3/go.mod h1:bSUUbmVwWkv1ZNVTWrQHa/i+73xIUvYYPsCvl5doiCs=
|
||||
github.com/kava-labs/ethermint v0.21.0-kava-v23-1 h1:5TSyCtPvFdMuSe8p2iMVqXmFBlK3lHyjaT9EqN752aI=
|
||||
github.com/kava-labs/ethermint v0.21.0-kava-v23-1/go.mod h1:rdm6AinxZ4dzPEv/cjH+/AGyTbKufJ3RE7M2MDyklH0=
|
||||
github.com/kava-labs/tm-db v0.6.7-kava.4 h1:M2RibOKmbi+k2OhAFry8z9+RJF0CYuDETB7/PrSdoro=
|
||||
github.com/kava-labs/tm-db v0.6.7-kava.4/go.mod h1:70tpLhNfwCP64nAlq+bU+rOiVfWr3Nnju1D1nhGDGKs=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
@ -837,9 +849,11 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg=
|
||||
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
|
||||
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
|
||||
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
@ -868,7 +882,6 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc
|
||||
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
@ -878,8 +891,9 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
@ -913,6 +927,9 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A=
|
||||
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
|
||||
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
|
||||
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
|
||||
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@ -949,6 +966,7 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
|
||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
@ -1059,9 +1077,9 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo=
|
||||
github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
|
||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w=
|
||||
github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
@ -1078,6 +1096,8 @@ github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfP
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
@ -1130,12 +1150,14 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
|
||||
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
|
||||
github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
|
||||
@ -1175,6 +1197,7 @@ github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y=
|
||||
github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
@ -1185,12 +1208,14 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
|
||||
github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo=
|
||||
github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
|
||||
@ -1262,6 +1287,7 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
|
||||
golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
|
||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||
@ -1290,6 +1316,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -1483,11 +1511,9 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -1508,8 +1534,10 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
@ -1561,6 +1589,7 @@ golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191126055441-b0650ceb63d9/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
@ -1599,6 +1628,7 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -1868,13 +1898,13 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
|
||||
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
@ -1890,7 +1920,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
@ -1907,6 +1937,7 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
|
||||
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
|
||||
|
124
localtestnet.sh
Executable file
124
localtestnet.sh
Executable file
@ -0,0 +1,124 @@
|
||||
#! /bin/bash
|
||||
set -e
|
||||
|
||||
validatorMnemonic="equip town gesture square tomorrow volume nephew minute witness beef rich gadget actress egg sing secret pole winter alarm law today check violin uncover"
|
||||
# kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c
|
||||
# kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0
|
||||
|
||||
faucetMnemonic="crash sort dwarf disease change advice attract clump avoid mobile clump right junior axis book fresh mask tube front require until face effort vault"
|
||||
# kava1adkm6svtzjsxxvg7g6rshg6kj9qwej8gwqadqd
|
||||
|
||||
evmFaucetMnemonic="hundred flash cattle inquiry gorilla quick enact lazy galaxy apple bitter liberty print sun hurdle oak town cash because round chalk marriage response success"
|
||||
# 0x3C854F92F726A7897C8B23F55B2D6E2C482EF3E0
|
||||
# kava18jz5lyhhy6ncjlyty064kttw93yzaulq7rlptu
|
||||
|
||||
userMnemonic="news tornado sponsor drastic dolphin awful plastic select true lizard width idle ability pigeon runway lift oppose isolate maple aspect safe jungle author hole"
|
||||
# 0x7Bbf300890857b8c241b219C6a489431669b3aFA
|
||||
# kava10wlnqzyss4accfqmyxwx5jy5x9nfkwh6qm7n4t
|
||||
|
||||
vestingMnemonic="never reject sniff east arctic funny twin feed upper series stay shoot vivid adapt defense economy pledge fetch invite approve ceiling admit gloom exit"
|
||||
# 0xa2F728F997f62F47D4262a70947F6c36885dF9fa
|
||||
# kava15tmj37vh7ch504px9fcfglmvx6y9m70646ev8t
|
||||
|
||||
DATA=~/.0gchain
|
||||
# remove any old state and config
|
||||
rm -rf $DATA
|
||||
|
||||
OS_FAMILY=$(uname -s)
|
||||
NATIVE_GO_OS=$(echo $OS_FAMILY | tr '[:upper:]' '[:lower:]')
|
||||
BINARY=./out/$NATIVE_GO_OS/0gchaind
|
||||
|
||||
# Create new data directory, overwriting any that alread existed
|
||||
chainID="zgchain_8888-1"
|
||||
$BINARY init validator --chain-id $chainID
|
||||
|
||||
# hacky enable of rest api
|
||||
sed -in-place='' 's/enable = false/enable = true/g' $DATA/config/app.toml
|
||||
|
||||
# Set evm tracer to json
|
||||
sed -in-place='' 's/tracer = ""/tracer = "json"/g' $DATA/config/app.toml
|
||||
|
||||
# Enable full error trace to be returned on tx failure
|
||||
sed -in-place='' '/iavl-cache-size/a\
|
||||
trace = true' $DATA/config/app.toml
|
||||
|
||||
# Set client chain id
|
||||
sed -in-place='' 's/chain-id = ""/chain-id = "zgchain_8888-1"/g' $DATA/config/client.toml
|
||||
|
||||
# avoid having to use password for keys
|
||||
$BINARY config keyring-backend test
|
||||
|
||||
# Create validator keys and add account to genesis
|
||||
validatorKeyName="validator"
|
||||
printf "$validatorMnemonic\n" | $BINARY keys add $validatorKeyName --eth --recover
|
||||
$BINARY add-genesis-account $validatorKeyName 2000000000000000000000ua0gi
|
||||
|
||||
# Create faucet keys and add account to genesis
|
||||
faucetKeyName="faucet"
|
||||
printf "$faucetMnemonic\n" | $BINARY keys add $faucetKeyName --eth --recover
|
||||
$BINARY add-genesis-account $faucetKeyName 1000000000000000000000ua0gi
|
||||
|
||||
evmFaucetKeyName="evm-faucet"
|
||||
printf "$evmFaucetMnemonic\n" | $BINARY keys add $evmFaucetKeyName --eth --recover
|
||||
$BINARY add-genesis-account $evmFaucetKeyName 1000000000000000000000ua0gi
|
||||
|
||||
userKeyName="user"
|
||||
printf "$userMnemonic\n" | $BINARY keys add $userKeyName --eth --recover
|
||||
$BINARY add-genesis-account $userKeyName 1000000000000000000000ua0gi
|
||||
|
||||
VESTING_ACCOUNT_START_TIME=$(date -u +%s)
|
||||
VESTING_ACCOUNT_END_TIME=$((VESTING_ACCOUNT_START_TIME + 30 * 60))
|
||||
|
||||
vestingKeyName="vesting"
|
||||
printf "$vestingMnemonic\n" | $BINARY keys add $vestingKeyName --eth --recover
|
||||
$BINARY add-genesis-account $vestingKeyName 1000000000000000000000ua0gi --vesting-amount 1000000000000000000000ua0gi --vesting-start-time $VESTING_ACCOUNT_START_TIME --vesting-end-time $VESTING_ACCOUNT_END_TIME
|
||||
|
||||
storageContractAcc="0g1vsjpjgw8p5f4x0nwp8ernl9lkszewcqqss7r5d"
|
||||
$BINARY add-genesis-account $storageContractAcc 1000000000000000000000ua0gi
|
||||
|
||||
# Create a delegation tx for the validator and add to genesis
|
||||
$BINARY gentx $validatorKeyName 1000000000000000000000ua0gi --keyring-backend test --chain-id $chainID
|
||||
$BINARY collect-gentxs
|
||||
|
||||
# Replace stake with ua0gi
|
||||
sed -in-place='' 's/stake/ua0gi/g' $DATA/config/genesis.json
|
||||
|
||||
# Replace the default evm denom of aphoton with neuron
|
||||
sed -in-place='' 's/aphoton/neuron/g' $DATA/config/genesis.json
|
||||
|
||||
GENESIS=$DATA/config/genesis.json
|
||||
TMP_GENESIS=$DATA/config/tmp_genesis.json
|
||||
|
||||
cat $GENESIS | jq '.consensus_params.block.max_gas = "25000000"' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Zero out the total supply so it gets recalculated during InitGenesis
|
||||
cat $GENESIS | jq '.app_state.bank.supply = []' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Disable fee market
|
||||
cat $GENESIS | jq '.app_state.feemarket.params.no_base_fee = true' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Disable london fork
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.london_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.arrow_glacier_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.gray_glacier_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.merge_netsplit_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.shanghai_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.cancun_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Add earn vault
|
||||
# cat $GENESIS | jq '.app_state.earn.params.allowed_vaults = [
|
||||
# {
|
||||
# denom: "usdx",
|
||||
# strategies: ["STRATEGY_TYPE_HARD"],
|
||||
# },
|
||||
# {
|
||||
# denom: "bkava",
|
||||
# strategies: ["STRATEGY_TYPE_SAVINGS"],
|
||||
# }]' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# cat $GENESIS | jq '.app_state.savings.params.supported_denoms = ["bkava-kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0"]' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
|
||||
$BINARY config broadcast-mode sync
|
||||
|
||||
$BINARY start --home $DATA
|
@ -11,8 +11,8 @@ There are two types of migration:
|
||||
Genesis migration starts a whole new blockchain (with new chain-id) for the new software version.
|
||||
In-Place upgrade keeps the blockchain (and chain-id) the same for the new software version.
|
||||
|
||||
We only support migrations between mainnet kava releases.
|
||||
We only support migrations from the previous mainnet kava version to the current. We don't support migrating between two old versions, use the old software version for this.
|
||||
We only support migrations between mainnet 0g-chain releases.
|
||||
We only support migrations from the previous mainnet 0g-chain version to the current. We don't support migrating between two old versions, use the old software version for this.
|
||||
We only support migrations from old to new versions, not the other way around.
|
||||
|
||||
Genesis Migration
|
||||
@ -22,7 +22,7 @@ The process is:
|
||||
- marshal it to json (using current codec)
|
||||
|
||||
On each release we can delete the previous releases migration and old GenesisState type.
|
||||
eg kava-3 migrates `auth.GenesisState` from kava-2 to `auth.GenesisState` from kava-3,
|
||||
but for kava-4 we don't need to keep around kava-2's `auth.GenesisState` type.
|
||||
eg 0g-chain-3 migrates `auth.GenesisState` from 0g-chain-2 to `auth.GenesisState` from 0g-chain-3,
|
||||
but for 0g-chain-4 we don't need to keep around 0g-chain-2's `auth.GenesisState` type.
|
||||
*/
|
||||
package migrate
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -41,7 +42,7 @@ func TestResetPeriodVestingAccount_NoVestingPeriods(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -64,7 +65,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -97,7 +98,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -125,25 +126,25 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(4e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(4e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // -15 days - vested
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // +15 days - vesting
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // +30 days - vesting
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
}
|
||||
|
||||
@ -159,36 +160,36 @@ func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
|
||||
expectedPeriods := []vestingtypes.Period{
|
||||
{
|
||||
Length: 15 * 24 * 60 * 60, // 15 days
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
{
|
||||
Length: 15 * 24 * 60 * 60, // 15 days
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(2e6))), vacc.OriginalVesting, "expected original vesting to be updated")
|
||||
assert.Equal(t, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(2e6))), vacc.OriginalVesting, "expected original vesting to be updated")
|
||||
assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated")
|
||||
assert.Equal(t, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period")
|
||||
assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated")
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(3e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(3e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // -15 days - vested
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // +15 days - vesting
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
}
|
||||
|
||||
@ -198,35 +199,35 @@ func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testin
|
||||
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
|
||||
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
|
||||
|
||||
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(2e6))), vacc.DelegatedFree, "expected delegated free to be updated")
|
||||
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated")
|
||||
assert.Equal(t, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(2e6))), vacc.DelegatedFree, "expected delegated free to be updated")
|
||||
assert.Equal(t, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated")
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_DelegatedVesting_LessThanVested(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(3e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(3e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // -15 days - vested
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // +15 days - vesting
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
}
|
||||
|
||||
vacc := createVestingAccount(balance, vestingStartTime, periods)
|
||||
vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))))
|
||||
vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))))
|
||||
|
||||
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
|
||||
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
|
||||
|
||||
assert.Equal(t, sdk.Coins(nil), vacc.DelegatedFree, "expected delegrated free to be unmodified")
|
||||
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ukava", sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified")
|
||||
assert.Equal(t, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified")
|
||||
}
|
||||
|
80
migrate/v0_25/migrate.md
Normal file
80
migrate/v0_25/migrate.md
Normal file
@ -0,0 +1,80 @@
|
||||
# Kava 15 Upgrade Instructions
|
||||
|
||||
## Software Version and Key Dates
|
||||
|
||||
- The version of `kava` for Kava 15 is v0.25.0
|
||||
- The Kava 14 chain will be shutdown with a `SoftwareUpgradeProposal` that
|
||||
activates at approximately 15:00 UTC on December 7th, 2023.
|
||||
|
||||
## Dependency Changes
|
||||
|
||||
### For validators using RocksDB
|
||||
|
||||
> [!NOTE]
|
||||
> If you use goleveldb or other database backends, this is not required.
|
||||
|
||||
If you use RocksDB as your database backend, you will need to update RocksDB
|
||||
from v7 to v8. The tested and recommended RocksDB version is `v8.1.1`.
|
||||
Please reference the [RocksDB repository](https://github.com/facebook/rocksdb/tree/v8.1.1)
|
||||
to update your installation before building the RocksDB kava binary.
|
||||
|
||||
## API Changes
|
||||
|
||||
If you require calculating the yearly staking reward percentages, standard
|
||||
calculation will no longer be accurate. [Additional Details can be found here.](./staking_rewards.md)
|
||||
|
||||
### On the day of the upgrade
|
||||
|
||||
The kava chain is expected to halt at block height **7637070**. **Do not stop your node and begin the upgrade before the upgrade height**, or you may go offline and be unable to recover until after the upgrade!
|
||||
|
||||
**Make sure the kava process is stopped before proceeding and that you have backed up your validator**. Failure to backup your validator could make it impossible to restart your node if the upgrade fails.
|
||||
|
||||
**Ensure you are using golang 1.20.x and not a different version.** Golang 1.19 and below may cause app hash mismatches!
|
||||
|
||||
To update to v0.25.0
|
||||
|
||||
```sh
|
||||
# check go version - look for 1.20!
|
||||
go version
|
||||
# go version go1.20.5 linux/amd64
|
||||
|
||||
# in the `kava` folder
|
||||
git fetch
|
||||
git checkout v0.25.0
|
||||
|
||||
# Note: Golang 1.20 must be installed before this step
|
||||
make install
|
||||
|
||||
# verify versions
|
||||
kava version --long
|
||||
# name: kava
|
||||
# server_name: kava
|
||||
# version: 0.25.0
|
||||
# commit: <commit placeholder>
|
||||
# build_tags: netgo ledger,
|
||||
# go: go version go1.20.5 linux/amd64
|
||||
# build_deps:
|
||||
# ...
|
||||
# cosmos_sdk_version: v0.46.11
|
||||
|
||||
# Restart node -
|
||||
kava start
|
||||
```
|
||||
|
||||
### Risks
|
||||
|
||||
As a validator, performing the upgrade procedure on your consensus nodes carries a heightened risk of double-signing and being slashed. The most important piece of this procedure is verifying your software version and genesis file hash before starting your validator and signing.
|
||||
|
||||
The riskiest thing a validator can do is discover that they made a mistake and repeat the upgrade procedure again during the network startup. If you discover a mistake in the process, the best thing to do is wait for the network to start before correcting it. If the network is halted and you have started with a different genesis file than the expected one, seek advice from a Kava developer before resetting your validator.
|
||||
|
||||
### Recovery
|
||||
|
||||
Prior to applying the Kava 15 upgrade, validators are encouraged to take a full data snapshot at the upgrade height before proceeding. Snap-shotting depends heavily on infrastructure, but generally this can be done by backing up the .kava directory.
|
||||
|
||||
It is critically important to back-up the .kava/data/priv_validator_state.json file after stopping your kava process. This file is updated every block as your validator participates in consensus rounds. It is a critical file needed to prevent double-signing, in case the upgrade fails and the previous chain needs to be restarted.
|
||||
|
||||
In the event that the upgrade does not succeed, validators and operators must downgrade back to v0.24.x of the Kava software and restore to their latest snapshot before restarting their nodes.
|
||||
|
||||
### Coordination
|
||||
|
||||
If the Kava 15 chain does not launch by December 8th, 2023 at 00:00 UTC, the launch should be considered a failure. In the event of launch failure, coordination will occur in the [Kava discord](https://discord.com/invite/kQzh3Uv).
|
80
migrate/v0_25/staking_rewards.md
Normal file
80
migrate/v0_25/staking_rewards.md
Normal file
@ -0,0 +1,80 @@
|
||||
# Migrate Staking Reward Calculation to Endpoint
|
||||
|
||||
Kava 15 (v0.25.x) changes the mechanism for staking rewards, which will no longer be inflationary but will be paid out of the community module. In order to continue displaying expected yields or APYs to users, wallets and explorers will need to update.
|
||||
|
||||
The endpoint calculates staking rewards for the current kava version and is forward compatible with future changes.
|
||||
|
||||
All consumers who display yearly staking reward percentages are encouraged to migrate from the standard calculation to using the endpoint, as the standard calculation will no longer be accurate.
|
||||
|
||||
Endpoint: `/kava/community/v1beta1/annualized_rewards`
|
||||
Example Response:
|
||||
```json
|
||||
{
|
||||
"staking_rewards": "0.203023625910000000"
|
||||
}
|
||||
```
|
||||
|
||||
## Before Kava 15
|
||||
|
||||
The staking APR is calculated the same way as other cosmos-sdk chains. Various parameters are fetched and then combined in this calculation:
|
||||
```
|
||||
staking_apr ≈ mint_inflation *
|
||||
(1 - distribution_params.community_tax) *
|
||||
(total_supply_ukava/pool.bonded_tokens)
|
||||
```
|
||||
|
||||
_Note this doesn’t include transaction fees paid to stakers._
|
||||
|
||||
Endpoints used:
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/params
|
||||
* https://api.data.kava.io/cosmos/distribution/v1beta1/params
|
||||
* https://api.data.kava.io/cosmos/bank/v1beta1/supply/by_denom?denom=ukava
|
||||
* https://api.data.kava.io/cosmos/staking/v1beta1/pool
|
||||
|
||||
Informational Endpoints
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/inflation
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/annual_provisions
|
||||
|
||||
## After Kava 15
|
||||
|
||||
Kava 15 implements new staking rewards as ratified in this proposal: https://www.mintscan.io/kava/proposals/141. They will come into effect at the “switchover time” on 2024-01-01 00:00 UTC.
|
||||
|
||||
* All delegating and claiming transactions remain unchanged. There is no change in how rewards are claimed or how claimable balances are queried.
|
||||
* After the switchover time, inflation will be set to zero (and rewards will be paid from the community module account).
|
||||
* After the switchover time, rewards are paid out according to:
|
||||
```
|
||||
staking apy ≈ community_params.staking_rewards_per_second *
|
||||
seconds_per_year / pool.bonded_tokens
|
||||
```
|
||||
|
||||
_Note this doesn’t include transaction fees paid to stakers._
|
||||
|
||||
* There is a new endpoint `kava/community/v1beta1/annualized_rewards`
|
||||
* before the switchover time, it will return the current staking APY (calculated in the previous section)
|
||||
* after the switchover time, it will return the new staking APY above
|
||||
|
||||
* Existing endpoints above will remain active, but the params will change such that the old apr calculation will return 0.
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/params
|
||||
* no format changes
|
||||
* `inflation_max` and `inflation_min` will be 0.0
|
||||
|
||||
* https://api.data.kava.io/cosmos/distribution/v1beta1/params
|
||||
* no format changes
|
||||
* `community_tax` will be 0.0
|
||||
|
||||
* https://api.data.kava.io/cosmos/bank/v1beta1/supply/by_denom?denom=ukava
|
||||
* no changes
|
||||
|
||||
* https://api.data.kava.io/cosmos/staking/v1beta1/pool
|
||||
* no changes
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/inflation
|
||||
* no format changes
|
||||
* `inflation` will be 0.0
|
||||
|
||||
* https://api.data.kava.io/cosmos/mint/v1beta1/annual_provisions
|
||||
* no format changes
|
||||
* `annual_provisions` will be 0.0
|
85
networks/devnet/deploy.sh
Executable file
85
networks/devnet/deploy.sh
Executable file
@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
|
||||
function help() {
|
||||
echo "Usage: deploy.sh IP1 [options]"
|
||||
echo ""
|
||||
echo " -i Identity file"
|
||||
echo " -k Keyring password to create key (for Linux only)"
|
||||
echo " -n Network (default: devnet)"
|
||||
echo " -c Chain ID (default: \"zgtendermint_16600-1\")"
|
||||
echo " -v schedule end time (unix epoch) for vesting accounts"
|
||||
echo ""
|
||||
}
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
IP_LIST=$1
|
||||
shift
|
||||
PEM_FLAG=""
|
||||
KEYRING_PASSWORD=""
|
||||
NETWORK="devnet"
|
||||
TAG_OR_BRANCH="dev"
|
||||
INIT_GENESIS_ENV=""
|
||||
VESTING_ACCOUNT_END_TIME=0
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-i)
|
||||
PEM_FLAG="-i $2";
|
||||
shift; shift
|
||||
;;
|
||||
-k)
|
||||
KEYRING_PASSWORD=$2;
|
||||
shift; shift
|
||||
;;
|
||||
-n)
|
||||
NETWORK=$2
|
||||
INIT_GENESIS_ENV="$INIT_GENESIS_ENV export ROOT_DIR=$2;"
|
||||
shift; shift
|
||||
;;
|
||||
-c)
|
||||
INIT_GENESIS_ENV="$INIT_GENESIS_ENV export CHAIN_ID=$2;"
|
||||
shift; shift
|
||||
;;
|
||||
-v)
|
||||
INIT_GENESIS_ENV="$INIT_GENESIS_ENV export VESTING_ACCOUNT_END_TIME=$2;"
|
||||
shift; shift
|
||||
;;
|
||||
*)
|
||||
help
|
||||
echo "Unknown flag passed: \"$1\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
IFS=","; declare -a IPS=($IP_LIST); unset IFS
|
||||
NUM_NODES=${#IPS[@]}
|
||||
|
||||
# Install dependent libraries and binary
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0g-chain; git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; git checkout $TAG_OR_BRANCH; ./networks/$NETWORK/install.sh"
|
||||
done
|
||||
|
||||
# Create genesis config on node0
|
||||
ssh $PEM_FLAG ubuntu@${IPS[0]} "cd 0g-chain/networks/$NETWORK; $INIT_GENESIS_ENV ./init-genesis.sh $IP_LIST $KEYRING_PASSWORD; tar czf ~/$NETWORK.tar.gz $NETWORK; rm -rf $NETWORK"
|
||||
scp $PEM_FLAG ubuntu@${IPS[0]}:$NETWORK.tar.gz .
|
||||
ssh $PEM_FLAG ubuntu@${IPS[0]} "rm $NETWORK.tar.gz"
|
||||
|
||||
# Copy genesis config to remote nodes
|
||||
tar xzf $NETWORK.tar.gz
|
||||
rm $NETWORK.tar.gz
|
||||
cd $NETWORK
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
tar czf node$i.tar.gz node$i
|
||||
scp $PEM_FLAG node$i.tar.gz ubuntu@${IPS[$i]}:~
|
||||
ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0gchaind-$NETWORK; tar xzf node$i.tar.gz; rm node$i.tar.gz; mv node$i 0gchaind-$NETWORK"
|
||||
rm node$i.tar.gz
|
||||
done
|
||||
|
||||
echo -e "\n\nSucceeded to deploy on $NUM_NODES nodes!\n"
|
193
networks/devnet/init-genesis.sh
Executable file
193
networks/devnet/init-genesis.sh
Executable file
@ -0,0 +1,193 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_DIR=${ROOT_DIR:-devnet}
|
||||
CHAIN_ID=${CHAIN_ID:-zgtendermint_16600-1}
|
||||
|
||||
# Usage: init-genesis.sh IP1 KEYRING_PASSWORD
|
||||
OS_NAME=`uname -o`
|
||||
USAGE="Usage: ${BASH_SOURCE[0]} IP1"
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
USAGE="$USAGE KEYRING_PASSWORD"
|
||||
fi
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "IP list not specified"
|
||||
echo $USAGE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
if [[ $# -eq 1 ]]; then
|
||||
echo "Keyring password not specified"
|
||||
echo $USAGE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PASSWORD=$2
|
||||
fi
|
||||
|
||||
0gchaind version 2>/dev/null || export PATH=$PATH:$(go env GOPATH)/bin
|
||||
|
||||
set -e
|
||||
|
||||
IFS=","; declare -a IPS=($1); unset IFS
|
||||
|
||||
NUM_NODES=${#IPS[@]}
|
||||
VALIDATOR_BALANCE=25000000000000ua0gi
|
||||
FAUCET_BALANCE=500000000000000ua0gi
|
||||
STAKING=5000000000000ua0gi
|
||||
VESTING_BALANCE=400000000000000ua0gi
|
||||
|
||||
VESTING_ACCOUNT_START_TIME=$(date -u +%s)
|
||||
|
||||
# Init configs
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
HOMEDIR="$ROOT_DIR"/node$i
|
||||
|
||||
# Change parameter token denominations to neuron
|
||||
GENESIS="$HOMEDIR"/config/genesis.json
|
||||
TMP_GENESIS="$HOMEDIR"/config/tmp_genesis.json
|
||||
|
||||
# Init
|
||||
0gchaind init "node$i" --home "$HOMEDIR" --chain-id "$CHAIN_ID" >/dev/null 2>&1
|
||||
|
||||
# Replace stake with neuron
|
||||
sed -in-place='' 's/stake/ua0gi/g' "$GENESIS"
|
||||
|
||||
# Replace the default evm denom of aphoton with neuron
|
||||
sed -in-place='' 's/aphoton/neuron/g' "$GENESIS"
|
||||
|
||||
cat $GENESIS | jq '.consensus_params.block.max_gas = "25000000"' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Zero out the total supply so it gets recalculated during InitGenesis
|
||||
cat $GENESIS | jq '.app_state.bank.supply = []' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Disable fee market
|
||||
cat $GENESIS | jq '.app_state.feemarket.params.no_base_fee = true' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Disable london fork
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.london_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.arrow_glacier_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.gray_glacier_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.merge_netsplit_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.shanghai_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.cancun_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# cat "$GENESIS" | jq '.app_state["staking"]["params"]["bond_denom"]="a0gi"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
# cat "$GENESIS" | jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="a0gi"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
|
||||
cat "$GENESIS" | jq '.app_state["staking"]["params"]["max_validators"]=200' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
cat "$GENESIS" | jq '.app_state["slashing"]["params"]["signed_blocks_window"]="1000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
|
||||
cat "$GENESIS" | jq '.app_state["consensus_params"]["block"]["time_iota_ms"]="3000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
cat "$GENESIS" | jq '.app_state.gov.voting_params.voting_period = "300s"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
|
||||
# Change app.toml
|
||||
APP_TOML="$HOMEDIR"/config/app.toml
|
||||
sed -i 's/minimum-gas-prices = "0neuron"/minimum-gas-prices = "1000000000neuron"/' "$APP_TOML"
|
||||
sed -i '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' "$APP_TOML"
|
||||
sed -i '/\[json-rpc\]/,/^\[/ s/address = "127.0.0.1:8545"/address = "0.0.0.0:8545"/' "$APP_TOML"
|
||||
|
||||
# Set evm tracer to json
|
||||
# sed -in-place='' 's/tracer = ""/tracer = "json"/g' "$APP_TOML"
|
||||
|
||||
# Enable full error trace to be returned on tx failure
|
||||
sed -in-place='' '/iavl-cache-size/a\
|
||||
trace = true' "$APP_TOML"
|
||||
done
|
||||
|
||||
# Update seeds in config.toml
|
||||
SEEDS=""
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
if [[ $i -gt 0 ]]; then SEEDS=$SEEDS,; fi
|
||||
NODE_ID=`0gchaind tendermint show-node-id --home $ROOT_DIR/node$i`
|
||||
SEEDS=$SEEDS$NODE_ID@${IPS[$i]}:26656
|
||||
done
|
||||
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
sed -i "/seeds = /c\seeds = \"$SEEDS\"" "$ROOT_DIR"/node$i/config/config.toml
|
||||
done
|
||||
|
||||
# Prepare validators
|
||||
#
|
||||
# Note, keyring backend `file` works bad on Windows, and `add-genesis-account`
|
||||
# do not supports --keyring-dir flag. As a result, we use keyring backend `os`,
|
||||
# which is the default value.
|
||||
#
|
||||
# Where key stored:
|
||||
# - Windows: Windows credentials management.
|
||||
# - Linux: under `--home` specified folder.
|
||||
if [[ "$OS_NAME" = "Msys" ]]; then
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
VALIDATOR="0gchain_validator_$i"
|
||||
set +e
|
||||
ret=`0gchaind keys list --keyring-backend os -n | grep $VALIDATOR`
|
||||
set -e
|
||||
if [[ "$ret" = "" ]]; then
|
||||
echo "Create validator key: $VALIDATOR"
|
||||
0gchaind keys add $VALIDATOR --keyring-backend os --eth
|
||||
fi
|
||||
done
|
||||
elif [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
# Create N validators for node0
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
yes $PASSWORD | 0gchaind keys add "0gchain_validator_$i" --keyring-backend os --home "$ROOT_DIR"/node0 --eth
|
||||
done
|
||||
|
||||
# Copy validators to other nodes
|
||||
for ((i=1; i<$NUM_NODES; i++)) do
|
||||
cp "$ROOT_DIR"/node0/keyhash "$ROOT_DIR"/node$i
|
||||
cp "$ROOT_DIR"/node0/*.address "$ROOT_DIR"/node$i
|
||||
cp "$ROOT_DIR"/node0/*.info "$ROOT_DIR"/node$i
|
||||
done
|
||||
else
|
||||
echo -e "\n\nOS: $OS_NAME"
|
||||
echo "Unsupported OS to generate keys for validators!!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Add all validators in genesis
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
for ((j=0; j<$NUM_NODES; j++)) do
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
yes $PASSWORD | 0gchaind add-genesis-account "0gchain_validator_$j" $VALIDATOR_BALANCE --home "$ROOT_DIR/node$i"
|
||||
else
|
||||
0gchaind add-genesis-account "0gchain_validator_$j" $VALIDATOR_BALANCE --home "$ROOT_DIR/node$i"
|
||||
fi
|
||||
done
|
||||
0gchaind add-genesis-account 0g1zyvrkyr8pmczkguxztxpp3qcd0uhkt0tfxjupt $FAUCET_BALANCE --home "$ROOT_DIR/node$i"
|
||||
0gchaind add-genesis-account 0g1jwuhghh6qrln4tthhqrdt3qrmjn9zm05xns46u $VESTING_BALANCE --vesting-amount $VESTING_BALANCE --vesting-start-time $VESTING_ACCOUNT_START_TIME --vesting-end-time $VESTING_ACCOUNT_END_TIME --home "$ROOT_DIR/node$i"
|
||||
done
|
||||
|
||||
# Prepare genesis txs
|
||||
mkdir -p "$ROOT_DIR"/gentxs
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
yes $PASSWORD | 0gchaind gentx "0gchain_validator_$i" $STAKING --home "$ROOT_DIR/node$i" --output-document "$ROOT_DIR/gentxs/node$i.json"
|
||||
else
|
||||
0gchaind gentx "0gchain_validator_$i" $STAKING --home "$ROOT_DIR/node$i" --output-document "$ROOT_DIR/gentxs/node$i.json"
|
||||
fi
|
||||
done
|
||||
|
||||
# Create genesis at node0 and copy to other nodes
|
||||
0gchaind collect-gentxs --home "$ROOT_DIR/node0" --gentx-dir "$ROOT_DIR/gentxs" >/dev/null 2>&1
|
||||
sed -i '/persistent_peers = /c\persistent_peers = ""' "$ROOT_DIR"/node0/config/config.toml
|
||||
0gchaind validate-genesis --home "$ROOT_DIR/node0"
|
||||
for ((i=1; i<$NUM_NODES; i++)) do
|
||||
cp "$ROOT_DIR"/node0/config/genesis.json "$ROOT_DIR"/node$i/config/genesis.json
|
||||
done
|
||||
|
||||
# For linux, backup keys for all validators
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
mkdir -p "$ROOT_DIR"/keyring-os
|
||||
|
||||
cp "$ROOT_DIR"/node0/keyhash "$ROOT_DIR"/keyring-os
|
||||
cp "$ROOT_DIR"/node0/*.address "$ROOT_DIR"/keyring-os
|
||||
cp "$ROOT_DIR"/node0/*.info "$ROOT_DIR"/keyring-os
|
||||
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
rm -f "$ROOT_DIR"/node$i/keyhash "$ROOT_DIR"/node$i/*.address "$ROOT_DIR"/node$i/*.info
|
||||
done
|
||||
fi
|
||||
|
||||
echo -e "\n\nSucceeded to init genesis!\n"
|
21
networks/devnet/install.sh
Executable file
21
networks/devnet/install.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Install dependent libraries
|
||||
go version 2>/dev/null || sudo snap install go --classic
|
||||
jq --version 2>/dev/null || sudo snap install jq
|
||||
make --version 2>/dev/null || sudo apt install make -y
|
||||
gcc --version 2>/dev/null || (sudo apt-get update; sudo apt install gcc -y)
|
||||
|
||||
# Build binary
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
0gchaind version 2>/dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
# Make under root dir
|
||||
SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"`
|
||||
cd $SCRIPT_DIR/../..
|
||||
rm -rf $(go env GOPATH)/bin/0gchaind
|
||||
make install
|
||||
|
||||
# Add gopath to path
|
||||
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.profile
|
||||
fi
|
@ -1,4 +1,4 @@
|
||||
all:
|
||||
docker build --tag kava/kavanode kavanode
|
||||
docker build --tag 0glabs/0g-chain-node 0g-chain-node
|
||||
|
||||
.PHONY: all
|
||||
|
84
networks/testnet/deploy.sh
Executable file
84
networks/testnet/deploy.sh
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
|
||||
function help() {
|
||||
echo "Usage: deploy.sh IP1,IP2,IP3 [options]"
|
||||
echo ""
|
||||
echo " -i Identity file"
|
||||
echo " -k Keyring password to create key (for Linux only)"
|
||||
echo " -n Network (default: testnet)"
|
||||
echo " -c Chain ID (default: \"zgtendermint_16600-1\")"
|
||||
echo " -v schedule end time (unix epoch) for vesting accounts"
|
||||
echo ""
|
||||
}
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
IP_LIST=$1
|
||||
shift
|
||||
PEM_FLAG=""
|
||||
KEYRING_PASSWORD=""
|
||||
NETWORK="testnet"
|
||||
INIT_GENESIS_ENV=""
|
||||
VESTING_ACCOUNT_END_TIME=0
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-i)
|
||||
PEM_FLAG="-i $2";
|
||||
shift; shift
|
||||
;;
|
||||
-k)
|
||||
KEYRING_PASSWORD=$2;
|
||||
shift; shift
|
||||
;;
|
||||
-n)
|
||||
NETWORK=$2
|
||||
INIT_GENESIS_ENV="$INIT_GENESIS_ENV export ROOT_DIR=$2;"
|
||||
shift; shift
|
||||
;;
|
||||
-c)
|
||||
INIT_GENESIS_ENV="$INIT_GENESIS_ENV export CHAIN_ID=$2;"
|
||||
shift; shift
|
||||
;;
|
||||
-v)
|
||||
INIT_GENESIS_ENV="$INIT_GENESIS_ENV export VESTING_ACCOUNT_END_TIME=$2;"
|
||||
shift; shift
|
||||
;;
|
||||
*)
|
||||
help
|
||||
echo "Unknown flag passed: \"$1\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
IFS=","; declare -a IPS=($IP_LIST); unset IFS
|
||||
NUM_NODES=${#IPS[@]}
|
||||
|
||||
# Install dependent libraries and binary
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0g-chain; git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; git checkout v0.2.3; ./networks/testnet/install.sh"
|
||||
done
|
||||
|
||||
# Create genesis config on node0
|
||||
ssh $PEM_FLAG ubuntu@${IPS[0]} "cd 0g-chain/networks/testnet; $INIT_GENESIS_ENV ./init-genesis.sh $IP_LIST $KEYRING_PASSWORD; tar czf ~/$NETWORK.tar.gz $NETWORK; rm -rf $NETWORK"
|
||||
scp $PEM_FLAG ubuntu@${IPS[0]}:$NETWORK.tar.gz .
|
||||
ssh $PEM_FLAG ubuntu@${IPS[0]} "rm $NETWORK.tar.gz"
|
||||
|
||||
# Copy genesis config to remote nodes
|
||||
tar xzf $NETWORK.tar.gz
|
||||
rm $NETWORK.tar.gz
|
||||
cd $NETWORK
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
tar czf node$i.tar.gz node$i
|
||||
scp $PEM_FLAG node$i.tar.gz ubuntu@${IPS[$i]}:~
|
||||
ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0gchaind-prod; tar xzf node$i.tar.gz; rm node$i.tar.gz; mv node$i 0gchaind-prod"
|
||||
rm node$i.tar.gz
|
||||
done
|
||||
|
||||
echo -e "\n\nSucceeded to deploy on $NUM_NODES nodes!\n"
|
17
networks/testnet/init-cosmovisor.sh
Normal file
17
networks/testnet/init-cosmovisor.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <0G Home>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
|
||||
|
||||
export DAEMON_NAME=0gchaind
|
||||
echo "export DAEMON_NAME=0gchaind" >> ~/.profile
|
||||
export DAEMON_HOME=$1
|
||||
echo "export DAEMON_HOME=$1" >> ~/.profile
|
||||
cosmovisor init $(whereis -b 0gchaind | awk '{print $2}')
|
||||
mkdir $DAEMON_HOME/cosmovisor/backup
|
||||
echo "export DAEMON_DATA_BACKUP_DIR=$DAEMON_HOME/cosmovisor/backup" >> ~/.profile
|
||||
echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=true" >> ~/.profile
|
192
networks/testnet/init-genesis.sh
Executable file
192
networks/testnet/init-genesis.sh
Executable file
@ -0,0 +1,192 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_DIR=${ROOT_DIR:-testnet}
|
||||
CHAIN_ID=${CHAIN_ID:-zgtendermint_16600-1}
|
||||
|
||||
# Usage: init-genesis.sh IP1,IP2,IP3 KEYRING_PASSWORD
|
||||
OS_NAME=`uname -o`
|
||||
USAGE="Usage: ${BASH_SOURCE[0]} IP1,IP2,IP3"
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
USAGE="$USAGE KEYRING_PASSWORD"
|
||||
fi
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "IP list not specified"
|
||||
echo $USAGE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
if [[ $# -eq 1 ]]; then
|
||||
echo "Keyring password not specified"
|
||||
echo $USAGE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PASSWORD=$2
|
||||
fi
|
||||
|
||||
0gchaind version 2>/dev/null || export PATH=$PATH:$(go env GOPATH)/bin
|
||||
|
||||
set -e
|
||||
|
||||
IFS=","; declare -a IPS=($1); unset IFS
|
||||
|
||||
NUM_NODES=${#IPS[@]}
|
||||
VALIDATOR_BALANCE=25000000000000ua0gi
|
||||
FAUCET_BALANCE=500000000000000ua0gi
|
||||
STAKING=5000000000000ua0gi
|
||||
VESTING_BALANCE=400000000000000ua0gi
|
||||
|
||||
VESTING_ACCOUNT_START_TIME=$(date -u +%s)
|
||||
|
||||
# Init configs
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
HOMEDIR="$ROOT_DIR"/node$i
|
||||
|
||||
# Change parameter token denominations to neuron
|
||||
GENESIS="$HOMEDIR"/config/genesis.json
|
||||
TMP_GENESIS="$HOMEDIR"/config/tmp_genesis.json
|
||||
|
||||
# Init
|
||||
0gchaind init "node$i" --home "$HOMEDIR" --chain-id "$CHAIN_ID" >/dev/null 2>&1
|
||||
|
||||
# Replace stake with neuron
|
||||
sed -in-place='' 's/stake/ua0gi/g' "$GENESIS"
|
||||
|
||||
# Replace the default evm denom of aphoton with neuron
|
||||
sed -in-place='' 's/aphoton/neuron/g' "$GENESIS"
|
||||
|
||||
cat $GENESIS | jq '.consensus_params.block.max_gas = "25000000"' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Zero out the total supply so it gets recalculated during InitGenesis
|
||||
cat $GENESIS | jq '.app_state.bank.supply = []' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Disable fee market
|
||||
cat $GENESIS | jq '.app_state.feemarket.params.no_base_fee = true' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# Disable london fork
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.london_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.arrow_glacier_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.gray_glacier_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.merge_netsplit_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.shanghai_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
cat $GENESIS | jq '.app_state.evm.params.chain_config.cancun_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
|
||||
|
||||
# cat "$GENESIS" | jq '.app_state["staking"]["params"]["bond_denom"]="a0gi"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
# cat "$GENESIS" | jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="a0gi"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
|
||||
cat "$GENESIS" | jq '.app_state["staking"]["params"]["max_validators"]=125' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
cat "$GENESIS" | jq '.app_state["slashing"]["params"]["signed_blocks_window"]="1000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
|
||||
cat "$GENESIS" | jq '.app_state["consensus_params"]["block"]["time_iota_ms"]="3000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
|
||||
|
||||
# Change app.toml
|
||||
APP_TOML="$HOMEDIR"/config/app.toml
|
||||
sed -i 's/minimum-gas-prices = "0neuron"/minimum-gas-prices = "1000000000neuron"/' "$APP_TOML"
|
||||
sed -i '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' "$APP_TOML"
|
||||
sed -i '/\[json-rpc\]/,/^\[/ s/address = "127.0.0.1:8545"/address = "0.0.0.0:8545"/' "$APP_TOML"
|
||||
|
||||
# Set evm tracer to json
|
||||
# sed -in-place='' 's/tracer = ""/tracer = "json"/g' "$APP_TOML"
|
||||
|
||||
# Enable full error trace to be returned on tx failure
|
||||
sed -in-place='' '/iavl-cache-size/a\
|
||||
trace = true' "$APP_TOML"
|
||||
done
|
||||
|
||||
# Update seeds in config.toml
|
||||
SEEDS=""
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
if [[ $i -gt 0 ]]; then SEEDS=$SEEDS,; fi
|
||||
NODE_ID=`0gchaind tendermint show-node-id --home $ROOT_DIR/node$i`
|
||||
SEEDS=$SEEDS$NODE_ID@${IPS[$i]}:26656
|
||||
done
|
||||
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
sed -i "/seeds = /c\seeds = \"$SEEDS\"" "$ROOT_DIR"/node$i/config/config.toml
|
||||
done
|
||||
|
||||
# Prepare validators
|
||||
#
|
||||
# Note, keyring backend `file` works bad on Windows, and `add-genesis-account`
|
||||
# do not supports --keyring-dir flag. As a result, we use keyring backend `os`,
|
||||
# which is the default value.
|
||||
#
|
||||
# Where key stored:
|
||||
# - Windows: Windows credentials management.
|
||||
# - Linux: under `--home` specified folder.
|
||||
if [[ "$OS_NAME" = "Msys" ]]; then
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
VALIDATOR="0gchain_validator_$i"
|
||||
set +e
|
||||
ret=`0gchaind keys list --keyring-backend os -n | grep $VALIDATOR`
|
||||
set -e
|
||||
if [[ "$ret" = "" ]]; then
|
||||
echo "Create validator key: $VALIDATOR"
|
||||
0gchaind keys add $VALIDATOR --keyring-backend os --eth
|
||||
fi
|
||||
done
|
||||
elif [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
# Create N validators for node0
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
yes $PASSWORD | 0gchaind keys add "0gchain_validator_$i" --keyring-backend os --home "$ROOT_DIR"/node0 --eth
|
||||
done
|
||||
|
||||
# Copy validators to other nodes
|
||||
for ((i=1; i<$NUM_NODES; i++)) do
|
||||
cp "$ROOT_DIR"/node0/keyhash "$ROOT_DIR"/node$i
|
||||
cp "$ROOT_DIR"/node0/*.address "$ROOT_DIR"/node$i
|
||||
cp "$ROOT_DIR"/node0/*.info "$ROOT_DIR"/node$i
|
||||
done
|
||||
else
|
||||
echo -e "\n\nOS: $OS_NAME"
|
||||
echo "Unsupported OS to generate keys for validators!!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Add all validators in genesis
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
for ((j=0; j<$NUM_NODES; j++)) do
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
yes $PASSWORD | 0gchaind add-genesis-account "0gchain_validator_$j" $VALIDATOR_BALANCE --home "$ROOT_DIR/node$i"
|
||||
else
|
||||
0gchaind add-genesis-account "0gchain_validator_$j" $VALIDATOR_BALANCE --home "$ROOT_DIR/node$i"
|
||||
fi
|
||||
done
|
||||
0gchaind add-genesis-account 0g1e4t48fq42tqxpapvpnuc9n9k998eex9rnyqzwm $FAUCET_BALANCE --home "$ROOT_DIR/node$i"
|
||||
0gchaind add-genesis-account 0g16yvxafe63uzuxu6xpvpxdz9agdvnh0zn8vnuj6 $VESTING_BALANCE --vesting-amount $VESTING_BALANCE --vesting-start-time $VESTING_ACCOUNT_START_TIME --vesting-end-time $VESTING_ACCOUNT_END_TIME --home "$ROOT_DIR/node$i"
|
||||
done
|
||||
|
||||
# Prepare genesis txs
|
||||
mkdir -p "$ROOT_DIR"/gentxs
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
yes $PASSWORD | 0gchaind gentx "0gchain_validator_$i" $STAKING --home "$ROOT_DIR/node$i" --output-document "$ROOT_DIR/gentxs/node$i.json"
|
||||
else
|
||||
0gchaind gentx "0gchain_validator_$i" $STAKING --home "$ROOT_DIR/node$i" --output-document "$ROOT_DIR/gentxs/node$i.json"
|
||||
fi
|
||||
done
|
||||
|
||||
# Create genesis at node0 and copy to other nodes
|
||||
0gchaind collect-gentxs --home "$ROOT_DIR/node0" --gentx-dir "$ROOT_DIR/gentxs" >/dev/null 2>&1
|
||||
sed -i '/persistent_peers = /c\persistent_peers = ""' "$ROOT_DIR"/node0/config/config.toml
|
||||
0gchaind validate-genesis --home "$ROOT_DIR/node0"
|
||||
for ((i=1; i<$NUM_NODES; i++)) do
|
||||
cp "$ROOT_DIR"/node0/config/genesis.json "$ROOT_DIR"/node$i/config/genesis.json
|
||||
done
|
||||
|
||||
# For linux, backup keys for all validators
|
||||
if [[ "$OS_NAME" = "GNU/Linux" ]]; then
|
||||
mkdir -p "$ROOT_DIR"/keyring-os
|
||||
|
||||
cp "$ROOT_DIR"/node0/keyhash "$ROOT_DIR"/keyring-os
|
||||
cp "$ROOT_DIR"/node0/*.address "$ROOT_DIR"/keyring-os
|
||||
cp "$ROOT_DIR"/node0/*.info "$ROOT_DIR"/keyring-os
|
||||
|
||||
for ((i=0; i<$NUM_NODES; i++)) do
|
||||
rm -f "$ROOT_DIR"/node$i/keyhash "$ROOT_DIR"/node$i/*.address "$ROOT_DIR"/node$i/*.info
|
||||
done
|
||||
fi
|
||||
|
||||
echo -e "\n\nSucceeded to init genesis!\n"
|
21
networks/testnet/install.sh
Executable file
21
networks/testnet/install.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Install dependent libraries
|
||||
go version 2>/dev/null || sudo snap install go --classic
|
||||
jq --version 2>/dev/null || sudo snap install jq
|
||||
make --version 2>/dev/null || sudo apt install make -y
|
||||
gcc --version 2>/dev/null || (sudo apt-get update; sudo apt install gcc -y)
|
||||
|
||||
# Build binary
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
0gchaind version 2>/dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
# Make under root dir
|
||||
SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"`
|
||||
cd $SCRIPT_DIR/../..
|
||||
rm -rf $(go env GOPATH)/bin/0gchaind
|
||||
make install
|
||||
|
||||
# Add gopath to path
|
||||
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.profile
|
||||
fi
|
6
precompiles/common/errors.go
Normal file
6
precompiles/common/errors.go
Normal file
@ -0,0 +1,6 @@
|
||||
package common
|
||||
|
||||
const (
|
||||
ErrGetStateDB = "get EVM StateDB failed"
|
||||
ErrInvalidNumberOfArgs = "invalid number of arguments; expected %d; got: %d"
|
||||
)
|
428
precompiles/dasigners/IDASigners.abi
Normal file
428
precompiles/dasigners/IDASigners.abi
Normal file
@ -0,0 +1,428 @@
|
||||
[
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"indexed": false,
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "pkG1",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "X",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "Y",
|
||||
"type": "uint256[2]"
|
||||
}
|
||||
],
|
||||
"indexed": false,
|
||||
"internalType": "struct BN254.G2Point",
|
||||
"name": "pkG2",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "NewSigner",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "string",
|
||||
"name": "socket",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "SocketUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "epochNumber",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_quorumId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes",
|
||||
"name": "_quorumBitmap",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "getAggPkG1",
|
||||
"outputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "aggPkG1",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "total",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "hit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_quorumId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getQuorum",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address[]",
|
||||
"name": "",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_quorumId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint32",
|
||||
"name": "_rowIndex",
|
||||
"type": "uint32"
|
||||
}
|
||||
],
|
||||
"name": "getQuorumRow",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address[]",
|
||||
"name": "_account",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"name": "getSigner",
|
||||
"outputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "socket",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "pkG1",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "X",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "Y",
|
||||
"type": "uint256[2]"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G2Point",
|
||||
"name": "pkG2",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"internalType": "struct IDASigners.SignerDetail[]",
|
||||
"name": "",
|
||||
"type": "tuple[]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_account",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "isSigner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "quorumCount",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "_signature",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "registerNextEpoch",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "socket",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "pkG1",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "X",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "Y",
|
||||
"type": "uint256[2]"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G2Point",
|
||||
"name": "pkG2",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"internalType": "struct IDASigners.SignerDetail",
|
||||
"name": "_signer",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "_signature",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "registerSigner",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_account",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "registeredEpoch",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "_socket",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "updateSocket",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
801
precompiles/dasigners/contract.go
Normal file
801
precompiles/dasigners/contract.go
Normal file
File diff suppressed because one or more lines are too long
155
precompiles/dasigners/dasigners.go
Normal file
155
precompiles/dasigners/dasigners.go
Normal file
@ -0,0 +1,155 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
precopmiles_common "github.com/0glabs/0g-chain/precompiles/common"
|
||||
dasignerskeeper "github.com/0glabs/0g-chain/x/dasigners/v1/keeper"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/evmos/ethermint/x/evm/statedb"
|
||||
)
|
||||
|
||||
const (
|
||||
PrecompileAddress = "0x0000000000000000000000000000000000001000"
|
||||
|
||||
RequiredGasMax uint64 = 1000_000_000
|
||||
|
||||
DASignersFunctionEpochNumber = "epochNumber"
|
||||
DASignersFunctionQuorumCount = "quorumCount"
|
||||
DASignersFunctionGetSigner = "getSigner"
|
||||
DASignersFunctionGetQuorum = "getQuorum"
|
||||
DASignersFunctionGetQuorumRow = "getQuorumRow"
|
||||
DASignersFunctionRegisterSigner = "registerSigner"
|
||||
DASignersFunctionUpdateSocket = "updateSocket"
|
||||
DASignersFunctionRegisterNextEpoch = "registerNextEpoch"
|
||||
DASignersFunctionGetAggPkG1 = "getAggPkG1"
|
||||
DASignersFunctionIsSigner = "isSigner"
|
||||
DASignersFunctionRegisteredEpoch = "registeredEpoch"
|
||||
)
|
||||
|
||||
var RequiredGasBasic = map[string]uint64{
|
||||
DASignersFunctionEpochNumber: 1000,
|
||||
DASignersFunctionQuorumCount: 1000,
|
||||
DASignersFunctionGetSigner: 100000,
|
||||
DASignersFunctionGetQuorum: 100000,
|
||||
DASignersFunctionGetQuorumRow: 10000,
|
||||
DASignersFunctionRegisterSigner: 100000,
|
||||
DASignersFunctionUpdateSocket: 50000,
|
||||
DASignersFunctionRegisterNextEpoch: 100000,
|
||||
DASignersFunctionGetAggPkG1: 1000000,
|
||||
DASignersFunctionIsSigner: 10000,
|
||||
DASignersFunctionRegisteredEpoch: 10000,
|
||||
}
|
||||
|
||||
var KVGasConfig storetypes.GasConfig = storetypes.GasConfig{
|
||||
HasCost: 0,
|
||||
DeleteCost: 0,
|
||||
ReadCostFlat: 0,
|
||||
ReadCostPerByte: 0,
|
||||
WriteCostFlat: 0,
|
||||
WriteCostPerByte: 0,
|
||||
IterNextCostFlat: 0,
|
||||
}
|
||||
|
||||
var _ vm.PrecompiledContract = &DASignersPrecompile{}
|
||||
|
||||
type DASignersPrecompile struct {
|
||||
abi abi.ABI
|
||||
dasignersKeeper dasignerskeeper.Keeper
|
||||
}
|
||||
|
||||
func NewDASignersPrecompile(dasignersKeeper dasignerskeeper.Keeper) (*DASignersPrecompile, error) {
|
||||
abi, err := abi.JSON(strings.NewReader(DASignersABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DASignersPrecompile{
|
||||
abi: abi,
|
||||
dasignersKeeper: dasignersKeeper,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Address implements vm.PrecompiledContract.
|
||||
func (d *DASignersPrecompile) Address() common.Address {
|
||||
return common.HexToAddress(PrecompileAddress)
|
||||
}
|
||||
|
||||
// RequiredGas implements vm.PrecompiledContract.
|
||||
func (d *DASignersPrecompile) RequiredGas(input []byte) uint64 {
|
||||
method, err := d.abi.MethodById(input[:4])
|
||||
if err != nil {
|
||||
return RequiredGasMax
|
||||
}
|
||||
if gas, ok := RequiredGasBasic[method.Name]; ok {
|
||||
return gas
|
||||
}
|
||||
return RequiredGasMax
|
||||
}
|
||||
|
||||
// Run implements vm.PrecompiledContract.
|
||||
func (d *DASignersPrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error) {
|
||||
// parse input
|
||||
if len(contract.Input) < 4 {
|
||||
return nil, vm.ErrExecutionReverted
|
||||
}
|
||||
method, err := d.abi.MethodById(contract.Input[:4])
|
||||
if err != nil {
|
||||
return nil, vm.ErrExecutionReverted
|
||||
}
|
||||
args, err := method.Inputs.Unpack(contract.Input[4:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// get state db and context
|
||||
stateDB, ok := evm.StateDB.(*statedb.StateDB)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrGetStateDB)
|
||||
}
|
||||
ctx := stateDB.GetContext()
|
||||
// reset gas config
|
||||
ctx = ctx.WithKVGasConfig(KVGasConfig)
|
||||
initialGas := ctx.GasMeter().GasConsumed()
|
||||
|
||||
var bz []byte
|
||||
switch method.Name {
|
||||
// queries
|
||||
case DASignersFunctionEpochNumber:
|
||||
bz, err = d.EpochNumber(ctx, evm, method, args)
|
||||
case DASignersFunctionQuorumCount:
|
||||
bz, err = d.QuorumCount(ctx, evm, method, args)
|
||||
case DASignersFunctionGetSigner:
|
||||
bz, err = d.GetSigner(ctx, evm, method, args)
|
||||
case DASignersFunctionGetQuorum:
|
||||
bz, err = d.GetQuorum(ctx, evm, method, args)
|
||||
case DASignersFunctionGetQuorumRow:
|
||||
bz, err = d.GetQuorumRow(ctx, evm, method, args)
|
||||
case DASignersFunctionGetAggPkG1:
|
||||
bz, err = d.GetAggPkG1(ctx, evm, method, args)
|
||||
case DASignersFunctionIsSigner:
|
||||
bz, err = d.IsSigner(ctx, evm, method, args)
|
||||
case DASignersFunctionRegisteredEpoch:
|
||||
bz, err = d.RegisteredEpoch(ctx, evm, method, args)
|
||||
// txs
|
||||
case DASignersFunctionRegisterSigner:
|
||||
bz, err = d.RegisterSigner(ctx, evm, stateDB, method, args)
|
||||
case DASignersFunctionRegisterNextEpoch:
|
||||
bz, err = d.RegisterNextEpoch(ctx, evm, stateDB, method, args)
|
||||
case DASignersFunctionUpdateSocket:
|
||||
bz, err = d.UpdateSocket(ctx, evm, stateDB, method, args)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cost := ctx.GasMeter().GasConsumed() - initialGas
|
||||
|
||||
if !contract.UseGas(cost) {
|
||||
return nil, vm.ErrOutOfGas
|
||||
}
|
||||
return bz, nil
|
||||
}
|
5
precompiles/dasigners/errors.go
Normal file
5
precompiles/dasigners/errors.go
Normal file
@ -0,0 +1,5 @@
|
||||
package dasigners
|
||||
|
||||
const (
|
||||
ErrInvalidSender = "sender address %s is not the same as signer address %s"
|
||||
)
|
60
precompiles/dasigners/events.go
Normal file
60
precompiles/dasigners/events.go
Normal file
@ -0,0 +1,60 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/evmos/ethermint/x/evm/statedb"
|
||||
)
|
||||
|
||||
const (
|
||||
NewSignerEvent = "NewSigner"
|
||||
SocketUpdatedEvent = "SocketUpdated"
|
||||
)
|
||||
|
||||
func (d *DASignersPrecompile) EmitNewSignerEvent(ctx sdk.Context, stateDB *statedb.StateDB, signer IDASignersSignerDetail) error {
|
||||
event := d.abi.Events[NewSignerEvent]
|
||||
quries := make([]interface{}, 2)
|
||||
quries[0] = event.ID
|
||||
quries[1] = signer.Signer
|
||||
topics, err := abi.MakeTopics(quries)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
arguments := abi.Arguments{event.Inputs[1], event.Inputs[2]}
|
||||
b, err := arguments.Pack(signer.PkG1, signer.PkG2)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stateDB.AddLog(&types.Log{
|
||||
Address: d.Address(),
|
||||
Topics: topics[0],
|
||||
Data: b,
|
||||
BlockNumber: uint64(ctx.BlockHeight()),
|
||||
})
|
||||
return d.EmitSocketUpdatedEvent(ctx, stateDB, signer.Signer, signer.Socket)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) EmitSocketUpdatedEvent(ctx sdk.Context, stateDB *statedb.StateDB, signer common.Address, socket string) error {
|
||||
event := d.abi.Events[SocketUpdatedEvent]
|
||||
quries := make([]interface{}, 2)
|
||||
quries[0] = event.ID
|
||||
quries[1] = signer
|
||||
topics, err := abi.MakeTopics(quries)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
arguments := abi.Arguments{event.Inputs[1]}
|
||||
b, err := arguments.Pack(socket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stateDB.AddLog(&types.Log{
|
||||
Address: d.Address(),
|
||||
Topics: topics[0],
|
||||
Data: b,
|
||||
BlockNumber: uint64(ctx.BlockHeight()),
|
||||
})
|
||||
return nil
|
||||
}
|
113
precompiles/dasigners/query.go
Normal file
113
precompiles/dasigners/query.go
Normal file
@ -0,0 +1,113 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
precopmiles_common "github.com/0glabs/0g-chain/precompiles/common"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
func (d *DASignersPrecompile) EpochNumber(ctx sdk.Context, _ *vm.EVM, method *abi.Method, _ []interface{}) ([]byte, error) {
|
||||
epochNumber, err := d.dasignersKeeper.GetEpochNumber(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(big.NewInt(int64(epochNumber)))
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) QuorumCount(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQueryQuorumCountRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.QuorumCount(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(big.NewInt(int64(response.QuorumCount)))
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) GetSigner(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQuerySignerRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.Signer(sdk.WrapSDKContext(ctx), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signers := make([]IDASignersSignerDetail, len(response.Signer))
|
||||
for i, signer := range response.Signer {
|
||||
signers[i] = NewIDASignersSignerDetail(signer)
|
||||
}
|
||||
return method.Outputs.Pack(signers)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) IsSigner(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
account := ToLowerHexWithoutPrefix(args[0].(common.Address))
|
||||
_, found, err := d.dasignersKeeper.GetSigner(ctx, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(found)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) RegisteredEpoch(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
if len(args) != 2 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args))
|
||||
}
|
||||
account := ToLowerHexWithoutPrefix(args[0].(common.Address))
|
||||
epoch := args[1].(*big.Int).Uint64()
|
||||
_, found, err := d.dasignersKeeper.GetRegistration(ctx, epoch, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(found)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) GetQuorum(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQueryEpochQuorumRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.EpochQuorum(sdk.WrapSDKContext(ctx), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signers := make([]common.Address, len(response.Quorum.Signers))
|
||||
for i, signer := range response.Quorum.Signers {
|
||||
signers[i] = common.HexToAddress(signer)
|
||||
}
|
||||
return method.Outputs.Pack(signers)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) GetQuorumRow(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQueryEpochQuorumRowRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.EpochQuorumRow(sdk.WrapSDKContext(ctx), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(common.HexToAddress(response.Signer))
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) GetAggPkG1(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQueryAggregatePubkeyG1Request(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.AggregatePubkeyG1(sdk.WrapSDKContext(ctx), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(NewBN254G1Point(response.AggregatePubkeyG1), big.NewInt(int64(response.Total)), big.NewInt(int64(response.Hit)))
|
||||
}
|
64
precompiles/dasigners/tx.go
Normal file
64
precompiles/dasigners/tx.go
Normal file
@ -0,0 +1,64 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/evmos/ethermint/x/evm/statedb"
|
||||
)
|
||||
|
||||
func (d *DASignersPrecompile) RegisterSigner(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
msg, err := NewMsgRegisterSigner(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// validation
|
||||
sender := ToLowerHexWithoutPrefix(evm.Origin)
|
||||
if sender != msg.Signer.Account {
|
||||
return nil, fmt.Errorf(ErrInvalidSender, sender, msg.Signer.Account)
|
||||
}
|
||||
// execute
|
||||
_, err = d.dasignersKeeper.RegisterSigner(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// emit events
|
||||
err = d.EmitNewSignerEvent(ctx, stateDB, args[0].(IDASignersSignerDetail))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack()
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) RegisterNextEpoch(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
msg, err := NewMsgRegisterNextEpoch(args, ToLowerHexWithoutPrefix(evm.Origin))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// execute
|
||||
_, err = d.dasignersKeeper.RegisterNextEpoch(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack()
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) UpdateSocket(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
msg, err := NewMsgUpdateSocket(args, ToLowerHexWithoutPrefix(evm.Origin))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// execute
|
||||
_, err = d.dasignersKeeper.UpdateSocket(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// emit events
|
||||
err = d.EmitSocketUpdatedEvent(ctx, stateDB, evm.Origin, args[0].(string))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack()
|
||||
}
|
175
precompiles/dasigners/types.go
Normal file
175
precompiles/dasigners/types.go
Normal file
@ -0,0 +1,175 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
precopmiles_common "github.com/0glabs/0g-chain/precompiles/common"
|
||||
dasignerstypes "github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
type BN254G1Point = struct {
|
||||
X *big.Int "json:\"X\""
|
||||
Y *big.Int "json:\"Y\""
|
||||
}
|
||||
|
||||
type BN254G2Point = struct {
|
||||
X [2]*big.Int "json:\"X\""
|
||||
Y [2]*big.Int "json:\"Y\""
|
||||
}
|
||||
|
||||
type IDASignersSignerDetail = struct {
|
||||
Signer common.Address "json:\"signer\""
|
||||
Socket string "json:\"socket\""
|
||||
PkG1 BN254G1Point "json:\"pkG1\""
|
||||
PkG2 BN254G2Point "json:\"pkG2\""
|
||||
}
|
||||
|
||||
func NewBN254G1Point(b []byte) BN254G1Point {
|
||||
return BN254G1Point{
|
||||
X: new(big.Int).SetBytes(b[:32]),
|
||||
Y: new(big.Int).SetBytes(b[32:64]),
|
||||
}
|
||||
}
|
||||
|
||||
func SerializeG1(p BN254G1Point) []byte {
|
||||
b := make([]byte, 0)
|
||||
b = append(b, common.LeftPadBytes(p.X.Bytes(), 32)...)
|
||||
b = append(b, common.LeftPadBytes(p.Y.Bytes(), 32)...)
|
||||
return b
|
||||
}
|
||||
|
||||
func NewBN254G2Point(b []byte) BN254G2Point {
|
||||
return BN254G2Point{
|
||||
X: [2]*big.Int{
|
||||
new(big.Int).SetBytes(b[:32]),
|
||||
new(big.Int).SetBytes(b[32:64]),
|
||||
},
|
||||
Y: [2]*big.Int{
|
||||
new(big.Int).SetBytes(b[64:96]),
|
||||
new(big.Int).SetBytes(b[96:128]),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func SerializeG2(p BN254G2Point) []byte {
|
||||
b := make([]byte, 0)
|
||||
b = append(b, common.LeftPadBytes(p.X[0].Bytes(), 32)...)
|
||||
b = append(b, common.LeftPadBytes(p.X[1].Bytes(), 32)...)
|
||||
b = append(b, common.LeftPadBytes(p.Y[0].Bytes(), 32)...)
|
||||
b = append(b, common.LeftPadBytes(p.Y[1].Bytes(), 32)...)
|
||||
return b
|
||||
}
|
||||
|
||||
func NewQueryQuorumCountRequest(args []interface{}) (*dasignerstypes.QueryQuorumCountRequest, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.QueryQuorumCountRequest{
|
||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewQuerySignerRequest(args []interface{}) (*dasignerstypes.QuerySignerRequest, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
accounts := args[0].([]common.Address)
|
||||
req := dasignerstypes.QuerySignerRequest{
|
||||
Accounts: make([]string, len(accounts)),
|
||||
}
|
||||
for i, account := range accounts {
|
||||
req.Accounts[i] = ToLowerHexWithoutPrefix(account)
|
||||
}
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
func NewQueryEpochQuorumRequest(args []interface{}) (*dasignerstypes.QueryEpochQuorumRequest, error) {
|
||||
if len(args) != 2 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.QueryEpochQuorumRequest{
|
||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||
QuorumId: args[1].(*big.Int).Uint64(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewQueryEpochQuorumRowRequest(args []interface{}) (*dasignerstypes.QueryEpochQuorumRowRequest, error) {
|
||||
if len(args) != 3 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 3, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.QueryEpochQuorumRowRequest{
|
||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||
QuorumId: args[1].(*big.Int).Uint64(),
|
||||
RowIndex: args[2].(uint32),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewQueryAggregatePubkeyG1Request(args []interface{}) (*dasignerstypes.QueryAggregatePubkeyG1Request, error) {
|
||||
if len(args) != 3 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 3, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.QueryAggregatePubkeyG1Request{
|
||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||
QuorumId: args[1].(*big.Int).Uint64(),
|
||||
QuorumBitmap: args[2].([]byte),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewIDASignersSignerDetail(signer *dasignerstypes.Signer) IDASignersSignerDetail {
|
||||
return IDASignersSignerDetail{
|
||||
Signer: common.HexToAddress(signer.Account),
|
||||
Socket: signer.Socket,
|
||||
PkG1: NewBN254G1Point(signer.PubkeyG1),
|
||||
PkG2: NewBN254G2Point(signer.PubkeyG2),
|
||||
}
|
||||
}
|
||||
|
||||
func ToLowerHexWithoutPrefix(addr common.Address) string {
|
||||
return strings.ToLower(addr.Hex()[2:])
|
||||
}
|
||||
|
||||
func NewMsgRegisterSigner(args []interface{}) (*dasignerstypes.MsgRegisterSigner, error) {
|
||||
if len(args) != 2 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args))
|
||||
}
|
||||
|
||||
signer := args[0].(IDASignersSignerDetail)
|
||||
return &dasignerstypes.MsgRegisterSigner{
|
||||
Signer: &dasignerstypes.Signer{
|
||||
Account: ToLowerHexWithoutPrefix(signer.Signer),
|
||||
Socket: signer.Socket,
|
||||
PubkeyG1: SerializeG1(signer.PkG1),
|
||||
PubkeyG2: SerializeG2(signer.PkG2),
|
||||
},
|
||||
Signature: SerializeG1(args[1].(BN254G1Point)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewMsgRegisterNextEpoch(args []interface{}, account string) (*dasignerstypes.MsgRegisterNextEpoch, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.MsgRegisterNextEpoch{
|
||||
Account: account,
|
||||
Signature: SerializeG1(args[0].(BN254G1Point)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewMsgUpdateSocket(args []interface{}, account string) (*dasignerstypes.MsgUpdateSocket, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.MsgUpdateSocket{
|
||||
Account: account,
|
||||
Socket: args[0].(string),
|
||||
}, nil
|
||||
}
|
25
proto/crypto/vrf/keys.proto
Normal file
25
proto/crypto/vrf/keys.proto
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright Tharsis Labs Ltd.(Evmos)
|
||||
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)
|
||||
syntax = "proto3";
|
||||
package crypto.vrf;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/crypto/vrf";
|
||||
|
||||
// PubKey defines a type alias for an vrf.PublicKey that implements
|
||||
// Vrf's PubKey interface. It represents the 32-byte compressed public
|
||||
// key format.
|
||||
message PubKey {
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
// key is the public key in byte form
|
||||
bytes key = 1;
|
||||
}
|
||||
|
||||
// PrivKey defines a type alias for an vrf.PrivateKey that implements
|
||||
// Vrf's PrivateKey interface.
|
||||
message PrivKey {
|
||||
// key is the private key in byte form
|
||||
bytes key = 1;
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
syntax = "proto3";
|
||||
package kava.auction.v1beta1;
|
||||
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/kava-labs/kava/x/auction/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// BaseAuction defines common attributes of all auctions
|
||||
message BaseAuction {
|
||||
option (cosmos_proto.implements_interface) = "Auction";
|
||||
|
||||
uint64 id = 1 [(gogoproto.customname) = "ID"];
|
||||
|
||||
string initiator = 2;
|
||||
|
||||
cosmos.base.v1beta1.Coin lot = 3 [(gogoproto.nullable) = false];
|
||||
|
||||
bytes bidder = 4 [
|
||||
(cosmos_proto.scalar) = "cosmos.AddressBytes",
|
||||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
|
||||
];
|
||||
|
||||
cosmos.base.v1beta1.Coin bid = 5 [(gogoproto.nullable) = false];
|
||||
|
||||
bool has_received_bids = 6;
|
||||
|
||||
google.protobuf.Timestamp end_time = 7 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdtime) = true
|
||||
];
|
||||
|
||||
google.protobuf.Timestamp max_end_time = 8 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdtime) = true
|
||||
];
|
||||
}
|
||||
|
||||
// SurplusAuction is a forward auction that burns what it receives from bids.
|
||||
// It is normally used to sell off excess pegged asset acquired by the CDP system.
|
||||
message SurplusAuction {
|
||||
option (cosmos_proto.implements_interface) = "Auction";
|
||||
|
||||
BaseAuction base_auction = 1 [
|
||||
(gogoproto.embed) = true,
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// DebtAuction is a reverse auction that mints what it pays out.
|
||||
// It is normally used to acquire pegged asset to cover the CDP system's debts that were not covered by selling
|
||||
// collateral.
|
||||
message DebtAuction {
|
||||
option (cosmos_proto.implements_interface) = "Auction";
|
||||
|
||||
BaseAuction base_auction = 1 [
|
||||
(gogoproto.embed) = true,
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
cosmos.base.v1beta1.Coin corresponding_debt = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// CollateralAuction is a two phase auction.
|
||||
// Initially, in forward auction phase, bids can be placed up to a max bid.
|
||||
// Then it switches to a reverse auction phase, where the initial amount up for auction is bid down.
|
||||
// Unsold Lot is sent to LotReturns, being divided among the addresses by weight.
|
||||
// Collateral auctions are normally used to sell off collateral seized from CDPs.
|
||||
message CollateralAuction {
|
||||
option (cosmos_proto.implements_interface) = "Auction";
|
||||
|
||||
BaseAuction base_auction = 1 [
|
||||
(gogoproto.embed) = true,
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
cosmos.base.v1beta1.Coin corresponding_debt = 2 [(gogoproto.nullable) = false];
|
||||
|
||||
cosmos.base.v1beta1.Coin max_bid = 3 [(gogoproto.nullable) = false];
|
||||
|
||||
WeightedAddresses lot_returns = 4 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// WeightedAddresses is a type for storing some addresses and associated weights.
|
||||
message WeightedAddresses {
|
||||
repeated bytes addresses = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.AddressBytes",
|
||||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
|
||||
];
|
||||
|
||||
repeated bytes weights = 2 [
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user