Skip to content

Commit

Permalink
Change account prefix to crc (#86)
Browse files Browse the repository at this point in the history
* change prefix to crc
  • Loading branch information
thomas-nguy authored Sep 20, 2021
1 parent a3b9829 commit 66966ed
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 7 deletions.
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

0 comments on commit 66966ed

Please sign in to comment.