Compare commits

...
108 Commits
Author SHA1 Message Date
anilCSE 984db173f0 fix lint 2022-09-06 22:30:47 +05:30
anilCSE 89b64fffef update golang-ci-action version 2022-09-06 22:22:16 +05:30
anilCSE 05a3eec1d6 fix linters 2022-09-06 22:17:11 +05:30
anilCSE c236863bad update readme 2022-09-06 19:31:52 +05:30
A. F. Dudley 680d585084 Delete dependabot.yml
add back later.
2022-08-31 06:51:55 -04:00
Ian Norden 17480f2716 Merge pull request #60 from vulcanize/murali/to_ipld_prime
feat: use ipld-prime in helpers
2022-08-29 14:04:12 -05:00
SpideyPool192 e8b3ca8cae use ipdl prime in 'helpers.go/GetCid' 2022-08-18 15:02:53 +05:30
erikdies 15c09c0157 Merge pull request #59 from sjors-lemniscap/main
Update documentation for chibaclonk_81337-4
2022-08-14 16:15:38 -04:00
sjors-lemniscap 5c495e4edb Update documentation for chibaclonk_81337-4 2022-08-14 18:56:55 +02:00
Sai Kumar 79078fdf7b Merge pull request #57 from sjors-lemniscap/main
update docs for chibaclonk_81337-3
2022-08-05 10:43:52 +05:30
sjors-lemniscap f9bc170fb8 Resolve comment for PR #57 2022-08-04 19:07:56 +02:00
sjors-lemniscap 35888ad0bf update docs for chibaclonk_81337-3 2022-08-03 19:51:28 +02:00
Sai Kumar 659e771780 Merge pull request #53 from vulcanize/sai/update_testnet_docs
update testnet docs
2022-07-06 18:50:20 +05:30
Sai Kumar 16936d3315 chore: update docs for testnet2 2022-07-06 18:49:27 +05:30
Sai Kumar 0fd0b284d6 Merge pull request #52 from vulcanize/sai/update_testnet_docs
update the chain-id for testnet2
2022-07-06 10:14:42 +05:30
Sai Kumar b38c7f3ec7 chore: update the chain-id for testnet2 2022-07-06 10:13:58 +05:30
Ian Norden 5f4ebc4648 Merge pull request #51 from vulcanize/sai/upgrade_v0.46_cosmos_sdk
update the version of vulcanize cosmos-sdk
2022-06-29 11:06:53 -05:00
Sai Kumar e9f8aa04f9 fix: fix the local multi node testnet setup 2022-06-27 11:07:07 +05:30
Sai Kumar 1c023f7b5d fix: fix the keys migrate 2022-06-24 20:17:40 +05:30
Sai Kumar f04ee6eaa8 fix : fix the test cases failing issue 2022-06-24 10:57:03 +05:30
erikdies 93a8da40e8 Create issues-notion-sync.yml 2022-06-23 04:42:56 -04:00
Sai Kumar b18840607f chore: update the version of cosmos-sdk 2022-06-22 19:07:29 +05:30
Ian Norden 7f4ee8313f Merge pull request #48 from vulcanize/sai/support_ante_handlers
refactor: add ante handlers
2022-06-07 08:59:14 -05:00
Sai Kumar 559159c30d fix: fix the test cases failing 2022-06-07 08:56:26 -05:00
Sai Kumar f89c866f50 fix: fix the test cases 2022-06-07 08:56:26 -05:00
Sai Kumar fc06fbfb48 refactor: updated to ante handlers support 2022-06-07 08:56:18 -05:00
Ian Norden 20ce3dfb3d Merge pull request #45 from vulcanize/sai/to_ipld_prime
feat: add `go-ipld-prime` instead of `go-ipld-cbor`
2022-06-07 08:44:59 -05:00
Sai Kumar ac5fd42bbf Merge branch 'main' into sai/to_ipld_prime 2022-06-07 12:36:56 +05:30
Sai Kumar eb0948b2c6 Merge pull request #47 from vulcanize/sai/fix_client_test
fix: fix the client test issues
2022-06-07 10:27:59 +05:30
Sai Kumar dde1038571 chroe: change the hashing algo 2022-06-03 19:36:06 +05:30
Sai Kumar e5cad8c48b fix: fix the client test issues 2022-06-02 13:23:03 +05:30
Sai Kumar 808a7fe2b3 Merge branch 'main' into sai/to_ipld_prime 2022-05-23 20:18:02 +05:30
Ian Norden 007e27dcbc Merge pull request #35 from vulcanize/sai/upgrade_cosmos_v0.46
upgrade: upgrade to vulcanize cosmos v0.46 SMT
2022-05-23 09:42:49 -05:00
Sai Kumar 399bf4f69f chore: made store as global 2022-05-23 12:40:27 +05:30
Sai Kumar 137a781bee feat: add go-ipld-prime for encode and decode CID 2022-05-23 12:38:46 +05:30
Sai Kumar a75f275f3e chore: fix the appExport failing test cases 2022-05-18 14:42:44 +05:30
roysc 92295c3061 clean up, rm unused 2022-05-18 16:08:56 +08:00
roysc 11e82761b4 Apply suggestions from code review 2022-05-18 16:02:55 +08:00
Sai Kumar 1bbb2d7f42 chore: small fix 2022-05-18 12:55:06 +05:30
Sai Kumar f9c4f75f76 refactor: add ibc-go to app 2022-05-18 12:52:25 +05:30
Sai Kumar 26238a6f2f chore: update the go-ethereum to v1.10.17 2022-05-18 11:58:32 +05:30
Sai Kumar b34e83a29a chore: address the pr comments 2022-05-18 11:27:11 +05:30
Sai Kumar d0fba5b727 Merge pull request #39 from vulcanize/roy/upgrade-to-v0.46
Fix Tx extension options & middleware issues
2022-05-17 08:20:21 +05:30
Sai Kumar f705908614 fix : fix the unit test for modules 2022-05-17 07:20:21 +05:30
Sai Kumar fd887f80bc fix: fix the module unit test cases 2022-05-16 21:14:14 +05:30
Sai Kumar 49cd996e80 Merge branch 'roy/upgrade-to-v0.46' of github.com:vulcanize/chiba-clonk into roy/upgrade-to-v0.46 2022-05-16 20:18:06 +05:30
roysc 2c9d18fd93 misc clean up 2022-05-16 22:22:29 +08:00
roysc b1f755db7b fix tx event query 2022-05-16 22:22:29 +08:00
roysc bfb702009a fix tx response decoding 2022-05-16 22:22:29 +08:00
roysc 54e49b83e7 ethereum needs "index events middleware" 2022-05-16 22:22:29 +08:00
roysc 68187bc75b misc cleanup 2022-05-16 22:22:29 +08:00
roysc 4040c3425f fix build flags for debugging 2022-05-16 22:22:29 +08:00
roysc 9de27fb24f test script cleanup 2022-05-16 22:22:29 +08:00
roysc a7aff81d32 fix gas limit panic 2022-05-16 22:22:29 +08:00
roysc 264aa45492 cleanup 2022-05-16 22:22:26 +08:00
roysc 00814e2714 TxExtensionOptionI for ExtensionOptionsEthereumTx 2022-05-16 22:22:20 +08:00
roysc 3f946920ad middleware refactor 2022-05-16 22:22:17 +08:00
roysc d9c6ab8740 ethereum needs "index events middleware" 2022-05-14 03:02:24 +08:00
roysc 075978b906 misc cleanup 2022-05-13 18:51:55 +08:00
roysc 3f77c8886a [dev] debug stuff 2022-05-13 18:48:39 +08:00
roysc 21026234fb test script cleanup 2022-05-13 17:53:48 +08:00
roysc 8beea8811d fix gas limit panic 2022-05-13 00:38:19 +08:00
roysc 75763bf1c4 [wip] cleanup 2022-05-12 20:26:04 +08:00
roysc d1c4da99b9 [wip] TxExtensionOptionI for ExtensionOptionsEthereumTx 2022-05-12 19:45:01 +08:00
roysc dda48584a5 [wip] middleware refactor 2022-05-12 19:28:21 +08:00
Sai Kumar 760cddf698 fix: fix the cli test cases for modules 2022-04-29 09:50:27 +05:30
Sai Kumar 752fb3944f test: add test cases for middleware 2022-04-28 23:04:20 +05:30
Sai Kumar eb1af33649 fix: fix the rpc test cases 2022-04-28 13:13:39 +05:30
Sai Kumar 63b66c1ffc fix: fix the make build issue 2022-04-26 20:07:50 +05:30
Sai Kumar fde19d25ad Merge branch 'sai/upgrade_cosmos_v0.46' of github.com:vulcanize/chiba-clonk into sai/upgrade_cosmos_v0.46 2022-04-26 19:04:47 +05:30
Sai Kumar 8ae41eb7cc WIP: fixing the test cases 2022-04-26 19:02:26 +05:30
Sai Kumar 19b1635e00 Merge branch 'main' into sai/upgrade_cosmos_v0.46 2022-04-26 17:28:34 +05:30
Sai Kumar de5fc87573 Merge pull request #36 from deep-stack/ng-gql-get-status
Fix GQL query getStatus
2022-04-26 16:29:16 +05:30
Sai Kumar e6d416db7f WIP: fixing the test cases 2022-04-26 16:22:19 +05:30
Sai Kumar 694d4c667d WIP: fixing the test cases 2022-04-26 16:09:18 +05:30
nabarun e20e7c24c8 fix: GQL getStatus query 2022-04-26 15:30:21 +05:30
Sai Kumar e8b0e2cf30 fix: fix the build issue 2022-04-26 10:30:05 +05:30
Sai Kumar fd59a37798 fix : fix the conflicts 2022-04-23 21:23:51 +05:30
Sai Kumar cf0be98f9b Merge branch 'main' into sai/upgrade_cosmos_v0.46 2022-04-23 21:23:06 +05:30
Sai Kumar 9d7333d4fb fix : fix the chain start 2022-04-23 20:07:00 +05:30
Sai Kumar feae504ff8 WIP: fix the start cmd 2022-04-22 18:25:14 +05:30
Ashwin Phatak cfeeece6bd Merge pull request #34 from deep-stack/ng-gql-get-accounts
Fix GQL query getAccounts
2022-04-22 15:59:39 +05:30
nabarun e3f97b1df9 fix: gql query getAccounts for high balances 2022-04-22 15:42:31 +05:30
A. F. Dudley a7f8611858 Delete stale.yml
Getting rid of this insane workflow.
2022-04-21 22:09:12 -04:00
Ashwin Phatak de7c0558c9 Merge pull request #33 from deep-stack/ng-client-set-record
Fixes to nameservice message types and GQL queries
2022-04-21 10:08:41 +05:30
nabarun 9d4c381e1a fix: increase timers for nameservice tests 2022-04-21 00:45:52 +05:30
nabarun 2ea883bc50 nameservice: return record id in setRecord message response 2022-04-20 17:21:52 +05:30
Sai Kumar 92791d5f9d WIP: trying to migrate auth handlers to middlewares 2022-04-20 17:20:55 +05:30
nabarun 92f07873f4 chore: replace with wrn with crn 2022-04-20 13:19:07 +05:30
nabarun 7f70108a4a nameservice: implement processing record and authority expiry 2022-04-19 15:51:37 +05:30
nabarun 8477b3d9cb Implement float, boolean and reference types for attributes keyValueInput 2022-04-19 08:58:10 +05:30
nabarun f7623b26f9 nameservice: return names with records query 2022-04-18 14:44:32 +05:30
nabarun d762ce98b3 nameservice: queryRecords filter by attributes 2022-04-13 17:33:42 +05:30
nabarun 8f5449f397 auction: change params for auction module test 2022-04-12 11:39:50 +05:30
Sai Kumar d377665800 fix: fix the params init 2022-04-11 18:00:11 +05:30
Sai Kumar 8cd1189e8c fix: fix the eth keys register 2022-04-11 15:50:05 +05:30
Sai Kumar a0e2858d4f WIP: upgrade cosmos-sdk from 0.45 to SMT 0.46 2022-04-11 13:39:39 +05:30
nabarun 2b8b18d659 fix: return nil response for gql queries 2022-04-08 18:02:18 +05:30
nabarun 555934b799 nameservice: change Record message types for chiba-clonk-client 2022-04-08 13:03:58 +05:30
Sai Kumar 39b742874c Update genesis-validators.md 2022-04-06 10:21:37 +05:30
Sai Kumar 2a6383ed99 Update genesis-validators.md 2022-04-06 10:18:56 +05:30
Ian Norden 8513dc1ffe Merge pull request #30 from vulcanize/sai/docs_for_testnet
docs: add docs for testnet
2022-04-05 21:28:40 -05:00
Sai Kumar a1ab3e9c23 chore: update staking amount for genesis validator 2022-04-06 07:55:41 +05:30
Sai Kumar 75ae6efb5f Merge branch 'sai/docs_for_testnet' of github.com:vulcanize/chiba-clonk into sai/docs_for_testnet 2022-04-06 07:47:17 +05:30
Sai Kumar 4b0940deeb chore: update docs for the token distributon 2022-04-06 07:47:02 +05:30
Sai Kumar df6dce0e3a Update README.md 2022-04-06 07:29:03 +05:30
Sai Kumar a4fc953e1a chore : update the docs 2022-04-06 07:26:51 +05:30
Sai Kumar dd114a939f docs: add docs for testnet 2022-04-06 06:58:21 +05:30
165 changed files with 5746 additions and 2020 deletions
-28
View File
@@ -1,28 +0,0 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
reviewers:
- fedekunze
- khoslaventures
labels:
- dependencies
- package-ecosystem: docker
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
reviewers:
- fedekunze
- khoslaventures
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
+29
View File
@@ -0,0 +1,29 @@
name: Notion Sync
on:
workflow_dispatch:
issues:
types:
[
opened,
edited,
labeled,
unlabeled,
assigned,
unassigned,
milestoned,
demilestoned,
reopened,
closed,
]
jobs:
notion_job:
runs-on: ubuntu-latest
name: Add GitHub Issues to Notion
steps:
- name: Add GitHub Issues to Notion
uses: vulcanize/notion-github-action@v1.2.4-issueid
with:
notion-token: ${{ secrets.NOTION_TOKEN }}
notion-db: ${{ secrets.NOTION_DATABASE }}
+54 -8
View File
@@ -13,18 +13,64 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6.0.1
- uses: technote-space/get-diff-action@v6.1.0
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- uses: golangci/golangci-lint-action@v2.5.2
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.42.1
version: v1.48.0
args: --timeout 10m
github-token: ${{ secrets.github_token }}
# Check only if there are differences in the source code
if: "env.GIT_DIFF"
markdown-lint:
name: Run markdown-lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6.1.0
with:
PATTERNS: |
docs/**/*.md
x/**/*.md
README.md
- uses: articulate/actions-markdownlint@v1.1.0
# Check only if there are differences in the source code
if: env.GIT_DIFF
python-lint:
name: Run flake8 on python integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v17
- uses: cachix/cachix-action@v10
with:
name: ethermint
- uses: technote-space/get-diff-action@v6.1.0
with:
PATTERNS: |
**/**.py
- run: |
nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py"
if: env.GIT_DIFF
gomod2nix:
name: Check gomod2nix.toml file is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v17
- uses: cachix/cachix-action@v10
with:
name: ethermint
- name: run gomod2nix
run: |
nix run -f ./nix gomod2nix
git diff --no-ext-diff --exit-code
-21
View File
@@ -1,21 +0,0 @@
name: "Close stale issues & pull requests"
on:
schedule:
- cron: "0 0 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: "This pull request has been automatically marked as stale because it has not had
recent activity. It will be closed in 7 days-before-close if no further activity occurs."
stale-issue-message: "This issue is stale because it has been open 45 days with no activity. Remove `Status: Stale` label or comment or this will be closed in 7 days."
days-before-stale: 45
days-before-close: 7
exempt-issue-labels: "Status: Blocked, Type: Bug, pinned, automerge"
exempt-pr-labels: "Status: Blocked, Type: Bug, pinned, automerge"
stale-pr-label: "Status: Stale"
stale-issue-label: "Status: Stale"
+8 -14
View File
@@ -13,38 +13,30 @@ linters:
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- gofumpt
- revive
- gosec
- gosimple
- govet
- ineffassign
# - lll TODO: enable
- lll
- misspell
- nakedret
- prealloc
- exportloopref
- staticcheck
- structcheck
- stylecheck
# - typecheck #TODO: enable
- typecheck
- unconvert
- unparam
- unused
- varcheck
- nolintlint
- asciicheck
# - exhaustive
- exportloopref
- gofumpt
- gomodguard
# - nestif
# - nlreturn
- noctx
- rowserrcheck
# - whitespace
# - wsl
- whitespace
issues:
exclude-rules:
@@ -57,6 +49,8 @@ issues:
max-same-issues: 50
linters-settings:
lll:
line-length: 150
dogsled:
max-blank-identifiers: 3
golint:
@@ -71,7 +65,7 @@ linters-settings:
require-explanation: false
require-specific: false
gofumpt:
lang-version: "1.17"
lang-version: "1.18"
gomodguard:
blocked:
versions: # List of blocked module version constraints
@@ -80,4 +74,4 @@ linters-settings:
reason: "CVE-2020-15114; CVE-2020-15136; CVE-2020-15115" # Reason why the version constraint exists. (Optional)
- https://github.com/dgrijalva/jwt-go: # Blocked module with version constraint
version: ">= 4.0.0-preview1" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional)
reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional)
+4 -4
View File
@@ -1,11 +1,11 @@
# Vulcanize dxns gql
# Vulcanize chiba-clonk gql
> Browser : http://localhost:9473 for gql
## Start server
```shell
./build/chibaclonkd start --gql-playground --gql-server
./build/chibaclonkd start --gql-playground --gql-server
```
Basic node status:
@@ -100,7 +100,7 @@ Query records.
```graphql
{
queryRecords(attributes: [{ key: "type", value: { string: "wrn:bot" } }]) {
queryRecords(attributes: [{ key: "type", value: { string: "crn:bot" } }]) {
id
names
bondId
@@ -316,7 +316,7 @@ LookUp Names
```graphql
{
lookupNames(names: ["wrn://hello/test"]){
lookupNames(names: ["crn://hello/test"]){
latest{
id
height
+18 -5
View File
@@ -73,8 +73,10 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=chibaclonk \
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ifeq (badgerdb,$(findstring badgerdb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=badgerdb
BUILD_TAGS += badgerdb
endif
# handle rocksdb
ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS)))
@@ -88,18 +90,27 @@ ifeq (boltdb,$(findstring boltdb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=boltdb
endif
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
ldflags += -w -s
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# Check for debug option
ifeq (debug,$(findstring debug,$(COSMOS_BUILD_OPTIONS)))
BUILD_FLAGS += -gcflags 'all=-N -l'
COSMOS_BUILD_OPTIONS += nostrip
endif
# check for nostrip option
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
ldflags += -w -s
endif
all: tools build lint test
# # The below include contains the tools and runsim targets.
# include contrib/devtools/Makefile
@@ -111,14 +122,16 @@ BUILD_TARGETS := build install
build: BUILD_ARGS=-o $(BUILDDIR)/
build-linux:
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build
GOOS=linux GOARCH=$(if $(findstring aarch64,$(shell uname -m)) || $(findstring arm64,$(shell uname -m)),arm64,amd64) LEDGER_ENABLED=false $(MAKE) build
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...
$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/
.PHONY: build build-linux cosmovisor
docker-build:
# TODO replace with kaniko
docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} .
+6 -59
View File
@@ -1,78 +1,25 @@
<!--
parent:
order: false
-->
<div align="center">
<h1> Ethermint </h1>
</div>
![banner](docs/ethermint.jpg)
<div align="center">
<a href="https://github.com/tharsis/ethermint/releases/latest">
<img alt="Version" src="https://img.shields.io/github/tag/tharsis/ethermint.svg" />
</a>
<a href="https://github.com/tharsis/ethermint/blob/main/LICENSE">
<img alt="License: Apache-2.0" src="https://img.shields.io/github/license/tharsis/ethermint.svg" />
</a>
<a href="https://pkg.go.dev/github.com/tharsis/ethermint">
<img alt="GoDoc" src="https://godoc.org/github.com/tharsis/ethermint?status.svg" />
</a>
<a href="https://goreportcard.com/report/github.com/tharsis/ethermint">
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/tharsis/ethermint"/>
</a>
<a href="https://bestpractices.coreinfrastructure.org/projects/5018">
<img alt="Lines of code" src="https://img.shields.io/tokei/lines/github/tharsis/ethermint">
</a>
</div>
<div align="center">
<a href="https://discord.gg/trje9XuAmy">
<img alt="Discord" src="https://img.shields.io/discord/809048090249134080.svg" />
</a>
<a href="https://github.com/tharsis/ethermint/actions?query=branch%3Amain+workflow%3ALint">
<img alt="Lint Status" src="https://github.com/tharsis/ethermint/actions/workflows/lint.yml/badge.svg?branch=main" />
</a>
<a href="https://codecov.io/gh/tharsis/ethermint">
<img alt="Code Coverage" src="https://codecov.io/gh/tharsis/ethermint/branch/main/graph/badge.svg" />
</a>
</div>
Ethermint is a scalable and interoperable Ethereum library, built on Proof-of-Stake with fast-finality using the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/) which runs on top of [Tendermint Core](https://github.com/tendermint/tendermint) consensus engine.
# Laconic Network
The Source of Proof. Laconic is a next generation data availability & verifiability layer with cryptographic proofs, powering internet-scale Web3 applications, built on Proof-of-Stake with fast-finality using the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/) which runs on top of [Tendermint Core](https://github.com/tendermint/tendermint) consensus engine.
**Note**: Requires [Go 1.17+](https://golang.org/dl/)
## Installation
For prerequisites and detailed build instructions please read the Evmos [Installation](https://evmos.dev/quickstart/installation.html) instructions. Once the dependencies are installed, run:
```bash
make install
```
Or check out the latest [release](https://github.com/tharsis/ethermint/releases).
## Quick Start
To learn how the Ethermint works from a high-level perspective, go to the [Introduction](https://evmos.dev/intro/overview.html) section from the documentation. You can also check the instructions to [Run a Node](https://evmos.dev/quickstart/run_node.html).
For an example on how Ethermint can be used on any Cosmos-SDK chain, please refer to [Evmos](https://www.github.com/tharsis/evmos).
## Community
The following chat channels and forums are a great spot to ask questions about Ethermint:
- [Evmos Twitter](https://twitter.com/EvmosOrg)
- [Evmos Discord](https://discord.gg/trje9XuAmy)
- [Evmos Telegram](https://t.me/EvmosOrg)
- [Tharsis Twitter](https://twitter.com/TharsisHQ)
- [Laconic Twitter](https://twitter.com/laconicnetwork)
- [Discord](https://discord.com/invite/ukhbBemyxY)
- [Website](https://laconic.com)
## Contributing
Looking for a good place to start contributing? Check out some [`good first issues`](https://github.com/tharsis/ethermint/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22).
Looking for a good place to start contributing? Check out some [`good first issues`](https://github.com/cerc-io/laconicd/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22).
For additional instructions, standards and style guides, please refer to the [Contributing](./CONTRIBUTING.md) document.
## Careers
See our open positions on [Cosmos Jobs](https://jobs.cosmos.network/project/evmos-d0sk1uxuh-remote/), [Notion](https://tharsis.notion.site), or feel free to [reach out](mailto:careers@thars.is) via email.
+2 -2
View File
@@ -10,7 +10,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
ethcrypto "github.com/ethereum/go-ethereum/crypto"
@@ -171,7 +171,7 @@ func VerifySignature(
Amount: tx.GetFee(),
Gas: tx.GetGas(),
},
msgs, tx.GetMemo(),
msgs, tx.GetMemo(), tx.GetTip(),
)
signerChainID, err := ethermint.ParseChainID(signerData.ChainID)
-1
View File
@@ -126,7 +126,6 @@ func (avd EthAccountVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx
if err := evmkeeper.CheckSenderBalance(sdk.NewIntFromBigInt(acct.Balance), txData); err != nil {
return ctx, sdkerrors.Wrap(err, "failed to check sender balance")
}
}
return next(ctx, tx, simulate)
}
+3 -2
View File
@@ -292,13 +292,14 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() {
return
}
ctx, err := dec.AnteHandle(suite.ctx.WithIsCheckTx(true).WithGasMeter(sdk.NewInfiniteGasMeter()), tc.tx, false, nextFn)
_, err := dec.AnteHandle(suite.ctx.WithIsCheckTx(true).WithGasMeter(sdk.NewInfiniteGasMeter()), tc.tx, false, nextFn)
if tc.expPass {
suite.Require().NoError(err)
} else {
suite.Require().Error(err)
}
suite.Require().Equal(tc.gasLimit, ctx.GasMeter().Limit())
// TODO: needs to check the gasmeter limit issue
// suite.Require().Equal(tc.gasLimit, ctx.GasMeter().Limit())
})
}
}
+3 -5
View File
@@ -26,6 +26,7 @@ type HandlerOptions struct {
SignModeHandler authsigning.SignModeHandler
SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
MaxTxGasWanted uint64
TxFeeChecker ante.TxFeeChecker
}
func (options HandlerOptions) Validate() error {
@@ -64,13 +65,11 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
RejectMessagesDecorator{}, // reject MsgEthereumTxs
ante.NewSetUpContextDecorator(),
ante.NewRejectExtensionOptionsDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
@@ -87,12 +86,11 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
ante.NewSetUpContextDecorator(),
// NOTE: extensions option decorator removed
// ante.NewRejectExtensionOptionsDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
+3 -3
View File
@@ -6,7 +6,7 @@ import (
"time"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
types2 "github.com/cosmos/cosmos-sdk/x/bank/types"
types3 "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/ethereum/go-ethereum/crypto"
@@ -60,7 +60,7 @@ func (suite *AnteTestSuite) StateDB() *statedb.StateDB {
func (suite *AnteTestSuite) SetupTest() {
checkTx := false
suite.app = app.Setup(checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
suite.app = app.Setup(suite.T(), checkTx, func(app *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
if suite.enableFeemarket {
// setup feemarketGenesis params
feemarketGenesis := feemarkettypes.DefaultGenesisState()
@@ -231,7 +231,7 @@ func (suite *AnteTestSuite) CreateTestEIP712CosmosTxBuilder(
fee := legacytx.NewStdFee(gas, gasAmount)
accNumber := suite.app.AccountKeeper.GetAccount(suite.ctx, from).GetAccountNumber()
data := legacytx.StdSignBytes(chainId, accNumber, nonce, 0, fee, []sdk.Msg{msg}, "")
data := legacytx.StdSignBytes(chainId, accNumber, nonce, 0, fee, []sdk.Msg{msg}, "", nil)
typedData, err := eip712.WrapTxToTypedData(ethermintCodec, ethChainId, msg, data, &eip712.FeeDelegationOptions{
FeePayer: from,
})
+138 -91
View File
@@ -11,22 +11,24 @@ import (
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/db"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/tharsis/ethermint/app/ante"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/store/streaming"
storetypes "github.com/cosmos/cosmos-sdk/store/v2alpha1"
"github.com/cosmos/cosmos-sdk/store/v2alpha1/multi"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
@@ -62,8 +64,10 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@@ -83,6 +87,10 @@ import (
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
"github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
@@ -96,13 +104,12 @@ import (
// unnamed import of statik for swagger UI support
_ "github.com/tharsis/ethermint/client/docs/statik"
"github.com/tharsis/ethermint/app/ante"
srvflags "github.com/tharsis/ethermint/server/flags"
ethermint "github.com/tharsis/ethermint/types"
"github.com/tharsis/ethermint/x/evm"
evmrest "github.com/tharsis/ethermint/x/evm/client/rest"
// evmrest "github.com/tharsis/ethermint/x/evm/client/rest"
evmkeeper "github.com/tharsis/ethermint/x/evm/keeper"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
"github.com/tharsis/ethermint/x/feemarket"
feemarketkeeper "github.com/tharsis/ethermint/x/feemarket/keeper"
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
@@ -149,8 +156,10 @@ var (
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler,
[]govclient.ProposalHandler{
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler,
},
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
@@ -165,7 +174,7 @@ var (
// Ethermint modules
evm.AppModuleBasic{},
feemarket.AppModuleBasic{},
// Vulcanize DXNS modules
// Vulcanize chiba-clonk modules
auction.AppModuleBasic{},
bond.AppModuleBasic{},
nameservice.AppModuleBasic{},
@@ -173,15 +182,14 @@ var (
// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
auctiontypes.ModuleName: nil,
auctiontypes.AuctionBurnModuleAccountName: nil,
nameservicetypes.ModuleName: nil,
@@ -210,13 +218,12 @@ type EthermintApp struct {
cdc *codec.LegacyAmino
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry
invCheckPeriod uint
invCheckPeriod uint
// keys to access the substores
keys map[string]*sdk.KVStoreKey
tkeys map[string]*sdk.TransientStoreKey
memKeys map[string]*sdk.MemoryStoreKey
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
memKeys map[string]*storetypes.MemoryStoreKey
// keepers
AccountKeeper authkeeper.AccountKeeper
@@ -244,7 +251,7 @@ type EthermintApp struct {
EvmKeeper *evmkeeper.Keeper
FeeMarketKeeper feemarketkeeper.Keeper
// DXNS keepers
// chiba-clonk keepers
AuctionKeeper auctionkeeper.Keeper
BondKeeper bondkeeper.Keeper
NameServiceKeeper nameservicekeeper.Keeper
@@ -263,7 +270,7 @@ type EthermintApp struct {
// NewEthermintApp returns a reference to a new initialized Ethermint application.
func NewEthermintApp(
logger log.Logger,
db dbm.DB,
db db.DBConnection,
traceStore io.Writer,
loadLatest bool,
skipUpgradeHeights map[int64]bool,
@@ -271,12 +278,67 @@ func NewEthermintApp(
invCheckPeriod uint,
encodingConfig simappparams.EncodingConfig,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
baseAppOptions ...baseapp.AppOption,
) *EthermintApp {
appCodec := encodingConfig.Marshaler
appCodec := encodingConfig.Codec
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
keys := sdk.NewKVStoreKeys(
// SDK keys
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey,
authzkeeper.StoreKey,
// ibc keys
ibchost.StoreKey, ibctransfertypes.StoreKey,
// ethermint keys
evmtypes.StoreKey, feemarkettypes.StoreKey,
// chiba-clonk keys
auctiontypes.StoreKey,
bondtypes.StoreKey,
nameservicetypes.StoreKey,
)
// Add the EVM transient store key
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
// initialize stores
setNamespaces := func(config *multi.StoreParams, ver uint64) error {
for _, key := range keys {
typ, err := storetypes.StoreKeyToType(key)
if err != nil {
return err
}
if err = config.RegisterSubstore(key, typ); err != nil {
return err
}
}
for _, key := range memKeys {
typ, err := storetypes.StoreKeyToType(key)
if err != nil {
return err
}
if err = config.RegisterSubstore(key, typ); err != nil {
return err
}
}
for _, key := range tkeys {
typ, err := storetypes.StoreKeyToType(key)
if err != nil {
return err
}
if err = config.RegisterSubstore(key, typ); err != nil {
return err
}
}
return nil
}
baseAppOptions = append(baseAppOptions, baseapp.StoreOption(setNamespaces))
// NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx
bApp := baseapp.NewBaseApp(
appName,
@@ -287,28 +349,15 @@ func NewEthermintApp(
)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
evmtypes.RegisterInterfaces(interfaceRegistry)
bApp.SetInterfaceRegistry(interfaceRegistry)
keys := sdk.NewKVStoreKeys(
// SDK keys
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey,
// ibc keys
ibchost.StoreKey, ibctransfertypes.StoreKey,
// ethermint keys
evmtypes.StoreKey, feemarkettypes.StoreKey,
// dxns keys
auctiontypes.StoreKey,
bondtypes.StoreKey,
nameservicetypes.StoreKey,
)
// Add the EVM transient store key
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
// configure state listening capabilities using AppOptions
// we are doing nothing with the returned streamingServices and waitGroup in this case
if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, keys); err != nil {
tmos.Exit(err.Error())
}
app := &EthermintApp{
BaseApp: bApp,
@@ -324,7 +373,7 @@ func NewEthermintApp(
// init params keeper and subspaces
app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
// set the BaseApp's parameter store
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))
// add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
@@ -338,7 +387,7 @@ func NewEthermintApp(
// use custom Ethermint account for contracts
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), ethermint.ProtoAccount, maccPerms,
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), ethermint.ProtoAccount, maccPerms, sdk.Bech32MainPrefix,
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(),
@@ -352,7 +401,7 @@ func NewEthermintApp(
)
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
&stakingKeeper, authtypes.FeeCollectorName,
)
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
@@ -361,7 +410,7 @@ func NewEthermintApp(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
@@ -369,7 +418,7 @@ func NewEthermintApp(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
)
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.BaseApp.MsgServiceRouter())
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper)
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))
@@ -378,7 +427,7 @@ func NewEthermintApp(
appCodec, keys[feemarkettypes.StoreKey], app.GetSubspace(feemarkettypes.ModuleName),
)
// Create Vulcanize dxns keepers
// Create Vulcanize chiba-clonk keepers
app.AuctionKeeper = auctionkeeper.NewKeeper(
app.AccountKeeper, app.BankKeeper, keys[auctiontypes.StoreKey],
appCodec, app.GetSubspace(auctiontypes.ModuleName),
@@ -411,16 +460,22 @@ func NewEthermintApp(
)
// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
govRouter := govv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
govConfig := govtypes.DefaultConfig()
/*
Example of setting gov params:
govConfig.MaxMetadataLen = 10000
*/
govKeeper := govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
&stakingKeeper, govRouter, app.MsgServiceRouter(), govConfig,
)
app.GovKeeper = *govKeeper.SetHooks(
@@ -438,7 +493,6 @@ func NewEthermintApp(
transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)
// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
app.IBCKeeper.SetRouter(ibcRouter)
@@ -470,7 +524,7 @@ func NewEthermintApp(
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
@@ -479,14 +533,13 @@ func NewEthermintApp(
params.NewAppModule(app.ParamsKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
// ibc modules
ibc.NewAppModule(app.IBCKeeper),
transferModule,
// Ethermint app modules
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
feemarket.NewAppModule(app.FeeMarketKeeper),
// DXNs modules
// chiba-clonk modules
auction.NewAppModule(appCodec, app.AuctionKeeper),
bond.NewAppModule(appCodec, app.BondKeeper),
nameservice.NewAppModule(app.NameServiceKeeper),
@@ -520,7 +573,7 @@ func NewEthermintApp(
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
// DXNS modules
// chiba-clonk modules
auctiontypes.ModuleName,
bondtypes.ModuleName,
nameservicetypes.ModuleName,
@@ -549,7 +602,7 @@ func NewEthermintApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
// DXNS modules
// chiba-clonk modules
auctiontypes.ModuleName,
bondtypes.ModuleName,
nameservicetypes.ModuleName,
@@ -582,7 +635,7 @@ func NewEthermintApp(
// Ethermint modules
evmtypes.ModuleName,
feemarkettypes.ModuleName,
// DXNS modules
// chiba-clonk modules
auctiontypes.ModuleName,
bondtypes.ModuleName,
nameservicetypes.ModuleName,
@@ -608,7 +661,7 @@ func NewEthermintApp(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
@@ -624,11 +677,6 @@ func NewEthermintApp(
app.sm.RegisterStoreDecoders()
// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
app.MountMemoryStores(memKeys)
// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
@@ -655,12 +703,6 @@ func NewEthermintApp(
app.SetAnteHandler(ante.NewAnteHandler(options))
app.SetEndBlocker(app.EndBlocker)
if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
}
}
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
@@ -692,7 +734,8 @@ func (app *EthermintApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain)
// LoadHeight loads state at a particular height
func (app *EthermintApp) LoadHeight(height int64) error {
return app.LoadVersion(height)
// return app.LoadVersion(height)
return nil
}
// ModuleAccountAddrs returns all the app's module account addresses.
@@ -740,21 +783,21 @@ func (app *EthermintApp) InterfaceRegistry() types.InterfaceRegistry {
// GetKey returns the KVStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *EthermintApp) GetKey(storeKey string) *sdk.KVStoreKey {
func (app *EthermintApp) GetKey(storeKey string) *storetypes.KVStoreKey {
return app.keys[storeKey]
}
// GetTKey returns the TransientStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *EthermintApp) GetTKey(storeKey string) *sdk.TransientStoreKey {
func (app *EthermintApp) GetTKey(storeKey string) *storetypes.TransientStoreKey {
return app.tkeys[storeKey]
}
// GetMemKey returns the MemStoreKey for the provided mem key.
//
// NOTE: This is solely used for testing purposes.
func (app *EthermintApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey {
func (app *EthermintApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
return app.memKeys[storeKey]
}
@@ -775,17 +818,16 @@ func (app *EthermintApp) SimulationManager() *module.SimulationManager {
// API server.
func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
evmrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// NOTE: in v0.46 legacy routes are removed
// rpc.RegisterRoutes(clientCtx, apiSvr.Router)
// evmrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router)
// Register grpc-gateway routes for all modules.
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// register swagger API from root so that other applications can override easily
@@ -799,7 +841,12 @@ func (app *EthermintApp) RegisterTxService(clientCtx client.Context) {
}
func (app *EthermintApp) RegisterTendermintService(clientCtx client.Context) {
tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry)
tmservice.RegisterTendermintService(
clientCtx,
app.BaseApp.GRPCQueryRouter(),
app.interfaceRegistry,
app.Query,
)
}
// RegisterSwaggerAPI registers swagger route with API Server
@@ -825,7 +872,7 @@ func GetMaccPerms() map[string][]string {
// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(
appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey,
appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey,
) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
@@ -836,14 +883,14 @@ func initParamsKeeper(
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
// ethermint subspaces
paramsKeeper.Subspace(evmtypes.ModuleName)
paramsKeeper.Subspace(feemarkettypes.ModuleName)
// dxns subspaces
// chiba-clonk subspaces
paramsKeeper.Subspace(auctiontypes.ModuleName)
paramsKeeper.Subspace(bondtypes.ModuleName)
paramsKeeper.Subspace(nameservicetypes.ModuleName)
+25 -21
View File
@@ -1,41 +1,45 @@
package app
import (
"encoding/json"
"os"
"testing"
memdb "github.com/cosmos/cosmos-sdk/db/memdb"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/simapp"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
"github.com/tharsis/ethermint/encoding"
)
func TestEthermintAppExport(t *testing.T) {
db := dbm.NewMemDB()
app := NewEthermintApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
encCfg := encoding.MakeConfig(ModuleBasics)
db := memdb.NewDB()
logger, _ := log.NewDefaultLogger("plain", "info", false)
app := NewTestAppWithCustomOptions(t, false, SetupOptions{
Logger: logger,
DB: db,
InvCheckPeriod: 0,
EncConfig: encCfg,
HomePath: DefaultNodeHome,
SkipUpgradeHeights: map[int64]bool{},
AppOpts: EmptyAppOptions{},
})
genesisState := NewDefaultGenesisState()
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)
for acc := range allowedReceivingModAcc {
// check module account is not blocked in bank
require.False(
t,
app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)),
"ensure that blocked addresses %s are properly set in bank keeper",
)
}
// Initialize the chain
app.InitChain(
abci.RequestInitChain{
ChainId: "ethermint_9000-1",
Validators: []abci.ValidatorUpdate{},
AppStateBytes: stateBytes,
},
)
app.Commit()
logger2, _ := log.NewDefaultLogger("plain", "info", false)
// Making a new app object with the db, so that initchain hasn't been called
app2 := NewEthermintApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
_, err = app2.ExportAppStateAndValidators(false, []string{})
app2 := NewEthermintApp(logger2, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{})
require.NoError(t, app2.Init())
_, err := app2.ExportAppStateAndValidators(false, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}
+6 -6
View File
@@ -2,21 +2,21 @@ package app
import (
"encoding/json"
"io"
"testing"
"github.com/cosmos/cosmos-sdk/db/memdb"
"github.com/cosmos/cosmos-sdk/simapp"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
"github.com/tharsis/ethermint/encoding"
)
func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) {
db := dbm.NewMemDB()
app := NewEthermintApp(log.NewTMLogger(io.Discard), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
db := memdb.NewDB()
logger, _ := log.NewDefaultLogger("plain", "info", false)
app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
genesisState := NewDefaultGenesisState()
genesisState := NewDefaultGenesisState(app.appCodec)
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
b.Fatal(err)
@@ -36,7 +36,7 @@ func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
// Making a new app object with the db, so that initchain hasn't been called
app2 := NewEthermintApp(log.NewTMLogger(log.NewSyncWriter(io.Discard)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
app2 := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
if _, err := app2.ExportAppStateAndValidators(false, []string{}); err != nil {
b.Fatal(err)
}
+3 -5
View File
@@ -6,20 +6,18 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/tharsis/ethermint/encoding"
)
// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState() simapp.GenesisState {
encCfg := encoding.MakeConfig(ModuleBasics)
return ModuleBasics.DefaultGenesis(encCfg.Marshaler)
func NewDefaultGenesisState(cdc codec.JSONCodec) simapp.GenesisState {
return ModuleBasics.DefaultGenesis(cdc)
}
// ExportAppStateAndValidators exports the state of the application for a genesis
+11 -9
View File
@@ -13,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -27,12 +26,14 @@ import (
"github.com/cosmos/cosmos-sdk/x/simulation"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/db/memdb"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
evmenc "github.com/tharsis/ethermint/encoding"
)
@@ -48,21 +49,22 @@ func init() {
const SimAppChainID = "simulation_777-1"
type storeKeysPrefixes struct {
A sdk.StoreKey
B sdk.StoreKey
A storetypes.StoreKey
B storetypes.StoreKey
Prefixes [][]byte
}
// fauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of
// an IAVLStore for faster simulation speed.
func fauxMerkleModeOpt(bapp *baseapp.BaseApp) {
var fauxMerkleModeOpt = baseapp.AppOptionFunc(func(bapp *baseapp.BaseApp) {
bapp.SetFauxMerkleMode()
}
})
// interBlockCacheOpt returns a BaseApp option function that sets the persistent
// inter-block write-through cache.
func interBlockCacheOpt() func(*baseapp.BaseApp) {
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager())
// TODO: implement this cache as enhancement to v2 multistore
func interBlockCacheOpt() baseapp.AppOptionFunc {
return func(*baseapp.BaseApp) {}
}
func TestFullAppSimulation(t *testing.T) {
@@ -310,7 +312,7 @@ func TestAppStateDeterminism(t *testing.T) {
logger = log.NewNopLogger()
}
db := dbm.NewMemDB()
db := memdb.NewDB()
app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), simapp.EmptyAppOptions{}, interBlockCacheOpt())
fmt.Printf(
+222 -19
View File
@@ -1,26 +1,50 @@
package app
import (
"context"
"encoding/json"
"testing"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/tharsis/ethermint/encoding"
"github.com/cosmos/cosmos-sdk/testutil/mock"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/stretchr/testify/require"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tharsis/ethermint/crypto/ethsecp256k1"
"github.com/tharsis/ethermint/encoding"
ethermint "github.com/tharsis/ethermint/types"
"github.com/cosmos/cosmos-sdk/db/memdb"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
)
// GenesisState of the blockchain is represented here as a map of raw json
// messages key'd by a identifier string.
// The identifier is used to determine which module genesis information belongs
// to so it may be appropriately routed during init chain.
// Within this application default genesis information is retrieved from
// the ModuleBasicManager which populates json from each BasicModule
// object provided to it during init.
// DefaultConsensusParams defines the default Tendermint consensus params used in
// EthermintApp testing.
var DefaultConsensusParams = &abci.ConsensusParams{
Block: &abci.BlockParams{
var DefaultConsensusParams = &tmproto.ConsensusParams{
Block: &tmproto.BlockParams{
MaxBytes: 200000,
MaxGas: -1, // no limit
},
@@ -36,21 +60,50 @@ var DefaultConsensusParams = &abci.ConsensusParams{
},
}
// Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp.
func Setup(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState) *EthermintApp {
db := dbm.NewMemDB()
app := NewEthermintApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
// SetupOptions defines arguments that are passed into `Simapp` constructor.
type SetupOptions struct {
Logger log.Logger
DB *memdb.MemDB
InvCheckPeriod uint
HomePath string
SkipUpgradeHeights map[int64]bool
EncConfig params.EncodingConfig
AppOpts types.AppOptions
}
func NewTestAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptions) *EthermintApp {
t.Helper()
privVal := mock.NewPV()
pubKey, err := privVal.GetPubKey(context.TODO())
require.NoError(t, err)
// create validator set with single validator
validator := tmtypes.NewValidator(pubKey, 1)
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
// generate genesis account
priv, err := ethsecp256k1.GenerateKey()
require.NoError(t, err)
address := common.BytesToAddress(priv.PubKey().Address().Bytes())
acc := &ethermint.EthAccount{
BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(address.Bytes()), nil, 0, 0),
CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(),
}
balance := banktypes.Balance{
Address: acc.GetAddress().String(),
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
}
app := NewEthermintApp(options.Logger, options.DB, nil, true, options.SkipUpgradeHeights, options.HomePath, options.InvCheckPeriod, options.EncConfig, options.AppOpts)
genesisState := NewDefaultGenesisState(app.appCodec)
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)
if !isCheckTx {
// init chain must be called to stop deliverState from being nil
genesisState := NewDefaultGenesisState()
if patchGenesis != nil {
genesisState = patchGenesis(app, genesisState)
}
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
panic(err)
}
stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)
// Initialize the chain
app.InitChain(
@@ -66,6 +119,148 @@ func Setup(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState)
return app
}
// Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp.
func Setup(t *testing.T, isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState) *EthermintApp {
t.Helper()
privVal := mock.NewPV()
pubKey, err := privVal.GetPubKey(context.TODO())
require.NoError(t, err)
// create validator set with single validator
validator := tmtypes.NewValidator(pubKey, 1)
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
priv, err := ethsecp256k1.GenerateKey()
require.NoError(t, err)
address := common.BytesToAddress(priv.PubKey().Address().Bytes())
acc := &ethermint.EthAccount{
BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(address.Bytes()), nil, 0, 0),
CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(),
}
balance := banktypes.Balance{
Address: acc.GetAddress().String(),
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
}
app := SetupWithGenesisValSet(t, valSet, patchGenesis, []authtypes.GenesisAccount{acc}, balance)
return app
}
func setup(withGenesis bool, invCheckPeriod uint, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState) (*EthermintApp, simapp.GenesisState) {
encCdc := encoding.MakeConfig(ModuleBasics)
app := NewEthermintApp(log.NewNopLogger(), memdb.NewDB(), nil, true, map[int64]bool{}, DefaultNodeHome, invCheckPeriod, encCdc, EmptyAppOptions{})
if withGenesis {
genesisState := NewDefaultGenesisState(encCdc.Codec)
if patchGenesis != nil {
genesisState = patchGenesis(app, genesisState)
}
return app, genesisState
}
return app, simapp.GenesisState{}
}
// SetupWithGenesisValSet initializes a new SimApp with a validator set and genesis accounts
// that also act as delegators. For simplicity, each validator is bonded with a delegation
// of one consensus engine unit in the default token of the simapp from first genesis
// account. A Nop logger is set in SimApp.
func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *EthermintApp {
t.Helper()
app, genesisState := setup(true, 5, patchGenesis)
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)
// init chain will set the validator set and initialize the genesis accounts
app.InitChain(
abci.RequestInitChain{
ChainId: "ethermint_9000-1",
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
// commit genesis changes
// app.Commit()
// app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{
// ChainID: "ethermint_9000-1",
// Height: app.LastBlockHeight() + 1,
// AppHash: app.LastCommitID().Hash,
// ValidatorsHash: valSet.Hash(),
// NextValidatorsHash: valSet.Hash(),
// }})
return app
}
func genesisStateWithValSet(t *testing.T, app *EthermintApp, genesisState simapp.GenesisState,
valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance,
) simapp.GenesisState {
// set genesis accounts
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis)
validators := make([]stakingtypes.Validator, 0, len(valSet.Validators))
delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators))
bondAmt := sdk.DefaultPowerReduction
for _, val := range valSet.Validators {
pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey)
require.NoError(t, err)
pkAny, err := codectypes.NewAnyWithValue(pk)
require.NoError(t, err)
validator := stakingtypes.Validator{
OperatorAddress: sdk.ValAddress(val.Address).String(),
ConsensusPubkey: pkAny,
Jailed: false,
Status: stakingtypes.Bonded,
Tokens: bondAmt,
DelegatorShares: sdk.OneDec(),
Description: stakingtypes.Description{},
UnbondingHeight: int64(0),
UnbondingTime: time.Unix(0, 0).UTC(),
Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
MinSelfDelegation: sdk.ZeroInt(),
}
validators = append(validators, validator)
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec()))
}
// set validators and delegations
stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations)
genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis)
totalSupply := sdk.NewCoins()
for _, b := range balances {
// add genesis acc tokens to total supply
totalSupply = totalSupply.Add(b.Coins...)
}
for range delegations {
// add delegated tokens to total supply
totalSupply = totalSupply.Add(sdk.NewCoin(sdk.DefaultBondDenom, 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(sdk.DefaultBondDenom, bondAmt)},
})
// update total supply
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{})
genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)
return genesisState
}
// CreateRandomAccounts will generate random accounts
func CreateRandomAccounts(accNum int) []sdk.AccAddress {
// createRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order.
@@ -77,3 +272,11 @@ func CreateRandomAccounts(accNum int) []sdk.AccAddress {
return testAddrs
}
// EmptyAppOptions is a stub implementing AppOptions
type EmptyAppOptions struct{}
// Get implements AppOptions
func (ao EmptyAppOptions) Get(o string) interface{} {
return nil
}
+3 -1
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"strings"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
"github.com/cosmos/cosmos-sdk/crypto"
@@ -30,12 +31,13 @@ func UnsafeExportEthKeyCommand() *cobra.Command {
keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend)
rootDir, _ := cmd.Flags().GetString(flags.FlagHome)
clientCtx := client.GetClientContextFromCmd(cmd)
kr, err := keyring.New(
sdk.KeyringServiceName(),
keyringBackend,
rootDir,
inBuf,
clientCtx.Codec,
hd.EthSecp256k1Option(),
)
if err != nil {
+3
View File
@@ -5,6 +5,7 @@ import (
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
"github.com/cosmos/cosmos-sdk/crypto"
@@ -31,12 +32,14 @@ func runImportCmd(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin())
keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend)
rootDir, _ := cmd.Flags().GetString(flags.FlagHome)
clientCtx := client.GetClientContextFromCmd(cmd)
kb, err := keyring.New(
sdk.KeyringServiceName(),
keyringBackend,
rootDir,
inBuf,
clientCtx.Codec,
hd.EthSecp256k1Option(),
)
if err != nil {
+1 -1
View File
@@ -92,7 +92,7 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun)
if dryRun {
kr, err = keyring.New(sdk.KeyringServiceName(), keyring.BackendMemory, clientCtx.KeyringDir, buf, hd.EthSecp256k1Option())
kr, err = keyring.New(sdk.KeyringServiceName(), keyring.BackendMemory, clientCtx.KeyringDir, buf, clientCtx.Codec, hd.EthSecp256k1Option())
clientCtx = clientCtx.WithKeyring(kr)
}
+6 -4
View File
@@ -122,7 +122,7 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
if dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun); dryRun {
// use in memory keybase
kb = keyring.NewInMemory(etherminthd.EthSecp256k1Option())
kb = keyring.NewInMemory(ctx.Codec, etherminthd.EthSecp256k1Option())
} else {
_, err = kb.Key(name)
if err == nil {
@@ -156,7 +156,9 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
return err
}
pks[i] = k.GetPubKey()
if pks[i], err = k.GetPubKey(); err != nil {
return err
}
}
if noSort, _ := cmd.Flags().GetBool(flagNoSort); !noSort {
@@ -183,7 +185,7 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
return err
}
info, err := kb.SavePubKey(name, pk, algo.Name())
info, err := kb.SaveOfflineKey(name, pk)
if err != nil {
return err
}
@@ -289,7 +291,7 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
return printCreate(cmd, info, showMnemonic, mnemonic, outputFormat)
}
func printCreate(cmd *cobra.Command, info keyring.Info, showMnemonic bool, mnemonic, outputFormat string) error {
func printCreate(cmd *cobra.Command, info *keyring.Record, showMnemonic bool, mnemonic, outputFormat string) error {
switch outputFormat {
case OutputFormatText:
cmd.PrintErrln()
+2 -13
View File
@@ -3,7 +3,6 @@ package keys
import (
"fmt"
"io"
"path/filepath"
yaml "gopkg.in/yaml.v2"
@@ -20,19 +19,9 @@ const (
defaultKeyDBName = "keys"
)
type bechKeyOutFn func(keyInfo cryptokeyring.Info) (cryptokeyring.KeyOutput, error)
type bechKeyOutFn func(keyInfo *cryptokeyring.Record) (cryptokeyring.KeyOutput, error)
// NewLegacyKeyBaseFromDir initializes a legacy keybase at the rootDir directory. Keybase
// options can be applied when generating this new Keybase.
func NewLegacyKeyBaseFromDir(rootDir string, opts ...cryptokeyring.KeybaseOption) (cryptokeyring.LegacyKeybase, error) {
return getLegacyKeyBaseFromDir(rootDir, opts...)
}
func getLegacyKeyBaseFromDir(rootDir string, opts ...cryptokeyring.KeybaseOption) (cryptokeyring.LegacyKeybase, error) {
return cryptokeyring.NewLegacy(defaultKeyDBName, filepath.Join(rootDir, "keys"), opts...)
}
func printKeyInfo(w io.Writer, keyInfo cryptokeyring.Info, bechKeyOut bechKeyOutFn, output string) {
func printKeyInfo(w io.Writer, keyInfo *cryptokeyring.Record, bechKeyOut bechKeyOutFn, output string) {
ko, err := bechKeyOut(keyInfo)
if err != nil {
panic(err)
+11 -7
View File
@@ -6,17 +6,18 @@ import (
"bufio"
"encoding/json"
"fmt"
"math/rand"
"net"
"os"
"path/filepath"
"time"
"github.com/ethereum/go-ethereum/common"
tmcfg "github.com/tendermint/tendermint/config"
"github.com/spf13/cobra"
tmconfig "github.com/tendermint/tendermint/config"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
@@ -34,6 +35,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
mintypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@@ -209,7 +212,7 @@ func initTestnetFiles(
args initArgs,
) error {
if args.chainID == "" {
args.chainID = fmt.Sprintf("ethermint_%d-1", tmrand.Int63n(9999999999999)+1)
args.chainID = fmt.Sprintf("ethermint_%d-1", rand.Int63n(9999999999999)+1)
}
nodeIDs := make([]string, args.numValidators)
@@ -261,7 +264,7 @@ func initTestnetFiles(
memo := fmt.Sprintf("%s@%s:26656", nodeIDs[i], ip)
genFiles = append(genFiles, nodeConfig.GenesisFile())
kb, err := keyring.New(sdk.KeyringServiceName(), args.keyringBackend, nodeDir, inBuf, hd.EthSecp256k1Option())
kb, err := keyring.New(sdk.KeyringServiceName(), args.keyringBackend, nodeDir, inBuf, clientCtx.Codec, hd.EthSecp256k1Option())
if err != nil {
return err
}
@@ -343,7 +346,8 @@ func initTestnetFiles(
customAppTemplate, customAppConfig := config.AppConfig(ethermint.AttoPhoton)
srvconfig.SetConfigTemplate(customAppTemplate)
if err := sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig); err != nil {
customTmConfig := tmcfg.DefaultConfig()
if err := sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTmConfig); err != nil {
return err
}
@@ -402,7 +406,7 @@ func initGenFiles(
stakingGenState.Params.BondDenom = coinDenom
appGenState[stakingtypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&stakingGenState)
var govGenState govtypes.GenesisState
var govGenState v1.GenesisState
clientCtx.Codec.MustUnmarshalJSON(appGenState[govtypes.ModuleName], &govGenState)
govGenState.DepositParams.MinDeposit[0].Denom = coinDenom
@@ -452,7 +456,7 @@ func collectGenFiles(
outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
) error {
var appState json.RawMessage
genTime := tmtime.Now()
genTime := time.Now()
for i := 0; i < numValidators; i++ {
nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i)
+1 -1
View File
@@ -23,6 +23,6 @@ func TestInitCmd(t *testing.T) {
fmt.Sprintf("--%s=%s", flags.FlagChainID, "ethermint_9000-1"),
})
err := svrcmd.Execute(rootCmd, app.DefaultNodeHome)
err := svrcmd.Execute(rootCmd, chibaclonkd.EnvPrefix, app.DefaultNodeHome)
require.NoError(t, err)
}
+5 -1
View File
@@ -63,6 +63,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
keyringBackend,
clientCtx.HomeDir,
inBuf,
clientCtx.Codec,
hd.EthSecp256k1Option(),
)
if err != nil {
@@ -77,7 +78,10 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
return fmt.Errorf("failed to get address from Keyring: %w", err)
}
addr = info.GetAddress()
addr, err = info.GetAddress()
if err != nil {
return fmt.Errorf("failed to get address from Keyring: %w", err)
}
}
coins, err := sdk.ParseCoinsNormalized(args[1])
+1 -1
View File
@@ -12,7 +12,7 @@ import (
func main() {
rootCmd, _ := NewRootCmd()
if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
switch e := err.(type) {
case server.ErrorCode:
os.Exit(e.Code)
+32 -16
View File
@@ -6,22 +6,18 @@ import (
"os"
"path/filepath"
"github.com/spf13/cast"
"github.com/spf13/cobra"
tmcli "github.com/tendermint/tendermint/libs/cli"
tmlog "github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/rpc"
dbm "github.com/cosmos/cosmos-sdk/db"
"github.com/cosmos/cosmos-sdk/db/badgerdb"
sdkserver "github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/snapshots"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
@@ -29,6 +25,11 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/spf13/cast"
"github.com/spf13/cobra"
tmcfg "github.com/tendermint/tendermint/config"
tmcli "github.com/tendermint/tendermint/libs/cli"
tmlog "github.com/tendermint/tendermint/libs/log"
"github.com/tharsis/ethermint/app"
ethermintclient "github.com/tharsis/ethermint/client"
@@ -48,7 +49,7 @@ const EnvPrefix = "CHIBACLONK"
func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
encodingConfig := encoding.MakeConfig(app.ModuleBasics)
initClientCtx := client.Context{}.
WithCodec(encodingConfig.Marshaler).
WithCodec(encodingConfig.Codec).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
@@ -83,8 +84,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
// FIXME: replace AttoPhoton with bond denom
customAppTemplate, customAppConfig := servercfg.AppConfig(ethermint.AttoPhoton)
customTMConfig := initTendermintConfig()
return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig)
return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig)
},
}
@@ -126,7 +128,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
}
// add rosetta
rootCmd.AddCommand(sdkserver.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler))
rootCmd.AddCommand(sdkserver.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec))
// Add flags for GQL server.
rootCmd = srvflags.AddGQLFlags(rootCmd)
@@ -138,6 +140,18 @@ func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
}
// initTendermintConfig helps to override default Tendermint Config values.
// return tmcfg.DefaultConfig if no custom configuration is required for the application.
func initTendermintConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()
// these values put a higher strain on node memory
// cfg.P2P.MaxNumInboundPeers = 100
// cfg.P2P.MaxNumOutboundPeers = 40
return cfg
}
func queryCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "query",
@@ -193,7 +207,7 @@ type appCreator struct {
}
// newApp is an appCreator
func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
func (a appCreator) newApp(logger tmlog.Logger, db dbm.DBConnection, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
var cache sdk.MultiStorePersistentCache
if cast.ToBool(appOpts.Get(sdkserver.FlagInterBlockCache)) {
@@ -211,7 +225,7 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer,
}
snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots")
snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir)
snapshotDB, err := badgerdb.NewDB(filepath.Join(snapshotDir, "metadata"))
if err != nil {
panic(err)
}
@@ -219,6 +233,10 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer,
if err != nil {
panic(err)
}
snapshotOptions := snapshottypes.NewSnapshotOptions(
cast.ToUint64(appOpts.Get(sdkserver.FlagStateSyncSnapshotInterval)),
cast.ToUint32(appOpts.Get(sdkserver.FlagStateSyncSnapshotKeepRecent)),
)
ethermintApp := app.NewEthermintApp(
logger, db, traceStore, true, skipUpgradeHeights,
@@ -234,9 +252,7 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer,
baseapp.SetInterBlockCache(cache),
baseapp.SetTrace(cast.ToBool(appOpts.Get(sdkserver.FlagTrace))),
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(sdkserver.FlagIndexEvents))),
baseapp.SetSnapshotStore(snapshotStore),
baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(sdkserver.FlagStateSyncSnapshotInterval))),
baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(sdkserver.FlagStateSyncSnapshotKeepRecent))),
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
)
return ethermintApp
@@ -245,7 +261,7 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer,
// appExport creates a new simapp (optionally at a given height)
// and exports state.
func (a appCreator) appExport(
logger tmlog.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string,
logger tmlog.Logger, db dbm.DBConnection, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string,
appOpts servertypes.AppOptions,
) (servertypes.ExportedApp, error) {
var ethermintApp *app.EthermintApp
+2 -2
View File
@@ -8,7 +8,7 @@ import (
const (
// Bech32Prefix defines the Bech32 prefix used for EthAccounts
Bech32Prefix = "ethm"
Bech32Prefix = ethermint.Bech32MainPrefix
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = Bech32Prefix
@@ -40,7 +40,7 @@ func SetBech32Prefixes(config *sdk.Config) {
func SetBip44CoinType(config *sdk.Config) {
config.SetCoinType(ethermint.Bip44CoinType)
config.SetPurpose(sdk.Purpose) // Shared
config.SetFullFundraiserPath(ethermint.BIP44HDPath) // nolint: staticcheck
config.SetFullFundraiserPath(ethermint.BIP44HDPath) //nolint: staticcheck
}
// RegisterDenoms registers the base and display denominations to the SDK.
+1
View File
@@ -10,4 +10,5 @@ import (
// RegisterInterfaces register the Ethermint key concrete types.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &ethsecp256k1.PubKey{})
registry.RegisterImplementations((*cryptotypes.PrivKey)(nil), &ethsecp256k1.PrivKey{})
}
+6 -4
View File
@@ -4,6 +4,7 @@ import (
"strings"
"testing"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common"
@@ -12,12 +13,14 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
cryptocodec "github.com/tharsis/ethermint/crypto/codec"
ethermint "github.com/tharsis/ethermint/types"
)
var protoCodec codec.Codec
func init() {
protoCodec = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
amino := codec.NewLegacyAmino()
cryptocodec.RegisterCrypto(amino)
}
@@ -28,7 +31,7 @@ func TestKeyring(t *testing.T) {
dir := t.TempDir()
mockIn := strings.NewReader("")
kr, err := keyring.New("ethermint", keyring.BackendTest, dir, mockIn, EthSecp256k1Option())
kr, err := keyring.New("ethermint", keyring.BackendTest, dir, mockIn, protoCodec, EthSecp256k1Option())
require.NoError(t, err)
// fail in retrieving key
@@ -40,9 +43,8 @@ func TestKeyring(t *testing.T) {
info, mnemonic, err := kr.NewMnemonic("foo", keyring.English, ethermint.BIP44HDPath, keyring.DefaultBIP39Passphrase, EthSecp256k1)
require.NoError(t, err)
require.NotEmpty(t, mnemonic)
require.Equal(t, "foo", info.GetName())
require.Equal(t, "foo", info.Name)
require.Equal(t, "local", info.GetType().String())
require.Equal(t, EthSecp256k1Type, info.GetAlgo())
hdPath := ethermint.BIP44HDPath
+89 -26
View File
@@ -179,17 +179,20 @@
- [QueryListNameRecordsRequest](#vulcanize.nameservice.v1beta1.QueryListNameRecordsRequest)
- [QueryListNameRecordsResponse](#vulcanize.nameservice.v1beta1.QueryListNameRecordsResponse)
- [QueryListRecordsRequest](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest)
- [QueryListRecordsRequest.KeyValueInput](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest.KeyValueInput)
- [QueryListRecordsRequest.ReferenceInput](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest.ReferenceInput)
- [QueryListRecordsRequest.ValueInput](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest.ValueInput)
- [QueryListRecordsResponse](#vulcanize.nameservice.v1beta1.QueryListRecordsResponse)
- [QueryLookupWrn](#vulcanize.nameservice.v1beta1.QueryLookupWrn)
- [QueryLookupWrnResponse](#vulcanize.nameservice.v1beta1.QueryLookupWrnResponse)
- [QueryLookupCrn](#vulcanize.nameservice.v1beta1.QueryLookupCrn)
- [QueryLookupCrnResponse](#vulcanize.nameservice.v1beta1.QueryLookupCrnResponse)
- [QueryParamsRequest](#vulcanize.nameservice.v1beta1.QueryParamsRequest)
- [QueryParamsResponse](#vulcanize.nameservice.v1beta1.QueryParamsResponse)
- [QueryRecordByBondIdRequest](#vulcanize.nameservice.v1beta1.QueryRecordByBondIdRequest)
- [QueryRecordByBondIdResponse](#vulcanize.nameservice.v1beta1.QueryRecordByBondIdResponse)
- [QueryRecordByIdRequest](#vulcanize.nameservice.v1beta1.QueryRecordByIdRequest)
- [QueryRecordByIdResponse](#vulcanize.nameservice.v1beta1.QueryRecordByIdResponse)
- [QueryResolveWrn](#vulcanize.nameservice.v1beta1.QueryResolveWrn)
- [QueryResolveWrnResponse](#vulcanize.nameservice.v1beta1.QueryResolveWrnResponse)
- [QueryResolveCrn](#vulcanize.nameservice.v1beta1.QueryResolveCrn)
- [QueryResolveCrnResponse](#vulcanize.nameservice.v1beta1.QueryResolveCrnResponse)
- [QueryWhoisRequest](#vulcanize.nameservice.v1beta1.QueryWhoisRequest)
- [QueryWhoisResponse](#vulcanize.nameservice.v1beta1.QueryWhoisResponse)
@@ -2362,11 +2365,12 @@ Params defines the nameservice module records
| ----- | ---- | ----- | ----------- |
| `id` | [string](#string) | | |
| `bond_id` | [string](#string) | | |
| `create_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `expiry_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `create_time` | [string](#string) | | |
| `expiry_time` | [string](#string) | | |
| `deleted` | [bool](#bool) | | |
| `owners` | [string](#string) | repeated | |
| `attributes` | [bytes](#bytes) | | |
| `attributes` | [string](#string) | | |
| `names` | [string](#string) | repeated | |
@@ -2597,6 +2601,8 @@ QueryListRecordsRequest is request type for nameservice records list
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `attributes` | [QueryListRecordsRequest.KeyValueInput](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest.KeyValueInput) | repeated | |
| `all` | [bool](#bool) | | |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. |
@@ -2604,6 +2610,58 @@ QueryListRecordsRequest is request type for nameservice records list
<a name="vulcanize.nameservice.v1beta1.QueryListRecordsRequest.KeyValueInput"></a>
### QueryListRecordsRequest.KeyValueInput
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `key` | [string](#string) | | |
| `value` | [QueryListRecordsRequest.ValueInput](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest.ValueInput) | | |
<a name="vulcanize.nameservice.v1beta1.QueryListRecordsRequest.ReferenceInput"></a>
### QueryListRecordsRequest.ReferenceInput
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `id` | [string](#string) | | |
<a name="vulcanize.nameservice.v1beta1.QueryListRecordsRequest.ValueInput"></a>
### QueryListRecordsRequest.ValueInput
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `type` | [string](#string) | | |
| `string` | [string](#string) | | |
| `int` | [int64](#int64) | | |
| `float` | [double](#double) | | |
| `boolean` | [bool](#bool) | | |
| `reference` | [QueryListRecordsRequest.ReferenceInput](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest.ReferenceInput) | | |
| `values` | [QueryListRecordsRequest.ValueInput](#vulcanize.nameservice.v1beta1.QueryListRecordsRequest.ValueInput) | repeated | |
<a name="vulcanize.nameservice.v1beta1.QueryListRecordsResponse"></a>
### QueryListRecordsResponse
@@ -2620,25 +2678,25 @@ QueryListRecordsResponse is response type for nameservice records list
<a name="vulcanize.nameservice.v1beta1.QueryLookupWrn"></a>
<a name="vulcanize.nameservice.v1beta1.QueryLookupCrn"></a>
### QueryLookupWrn
QueryLookupWrn is request type for LookupWrn
### QueryLookupCrn
QueryLookupCrn is request type for LookupCrn
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `wrn` | [string](#string) | | |
| `crn` | [string](#string) | | |
<a name="vulcanize.nameservice.v1beta1.QueryLookupWrnResponse"></a>
<a name="vulcanize.nameservice.v1beta1.QueryLookupCrnResponse"></a>
### QueryLookupWrnResponse
QueryLookupWrnResponse is response type for QueryLookupWrn
### QueryLookupCrnResponse
QueryLookupCrnResponse is response type for QueryLookupCrn
| Field | Type | Label | Description |
@@ -2737,25 +2795,25 @@ QueryRecordByIdResponse is response type for nameservice records by id
<a name="vulcanize.nameservice.v1beta1.QueryResolveWrn"></a>
<a name="vulcanize.nameservice.v1beta1.QueryResolveCrn"></a>
### QueryResolveWrn
QueryResolveWrn is request type for ResolveWrn
### QueryResolveCrn
QueryResolveCrn is request type for ResolveCrn
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `wrn` | [string](#string) | | |
| `crn` | [string](#string) | | |
<a name="vulcanize.nameservice.v1beta1.QueryResolveWrnResponse"></a>
<a name="vulcanize.nameservice.v1beta1.QueryResolveCrnResponse"></a>
### QueryResolveWrnResponse
QueryResolveWrnResponse is response type for QueryResolveWrn
### QueryResolveCrnResponse
QueryResolveCrnResponse is response type for QueryResolveCrn
| Field | Type | Label | Description |
@@ -2817,8 +2875,8 @@ Query defines the gRPC querier service for nameservice module
| `GetNameServiceModuleBalance` | [GetNameServiceModuleBalanceRequest](#vulcanize.nameservice.v1beta1.GetNameServiceModuleBalanceRequest) | [GetNameServiceModuleBalanceResponse](#vulcanize.nameservice.v1beta1.GetNameServiceModuleBalanceResponse) | Get nameservice module balance | GET|/vulcanize/nameservice/v1beta1/balance|
| `ListNameRecords` | [QueryListNameRecordsRequest](#vulcanize.nameservice.v1beta1.QueryListNameRecordsRequest) | [QueryListNameRecordsResponse](#vulcanize.nameservice.v1beta1.QueryListNameRecordsResponse) | List name records | GET|/vulcanize/nameservice/v1beta1/names|
| `Whois` | [QueryWhoisRequest](#vulcanize.nameservice.v1beta1.QueryWhoisRequest) | [QueryWhoisResponse](#vulcanize.nameservice.v1beta1.QueryWhoisResponse) | Whois method retrieve the name authority info | GET|/vulcanize/nameservice/v1beta1/whois/{name}|
| `LookupWrn` | [QueryLookupWrn](#vulcanize.nameservice.v1beta1.QueryLookupWrn) | [QueryLookupWrnResponse](#vulcanize.nameservice.v1beta1.QueryLookupWrnResponse) | LookupWrn | GET|/vulcanize/nameservice/v1beta1/lookup|
| `ResolveWrn` | [QueryResolveWrn](#vulcanize.nameservice.v1beta1.QueryResolveWrn) | [QueryResolveWrnResponse](#vulcanize.nameservice.v1beta1.QueryResolveWrnResponse) | ResolveWrn | GET|/vulcanize/nameservice/v1beta1/resolve|
| `LookupCrn` | [QueryLookupCrn](#vulcanize.nameservice.v1beta1.QueryLookupCrn) | [QueryLookupCrnResponse](#vulcanize.nameservice.v1beta1.QueryLookupCrnResponse) | LookupCrn | GET|/vulcanize/nameservice/v1beta1/lookup|
| `ResolveCrn` | [QueryResolveCrn](#vulcanize.nameservice.v1beta1.QueryResolveCrn) | [QueryResolveCrnResponse](#vulcanize.nameservice.v1beta1.QueryResolveCrnResponse) | ResolveCrn | GET|/vulcanize/nameservice/v1beta1/resolve|
| `GetRecordExpiryQueue` | [QueryGetRecordExpiryQueue](#vulcanize.nameservice.v1beta1.QueryGetRecordExpiryQueue) | [QueryGetRecordExpiryQueueResponse](#vulcanize.nameservice.v1beta1.QueryGetRecordExpiryQueueResponse) | GetRecordExpiryQueue | GET|/vulcanize/nameservice/v1beta1/record-expiry|
| `GetAuthorityExpiryQueue` | [QueryGetAuthorityExpiryQueue](#vulcanize.nameservice.v1beta1.QueryGetAuthorityExpiryQueue) | [QueryGetAuthorityExpiryQueueResponse](#vulcanize.nameservice.v1beta1.QueryGetAuthorityExpiryQueueResponse) | GetAuthorityExpiryQueue | GET|/vulcanize/nameservice/v1beta1/authority-expiry|
@@ -2868,7 +2926,7 @@ MsgDeleteNameAuthority is SDK message for DeleteNameAuthority
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `wrn` | [string](#string) | | |
| `crn` | [string](#string) | | |
| `signer` | [string](#string) | | |
@@ -3053,7 +3111,7 @@ MsgSetName
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `wrn` | [string](#string) | | |
| `crn` | [string](#string) | | |
| `cid` | [string](#string) | | |
| `signer` | [string](#string) | | |
@@ -3095,6 +3153,11 @@ MsgSetRecord
MsgSetRecordResponse
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `id` | [string](#string) | | |
@@ -3134,7 +3197,7 @@ Msg
| `DissociateBond` | [MsgDissociateBond](#vulcanize.nameservice.v1beta1.MsgDissociateBond) | [MsgDissociateBondResponse](#vulcanize.nameservice.v1beta1.MsgDissociateBondResponse) | DissociateBond | |
| `DissociateRecords` | [MsgDissociateRecords](#vulcanize.nameservice.v1beta1.MsgDissociateRecords) | [MsgDissociateRecordsResponse](#vulcanize.nameservice.v1beta1.MsgDissociateRecordsResponse) | DissociateRecords | |
| `ReAssociateRecords` | [MsgReAssociateRecords](#vulcanize.nameservice.v1beta1.MsgReAssociateRecords) | [MsgReAssociateRecordsResponse](#vulcanize.nameservice.v1beta1.MsgReAssociateRecordsResponse) | ReAssociateRecords | |
| `SetName` | [MsgSetName](#vulcanize.nameservice.v1beta1.MsgSetName) | [MsgSetNameResponse](#vulcanize.nameservice.v1beta1.MsgSetNameResponse) | SetName will store the name with given wrn and name | |
| `SetName` | [MsgSetName](#vulcanize.nameservice.v1beta1.MsgSetName) | [MsgSetNameResponse](#vulcanize.nameservice.v1beta1.MsgSetNameResponse) | SetName will store the name with given crn and name | |
| `ReserveName` | [MsgReserveAuthority](#vulcanize.nameservice.v1beta1.MsgReserveAuthority) | [MsgReserveAuthorityResponse](#vulcanize.nameservice.v1beta1.MsgReserveAuthorityResponse) | Reserve name | |
| `DeleteName` | [MsgDeleteNameAuthority](#vulcanize.nameservice.v1beta1.MsgDeleteNameAuthority) | [MsgDeleteNameAuthorityResponse](#vulcanize.nameservice.v1beta1.MsgDeleteNameAuthorityResponse) | Delete Name method will remove authority name | |
| `SetAuthorityBond` | [MsgSetAuthorityBond](#vulcanize.nameservice.v1beta1.MsgSetAuthorityBond) | [MsgSetAuthorityBondResponse](#vulcanize.nameservice.v1beta1.MsgSetAuthorityBondResponse) | SetAuthorityBond | |
+1 -4
View File
@@ -4,7 +4,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
cryptocodec "github.com/tharsis/ethermint/crypto/codec"
ethermint "github.com/tharsis/ethermint/types"
@@ -12,9 +11,7 @@ import (
// RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
sdk.RegisterLegacyAminoCodec(cdc)
cryptocodec.RegisterCrypto(cdc)
codec.RegisterEvidences(cdc)
std.RegisterLegacyAminoCodec(cdc)
}
// RegisterInterfaces registers Interfaces from types, crypto, and SDK std.
+7 -6
View File
@@ -1,7 +1,7 @@
package encoding
import (
amino "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/types/module"
@@ -12,15 +12,16 @@ import (
// MakeConfig creates an EncodingConfig for testing
func MakeConfig(mb module.BasicManager) params.EncodingConfig {
cdc := amino.NewLegacyAmino()
amino := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := amino.NewProtoCodec(interfaceRegistry)
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)
encodingConfig := params.EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes),
Amino: cdc,
Codec: marshaler,
TxConfig: txCfg,
Amino: amino,
}
enccodec.RegisterLegacyAminoCodec(encodingConfig.Amino)
-1
View File
@@ -309,7 +309,6 @@ func traverseFields(
}
if fieldType.Kind() == reflect.Struct {
var fieldTypedef string
if isCollection {
+95 -58
View File
@@ -3,14 +3,17 @@ module github.com/tharsis/ethermint
go 1.17
require (
github.com/btcsuite/btcd v0.22.0-beta
cosmossdk.io/math v1.0.0-beta.2
github.com/99designs/gqlgen v0.17.2
github.com/btcsuite/btcd v0.22.1
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/cosmos/cosmos-sdk v0.45.1
github.com/cosmos/cosmos-sdk v0.46.0-rc1
github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/ibc-go/v3 v3.0.0
github.com/cosmos/ibc-go/v3 v3.0.0-alpha1.0.20220530074104-c7c115244bad
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.8.0
github.com/ethereum/go-ethereum v1.10.16
github.com/ethereum/go-ethereum v1.10.17
github.com/gibson042/canonicaljson-go v1.0.3
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
@@ -19,7 +22,9 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/holiman/uint256 v1.2.0
github.com/improbable-eng/grpc-web v0.15.0
github.com/ipfs/go-cid v0.0.4
github.com/ipfs/go-ipld-cbor v0.0.6
github.com/ipld/go-ipld-prime v0.16.0
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/multiformats/go-multihash v0.1.0
github.com/onsi/ginkgo v1.16.5
@@ -27,153 +32,185 @@ require (
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/rs/cors v1.8.2
github.com/spf13/cast v1.4.1
github.com/rs/zerolog v1.26.1
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.10.1
github.com/spf13/viper v1.12.0
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969
github.com/stretchr/testify v1.7.1
github.com/tendermint/tendermint v0.34.14
github.com/tendermint/tm-db v0.6.7
github.com/tendermint/tendermint v0.35.6
github.com/tyler-smith/go-bip39 v1.1.0
google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de
google.golang.org/grpc v1.45.0
github.com/vektah/gqlparser/v2 v2.4.1
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
google.golang.org/grpc v1.47.0
google.golang.org/protobuf v1.28.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
gopkg.in/yaml.v3 v3.0.0
)
require (
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
github.com/99designs/gqlgen v0.17.2 // indirect
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/compute v1.6.1 // indirect
cloud.google.com/go/iam v0.3.0 // indirect
cloud.google.com/go/storage v1.14.0 // indirect
cosmossdk.io/api v0.1.0-alpha8 // indirect
cosmossdk.io/errors v1.0.0-beta.6 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/keyring v1.1.6 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/Workiva/go-datastructures v1.0.52 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/agnivade/levenshtein v1.1.0 // indirect
github.com/armon/go-metrics v0.3.10 // indirect
github.com/armon/go-metrics v0.3.11 // indirect
github.com/aws/aws-sdk-go v1.40.45 // indirect
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/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.17.3 // indirect
github.com/cosmos/iavl v0.18.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/badger/v3 v3.2103.2 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/flatbuffers v2.0.0+incompatible // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.6.1 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.4.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huin/goupnp v1.0.2 // indirect
github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/ipfs/go-block-format v0.0.2 // indirect
github.com/ipfs/go-cid v0.0.3 // indirect
github.com/ipfs/go-ipfs-util v0.0.1 // indirect
github.com/ipfs/go-ipld-format v0.0.1 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/lib/pq v1.10.2 // indirect
github.com/lazyledger/smt v0.2.1-0.20210709230900-03ea40719554 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/highwayhash v1.0.1 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
github.com/multiformats/go-multibase v0.0.1 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20210609091139-0a56a4bca00b // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.29.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/rs/zerolog v1.23.0 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/vektah/gqlparser/v2 v2.4.1 // indirect
github.com/tendermint/tm-db v0.6.7 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158 // indirect
github.com/zondax/hid v0.9.0 // indirect
github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.9 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
google.golang.org/api v0.81.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
lukechampine.com/blake3 v1.1.6 // indirect
nhooyr.io/websocket v1.8.6 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
// replace cosmos
github.com/cosmos/cosmos-sdk => github.com/vulcanize/cosmos-sdk v0.46.0-smt-0.0.5-alpha
github.com/cosmos/cosmos-sdk/db => github.com/vulcanize/cosmos-sdk/db v1.0.0-beta.1
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
google.golang.org/grpc => google.golang.org/grpc v1.33.2
google.golang.org/grpc => google.golang.org/grpc v1.44.0
)
+767 -180
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -1,11 +1,11 @@
# Vulcanize dxns gql
# Vulcanize chiba-clonk gql
> Browser : http://localhost:9473 for gql
## Start server
```shell
./build/chibaclonkd start --gql-playground --gql-server
./build/chibaclonkd start --gql-playground --gql-server
```
Basic node status:
@@ -100,7 +100,7 @@ Query records.
```graphql
{
queryRecords(attributes: [{ key: "type", value: { string: "wrn:bot" } }]) {
queryRecords(attributes: [{ key: "type", value: { string: "crn:bot" } }]) {
id
names
bondId
@@ -316,7 +316,7 @@ LookUp Names
```graphql
{
lookupNames(names: ["wrn://hello/test"]){
lookupNames(names: ["crn://hello/test"]){
latest{
id
height
+2 -2
View File
@@ -988,7 +988,7 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er
}
var sources = []*ast.Source{
{Name: "vulcanize/dxns/schema.graphql", Input: `# Reference to another record.
{Name: "vulcanize/chiba-clonk/schema.graphql", Input: `# Reference to another record.
type Reference {
id: String! # ID of linked record.
}
@@ -1096,7 +1096,7 @@ type PeerInfo {
remote_ip: String!
}
# Vulcanize DXNS status.
# Vulcanize chiba-clonk status.
type Status {
version: String!
node: NodeInfo!
+1 -1
View File
@@ -4,7 +4,7 @@
# for detailed .gqlgen.yml documentation.
schema:
- vulcanize/dxns/*.graphql
- vulcanize/chiba-clonk/*.graphql
exec:
filename: generated.go
model:
+36 -25
View File
@@ -3,13 +3,14 @@ package gql
import (
"context"
"encoding/base64"
"strconv"
"github.com/cosmos/cosmos-sdk/client"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
bondtypes "github.com/tharsis/ethermint/x/bond/types"
nstypes "github.com/tharsis/ethermint/x/nameservice/types"
"strconv"
)
// DefaultLogNumLines is the number of log lines to tail by default.
@@ -75,17 +76,18 @@ func (q queryResolver) ResolveNames(ctx context.Context, names []string) ([]*Rec
nsQueryClient := nstypes.NewQueryClient(q.ctx)
var gqlResponse []*Record
for _, name := range names {
res, err := nsQueryClient.ResolveWrn(context.Background(), &nstypes.QueryResolveWrn{Wrn: name})
res, err := nsQueryClient.ResolveCrn(context.Background(), &nstypes.QueryResolveCrn{Crn: name})
if err != nil {
return nil, err
}
// Return nil for record not found.
gqlResponse = append(gqlResponse, nil)
} else {
gqlRecord, err := getGQLRecord(context.Background(), q, *res.GetRecord())
if err != nil {
return nil, err
}
gqlRecord, err := getGQLRecord(context.Background(), q, *res.GetRecord())
if err != nil {
return nil, err
gqlResponse = append(gqlResponse, gqlRecord)
}
gqlResponse = append(gqlResponse, gqlRecord)
}
return gqlResponse, nil
@@ -96,17 +98,18 @@ func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*Name
var gqlResponse []*NameRecord
for _, name := range names {
res, err := nsQueryClient.LookupWrn(context.Background(), &nstypes.QueryLookupWrn{Wrn: name})
res, err := nsQueryClient.LookupCrn(context.Background(), &nstypes.QueryLookupCrn{Crn: name})
if err != nil {
return nil, err
}
// Return nil for name not found.
gqlResponse = append(gqlResponse, nil)
} else {
gqlRecord, err := getGQLNameRecord(res.GetName())
if err != nil {
return nil, err
}
gqlRecord, err := getGQLNameRecord(res.GetName())
if err != nil {
return nil, err
gqlResponse = append(gqlResponse, gqlRecord)
}
gqlResponse = append(gqlResponse, gqlRecord)
}
return gqlResponse, nil
@@ -114,7 +117,14 @@ func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*Name
func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*Record, error) {
nsQueryClient := nstypes.NewQueryClient(q.ctx)
res, err := nsQueryClient.ListRecords(context.Background(), &nstypes.QueryListRecordsRequest{})
res, err := nsQueryClient.ListRecords(
context.Background(),
&nstypes.QueryListRecordsRequest{
Attributes: parseRequestAttributes(attributes),
All: (all != nil && *all),
},
)
if err != nil {
return nil, err
}
@@ -131,7 +141,6 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI
}
return gqlResponse, nil
}
func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error) {
@@ -141,13 +150,15 @@ func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Re
for i, id := range ids {
res, err := nsQueryClient.GetRecord(context.Background(), &nstypes.QueryRecordByIdRequest{Id: id})
if err != nil {
return nil, err
// Return nil for record not found.
gqlResponse[i] = nil
} else {
record, err := getGQLRecord(context.Background(), q, res.GetRecord())
if err != nil {
return nil, err
}
gqlResponse[i] = record
}
record, err := getGQLRecord(context.Background(), q, res.GetRecord())
if err != nil {
return nil, err
}
gqlResponse[i] = record
}
return gqlResponse, nil
+2 -1
View File
@@ -2,12 +2,13 @@ package gql
import (
"fmt"
"net/http"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground"
"github.com/cosmos/cosmos-sdk/client"
"github.com/ethereum/go-ethereum/log"
"github.com/spf13/viper"
"net/http"
)
// Server configures and starts the GQL server.
+12 -11
View File
@@ -2,15 +2,16 @@ package gql
import (
"context"
"github.com/cosmos/cosmos-sdk/client"
"os"
"os/exec"
"strconv"
"strings"
"github.com/cosmos/cosmos-sdk/client"
)
// NodeDataPath is the path to the ethermintd data folder.
var NodeDataPath = os.ExpandEnv("$HOME/.ethermintd/data")
// NodeDataPath is the path to the chibaclonkd data folder.
var NodeDataPath = os.ExpandEnv("$HOME/.chibaclonkd/data")
func getStatusInfo(client client.Context) (*NodeInfo, *SyncInfo, *ValidatorInfo, error) {
nodeClient, err := client.GetNode()
@@ -48,17 +49,17 @@ func getNetInfo(client client.Context) (string, []*PeerInfo, error) {
return "", nil, err
}
peers := netInfo.Peers
peersInfo := make([]*PeerInfo, len(peers))
for index, peer := range peers {
peersInfo := make([]*PeerInfo, netInfo.NPeers)
// TODO: find a way to get the peer information from nodeClient
for index, peer := range netInfo.Peers {
peersInfo[index] = &PeerInfo{
Node: &NodeInfo{
ID: string(peer.NodeInfo.ID()),
Moniker: peer.NodeInfo.Moniker,
Network: peer.NodeInfo.Network,
ID: string(peer.ID),
// Moniker: peer.Node.Moniker,
// Network: peer.Node.Network,
},
IsOutbound: peer.IsOutbound,
RemoteIP: peer.RemoteIP,
// IsOutbound: peer.IsOutbound,
// RemoteIP: peer.RemoteIP,
}
}
+54 -5
View File
@@ -3,12 +3,13 @@ package gql
import (
"context"
"encoding/json"
"reflect"
"strconv"
sdk "github.com/cosmos/cosmos-sdk/types"
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
bondtypes "github.com/tharsis/ethermint/x/bond/types"
nstypes "github.com/tharsis/ethermint/x/nameservice/types"
"reflect"
"strconv"
)
// OwnerAttributeName denotes the owner attribute name for a bond.
@@ -23,7 +24,7 @@ const ExpiryTimeAttributeName = "expiryTime"
func getGQLCoin(coin sdk.Coin) *Coin {
gqlCoin := Coin{
Type: coin.Denom,
Quantity: strconv.FormatInt(coin.Amount.Int64(), 10),
Quantity: coin.Amount.BigInt().String(),
}
return &gqlCoin
@@ -37,6 +38,7 @@ func getGQLCoins(coins sdk.Coins) []*Coin {
return gqlCoins
}
func GetGQLNameAuthorityRecord(record *nstypes.NameAuthority) (*AuthorityRecord, error) {
if record == nil {
return nil, nil
@@ -72,9 +74,10 @@ func getGQLRecord(ctx context.Context, resolver QueryResolver, record nstypes.Re
return &Record{
ID: record.Id,
BondID: record.GetBondId(),
CreateTime: record.GetCreateTime().String(),
ExpiryTime: record.GetExpiryTime().String(),
CreateTime: record.GetCreateTime(),
ExpiryTime: record.GetExpiryTime(),
Owners: record.GetOwners(),
Names: record.GetNames(),
Attributes: attributes,
References: references,
}, nil
@@ -265,3 +268,49 @@ func mapToKeyValuePairs(attrs map[string]interface{}) ([]*KeyValue, error) {
return kvPairs, nil
}
func parseRequestAttributes(attrs []*KeyValueInput) []*nstypes.QueryListRecordsRequest_KeyValueInput {
kvPairs := []*nstypes.QueryListRecordsRequest_KeyValueInput{}
for _, value := range attrs {
kvPair := &nstypes.QueryListRecordsRequest_KeyValueInput{
Key: value.Key,
Value: &nstypes.QueryListRecordsRequest_ValueInput{},
}
if value.Value.String != nil {
kvPair.Value.String_ = *value.Value.String
kvPair.Value.Type = "string"
}
if value.Value.Int != nil {
kvPair.Value.Int = int64(*value.Value.Int)
kvPair.Value.Type = "int"
}
if value.Value.Float != nil {
kvPair.Value.Float = *value.Value.Float
kvPair.Value.Type = "float"
}
if value.Value.Boolean != nil {
kvPair.Value.Boolean = *value.Value.Boolean
kvPair.Value.Type = "boolean"
}
if value.Value.Reference != nil {
reference := &nstypes.QueryListRecordsRequest_ReferenceInput{
Id: value.Value.Reference.ID,
}
kvPair.Value.Reference = reference
kvPair.Value.Type = "reference"
}
// TODO: Handle arrays.
kvPairs = append(kvPairs, kvPair)
}
return kvPairs
}
@@ -106,7 +106,7 @@ type PeerInfo {
remote_ip: String!
}
# Vulcanize DXNS status.
# Vulcanize chiba-clonk status.
type Status {
version: String!
node: NodeInfo!
+25 -1
View File
@@ -32,6 +32,30 @@ cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["staking"]["params"]
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="aphoton"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
# Custom modules
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["record_rent"]["denom"]="aphoton"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_rent"]["denom"]="aphoton"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_auction_commit_fee"]["denom"]="aphoton"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_auction_reveal_fee"]["denom"]="aphoton"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_auction_minimum_bid"]["denom"]="aphoton"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
if [[ "$TEST_NAMESERVICE_EXPIRY" == "true" ]]; then
echo "Setting timers for expiry tests."
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["record_rent_duration"]="60s"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_grace_period"]="60s"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_rent_duration"]="60s"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
fi
if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then
echo "Enabling auction and setting timers."
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_auction_enabled"]=true' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_rent_duration"]="60s"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_grace_period"]="300s"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_auction_commits_duration"]="60s"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["nameservice"]["params"]["authority_auction_reveals_duration"]="60s"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
fi
# increase block time (?)
cat $HOME/.chibaclonkd/config/genesis.json | jq '.consensus_params["block"]["time_iota_ms"]="1000"' > $HOME/.chibaclonkd/config/tmp_genesis.json && mv $HOME/.chibaclonkd/config/tmp_genesis.json $HOME/.chibaclonkd/config/genesis.json
@@ -87,4 +111,4 @@ if [[ $1 == "pending" ]]; then
fi
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
chibaclonkd start --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --gql-server --gql-playground
chibaclonkd start --mode validator --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --gql-server --gql-playground
+3 -2
View File
@@ -14,7 +14,8 @@ WORKDIR /go/src/github.com/vulcanize/chiba-clonk
COPY . .
# build binary
RUN make build-linux
# RUN make build-linux
RUN COSMOS_BUILD_OPTIONS=badgerdb make build
# Final image
@@ -30,4 +31,4 @@ COPY --from=build-env /go/src/github.com/vulcanize/chiba-clonk/build/chibaclonkd
EXPOSE 26656 26657 1317 9090 8545 8546
# Run ethermintd by default
CMD ["chibaclonkd","start","--gql-playground","--gql-server","--home","/chibaclonk"]
CMD ["chibaclonkd","start","--gql-playground","--gql-server","--home","/chibaclonk","--mode","validator","--db-backend","badgerdb"]
@@ -68,23 +68,22 @@ message Record {
string bond_id = 2 [
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
];
google.protobuf.Timestamp create_time = 3 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
string create_time = 3 [
(gogoproto.moretags) = "json:\"createTime\" yaml:\"createTime\""
];
google.protobuf.Timestamp expiry_time = 4 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
string expiry_time = 4 [
(gogoproto.moretags) = "json:\"expiryTime\" yaml:\"expiryTime\""
];
bool deleted = 5;
repeated string owners = 6 [
(gogoproto.moretags) = "json:\"owners\" yaml:\"owners\""
];
bytes attributes = 7 [
string attributes = 7 [
(gogoproto.moretags) = "json:\"attributes\" yaml:\"attributes\""
];
repeated string names = 8 [
(gogoproto.moretags) = "json:\"names\" yaml:\"names\""
];
}
// AuthorityEntry defines the nameservice module AuthorityEntries
+35 -15
View File
@@ -39,12 +39,12 @@ service Query {
rpc Whois(QueryWhoisRequest) returns (QueryWhoisResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/whois/{name}";
}
// LookupWrn
rpc LookupWrn(QueryLookupWrn) returns (QueryLookupWrnResponse){
// LookupCrn
rpc LookupCrn(QueryLookupCrn) returns (QueryLookupCrnResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/lookup";
}
// ResolveWrn
rpc ResolveWrn(QueryResolveWrn) returns (QueryResolveWrnResponse){
// ResolveCrn
rpc ResolveCrn(QueryResolveCrn) returns (QueryResolveCrnResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/resolve";
}
// GetRecordExpiryQueue
@@ -68,8 +68,28 @@ message QueryParamsResponse{
// QueryListRecordsRequest is request type for nameservice records list
message QueryListRecordsRequest{
message ReferenceInput {
string id = 1;
}
message ValueInput {
string type = 1;
string string = 2;
int64 int = 3;
double float = 4;
bool boolean = 5;
ReferenceInput reference = 6;
repeated ValueInput values = 7;
}
message KeyValueInput {
string key = 1;
ValueInput value = 2;
}
repeated KeyValueInput attributes = 1;
bool all = 2;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryListRecordsResponse is response type for nameservice records list
@@ -158,23 +178,23 @@ message QueryWhoisResponse{
];
}
// QueryLookupWrn is request type for LookupWrn
message QueryLookupWrn{
string wrn = 1;
// QueryLookupCrn is request type for LookupCrn
message QueryLookupCrn{
string crn = 1;
}
// QueryLookupWrnResponse is response type for QueryLookupWrn
message QueryLookupWrnResponse{
// QueryLookupCrnResponse is response type for QueryLookupCrn
message QueryLookupCrnResponse{
NameRecord name = 1;
}
// QueryResolveWrn is request type for ResolveWrn
message QueryResolveWrn{
string wrn = 1;
// QueryResolveCrn is request type for ResolveCrn
message QueryResolveCrn{
string crn = 1;
}
// QueryResolveWrnResponse is response type for QueryResolveWrn
message QueryResolveWrnResponse{
// QueryResolveCrnResponse is response type for QueryResolveCrn
message QueryResolveCrnResponse{
Record record = 1;
}
+4 -3
View File
@@ -20,7 +20,7 @@ service Msg {
rpc DissociateRecords(MsgDissociateRecords) returns (MsgDissociateRecordsResponse){}
// ReAssociateRecords
rpc ReAssociateRecords(MsgReAssociateRecords) returns (MsgReAssociateRecordsResponse){}
// SetName will store the name with given wrn and name
// SetName will store the name with given crn and name
rpc SetName(MsgSetName) returns (MsgSetNameResponse){}
// Reserve name
rpc ReserveName(MsgReserveAuthority) returns (MsgReserveAuthorityResponse){}
@@ -43,6 +43,7 @@ message MsgSetRecord{
// MsgSetRecordResponse
message MsgSetRecordResponse{
string id = 1;
}
// Payload
@@ -56,7 +57,7 @@ message Payload {
// MsgSetName
message MsgSetName{
string wrn = 1;
string crn = 1;
string cid = 2;
string signer = 3;
}
@@ -92,7 +93,7 @@ message MsgSetAuthorityBondResponse{
// MsgDeleteNameAuthority is SDK message for DeleteNameAuthority
message MsgDeleteNameAuthority{
string wrn = 1;
string crn = 1;
string signer = 2;
}
+74 -43
View File
@@ -3,6 +3,8 @@
package rpc
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
@@ -35,92 +37,96 @@ const (
apiVersion = "1.0"
)
// GetRPCAPIs returns the list of all APIs
func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, selectedAPIs []string) []rpc.API {
nonceLock := new(types.AddrLocker)
evmBackend := backend.NewEVMBackend(ctx, ctx.Logger, clientCtx)
// APICreator creates the json-rpc api implementations.
type APICreator = func(*server.Context, client.Context, *rpcclient.WSClient) []rpc.API
var apis []rpc.API
// remove duplicates
selectedAPIs = unique(selectedAPIs)
// apiCreators defines the json-rpc api namespaces.
var apiCreators map[string]APICreator
for index := range selectedAPIs {
switch selectedAPIs[index] {
case EthNamespace:
apis = append(apis,
rpc.API{
func init() {
apiCreators = map[string]APICreator{
EthNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient) []rpc.API {
nonceLock := new(types.AddrLocker)
evmBackend := backend.NewEVMBackend(ctx, ctx.Logger, clientCtx)
return []rpc.API{
{
Namespace: EthNamespace,
Version: apiVersion,
Service: eth.NewPublicAPI(ctx.Logger, clientCtx, evmBackend, nonceLock),
Public: true,
},
rpc.API{
{
Namespace: EthNamespace,
Version: apiVersion,
Service: filters.NewPublicAPI(ctx.Logger, clientCtx, tmWSClient, evmBackend),
Public: true,
},
)
case Web3Namespace:
apis = append(apis,
rpc.API{
}
},
Web3Namespace: func(*server.Context, client.Context, *rpcclient.WSClient) []rpc.API {
return []rpc.API{
{
Namespace: Web3Namespace,
Version: apiVersion,
Service: web3.NewPublicAPI(),
Public: true,
},
)
case NetNamespace:
apis = append(apis,
rpc.API{
}
},
NetNamespace: func(_ *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API {
return []rpc.API{
{
Namespace: NetNamespace,
Version: apiVersion,
Service: net.NewPublicAPI(clientCtx),
Public: true,
},
)
case PersonalNamespace:
apis = append(apis,
rpc.API{
}
},
PersonalNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API {
evmBackend := backend.NewEVMBackend(ctx, ctx.Logger, clientCtx)
return []rpc.API{
{
Namespace: PersonalNamespace,
Version: apiVersion,
Service: personal.NewAPI(ctx.Logger, clientCtx, evmBackend),
Public: false,
},
)
case TxPoolNamespace:
apis = append(apis,
rpc.API{
}
},
TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient) []rpc.API {
return []rpc.API{
{
Namespace: TxPoolNamespace,
Version: apiVersion,
Service: txpool.NewPublicAPI(ctx.Logger),
Public: true,
},
)
case DebugNamespace:
apis = append(apis,
rpc.API{
}
},
DebugNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API {
evmBackend := backend.NewEVMBackend(ctx, ctx.Logger, clientCtx)
return []rpc.API{
{
Namespace: DebugNamespace,
Version: apiVersion,
Service: debug.NewAPI(ctx, evmBackend, clientCtx),
Public: true,
},
)
case MinerNamespace:
apis = append(apis,
rpc.API{
}
},
MinerNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API {
evmBackend := backend.NewEVMBackend(ctx, ctx.Logger, clientCtx)
return []rpc.API{
{
Namespace: MinerNamespace,
Version: apiVersion,
Service: miner.NewPrivateAPI(ctx, clientCtx, evmBackend),
Public: false,
},
)
default:
ctx.Logger.Error("invalid namespace value", "namespace", selectedAPIs[index])
}
}
},
}
return apis
}
func unique(intSlice []string) []string {
@@ -134,3 +140,28 @@ func unique(intSlice []string) []string {
}
return list
}
// GetRPCAPIs returns the list of all APIs
func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, selectedAPIs []string) []rpc.API {
var apis []rpc.API
for _, ns := range selectedAPIs {
if creator, ok := apiCreators[ns]; ok {
apis = append(apis, creator(ctx, clientCtx, tmWSClient)...)
} else {
ctx.Logger.Error("invalid namespace value", "namespace", ns)
}
}
return apis
}
// RegisterAPINamespace registers a new API namespace with the API creator.
// This function fails if the namespace is already registered.
func RegisterAPINamespace(ns string, creator APICreator) error {
if _, ok := apiCreators[ns]; ok {
return fmt.Errorf("duplicated api namespace %s", ns)
}
apiCreators[ns] = creator
return nil
}
+4 -4
View File
@@ -1,7 +1,6 @@
package backend
import (
"bytes"
"context"
"encoding/json"
"fmt"
@@ -15,7 +14,8 @@ import (
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"
tmrpctypes "github.com/tendermint/tendermint/rpc/coretypes"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
@@ -334,8 +334,8 @@ func (e *EVMBackend) BlockBloom(height *int64) (ethtypes.Bloom, error) {
}
for _, attr := range event.Attributes {
if bytes.Equal(attr.Key, bAttributeKeyEthereumBloom) {
return ethtypes.BytesToBloom(attr.Value), nil
if attr.Key == string(bAttributeKeyEthereumBloom) {
return ethtypes.BytesToBloom([]byte(attr.Value)), nil
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"
tmrpctypes "github.com/tendermint/tendermint/rpc/coretypes"
rpctypes "github.com/tharsis/ethermint/rpc/ethereum/types"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
)
+2 -3
View File
@@ -55,7 +55,6 @@ func (e *EVMBackend) SetTxDefaults(args evmtypes.TransactionArgs) (evmtypes.Tran
if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
return args, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
}
} else {
if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil {
return args, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
@@ -238,12 +237,12 @@ func TxLogsFromEvents(events []abci.Event, msgIndex int) ([]*ethtypes.Log, error
func ParseTxLogsFromEvent(event abci.Event) ([]*ethtypes.Log, error) {
logs := make([]*evmtypes.Log, 0, len(event.Attributes))
for _, attr := range event.Attributes {
if !bytes.Equal(attr.Key, []byte(evmtypes.AttributeKeyTxLog)) {
if !bytes.Equal([]byte(attr.Key), []byte(evmtypes.AttributeKeyTxLog)) {
continue
}
var log evmtypes.Log
if err := json.Unmarshal(attr.Value, &log); err != nil {
if err := json.Unmarshal([]byte(attr.Value), &log); err != nil {
return nil, err
}
+2 -2
View File
@@ -14,7 +14,7 @@ import (
"time"
"github.com/davecgh/go-spew/spew"
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"
tmrpctypes "github.com/tendermint/tendermint/rpc/coretypes"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
@@ -284,7 +284,7 @@ func (a *API) BlockProfile(file string, nsec uint) error {
// CpuProfile turns on CPU profiling for nsec seconds and writes
// profile data to file.
func (a *API) CpuProfile(file string, nsec uint) error { // nolint: golint, stylecheck, revive
func (a *API) CpuProfile(file string, nsec uint) error { //nolint: golint, stylecheck, revive
a.logger.Debug("debug_cpuProfile", "file", file, "nsec", nsec)
if err := a.StartCPUProfile(file); err != nil {
return err
+8 -3
View File
@@ -20,7 +20,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/log"
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"
tmrpctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
@@ -74,6 +74,7 @@ func NewPublicAPI(
viper.GetString(flags.FlagKeyringBackend),
clientCtx.KeyringDir,
clientCtx.Input,
clientCtx.Codec,
hd.EthSecp256k1Option(),
)
if err != nil {
@@ -126,7 +127,7 @@ func (e *PublicAPI) ProtocolVersion() hexutil.Uint {
}
// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
func (e *PublicAPI) ChainId() (*hexutil.Big, error) { // nolint
func (e *PublicAPI) ChainId() (*hexutil.Big, error) { //nolint
e.logger.Debug("eth_chainId")
// if current block is at or past the EIP-155 replay-protection fork block, return chainID from config
bn, err := e.backend.BlockNumber()
@@ -242,7 +243,11 @@ func (e *PublicAPI) Accounts() ([]common.Address, error) {
}
for _, info := range infos {
addressBytes := info.GetPubKey().Address().Bytes()
pubKey, err := info.GetPubKey()
if err != nil {
return addresses, err
}
addressBytes := pubKey.Address().Bytes()
addresses = append(addresses, common.BytesToAddress(addressBytes))
}
+10 -4
View File
@@ -11,7 +11,7 @@ import (
"github.com/tendermint/tendermint/libs/log"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
coretypes "github.com/tendermint/tendermint/rpc/coretypes"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
tmtypes "github.com/tendermint/tendermint/types"
@@ -371,7 +371,13 @@ func (api *PublicFilterAPI) Logs(ctx context.Context, crit filters.FilterCriteri
}
// filter only events from EVM module txs
_, isMsgEthereumTx := ev.Events[evmtypes.TypeMsgEthereumTx]
var isMsgEthereumTx bool
for _, event := range ev.Events {
if event.Type == evmtypes.TypeMsgEthereumTx {
isMsgEthereumTx = true
}
}
if !isMsgEthereumTx {
// ignore transaction as it's not from the evm module
@@ -385,7 +391,7 @@ func (api *PublicFilterAPI) Logs(ctx context.Context, crit filters.FilterCriteri
continue
}
txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data)
txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data, api.clientCtx.Codec)
if err != nil {
return
}
@@ -461,7 +467,7 @@ func (api *PublicFilterAPI) NewFilter(criteria filters.FilterCriteria) (rpc.ID,
continue
}
txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data)
txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data, api.clientCtx.Codec)
if err != nil {
return
}
@@ -11,7 +11,7 @@ import (
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
coretypes "github.com/tendermint/tendermint/rpc/coretypes"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
tmtypes "github.com/tendermint/tendermint/types"
@@ -27,9 +27,9 @@ import (
)
var (
txEvents = tmtypes.QueryForEvent(tmtypes.EventTx).String()
evmEvents = tmquery.MustParse(fmt.Sprintf("%s='%s' AND %s.%s='%s'", tmtypes.EventTypeKey, tmtypes.EventTx, sdk.EventTypeMessage, sdk.AttributeKeyModule, evmtypes.ModuleName)).String()
headerEvents = tmtypes.QueryForEvent(tmtypes.EventNewBlockHeader).String()
txEvents = tmtypes.QueryForEvent(tmtypes.EventTxValue).String()
evmEvents = tmquery.MustCompile(fmt.Sprintf("%s='%s' AND %s.%s='%s'", tmtypes.EventTypeKey, tmtypes.EventTxValue, sdk.EventTypeMessage, sdk.AttributeKeyModule, evmtypes.ModuleName)).String()
headerEvents = tmtypes.QueryForEvent(tmtypes.EventNewBlockHeaderValue).String()
)
// EventSystem creates subscriptions, processes events and broadcasts them to the
@@ -45,7 +45,7 @@ func NewRangeFilter(logger log.Logger, backend Backend, begin, end int64, addres
// Flatten the address and topic filter clauses into a single bloombits filter
// system. Since the bloombits are not positional, nil topics are permitted,
// which get flattened into a nil byte slice.
var filtersBz [][][]byte // nolint: prealloc
var filtersBz [][][]byte //nolint: prealloc
if len(addresses) > 0 {
filter := make([][]byte, len(addresses))
for i, address := range addresses {
@@ -7,7 +7,7 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/rpc"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
coretypes "github.com/tendermint/tendermint/rpc/coretypes"
)
// Subscription defines a wrapper for the private subscription
+1 -1
View File
@@ -124,7 +124,7 @@ func (api *API) SetEtherbase(etherbase common.Address) bool {
return false
}
if err := tx.Sign(txFactory, keyInfo.GetName(), builder, false); err != nil {
if err := tx.Sign(txFactory, keyInfo.Name, builder, false); err != nil {
api.logger.Debug("failed to sign tx", "error", err.Error())
return false
}
+7 -2
View File
@@ -102,7 +102,11 @@ func (api *PrivateAccountAPI) ListAccounts() ([]common.Address, error) {
}
for _, info := range list {
addrs = append(addrs, common.BytesToAddress(info.GetPubKey().Address()))
pubKey, err := info.GetPubKey()
if err != nil {
return nil, err
}
addrs = append(addrs, common.BytesToAddress(pubKey.Address()))
}
return addrs, nil
@@ -131,7 +135,8 @@ func (api *PrivateAccountAPI) NewAccount(password string) (common.Address, error
return common.Address{}, err
}
addr := common.BytesToAddress(info.GetPubKey().Address().Bytes())
pubKeyAddr, err := info.GetAddress()
addr := common.BytesToAddress(pubKeyAddr.Bytes())
api.logger.Info("Your new key was generated", "address", addr.String())
api.logger.Info("Please backup your key file!", "path", os.Getenv("HOME")+"/.ethermint/"+name) // TODO: pass the correct binary
api.logger.Info("Please remember your password!")
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"github.com/pkg/errors"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
coretypes "github.com/tendermint/tendermint/rpc/coretypes"
)
type UnsubscribeFunc func()
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"time"
"github.com/stretchr/testify/require"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
coretypes "github.com/tendermint/tendermint/rpc/coretypes"
)
func TestAddTopic(t *testing.T) {
+11 -3
View File
@@ -242,7 +242,7 @@ func BaseFeeFromEvents(events []abci.Event) *big.Int {
}
for _, attr := range event.Attributes {
if bytes.Equal(attr.Key, []byte(feemarkettypes.AttributeKeyBaseFee)) {
if attr.Key == feemarkettypes.AttributeKeyBaseFee {
result, success := new(big.Int).SetString(string(attr.Value), 10)
if success {
return result
@@ -250,6 +250,14 @@ func BaseFeeFromEvents(events []abci.Event) *big.Int {
return nil
}
// if bytes.Equal(attr.Key, []byte(feemarkettypes.AttributeKeyBaseFee)) {
// result, success := new(big.Int).SetString(string(attr.Value), 10)
// if success {
// return result
// }
// return nil
// }
}
}
return nil
@@ -310,10 +318,10 @@ func FindTxAttributesByIndex(events []abci.Event, txIndex uint64) int {
// FindAttribute find event attribute with specified key, if not found returns nil.
func FindAttribute(attrs []abci.EventAttribute, key []byte) []byte {
for _, attr := range attrs {
if !bytes.Equal(attr.Key, key) {
if !bytes.Equal([]byte(attr.Key), key) {
continue
}
return attr.Value
return []byte(attr.Value)
}
return nil
}
+1 -1
View File
@@ -536,7 +536,7 @@ func (api *pubSubAPI) subscribeLogs(wsConn *wsConn, subID rpc.ID, extra interfac
continue
}
txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data)
txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data, api.clientCtx.Codec)
if err != nil {
api.logger.Error("failed to decode tx response", "error", err.Error())
return
+1 -1
View File
@@ -35,7 +35,7 @@ cat $HOME/.chibaclonkd/config/genesis.json | jq '.app_state["mint"]["params"]["m
"$PWD"/build/chibaclonkd validate-genesis
# Start the node (remove the --pruning=nothing flag if historical queries are not needed) in background and log to file
"$PWD"/build/chibaclonkd start --pruning=nothing --rpc.unsafe --json-rpc.address="0.0.0.0:8545" --keyring-backend test > ethermintd.log 2>&1 &
"$PWD"/build/chibaclonkd start --pruning=nothing --mode validator --rpc.unsafe --json-rpc.address="0.0.0.0:8545" --keyring-backend test > ethermintd.log 2>&1 &
# Give ethermintd node enough time to launch
sleep 5
+26 -22
View File
@@ -17,10 +17,10 @@ RPC_PORT="854"
IP_ADDR="0.0.0.0"
KEY="mykey"
CHAINID="ethermint_9000-1"
CHAINID="chibaclonk_9000-1"
MONIKER="mymoniker"
## default port prefixes for ethermintd
## default port prefixes for chibaclonkd
NODE_P2P_PORT="2660"
NODE_PORT="2663"
NODE_RPC_PORT="2666"
@@ -32,6 +32,7 @@ usage() {
echo "-q <number> -- Quantity of nodes to run. eg: 3"
echo "-z <number> -- Quantity of nodes to run tests against eg: 3"
echo "-s <number> -- Sleep between operations in secs. eg: 5"
echo "-m <string> -- Mode for testing. eg: rpc"
echo "-r <string> -- Remove test dir after, eg: true, default is false"
exit 1
}
@@ -52,15 +53,15 @@ done
set -euxo pipefail
DATA_DIR=$(mktemp -d -t ethermint-datadir.XXXXX)
DATA_DIR=$(mktemp -d -t chibaclonk-datadir.XXXXX)
if [[ ! "$DATA_DIR" ]]; then
echo "Could not create $DATA_DIR"
exit 1
fi
# Compile ethermint
echo "compiling ethermint"
# Compile chibaclonk
echo "compiling chibaclonk"
make build
# PID array declaration
@@ -103,18 +104,22 @@ init_func() {
}
start_func() {
echo "starting ethermint node $i in background ..."
"$PWD"/build/chibaclonkd start --pruning=nothing --rpc.unsafe \
--p2p.laddr tcp://$IP_ADDR:$NODE_P2P_PORT"$i" --address tcp://$IP_ADDR:$NODE_PORT"$i" --rpc.laddr tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--json-rpc.address=$IP_ADDR:$RPC_PORT"$i" \
--json-rpc.api="eth,txpool,personal,net,debug,web3" \
--keyring-backend test --home "$DATA_DIR$i" \
echo "starting chibaclonk node $i in background ..."
"$PWD"/build/chibaclonkd start \
--pruning=nothing --rpc.unsafe \
--p2p.laddr tcp://$IP_ADDR:$NODE_P2P_PORT"$i" \
--address tcp://$IP_ADDR:$NODE_PORT"$i" \
--rpc.laddr tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--json-rpc.address=$IP_ADDR:$RPC_PORT"$i" \
--json-rpc.api="eth,txpool,personal,net,debug,web3" \
--keyring-backend test --mode validator --home "$DATA_DIR$i" \
--log_level debug \
>"$DATA_DIR"/node"$i".log 2>&1 & disown
ETHERMINT_PID=$!
echo "started ethermint node, pid=$ETHERMINT_PID"
CHIBACLONK_PID=$!
echo "started chibaclonk node, pid=$CHIBACLONK_PID"
# add PID to array
arr+=("$ETHERMINT_PID")
arr+=("$CHIBACLONK_PID")
if [[ $MODE == "pending" ]]; then
echo "waiting for the first block..."
@@ -144,7 +149,7 @@ if [[ -z $TEST || $TEST == "integration" ]] ; then
for i in $(seq 1 "$TEST_QTD"); do
HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i"
echo "going to test ethermint node $HOST_RPC ..."
echo "going to test chibaclonk node $HOST_RPC ..."
MODE=$MODE HOST=$HOST_RPC go test ./tests/e2e/... -timeout=$time_out -v -short
TEST_FAIL=$?
done
@@ -158,21 +163,20 @@ if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then
for i in $(seq 1 "$TEST_QTD"); do
HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i"
echo "going to test ethermint node $HOST_RPC ..."
echo "going to test chibaclonk node $HOST_RPC ..."
MODE=$MODE HOST=$HOST_RPC go test ./tests/rpc/... -timeout=$time_out -v -short
TEST_FAIL=$?
done
fi
stop_func() {
ETHERMINT_PID=$i
echo "shutting down node, pid=$ETHERMINT_PID ..."
CHIBACLONK_PID=$i
echo "shutting down node, pid=$CHIBACLONK_PID ..."
# Shutdown ethermint node
kill -9 "$ETHERMINT_PID"
wait "$ETHERMINT_PID"
# Shutdown chibaclonk node
kill -9 "$CHIBACLONK_PID"
wait "$CHIBACLONK_PID"
if [ $REMOVE_DATA_DIR == "true" ]
then
+1 -1
View File
@@ -3,7 +3,7 @@ export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin
# remove existing daemon
rm -rf ~/.ethermintd
rm -rf ~/.chibaclonk*
# build ethermint binary
make install
+2 -1
View File
@@ -6,7 +6,8 @@ chibaclonkd validate-genesis --home /chibaclonk
echo "starting chibaclonk node $ID in background ..."
chibaclonkd start \
--home /chibaclonk \
--keyring-backend test
--keyring-backend test \
--mode validator
echo "started ethermint node"
tail -f /dev/null
+7 -7
View File
@@ -61,8 +61,8 @@ if [[ ! "$DATA_CLI_DIR" ]]; then
exit 1
fi
# Compile ethermint
echo "compiling ethermint"
# Compile chibaclonk
echo "compiling chibaclonk"
make build
# PID array declaration
@@ -89,15 +89,15 @@ init_func() {
}
start_func() {
echo "starting ethermint node $i in background ..."
echo "starting chibaclonk node $i in background ..."
"$PWD"/build/chibaclonkd start --pruning=nothing --rpc.unsafe \
--p2p.laddr tcp://$IP_ADDR:$NODE_P2P_PORT"$i" --address tcp://$IP_ADDR:$NODE_PORT"$i" --rpc.laddr tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--json-rpc.address=$IP_ADDR:$RPC_PORT"$i" \
--keyring-backend test --home "$DATA_DIR$i" \
--keyring-backend test --mode validator --home "$DATA_DIR$i" \
>"$DATA_DIR"/node"$i".log 2>&1 & disown
ETHERMINT_PID=$!
echo "started ethermint node, pid=$ETHERMINT_PID"
echo "started chibaclonk node, pid=$ETHERMINT_PID"
# add PID to array
arr+=("$ETHERMINT_PID")
}
@@ -123,7 +123,7 @@ if [[ -z $TEST || $TEST == "rpc" ]]; then
for i in $(seq 1 "$TEST_QTD"); do
HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i"
echo "going to test ethermint node $HOST_RPC ..."
echo "going to test chibaclonk node $HOST_RPC ..."
MODE=$MODE HOST=$HOST_RPC go test ./tests/e2e/... -timeout=300s -v -short
MODE=$MODE HOST=$HOST_RPC go test ./tests/rpc/... -timeout=300s -v -short
@@ -136,7 +136,7 @@ stop_func() {
ETHERMINT_PID=$i
echo "shutting down node, pid=$ETHERMINT_PID ..."
# Shutdown ethermint node
# Shutdown chibaclonk node
kill -9 "$ETHERMINT_PID"
wait "$ETHERMINT_PID"
}
+59 -46
View File
@@ -16,36 +16,42 @@ import (
"github.com/spf13/cobra"
tmservice "github.com/tendermint/tendermint/libs/service"
"google.golang.org/grpc"
abciserver "github.com/tendermint/tendermint/abci/server"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
tmos "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/rpc/client/local"
dbm "github.com/tendermint/tm-db"
"github.com/cosmos/cosmos-sdk/server/rosetta"
crgserver "github.com/cosmos/cosmos-sdk/server/rosetta/lib/server"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
dbm "github.com/cosmos/cosmos-sdk/db"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/api"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
"github.com/cosmos/cosmos-sdk/server/rosetta"
crgserver "github.com/cosmos/cosmos-sdk/server/rosetta/lib/server"
"github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
abciclient "github.com/tendermint/tendermint/abci/client"
abciserver "github.com/tendermint/tendermint/abci/server"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
tmos "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/rpc/client/local"
tmtypes "github.com/tendermint/tendermint/types"
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
"github.com/tharsis/ethermint/gql"
ethdebug "github.com/tharsis/ethermint/rpc/ethereum/namespaces/debug"
"github.com/tharsis/ethermint/server/config"
srvflags "github.com/tharsis/ethermint/server/flags"
)
"github.com/tharsis/ethermint/gql"
const (
// gRPC-related flags
flagGRPCOnly = "grpc-only"
flagGRPCEnable = "grpc.enable"
flagGRPCAddress = "grpc.address"
flagGRPCWebEnable = "grpc-web.enable"
flagGRPCWebAddress = "grpc-web.address"
)
// StartCmd runs the service passed in, either stand-alone or in-process with
@@ -139,9 +145,8 @@ which accepts a path for the resulting pprof file.
cmd.Flags().Bool(server.FlagInterBlockCache, true, "Enable inter-block caching")
cmd.Flags().String(srvflags.CPUProfile, "", "Enable CPU profiling and write to the provided file")
cmd.Flags().Bool(server.FlagTrace, false, "Provide full stack traces for errors in ABCI Log")
cmd.Flags().String(server.FlagPruning, storetypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)")
cmd.Flags().String(server.FlagPruning, pruningtypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)")
cmd.Flags().Uint64(server.FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')")
cmd.Flags().Uint64(server.FlagPruningKeepEvery, 0, "Offset heights to keep on disk after 'keep-every' (ignored if pruning is not 'custom')")
cmd.Flags().Uint64(server.FlagPruningInterval, 0, "Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom')")
cmd.Flags().Uint(server.FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks")
cmd.Flags().Uint64(server.FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks")
@@ -186,10 +191,11 @@ func startStandAlone(ctx *server.Context, appCreator types.AppCreator) error {
transport := ctx.Viper.GetString(srvflags.Transport)
home := ctx.Viper.GetString(flags.FlagHome)
db, err := openDB(home)
db, err := openDB(home, server.GetAppDBBackend((ctx.Viper)))
if err != nil {
return err
}
defer func() {
if err := db.Close(); err != nil {
ctx.Logger.With("error", err).Error("error closing db")
@@ -261,9 +267,8 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
}
traceWriterFile := ctx.Viper.GetString(srvflags.TraceStore)
db, err := openDB(home)
db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
if err != nil {
logger.Error("failed to open DB", "error", err.Error())
return err
}
defer func() {
@@ -294,38 +299,46 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper)
nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
genDoc, err := tmtypes.GenesisDocFromFile(cfg.GenesisFile())
if err != nil {
logger.Error("failed load or gen node key", "error", err.Error())
return err
}
genDocProvider := node.DefaultGenesisDocProviderFunc(cfg)
tmNode, err := node.NewNode(
cfg,
pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()),
nodeKey,
proxy.NewLocalClientCreator(app),
genDocProvider,
node.DefaultDBProvider,
node.DefaultMetricsProvider(cfg.Instrumentation),
ctx.Logger.With("server", "node"),
var (
tmNode tmservice.Service
gRPCOnly = ctx.Viper.GetBool(flagGRPCOnly)
)
if err != nil {
logger.Error("failed init node", "error", err.Error())
return err
}
if gRPCOnly {
ctx.Logger.Info("starting node in gRPC only mode; Tendermint is disabled")
config.GRPC.Enable = true
} else {
ctx.Logger.Info("starting node with ABCI Tendermint in-process")
if err := tmNode.Start(); err != nil {
logger.Error("failed start tendermint server", "error", err.Error())
return err
tmNode, err = node.New(cfg, ctx.Logger, abciclient.NewLocalCreator(app), genDoc)
if err != nil {
return err
}
if err := tmNode.Start(); err != nil {
return err
}
}
// Add the tx service to the gRPC router. We only need to register this
// service if API or gRPC or JSONRPC is enabled, and avoid doing so in the general
// case, because it spawns a new local tendermint RPC client.
if config.API.Enable || config.GRPC.Enable || config.JSONRPC.Enable {
clientCtx = clientCtx.WithClient(local.New(tmNode))
node, ok := tmNode.(local.NodeService)
if !ok {
return fmt.Errorf("unable to set node type; please try re-installing the binary")
}
localNode, err := local.New(node)
if err != nil {
return err
}
clientCtx = clientCtx.WithClient(localNode)
app.RegisterTxService(clientCtx)
app.RegisterTendermintService(clientCtx)
@@ -333,7 +346,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
var apiSrv *api.Server
if config.API.Enable {
genDoc, err := genDocProvider()
genDoc, err := tmtypes.GenesisDocFromFile(cfg.GenesisFile())
if err != nil {
return err
}
@@ -364,7 +377,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
grpcWebSrv *http.Server
)
if config.GRPC.Enable {
grpcSrv, err = servergrpc.StartGRPCServer(clientCtx, app, config.GRPC.Address)
grpcSrv, err = servergrpc.StartGRPCServer(clientCtx, app, config.GRPC)
if err != nil {
return err
}
@@ -419,7 +432,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
)
if config.JSONRPC.Enable {
genDoc, err := genDocProvider()
genDoc, err := tmtypes.GenesisDocFromFile(cfg.GenesisFile())
if err != nil {
return err
}
@@ -481,9 +494,9 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
return server.WaitForQuitSignals()
}
func openDB(rootDir string) (dbm.DB, error) {
func openDB(rootDir string, backendType dbm.BackendType) (dbm.DBConnection, error) {
dataDir := filepath.Join(rootDir, "data")
return sdk.NewLevelDB("application", dataDir)
return dbm.NewDB("application", backendType, dataDir)
}
func openTraceWriter(traceWriterFile string) (w io.Writer, err error) {
+16 -12
View File
@@ -11,6 +11,7 @@ import (
sdkserver "github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/version"
tmcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
tmlog "github.com/tendermint/tendermint/libs/log"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
@@ -28,6 +29,10 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type
sdkserver.ShowValidatorCmd(),
sdkserver.ShowAddressCmd(),
sdkserver.VersionCmd(),
tmcmd.ResetAllCmd,
tmcmd.ResetStateCmd,
tmcmd.InspectCmd,
sdkserver.MakeKeyMigrateCmd(),
)
startCmd := StartCmd(appCreator, defaultNodeHome)
@@ -35,7 +40,6 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type
rootCmd.AddCommand(
startCmd,
sdkserver.UnsafeResetAllCmd(),
tendermintCmd,
sdkserver.ExportCmd(appExport, defaultNodeHome),
version.NewVersionCommand(),
@@ -43,15 +47,16 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type
}
func ConnectTmWS(tmRPCAddr, tmEndpoint string, logger tmlog.Logger) *rpcclient.WSClient {
tmWsClient, err := rpcclient.NewWS(tmRPCAddr, tmEndpoint,
rpcclient.MaxReconnectAttempts(256),
rpcclient.ReadWait(120*time.Second),
rpcclient.WriteWait(120*time.Second),
rpcclient.PingPeriod(50*time.Second),
rpcclient.OnReconnect(func() {
logger.Debug("EVM RPC reconnects to Tendermint WS", "address", tmRPCAddr+tmEndpoint)
}),
)
tmWsClient, err := rpcclient.NewWSWithOptions(tmRPCAddr, tmEndpoint, rpcclient.WSOptions{
MaxReconnectAttempts: 256, // first: 2 sec, last: 17 min.
WriteWait: 120 * time.Second,
ReadWait: 120 * time.Second,
PingPeriod: 50 * time.Second,
})
tmWsClient.OnReconnect(func() {
logger.Debug("EVM RPC reconnects to Tendermint WS", "address", tmRPCAddr+tmEndpoint)
})
if err != nil {
logger.Error(
@@ -59,7 +64,7 @@ func ConnectTmWS(tmRPCAddr, tmEndpoint string, logger tmlog.Logger) *rpcclient.W
"address", tmRPCAddr+tmEndpoint,
"error", err,
)
} else if err := tmWsClient.OnStart(); err != nil {
} else if err := tmWsClient.Start(); err != nil {
logger.Error(
"Tendermint WS client could not start",
"address", tmRPCAddr+tmEndpoint,
@@ -77,7 +82,6 @@ func MountGRPCWebServices(
logger tmlog.Logger,
) {
for _, res := range grpcResources {
logger.Info("[GRPC Web] HTTP POST mounted", "resource", res)
s := router.Methods("POST").Subrouter()
+11
View File
@@ -0,0 +1,11 @@
# Testnet
## Setup local chibaclonk multi node testnet in local enviorment
```shell
$ bash multinode_testnet.sh
or
# this is create localnet with docker containers
$ make localnet-start
```
+205
View File
@@ -0,0 +1,205 @@
# Instructions to Run Full Node
Hardware
---
#### Supported
- **Operating System (OS):** Ubuntu 20.04
- **CPU:** 1 core
- **RAM:** 2GB
- **Storage:** 25GB SSD
#### Recommended
- **Operating System (OS):** Ubuntu 20.04
- **CPU:** 2 core
- **RAM:** 4GB
- **Storage:** 50GB SSD
# A) Setup
## 1) Install Golang (go)
1.1) Remove any existing installation of `go`
```
sudo rm -rf /usr/local/go
```
1.2) Install latest/required Go version (installing `go1.17.2`)
```
curl https://golang.org/dl/go1.17.2.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.17.2.linux-amd64.tar.gz
```
1.3) Update env variables to include `go`
```
cat <<'EOF' >>$HOME/.profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
EOF
source $HOME/.profile
```
1.4) Check the version of go installed
```
go version
```
### 2) Install required software packages
```
sudo apt-get install git curl build-essential make jq -y
```
### 3) Install `chibaclonkd`
```
git clone https://github.com/vulcanize/chiba-clonk.git
cd chiba-clonk
git fetch --all
git checkout main
make install
```
### 4) Verify your installation
```
chibaclonkd version --long
```
On running the above command, you should see a similar response like this. Make sure that the *version* and *commit
hash* are accurate
```
name: chibaclonkd
server_name: chibaclonkd
```
### 5) Initialize Node
**Not required if you have already initialized before**
```
chibaclonkd init <your-node-moniker> --chain-id chibaclonk_81337-2
```
On running the above command, node will be initialized with default configuration. (config files will be saved in node's
default home directory (~/.chibaclonkd/config)
NOTE: Backup node and validator keys . You will need to use these keys at a later point in time.
---
# B) Starting Node
## 1) Download Final Genesis
Use `curl` to download the genesis file
**Replace your **genesis** file with published genesis file**
```shell
# Will be updated
curl {GENESIS_LINK} | jq .result.genesis > ~/.chibaclonkd/config/genesis.json
```
Verify sha256 hash of genesis file with the below command
```
jq -S -c -M '' ~/.chibaclonkd/config/genesis.json | shasum -a 256
```
genesis sha256 hash should be
```
{WILL BE UPDATED}
```
## 2) Update Peers & Seeds in config.toml
```
<!-- Note: don't use peers
peers="5ad2e6c35f2c84ff3ee31d89a95b34d92cb6afb1@157.230.101.237:26656,defc95b08547b6ef254723ad9621967a7e819020@161.35.223.44:26656" -->
{peers={WILL BE UPDATED}}
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" ~/.chibaclonkd/config/config.toml
```
## 3) Start the Full Node
#### 3.1) Start node as `systemctl` service
3.1.1) Create the service file
```
sudo tee /etc/systemd/system/chibaclonkd.service > /dev/null <<EOF
[Unit]
Description=chibaclonkd Daemon
After=network-online.target
[Service]
User=$USER
ExecStart=$(which chibaclonkd) start --gql-playground --gql-server
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
```
3.1.2) Load service and start
```
sudo systemctl daemon-reload
sudo systemctl enable chibaclonkd
sudo systemctl start chibaclonkd
```
3.1.3) Check status of service
```
sudo systemctl status chibaclonkd
```
`NOTE:`
A helpful command here is `journalctl` that can be used to:
a) check logs
```
journalctl -u chibaclonkd
```
b) most recent logs
```
journalctl -xeu chibaclonkd
```
c) logs from previous day
```
journalctl --since "1 day ago" -u chibaclonkd
```
d) Check logs with follow flag
```
journalctl -f -u chibaclonkd
```
+274
View File
@@ -0,0 +1,274 @@
# Validator Guide for chibaclonk_81337-4 Testnet
## Hardware Prerequisites
### Supported
- **Operating System (OS):** Ubuntu 20.04
- **CPU:** 1 core
- **RAM:** 2GB
- **Storage:** 25GB SSD
### Recommended
- **Operating System (OS):** Ubuntu 20.04
- **CPU:** 2 core
- **RAM:** 4GB
- **Storage:** 50GB SSD
## Network Prerequisites
- **TCP 26656** for Peer-to-Peer Network Communication
- **TCP 26660** for Prometheus Metrics (doesn't have to be exposed publicly)
# Validator Setup
## Install required software packages
```sh
# Update Ubuntu
sudo apt update
sudo apt upgrade -y
# Install required software packages
sudo apt install git curl build-essential make jq -y
```
---
## Install Go
```sh
# Remove any existing installation of `go`
sudo rm -rf /usr/local/go
# Install Go version 1.17.2
curl https://dl.google.com/go/go1.17.2.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf -
# Update env variables to include go
cat <<'EOF' >>$HOME/.profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
EOF
source $HOME/.profile
```
Check the version of go installed
```sh
go version
# Should return something like: go version go1.17.2 linux/amd64
```
---
## Install `chibaclonk`
```sh
git clone https://github.com/vulcanize/chiba-clonk.git
cd chiba-clonk
# Checkout main branch
git fetch --all
git checkout main
# Build and install chibaclonk
make install
```
Verify your installation
```sh
chibaclonkd version --long
```
On running the above command, you should see a similar response like this. Make sure that the *version* and *commit
hash* are accurate
```sh
name: chibaclonk
server_name: chibaclonkd
```
---
## Initialize Validator Node
**Not required if you have already initialized before**
```sh
# Initialize the validator node
chibaclonkd init <your-node-moniker> --chain-id chibaclonk_81337-4
```
Running the above commands will initialize the validator node with default configuration. The config files will be saved in the default location (`~/.chibaclonkd/config`).
**NOTE:** Backup your node and validator keys. You will need to use these keys at a later point in time.
---
## Overwrite Validator Initialization from previous testnet
**Required for `chibaclonk_81337-4`**
First we have to reset the previous genesis state (only because the `chibaclonk_81337-3` testnet failed) whereafter we can initialize the validator node for `chibaclonk_81337-4`
```sh
# Stop your node (in case it was still running)
systemctl stop chibaclonkd
# Keep a backup of your old validator directory
cp -a ~/.chibaclonkd ~/backup-chibaclonk_81337-2
# Reset the state of your validator
chibaclonkd tendermint unsafe-reset-all --home $HOME/.chibaclonkd
# Remove your previous genesis transactions
rm $HOME/.chibaclonkd/config/gentx/gentx*.json
# Overwrite your genesis state with the new chain-id
chibaclonkd init --overwrite <your-node-moniker> --chain-id chibaclonk_81337-4
```
Running the above commands will re-initialize the validator node with default configuration. The config files will be saved in the default location (`~/.chibaclonkd/config`).
**NOTE:** Backup your node and validator keys. You will need to use these keys at a later point in time.
---
## Create Account keys
If you have participated in a previous testnet and have a mnemonic phrase, use below command to recover your account:
```sh
chibaclonkd keys add <key-name> --recover
```
To create a new account use:
```sh
chibaclonkd keys add <key-name>
```
**NOTE:** Save the `mnemonic` and related account details (public key). You will need to use the mnemonic and / or private key to recover accounts at a later point in time.
---
## Add Genesis Account
**NOTE:** Don't add more than 12,900 CHK , if you add more than that, your gentx will be ignored.
```sh
chibaclonkd add-genesis-account <key-name> 12900000000000000000000achk --keyring-backend os
```
Create Your `gentx` transaction file
```sh
chibaclonkd gentx <key-name> 12900000000000000000000achk \
--pubkey=$(chibaclonkd tendermint show-validator) \
--chain-id="chibaclonk_81337-4" \
--moniker="<your-moniker-name>" \
--website="<your-validator-website>" \
--details="<your-validator-description>" \
--identity="<your-keybase-public-key>" \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--min-self-delegation="1"
```
**NOTE:**
- `<key-name>` and `chain-id` are required. other flags are optional
- Don't change the amount value while creating your gentx
- Genesis transaction file will be saved in `~/.chibaclonkd/config/gentx` folder
---
## Submit Your gentx
Submit your `gentx` file to the [https://github.com/vulcanize/laconic-testnet]() repository in the following format:
`<validator-moniker>-gentx.json`
**NOTE:** (Do NOT use spaces in the file name)
To submit the gentx file, follow the below process:
- Fork the [https://github.com/vulcanize/laconic-testnet]() repository
- Upload your gentx file in the `chibaclonk_81337-4/config/gentxs` folder
- Submit Pull Request to [https://github.com/vulcanize/laconic-testnet]() with name `ADD <your-moniker> gentx`
The genesis file will be published in the `chibaclonk_81337-4/config/` folder within the [https://github.com/vulcanize/laconic-testnet]() repository.
# CONTINUE WITH BELOW STEPS ONLY AFTER GENESIS FILE HAS BEEN PUBLISHED
## Adjust validator node configuration
```sh
# Set seed & peers variable
seeds="<seeds node list here>"
peers="<peers node list here>"
# Update seeds, persistent_peers and prometheus parameters in config.toml
sed -i.bak -e "s/^seeds *=.*/seeds = \"$seeds\"/; s/^persistent_peers *=.*/persistent_peers = \"$peers\"/; s/^prometheus *=.*/prometheus = true/" $HOME/.chibaclonkd/config/config.toml
# Create systemd validator service
sudo tee /etc/systemd/system/chibaclonkd.service > /dev/null <<EOF
[Unit]
Description=chibaclonkd Daemon
After=network-online.target
[Service]
User=$USER
ExecStart=$(which chibaclonkd) start --mode validator --gql-playground --gql-server --log_level=warn
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
#Reload systemd and start the validator node
sudo systemctl daemon-reload
sudo systemctl enable chibaclonkd
sudo systemctl start chibaclonkd
```
Check status of service
```sh
sudo systemctl status chibaclonkd
```
---
## Helpful Commands
```sh
# Check logs
journalctl -u chibaclonkd
# Most recent logs
journalctl -xeu chibaclonkd
# Logs from previous day
journalctl --since "1 day ago" -u chibaclonkd
# Check logs with follow flag
journalctl -f -u chibaclonkd
# Check discovered peers
curl http://localhost:26657/net_info
# Check network consensus state
curl http://localhost:26657/consensus_state
# Check the sync status of your validator node
chibaclonkd status | jq .SyncInfo
```
+232
View File
@@ -0,0 +1,232 @@
#/bin/sh
# clean the existed chain
rm -rf ~/.testchibaclonk*
echo "Installing the require tools "
sudo apt-get install git curl build-essential make nohup jq -y
echo "Done Installing the tools"
command_exists() {
type "$1" &>/dev/null
}
if command_exists go; then
echo "Golang is already installed"
else
echo "Installing golang dependencies"
wget https://golang.org/dl/go1.17.2.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.17.2.linux-amd64.tar.gz
echo "Updating the profile"
export GOPATH=$HOME/go
export GOROOT=/usr/local/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:/usr/local/go/bin:$GOBIN
echo "" >>~/.profile
echo 'export GOPATH=$HOME/go' >>~/.profile
echo 'export GOROOT=/usr/local/go' >>~/.profile
echo 'export GOBIN=$GOPATH/bin' >>~/.profile
echo 'export PATH=$PATH:/usr/local/go/bin:$GOBIN' >>~/.profile
source ~/.profile
mkdir -p "$GOBIN"
mkdir -p $GOPATH/src/github.com
go version
fi
# chain env variables
export DAEMON_HOME=~/.testchibaclonk
export CHAINID=chibaclonk_9000-1
export DENOM=achk
export GH_URL=https://github.com/vulcanize/chiba-clonk.git
export CHAIN_VERSION=main
export DAEMON=chibaclonkd
display_usage() {
printf "** Please check the exported values:: **\n Daemon : $DAEMON\n Denom : $DENOM\n ChainID : $CHAINID\n DaemonHome : $DAEMON_HOME\n \n Github URL : $GH_URL\n Chain Version : $CHAIN_VERSION\n"
exit 1
}
if [ -z $DAEMON ] || [ -z $DENOM ] || [ -z $CHAINID ] || [ -z $DAEMON_HOME ] || [ -z $GH_URL ] || [ -z $CHAIN_VERSION ]; then
display_usage
fi
echo "--------- Install $DAEMON ---------"
git clone -b $CHAIN_VERSION --single-branch $GH_URL && cd $(basename $_ .git)
git fetch && git checkout $CHAIN_VERSION
make install
cd $HOME
# check version
$DAEMON version --long
#echo "----------Create test keys-----------"
export DAEMON_HOME_1=$DAEMON_HOME-1
export DAEMON_HOME_2=$DAEMON_HOME-2
export DAEMON_HOME_3=$DAEMON_HOME-3
export DAEMON_HOME_4=$DAEMON_HOME-4
printf "DAEMON_HOME_1=$DAEMON_HOME_1\nDAEMON_HOME_2=$DAEMON_HOME_2\nDAEMON_HOME_3=$DAEMON_HOME_3\nDAEMON_HOME_4=$DAEMON_HOME_4\n"
rm -rf $DAEMON_HOME*
echo "-----Create daemon home directories if not exist------"
mkdir -p "$DAEMON_HOME_1"
mkdir -p "$DAEMON_HOME_2"
mkdir -p "$DAEMON_HOME_3"
mkdir -p "$DAEMON_HOME_4"
echo "--------Start initializing the chain ($CHAINID)---------"
$DAEMON init --chain-id $CHAINID $DAEMON_HOME_1 --home $DAEMON_HOME_1 --keyring-backend test
$DAEMON init --chain-id $CHAINID $DAEMON_HOME_2 --home $DAEMON_HOME_2 --keyring-backend test
$DAEMON init --chain-id $CHAINID $DAEMON_HOME_3 --home $DAEMON_HOME_3 --keyring-backend test
$DAEMON init --chain-id $CHAINID $DAEMON_HOME_4 --home $DAEMON_HOME_4 --keyring-backend test
echo "---------Creating four keys-------------"
$DAEMON keys add validator1 --home $DAEMON_HOME_1 --keyring-backend test
$DAEMON keys add validator2 --home $DAEMON_HOME_2 --keyring-backend test
$DAEMON keys add validator3 --home $DAEMON_HOME_3 --keyring-backend test
$DAEMON keys add validator4 --home $DAEMON_HOME_4 --keyring-backend test
echo "----------Genesis creation---------"
$DAEMON --home $DAEMON_HOME_1 add-genesis-account validator1 1000000000000$DENOM --keyring-backend test
$DAEMON --home $DAEMON_HOME_2 add-genesis-account validator2 1000000000000$DENOM --keyring-backend test
$DAEMON --home $DAEMON_HOME_3 add-genesis-account validator3 1000000000000$DENOM --keyring-backend test
$DAEMON --home $DAEMON_HOME_4 add-genesis-account validator4 1000000000000$DENOM --keyring-backend test
$DAEMON --home $DAEMON_HOME_1 add-genesis-account $($DAEMON keys show validator2 -a --home $DAEMON_HOME_2 --keyring-backend test) 1000000000000$DENOM
$DAEMON --home $DAEMON_HOME_1 add-genesis-account $($DAEMON keys show validator3 -a --home $DAEMON_HOME_3 --keyring-backend test) 1000000000000$DENOM
$DAEMON --home $DAEMON_HOME_1 add-genesis-account $($DAEMON keys show validator4 -a --home $DAEMON_HOME_4 --keyring-backend test) 1000000000000$DENOM
echo "--------Gentx--------"
$DAEMON gentx validator1 90000000000$DENOM --chain-id $CHAINID --keyring-backend test --home $DAEMON_HOME_1
$DAEMON gentx validator2 90000000000$DENOM --chain-id $CHAINID --keyring-backend test --home $DAEMON_HOME_2
$DAEMON gentx validator3 90000000000$DENOM --chain-id $CHAINID --keyring-backend test --home $DAEMON_HOME_3
$DAEMON gentx validator4 90000000000$DENOM --chain-id $CHAINID --keyring-backend test --home $DAEMON_HOME_4
echo "---------Copy all the genesis to $DAEMON_HOME_1----------"
cp $DAEMON_HOME_2/config/gentx/*.json $DAEMON_HOME_1/config/gentx/
cp $DAEMON_HOME_3/config/gentx/*.json $DAEMON_HOME_1/config/gentx/
cp $DAEMON_HOME_4/config/gentx/*.json $DAEMON_HOME_1/config/gentx/
echo "----------collect-gentxs------------"
$DAEMON collect-gentxs --home $DAEMON_HOME_1
echo "---------Updating $DAEMON_HOME_1 genesis.json ------------"
sed -i "s/172800000000000/600000000000/g" $DAEMON_HOME_1/config/genesis.json
sed -i "s/172800s/600s/g" $DAEMON_HOME_1/config/genesis.json
sed -i "s/stake/$DENOM/g" $DAEMON_HOME_1/config/genesis.json
echo "---------Distribute genesis.json of $DAEMON_HOME_1 to remaining nodes-------"
cp $DAEMON_HOME_1/config/genesis.json $DAEMON_HOME_2/config/
cp $DAEMON_HOME_1/config/genesis.json $DAEMON_HOME_3/config/
cp $DAEMON_HOME_1/config/genesis.json $DAEMON_HOME_4/config/
echo "---------Getting public IP address-----------"
IP="127.0.0.1"
echo "Public IP address: ${IP}"
echo "----------Update node-id of $DAEMON_HOME_1 in remaining nodes---------"
nodeID=$("${DAEMON}" tendermint show-node-id --home $DAEMON_HOME_1)
echo $nodeID
PERSISTENT_PEERS="$nodeID@$IP:16656"
echo "PERSISTENT_PEERS : $PERSISTENT_PEERS"
echo "----------Updating $DAEMON_HOME_1 chain config-----------"
sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:16657#g' $DAEMON_HOME_1/config/config.toml
sed -i 's#tcp://0.0.0.0:26656#tcp://0.0.0.0:16656#g' $DAEMON_HOME_1/config/config.toml
sed -i '/persistent_peers =/c\persistent_peers = "'""'"' $DAEMON_HOME_1/config/config.toml
sed -i '/max_num_inbound_peers =/c\max_num_inbound_peers = 140' $DAEMON_HOME_1/config/config.toml
sed -i '/max_num_outbound_peers =/c\max_num_outbound_peers = 110' $DAEMON_HOME_1/config/config.toml
sed -i '/pprof_laddr =/c\# pprof_laddr = "localhost:6060"' $DAEMON_HOME_1/config/config.toml
sed -i '/allow_duplicate_ip =/c\allow_duplicate_ip = true' $DAEMON_HOME_1/config/config.toml
sed -i 's#0.0.0.0:9090#0.0.0.0:1090#g' $DAEMON_HOME_1/config/app.toml
sed -i 's#0.0.0.0:9091#0.0.0.0:1091#g' $DAEMON_HOME_1/config/app.toml
sed -i 's#0.0.0.0:8545#0.0.0.0:1545#g' $DAEMON_HOME_1/config/app.toml
sed -i 's#0.0.0.0:8546#0.0.0.0:1546#g' $DAEMON_HOME_1/config/app.toml
echo "----------Updating $DAEMON_HOME_2 chain config-----------"
sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $DAEMON_HOME_2/config/config.toml
sed -i 's#tcp://0.0.0.0:26656#tcp://0.0.0.0:26656#g' $DAEMON_HOME_2/config/config.toml
sed -i '/persistent_peers =/c\persistent_peers = "'"$PERSISTENT_PEERS"'"' $DAEMON_HOME_2/config/config.toml
sed -i '/max_num_inbound_peers =/c\max_num_inbound_peers = 140' $DAEMON_HOME_2/config/config.toml
sed -i '/max_num_outbound_peers =/c\max_num_outbound_peers = 110' $DAEMON_HOME_2/config/config.toml
sed -i '/pprof_laddr =/c\# pprof_laddr = "localhost:6060"' $DAEMON_HOME_2/config/config.toml
sed -i '/allow_duplicate_ip =/c\allow_duplicate_ip = true' $DAEMON_HOME_2/config/config.toml
sed -i 's#0.0.0.0:9090#0.0.0.0:2090#g' $DAEMON_HOME_2/config/app.toml
sed -i 's#0.0.0.0:9091#0.0.0.0:2091#g' $DAEMON_HOME_2/config/app.toml
sed -i 's#0.0.0.0:8545#0.0.0.0:2545#g' $DAEMON_HOME_2/config/app.toml
sed -i 's#0.0.0.0:8546#0.0.0.0:2546#g' $DAEMON_HOME_2/config/app.toml
echo "----------Updating $DAEMON_HOME_3 chain config------------"
sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:36657#g' $DAEMON_HOME_3/config/config.toml
sed -i 's#tcp://0.0.0.0:26656#tcp://0.0.0.0:36656#g' $DAEMON_HOME_3/config/config.toml
sed -i '/persistent_peers =/c\persistent_peers = "'"$PERSISTENT_PEERS"'"' $DAEMON_HOME_3/config/config.toml
sed -i '/max_num_inbound_peers =/c\max_num_inbound_peers = 140' $DAEMON_HOME_3/config/config.toml
sed -i '/max_num_outbound_peers =/c\max_num_outbound_peers = 110' $DAEMON_HOME_3/config/config.toml
sed -i '/pprof_laddr =/c\# pprof_laddr = "localhost:6060"' $DAEMON_HOME_3/config/config.toml
sed -i '/allow_duplicate_ip =/c\allow_duplicate_ip = true' $DAEMON_HOME_3/config/config.toml
sed -i 's#0.0.0.0:9090#0.0.0.0:3090#g' $DAEMON_HOME_3/config/app.toml
sed -i 's#0.0.0.0:9091#0.0.0.0:3091#g' $DAEMON_HOME_3/config/app.toml
sed -i 's#0.0.0.0:8545#0.0.0.0:3545#g' $DAEMON_HOME_3/config/app.toml
sed -i 's#0.0.0.0:8546#0.0.0.0:3546#g' $DAEMON_HOME_3/config/app.toml
echo "----------Updating $DAEMON_HOME_4 chain config------------"
sed -i 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:46657#g' $DAEMON_HOME_4/config/config.toml
sed -i 's#tcp://0.0.0.0:26656#tcp://0.0.0.0:46656#g' $DAEMON_HOME_4/config/config.toml
sed -i '/persistent_peers =/c\persistent_peers = "'"$PERSISTENT_PEERS"'"' $DAEMON_HOME_4/config/config.toml
sed -i '/max_num_inbound_peers =/c\max_num_inbound_peers = 140' $DAEMON_HOME_4/config/config.toml
sed -i '/max_num_outbound_peers =/c\max_num_outbound_peers = 110' $DAEMON_HOME_4/config/config.toml
sed -i '/pprof_laddr =/c\# pprof_laddr = "localhost:6060"' $DAEMON_HOME_4/config/config.toml
sed -i '/allow_duplicate_ip =/c\allow_duplicate_ip = true' $DAEMON_HOME_4/config/config.toml
sed -i 's#0.0.0.0:9090#0.0.0.0:4090#g' $DAEMON_HOME_4/config/app.toml
sed -i 's#0.0.0.0:9091#0.0.0.0:4091#g' $DAEMON_HOME_4/config/app.toml
sed -i 's#0.0.0.0:8545#0.0.0.0:4545#g' $DAEMON_HOME_4/config/app.toml
sed -i 's#0.0.0.0:8546#0.0.0.0:4546#g' $DAEMON_HOME_4/config/app.toml
echo "starting the chains"
nohup $(which $DAEMON) start --gql-playground --gql-server --home $DAEMON_HOME_1 >$DAEMON_HOME_1.log &
sleep 5s
echo "Checking $DAEMON_HOME_1 chain status"
$DAEMON status --node tcp://localhost:16657
nohup $(which $DAEMON) start --gql-playground --gql-server --home $DAEMON_HOME_2 >$DAEMON_HOME_2.log &
sleep 5s
echo "Checking $DAEMON_HOME_2 chain status"
$DAEMON status --node tcp://localhost:26657
nohup $(which $DAEMON) start --gql-playground --gql-server --home $DAEMON_HOME_3 >$DAEMON_HOME_3.log &
sleep 5s
echo "Checking $DAEMON_HOME_3 chain status"
$DAEMON status --node tcp://localhost:36657
nohup $(which $DAEMON) start --gql-playground --gql-server --home $DAEMON_HOME_4 >$DAEMON_HOME_4.log &
sleep 5s
echo "Checking $DAEMON_HOME_4 chain status"
$DAEMON status --node tcp://localhost:46657
+54
View File
@@ -0,0 +1,54 @@
### Create Validator Post Genesis
1. Run Full Node
2. Create Account and Get test tokens
3. Create Validator
### 1.Run Full Node
- Check "[Run Full Node](full_node.md)" section to Run a Full Node
### 2. Create Account & Get test tokens
```
chibaclonkd keys add <key-name> --keyring-backend test
```
NOTE: Save `mnemonic` and related account details (public key). You will need to use the need mnemonic/private key to
recover accounts at a later point in time.
##### Get Test tokens from faucet
- Faucet website link will be updated
- 1 CHK = 1 * 10e^18 achk
### 3.Create Validator
- ##### Check full node sync status
`chibaclonkd status 2>&1 | jq -r ".SyncInfo"`
`catching_up: false` means node is completely synced
- ##### Create validator
`Note:` Only execute below transaction after complete sync of your full node
Please replace `key_name` with your key name, amount with staking amount, validator description and `moniker` also
```
chibaclonkd tx staking create-validator \
--amount="AMOUNT" \
--pubkey=$(chibaclonkd tendermint show-validator) \
--moniker="my-moniker" \
--website="https://myweb.site" \
--details="description of your validator" \
--chain-id="chibaclonk_81337-2" \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--min-self-delegation="1" \
--gas="auto" \
--gas-adjustment="1.2" \
--gas-prices="0.025achk" \
--from=<key_name>
```
+2 -2
View File
@@ -7,7 +7,7 @@ import (
"math/big"
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"cosmossdk.io/math"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
// . "github.com/onsi/ginkgo"
@@ -567,7 +567,7 @@ func (s *IntegrationTestSuite) deployContract(data []byte) (transaction common.H
// Deploys erc20 contract, commits block and returns contract address
func (s *IntegrationTestSuite) deployERC20Contract() (transaction common.Hash, contractAddr common.Address) {
owner := common.BytesToAddress(s.network.Validators[0].Address)
supply := sdk.NewIntWithDecimal(1000, 18).BigInt()
supply := math.NewIntWithDecimal(1000, 18).BigInt()
ctorArgs, err := evmtypes.ERC20Contract.ABI.Pack("", owner, supply)
s.Require().NoError(err)
+1 -1
View File
@@ -59,7 +59,7 @@ type ImporterTestSuite struct {
/// DoSetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *ImporterTestSuite) DoSetupTest(t require.TestingT) {
checkTx := false
suite.app = app.Setup(checkTx, nil)
suite.app = app.Setup(suite.T(), checkTx, nil)
// consensus key
priv, err := ethsecp256k1.GenerateKey()
require.NoError(t, err)
+1 -12
View File
@@ -301,17 +301,6 @@ func deployTestContract(t *testing.T) (hexutil.Bytes, map[string]interface{}) {
return hash, receipt
}
func getTransactionReceipt(t *testing.T, hash hexutil.Bytes) map[string]interface{} {
param := []string{hash.String()}
rpcRes := call(t, "eth_getTransactionReceipt", param)
receipt := make(map[string]interface{})
err := json.Unmarshal(rpcRes.Result, &receipt)
require.NoError(t, err)
return receipt
}
func waitForReceipt(t *testing.T, hash hexutil.Bytes) map[string]interface{} {
timeout := time.After(12 * time.Second)
ticker := time.Tick(500 * time.Millisecond)
@@ -321,7 +310,7 @@ func waitForReceipt(t *testing.T, hash hexutil.Bytes) map[string]interface{} {
case <-timeout:
return nil
case <-ticker:
receipt := getTransactionReceipt(t, hash)
receipt := GetTransactionReceipt(t, hash)
if receipt != nil {
return receipt
}
+1 -1
View File
@@ -58,4 +58,4 @@ chibaclonkd collect-gentxs
chibaclonkd validate-genesis
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
chibaclonkd start --pruning=nothing --rpc.unsafe --keyring-backend test --log_level info --json-rpc.api eth,txpool,personal,net,debug,web3 --api.enable
chibaclonkd start --pruning=nothing --rpc.unsafe --keyring-backend test --log_level info --json-rpc.api eth,txpool,personal,net,debug,web3 --api.enable --mode validator
+35 -42
View File
@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math/rand"
"net/http"
"net/url"
"os"
@@ -15,16 +16,14 @@ import (
"testing"
"time"
tmcfg "github.com/tendermint/tendermint/config"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
tmcfg "github.com/tendermint/tendermint/config"
tmflags "github.com/tendermint/tendermint/libs/cli/flags"
"github.com/tendermint/tendermint/libs/log"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/libs/service"
tmclient "github.com/tendermint/tendermint/rpc/client"
dbm "github.com/tendermint/tm-db"
"google.golang.org/grpc"
"github.com/cosmos/cosmos-sdk/baseapp"
@@ -34,13 +33,14 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/db/memdb"
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/api"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/params"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -68,10 +68,10 @@ type AppConstructor = func(val Validator) servertypes.Application
func NewAppConstructor(encodingCfg params.EncodingConfig) AppConstructor {
return func(val Validator) servertypes.Application {
return app.NewEthermintApp(
val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0,
val.Ctx.Logger, memdb.NewDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0,
encodingCfg,
simapp.EmptyAppOptions{},
baseapp.SetPruning(storetypes.NewPruningOptionsFromString(val.AppConfig.Pruning)),
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)),
baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices),
)
}
@@ -113,22 +113,22 @@ func DefaultConfig() Config {
encCfg := encoding.MakeConfig(app.ModuleBasics)
return Config{
Codec: encCfg.Marshaler,
Codec: encCfg.Codec,
TxConfig: encCfg.TxConfig,
LegacyAmino: encCfg.Amino,
InterfaceRegistry: encCfg.InterfaceRegistry,
AccountRetriever: authtypes.AccountRetriever{},
AppConstructor: NewAppConstructor(encCfg),
GenesisState: app.ModuleBasics.DefaultGenesis(encCfg.Marshaler),
GenesisState: app.ModuleBasics.DefaultGenesis(encCfg.Codec),
TimeoutCommit: 2 * time.Second,
ChainID: fmt.Sprintf("ethermint_%d-1", tmrand.Int63n(9999999999999)+1),
ChainID: fmt.Sprintf("ethermint_%d-1", rand.Int63n(9999999999999)+1),
NumValidators: 4,
BondDenom: ethermint.AttoPhoton,
MinGasPrices: fmt.Sprintf("0.000006%s", ethermint.AttoPhoton),
AccountTokens: sdk.TokensFromConsensusPower(1000, ethermint.PowerReduction),
StakingTokens: sdk.TokensFromConsensusPower(500, ethermint.PowerReduction),
BondedTokens: sdk.TokensFromConsensusPower(100, ethermint.PowerReduction),
PruningStrategy: storetypes.PruningOptionNothing,
PruningStrategy: pruningtypes.PruningOptionNothing,
CleanupDir: true,
SigningAlgo: string(hd.EthSecp256k1Type),
KeyringOptions: []keyring.Option{hd.EthSecp256k1Option()},
@@ -174,7 +174,7 @@ type (
RPCClient tmclient.Client
JSONRPCClient *ethclient.Client
tmNode *node.Node
tmNode service.Service
api *api.Server
grpc *grpc.Server
grpcWeb *http.Server
@@ -255,6 +255,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
ctx := server.NewDefaultContext()
tmCfg := ctx.Config
tmCfg.Consensus.TimeoutCommit = cfg.TimeoutCommit
tmCfg.Mode = tmcfg.ModeValidator
// Only allow the first validator to expose an RPC, API and gRPC
// server/client due to Tendermint in-process constraints.
@@ -322,17 +323,18 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
appCfg.JSONRPC.API = config.GetAPINamespaces()
}
logger := log.NewNopLogger()
logger := server.ZeroLogWrapper{Logger: zerolog.Nop()}
if cfg.EnableTMLogging {
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
logger, _ = tmflags.ParseLogLevel("info", logger, tmcfg.DefaultLogLevel)
logWriter := zerolog.ConsoleWriter{Out: os.Stderr}
logger = server.ZeroLogWrapper{Logger: zerolog.New(logWriter).Level(zerolog.InfoLevel).With().Timestamp().Logger()}
}
ctx.Logger = logger
ctx.Logger = logger
nodeDirName := fmt.Sprintf("node%d", i)
nodeDir := filepath.Join(network.BaseDir, nodeDirName, "evmosd")
clientDir := filepath.Join(network.BaseDir, nodeDirName, "evmoscli")
nodeDir := filepath.Join(network.BaseDir, nodeDirName, "chibaclonkd")
clientDir := filepath.Join(network.BaseDir, nodeDirName, "chibaclonkcli")
gentxsDir := filepath.Join(network.BaseDir, "gentxs")
err := os.MkdirAll(filepath.Join(nodeDir, "config"), 0o750)
@@ -370,7 +372,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
nodeIDs[i] = nodeID
valPubKeys[i] = pubKey
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, clientDir, buf, cfg.KeyringOptions...)
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, clientDir, buf, cfg.Codec, cfg.KeyringOptions...)
if err != nil {
return nil, err
}
@@ -429,7 +431,6 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
)
if err != nil {
return nil, err
}
@@ -527,6 +528,13 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
l.Log("started test network")
height, err := network.LatestHeight()
if err != nil {
return nil, err
}
l.Log("started test network at height:", height)
// Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as any
// defer in a test would not be called.
server.TrapSignal(network.Cleanup)
@@ -560,22 +568,22 @@ func (n *Network) WaitForHeight(h int64) (int64, error) {
// provide a custom timeout.
func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, error) {
ticker := time.NewTicker(time.Second)
timeout := time.After(t)
defer ticker.Stop()
timeout := time.NewTimer(t)
defer timeout.Stop()
if len(n.Validators) == 0 {
return 0, errors.New("no validators available")
}
var latestHeight int64
val := n.Validators[0]
for {
select {
case <-timeout:
ticker.Stop()
case <-timeout.C:
return latestHeight, errors.New("timeout exceeded waiting for block")
case <-ticker.C:
status, err := val.RPCClient.Status(context.Background())
status, err := n.Validators[0].RPCClient.Status(context.Background())
if err == nil && status != nil {
latestHeight = status.SyncInfo.LatestBlockHeight
if latestHeight >= h {
@@ -629,21 +637,6 @@ func (n *Network) Cleanup() {
_ = v.grpcWeb.Close()
}
}
if v.jsonrpc != nil {
shutdownCtx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second)
defer cancelFn()
if err := v.jsonrpc.Shutdown(shutdownCtx); err != nil {
v.tmNode.Logger.Error("HTTP server shutdown produced a warning", "error", err.Error())
} else {
v.tmNode.Logger.Info("HTTP server shut down, waiting 5 sec")
select {
case <-time.Tick(5 * time.Second):
case <-v.jsonrpcDone:
}
}
}
}
if n.Config.CleanupDir {
+30 -26
View File
@@ -3,18 +3,17 @@ package network
import (
"encoding/json"
"fmt"
"io/ioutil"
"path/filepath"
"time"
"github.com/ethereum/go-ethereum/ethclient"
abciclient "github.com/tendermint/tendermint/abci/client"
tmos "github.com/tendermint/tendermint/libs/os"
tmtime "github.com/tendermint/tendermint/libs/time"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/rpc/client/local"
"github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/server/api"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
@@ -25,9 +24,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
mintypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/tharsis/ethermint/server"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
)
@@ -41,36 +40,35 @@ func startInProcess(cfg Config, val *Validator) error {
return err
}
nodeKey, err := p2p.LoadOrGenNodeKey(tmCfg.NodeKeyFile())
app := cfg.AppConstructor(*val)
genDoc, err := types.GenesisDocFromFile(tmCfg.GenesisFile())
if err != nil {
return err
}
app := cfg.AppConstructor(*val)
genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg)
tmNode, err := node.NewNode(
val.tmNode, err = node.New(
tmCfg,
pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()),
nodeKey,
proxy.NewLocalClientCreator(app),
genDocProvider,
node.DefaultDBProvider,
node.DefaultMetricsProvider(tmCfg.Instrumentation),
logger.With("module", val.Moniker),
abciclient.NewLocalCreator(app),
genDoc,
)
if err != nil {
return err
}
if err := tmNode.Start(); err != nil {
if err := val.tmNode.Start(); err != nil {
return err
}
val.tmNode = tmNode
if val.RPCAddress != "" {
val.RPCClient = local.New(tmNode)
node, ok := val.tmNode.(local.NodeService)
if !ok {
panic("can't cast service.Service to NodeService")
}
val.RPCClient, err = local.New(node)
if err != nil {
panic("cant create a local node")
}
}
// We'll need a RPC client if the validator exposes a gRPC or REST endpoint.
@@ -107,7 +105,7 @@ func startInProcess(cfg Config, val *Validator) error {
}
if val.AppConfig.GRPC.Enable {
grpcSrv, err := servergrpc.StartGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC.Address)
grpcSrv, err := servergrpc.StartGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC)
if err != nil {
return err
}
@@ -152,7 +150,7 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error {
for i := 0; i < cfg.NumValidators; i++ {
tmCfg := vals[i].Ctx.Config
nodeDir := filepath.Join(outputDir, vals[i].Moniker, "evmosd")
nodeDir := filepath.Join(outputDir, vals[i].Moniker, "chibaclonkd")
gentxsDir := filepath.Join(outputDir, "gentxs")
tmCfg.Moniker = vals[i].Moniker
@@ -206,7 +204,7 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance
stakingGenState.Params.BondDenom = cfg.BondDenom
cfg.GenesisState[stakingtypes.ModuleName] = cfg.Codec.MustMarshalJSON(&stakingGenState)
var govGenState govtypes.GenesisState
var govGenState v1.GenesisState
cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[govtypes.ModuleName], &govGenState)
govGenState.DepositParams.MinDeposit[0].Denom = cfg.BondDenom
@@ -252,12 +250,18 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance
}
func WriteFile(name string, dir string, contents []byte) error {
file := filepath.Join(dir, name)
writePath := filepath.Join(dir)
file := filepath.Join(writePath, name)
err := tmos.EnsureDir(dir, 0o755)
err := tmos.EnsureDir(writePath, 0o755)
if err != nil {
return err
}
return tmos.WriteFile(file, contents, 0o644)
err = ioutil.WriteFile(file, contents, 0o644) //nolint: gosec
if err != nil {
return err
}
return nil
}
+6
View File
@@ -0,0 +1,6 @@
package types
const (
// Bech32MainPrefix defines the main SDK Bech32 prefix of an account's address
Bech32MainPrefix = "ethm"
)
+7 -1
View File
@@ -2,6 +2,7 @@ package types
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
@@ -19,8 +20,13 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
&EthAccount{},
)
registry.RegisterInterface(
"ethermint.v1.ExtensionOptionsWeb3Tx",
"ethermint.types.v1.ExtensionOptionsWeb3Tx",
(*ExtensionOptionsWeb3TxI)(nil),
&ExtensionOptionsWeb3Tx{},
)
registry.RegisterInterface(
"ethermint.types.v1.ExtensionOptionsWeb3Tx",
(*tx.TxExtensionOptionI)(nil),
&ExtensionOptionsWeb3Tx{},
)
}
+10 -2
View File
@@ -26,7 +26,7 @@ type infiniteGasMeterWithLimit struct {
}
// NewInfiniteGasMeterWithLimit returns a reference to a new infiniteGasMeter.
func NewInfiniteGasMeterWithLimit(limit sdk.Gas) sdk.GasMeter {
func NewInfiniteGasMeterWithLimit(limit sdk.Gas) *infiniteGasMeterWithLimit {
return &infiniteGasMeterWithLimit{
consumed: 0,
limit: limit,
@@ -45,6 +45,14 @@ func (g *infiniteGasMeterWithLimit) Limit() sdk.Gas {
return g.limit
}
// GasRemaining returns the gas left in the GasMeter.
func (g *infiniteGasMeterWithLimit) GasRemaining() sdk.Gas {
if g.IsPastLimit() {
return 0
}
return g.limit - g.consumed
}
// addUint64Overflow performs the addition operation on two uint64 integers and
// returns a boolean on whether or not the result overflows.
func addUint64Overflow(a, b uint64) (uint64, bool) {
@@ -67,7 +75,7 @@ func (g *infiniteGasMeterWithLimit) ConsumeGas(amount sdk.Gas, descriptor string
// RefundGas will deduct the given amount from the gas consumed. If the amount is greater than the
// gas consumed, the function will panic.
//
// Use case: This functionality enables refunding gas to the trasaction or block gas pools so that
// Use case: This functionality enables refunding gas to the transaction or block gas pools so that
// EVM-compatible chains can fully support the go-ethereum StateDb interface.
// See https://github.com/cosmos/cosmos-sdk/pull/9403 for reference.
func (g *infiniteGasMeterWithLimit) RefundGas(amount sdk.Gas, descriptor string) {
+58 -2
View File
@@ -8,11 +8,27 @@ import (
"bytes"
"errors"
"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
"github.com/ipld/go-ipld-prime/fluent"
"github.com/ipld/go-ipld-prime/linking"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
"github.com/ipld/go-ipld-prime/multicodec"
"github.com/ipld/go-ipld-prime/storage/memstore"
canonicalJson "github.com/gibson042/canonicaljson-go"
cbor "github.com/ipfs/go-ipld-cbor"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
mh "github.com/multiformats/go-multihash"
)
var store = memstore.Store{}
func init() {
multicodec.RegisterEncoder(0x71, dagcbor.Encode)
multicodec.RegisterDecoder(0x71, dagcbor.Decode)
}
// GenerateHash returns the hash of the canonicalized JSON input.
func GenerateHash(json map[string]interface{}) (string, []byte, error) {
content, err := canonicalJson.Marshal(json)
@@ -20,12 +36,12 @@ func GenerateHash(json map[string]interface{}) (string, []byte, error) {
return "", nil, err
}
cid, err := CIDFromJSONBytes(content)
cidString, err := CIDFromJSONBytesUsingIpldPrime(content)
if err != nil {
return "", nil, err
}
return cid, content, nil
return cidString, content, nil
}
// CIDFromJSONBytes returns CID (cbor) for json (as bytes).
@@ -50,3 +66,43 @@ func GetAttributeAsString(obj map[string]interface{}, attr string) (string, erro
return "", errors.New("attribute not found")
}
// CIDFromJSONBytesUsingIpldPrime returns CID (dagcbor) for json (as bytes).
func CIDFromJSONBytesUsingIpldPrime(content []byte) (string, error) {
lsys := cidlink.DefaultLinkSystem()
// We want to store the serialized data somewhere.
// We'll use an in-memory store for this. (It's a package scoped variable.)
// You can use any kind of storage system here;
// or if you need even more control, you could also write a function that conforms to the linking.BlockWriteOpener interface.
lsys.SetWriteStorage(&store)
// To create any links, first we need a LinkPrototype.
// This gathers together any parameters that might be needed when making a link.
// (For CIDs, the version, the codec, and the multihash type are all parameters we'll need.)
// Often, you can probably make this a constant for your whole application.
lp := cidlink.LinkPrototype{Prefix: cid.Prefix{
Version: 1, // Usually '1'.
Codec: 0x71, // 0x71 means "dag-cbor" -- See the multicodecs table: https://github.com/multiformats/multicodec/
MhType: 0x12, // 0x12 means "sha2-256" -- See the multicodecs table: https://github.com/multiformats/multicodec/
MhLength: 32, // sha2-256 hash has a 32-byte sum.
}}
// And we need some data to link to! Here's a quick piece of example data:
n, err := fluent.Build(basicnode.Prototype.Any, func(na fluent.NodeAssembler) {
na.AssignBytes(content)
})
if err != nil {
return "", err
}
// Now: time to apply the LinkSystem, and do the actual store operation!
lnk, err := lsys.Store(
linking.LinkContext{}, // The zero value is fine. Configure it it you want cancellability or other features.
lp, // The LinkPrototype says what codec and hashing to use.
n, // And here's our data.
)
if err != nil {
return "", err
}
return lnk.String(), nil
}
+1 -1
View File
@@ -16,7 +16,7 @@ func GenerateMnemonic() (string, error) {
return "", err
}
mnemonic, err := bip39.NewMnemonic(entropySeed[:])
mnemonic, err := bip39.NewMnemonic(entropySeed)
if err != nil {
return "", err
}
+1 -1
View File
@@ -134,7 +134,7 @@ func GetCmdCommitBid() *cobra.Command {
}
// Save reveal file.
ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0600)
ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600)
msg := types.NewMsgCommitBid(auctionID, commitHash, clientCtx.GetFromAddress())
err = msg.ValidateBasic()
+2 -3
View File
@@ -36,6 +36,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
@@ -61,9 +62,7 @@ func (s *IntegrationTestSuite) createAccountWithBalance(accountName string, acco
info, _, err := val.ClientCtx.Keyring.NewMnemonic(accountName, keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.EthSecp256k1)
sr.NoError(err)
val.ClientCtx.Keyring.SavePubKey(accountName, info.GetPubKey(), hd.EthSecp256k1Type)
newAddr := sdk.AccAddress(info.GetPubKey().Address())
newAddr, _ := info.GetAddress()
_, err = banktestutil.MsgSendExec(
val.ClientCtx,
val.Address,
+1 -1
View File
@@ -3,7 +3,7 @@ package testutil
import (
"fmt"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/testutil/rest"
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
)
+3 -3
View File
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/tharsis/ethermint/app"
"github.com/tharsis/ethermint/x/auction/types"
)
@@ -40,7 +40,7 @@ func (suite *KeeperTestSuite) TestGrpcGetAllAuctions() {
suite.Run(fmt.Sprintf("Case %s", test.msg), func() {
if test.createAuctions {
account := app.CreateRandomAccounts(1)[0]
err := simapp.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(
err := testutil.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(
sdk.Coin{Amount: sdk.NewInt(100), Denom: sdk.DefaultBondDenom},
))
@@ -329,7 +329,7 @@ func (suite *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.
accounts := app.CreateRandomAccounts(accCount)
for _, account := range accounts {
err := simapp.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(
err := testutil.FundAccount(suite.app.BankKeeper, ctx, account, sdk.NewCoins(
sdk.Coin{Amount: sdk.NewInt(100), Denom: sdk.DefaultBondDenom},
))
if err != nil {
+4 -6
View File
@@ -7,12 +7,12 @@ import (
"time"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
params "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tharsis/ethermint/x/auction/types"
wnsUtils "github.com/tharsis/ethermint/utils"
@@ -43,7 +43,7 @@ type Keeper struct {
// Track auction usage in other cosmos-sdk modules (more like a usage tracker).
usageKeepers []types.AuctionUsageKeeper
storeKey sdk.StoreKey // Unexposed key to access store from sdk.Context
storeKey storetypes.StoreKey // Unexposed key to access store from sdk.Context
cdc codec.BinaryCodec // The wire codec for binary encoding/decoding.
@@ -58,7 +58,7 @@ type AuctionClientKeeper interface {
}
// NewKeeper creates new instances of the auction Keeper
func NewKeeper(accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, storeKey sdk.StoreKey, cdc codec.BinaryCodec, ps params.Subspace) Keeper {
func NewKeeper(accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, ps params.Subspace) Keeper {
if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}
@@ -382,7 +382,7 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg types.MsgCommitBid) (*types.Bid,
return &bid, nil
}
// RevealBid reeals a bid comitted earlier.
// RevealBid reeals a bid committed earlier.
func (k Keeper) RevealBid(ctx sdk.Context, msg types.MsgRevealBid) (*types.Auction, error) {
if !k.HasAuction(ctx, msg.AuctionId) {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.")
@@ -561,7 +561,6 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
ctx.Logger().Info(fmt.Sprintf("Updated 1st bid %s %s", highestBid.BidderAddress, highestBid.BidAmount.String()))
ctx.Logger().Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String()))
} else if secondHighestBid == nil || secondHighestBid.BidAmount.IsLT(bid.BidAmount) {
ctx.Logger().Info(fmt.Sprintf("New 2nd highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
@@ -588,7 +587,6 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
ctx.Logger().Info(fmt.Sprintf("Auction %s winner %s.", auction.Id, auction.WinnerAddress))
ctx.Logger().Info(fmt.Sprintf("Auction %s winner bid %s.", auction.Id, auction.WinningBid.String()))
ctx.Logger().Info(fmt.Sprintf("Auction %s winner price %s.", auction.Id, auction.WinningPrice.String()))
} else {
ctx.Logger().Info(fmt.Sprintf("Auction %s has no valid revealed bids (no winner).", auction.Id))
}
+2 -2
View File
@@ -22,7 +22,7 @@ type KeeperTestSuite struct {
}
func (suite *KeeperTestSuite) SetupTest() {
testApp := app.Setup(false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
testApp := app.Setup(suite.T(), false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
return genesis
})
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
@@ -37,7 +37,7 @@ func (suite *KeeperTestSuite) SetupTest() {
}
func TestParams(t *testing.T) {
testApp := app.Setup(false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
testApp := app.Setup(t, false, func(ea *app.EthermintApp, genesis simapp.GenesisState) simapp.GenesisState {
return genesis
})
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
-1
View File
@@ -79,7 +79,6 @@ func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types
return &types.MsgCommitBidResponse{Bid: resp}, nil
}
//RevealBid is the command for revealing a bid
func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
+1 -1
View File
@@ -56,7 +56,7 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEnc
if err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
}
// Once json successfully marshalled, passes along to genesis.go
// Once json successfully marshaled, passes along to genesis.go
return ValidateGenesis(data)
}
-2
View File
@@ -63,7 +63,6 @@ func (msg MsgCreateAuction) GetSigners() []sdk.AccAddress {
// NewMsgCommitBid is the constructor function for MsgCommitBid.
func NewMsgCommitBid(auctionID string, commitHash string, signer sdk.AccAddress) MsgCommitBid {
return MsgCommitBid{
AuctionId: auctionID,
CommitHash: commitHash,
@@ -107,7 +106,6 @@ func (msg MsgCommitBid) GetSigners() []sdk.AccAddress {
// NewMsgRevealBid is the constructor function for MsgRevealBid.
func NewMsgRevealBid(auctionID string, reveal string, signer sdk.AccAddress) MsgRevealBid {
return MsgRevealBid{
AuctionId: auctionID,
Reveal: reveal,
+1 -1
View File
@@ -104,7 +104,7 @@ func WithdrawBondCmd() *cobra.Command {
return cmd
}
// CancelBondCmd is the CLI command for cancelling a bond.
// CancelBondCmd is the CLI command for canceling a bond.
func CancelBondCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "cancel [bond Id]",

Some files were not shown because too many files have changed in this diff Show More