Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change account prefix to crc #86

Merged
merged 2 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [cronos#59](https://github.com/crypto-org-chain/cronos/pull/59) gravity bridged tokens are converted to crc20
automatically
- [cronos#68](https://github.com/crypto-org-chain/cronos/issues/68) support SendCroToIbc in evm_log_handlers
- [cronos#86](https://github.com/crypto-org-chain/cronos/issues/86) change account prefix

*August 19, 2021*

Expand Down
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ COVERAGE ?= coverage.txt

GOPATH ?= $(shell $(GO) env GOPATH)
BINDIR ?= ~/go/bin
NETWORK ?= mainnet

TESTNET_FLAGS ?=

ifeq ($(NETWORK),testnet)
BUILD_TAGS := -tags testnet
endif

all: build
build: go.sum
build: check-network go.sum
@go build -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) -o $(BUILDDIR)/cronosd ./cmd/cronosd

install: go.sum
@go install -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) ./cmd/cronosd
install: check-network go.sum
@go install -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) ./cmd/cronosd

test:
@go test -v -mod=readonly $(PACKAGES) -coverprofile=$(COVERAGE) -covermode=atomic
Expand Down Expand Up @@ -177,6 +183,14 @@ gen-cronos-contracts:

.PHONY: gen-cronos-contracts test-cronos-contracts

check-network:
ifeq ($(NETWORK),mainnet)
else ifeq ($(NETWORK),testnet)
else
@echo "Unrecognized network: ${NETWORK}"
endif
@echo "building network: ${NETWORK}"

###############################################################################
### Protobuf ###
###############################################################################
Expand Down
5 changes: 3 additions & 2 deletions app/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package app

import (
sdk "github.com/cosmos/cosmos-sdk/types"
cmdcfg "github.com/tharsis/ethermint/cmd/config"
cmdcfg "github.com/crypto-org-chain/cronos/cmd/cronosd/config"
ethcfg "github.com/tharsis/ethermint/cmd/config"
)

func SetConfig() {
config := sdk.GetConfig()
// use the configurations from ethermint
cmdcfg.SetBech32Prefixes(config)
cmdcfg.SetBip44CoinType(config)
ethcfg.SetBip44CoinType(config)
// Make sure address is compatible with ethereum
config.SetAddressVerifier(VerifyAddressFormat)
config.Seal()
Expand Down
10 changes: 10 additions & 0 deletions cmd/cronosd/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package config

import sdk "github.com/cosmos/cosmos-sdk/types"

// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings.
func SetBech32Prefixes(config *sdk.Config) {
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
}
23 changes: 23 additions & 0 deletions cmd/cronosd/config/prefix_mainnet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// +build !testnet

package config

import sdk "github.com/cosmos/cosmos-sdk/types"

const (
// Bech32Prefix defines the Bech32 prefix used for Cronos Accounts
Bech32Prefix = "crc"

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = Bech32Prefix
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic
)
23 changes: 23 additions & 0 deletions cmd/cronosd/config/prefix_testnet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// +build testnet

package config

import sdk "github.com/cosmos/cosmos-sdk/types"

const (
// Bech32Prefix defines the Bech32 prefix used for Cronos Accounts
Bech32Prefix = "tcrc"

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = Bech32Prefix
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic
)
2 changes: 1 addition & 1 deletion integration_tests/test_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def gravity(cronos, geth, suspend_capture):
f"--ethereum-key={eth_accounts[i].key.hex()} "
f"--cosmos-grpc=http://localhost:{grpc_port} "
f"--ethereum-rpc={geth.provider.endpoint_uri} "
"--address-prefix=ethm --fees=basetcro "
"--address-prefix=crc --fees=basetcro "
f"--contract-address={contract.address} "
f"--metrics-listen 127.0.0.1:{metrics_port}"
)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"community": "5D665FBD2FB40CB8E9849263B04457BA46D5F948972D0FE4C1F19B6B0F243574",
}
ADDRS = {name: Account.from_key(key).address for name, key in KEYS.items()}
CRONOS_ADDRESS_PREFIX = "ethm"
CRONOS_ADDRESS_PREFIX = "crc"


def wait_for_fn(name, fn, *, timeout=120, interval=1):
Expand Down