okx / exchain

⛓️ EVM & Wasm $ IBC-compatible, OKTC is a L1 blockchain network built on top of Cosmos SDK that aims for optimal interoperability and performance ✨
https://www.okx.com/oktc
Other
561 stars 182 forks source link

Failed to setup testnet locally #3040

Open chenrui333 opened 1 year ago

chenrui333 commented 1 year ago

I have run make testnet LINK_STATICALLY=true successfully in my local, since I am running on macOS arm, I have commented out this block

ifeq ($(LINK_STATICALLY),true)
    ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif

Otherwise I would get ld: library not found for -lcrt0.o

Now I am trying to set up testnet reading this doc, https://www.okx.com/okc/docs/dev/quick-start/join-okc-testnet.html

But I am seeing this error when running exchaind init

The error is as below:

$ exchaind init ruitest --chain-id exchain-65 --home ~/.exchaind
ERROR: Must use <make testnet> to rebuild if chain-id is <exchain-65>, Current GenesisHeight is <0>

If I change chain-id from 65 to 67, it would pass (I saw in the tutorial video that the chain-id should be 67??).

Now with exchain-67, I got some validator error:

error during handshake: error on replay: validator set is nil in genesis and still empty after InitChain

Let me know if I need provide more info.

cwbhhjl commented 1 year ago

When you execute 'make', you will see output like this:

go install -v -ldflags '-X github.com/okex/exchain/libs/cosmos-sdk/version.Version=v1.6.8.5 
-X github.com/okex/exchain/libs/cosmos-sdk/version.Name=exchain 
-X github.com/okex/exchain/libs/cosmos-sdk/version.ServerName=exchaind 
-X github.com/okex/exchain/libs/cosmos-sdk/version.ClientName=exchaincli 
-X github.com/okex/exchain/libs/cosmos-sdk/version.Commit=71582060ed0ee1602b78bdce7c183c4ec4144456 
-X github.com/okex/exchain/libs/cosmos-sdk/version.CosmosSDK=v0.39.2 
-X github.com/okex/exchain/libs/cosmos-sdk/version.Tendermint=v0.33.9 
-X "github.com/okex/exchain/libs/cosmos-sdk/version.BuildTags=netgo rocksdb muslc" 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_GENESIS_HEIGHT=1121818 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_MERCURY_HEIGHT=5300000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS_HEIGHT=8510000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS1_HEIGHT=12067000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS2_HEIGHT=14781000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS3_HEIGHT=15540000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS4_HEIGHT=17531500 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS5_HEIGHT=18861500 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_EARTH_HEIGHT=17364500 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_MARS_HEIGHT=0 
-X github.com/okex/exchain/libs/tendermint/types.DBBackend=rocksdb 
-X github.com/okex/exchain/libs/cosmos-sdk/server.ChainID=exchain-65'
 -tags "netgo rocksdb muslc" ./cmd/exchaind

You may notice that 'types.MILESTONE_GENESIS_HEIGHT' is set to 1121818. When 'make testnet' is executed, some parameters are set to match the network configuration of OKC testnet, whose chain ID is 65. If you compile 'exchaind' using 'make testnet' and configure it with a chain ID other than 65, it will report an error, for example.

exchaind init ruitest --chain-id exchain-66
ERROR: Must use <make mainnet> to rebuild if chain-id is <exchain-66>, Current GenesisHeight is <1121818>

it shows 'GenesisHeight is <1121818>', the same as the one passed when executing 'make', while your output shows 'Current GenesisHeight is <0>', so it doesn't seem like the testnet configuration is being used. Could you try executing 'make testnet' again and observe the output of 'make'?

cwbhhjl commented 1 year ago

By the way, may I ask if you intend to run a testnet node or just need to start some test nodes locally without joining the testnet?

chenrui333 commented 1 year ago

When you execute 'make', you will see output like this:

go install -v -ldflags '-X github.com/okex/exchain/libs/cosmos-sdk/version.Version=v1.6.8.5 
-X github.com/okex/exchain/libs/cosmos-sdk/version.Name=exchain 
-X github.com/okex/exchain/libs/cosmos-sdk/version.ServerName=exchaind 
-X github.com/okex/exchain/libs/cosmos-sdk/version.ClientName=exchaincli 
-X github.com/okex/exchain/libs/cosmos-sdk/version.Commit=71582060ed0ee1602b78bdce7c183c4ec4144456 
-X github.com/okex/exchain/libs/cosmos-sdk/version.CosmosSDK=v0.39.2 
-X github.com/okex/exchain/libs/cosmos-sdk/version.Tendermint=v0.33.9 
-X "github.com/okex/exchain/libs/cosmos-sdk/version.BuildTags=netgo rocksdb muslc" 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_GENESIS_HEIGHT=1121818 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_MERCURY_HEIGHT=5300000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS_HEIGHT=8510000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS1_HEIGHT=12067000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS2_HEIGHT=14781000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS3_HEIGHT=15540000 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS4_HEIGHT=17531500 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS5_HEIGHT=18861500 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_EARTH_HEIGHT=17364500 
-X github.com/okex/exchain/libs/tendermint/types.MILESTONE_MARS_HEIGHT=0 
-X github.com/okex/exchain/libs/tendermint/types.DBBackend=rocksdb 
-X github.com/okex/exchain/libs/cosmos-sdk/server.ChainID=exchain-65'
 -tags "netgo rocksdb muslc" ./cmd/exchaind

You may notice that 'types.MILESTONE_GENESIS_HEIGHT' is set to 1121818. When 'make testnet' is executed, some parameters are set to match the network configuration of OKC testnet, whose chain ID is 65. If you compile 'exchaind' using 'make testnet' and configure it with a chain ID other than 65, it will report an error, for example.

exchaind init ruitest --chain-id exchain-66
ERROR: Must use <make mainnet> to rebuild if chain-id is <exchain-66>, Current GenesisHeight is <1121818>

it shows 'GenesisHeight is <1121818>', the same as the one passed when executing 'make', while your output shows 'Current GenesisHeight is <0>', so it doesn't seem like the testnet configuration is being used. Could you try executing 'make testnet' again and observe the output of 'make'?

this is what I have

CGO_CFLAGS="-I/opt/homebrew/Cellar/rocksdb/6.27.3_1/include" CGO_LDFLAGS="-L/opt/homebrew/Cellar/rocksdb/6.27.3_1/lib -lrocksdb -lstdc++ -lm  -lsnappy -llz4" go install -v -ldflags '-X github.com/okex/exchain/libs/cosmos-sdk/version.Version=v1.6.8.5 -X github.com/okex/exchain/libs/cosmos-sdk/version.Name=exchain -X github.com/okex/exchain/libs/cosmos-sdk/version.ServerName=exchaind -X github.com/okex/exchain/libs/cosmos-sdk/version.ClientName=exchaincli -X github.com/okex/exchain/libs/cosmos-sdk/version.Commit=34fc925e1713697c27da5d358f9d5d37c52d2b22 -X github.com/okex/exchain/libs/cosmos-sdk/version.CosmosSDK=v0.39.2 -X github.com/okex/exchain/libs/cosmos-sdk/version.Tendermint=v0.33.9 -X "github.com/okex/exchain/libs/cosmos-sdk/version.BuildTags=netgo rocksdb muslc" -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_GENESIS_HEIGHT=1121818 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_MERCURY_HEIGHT=5300000 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS_HEIGHT=8510000 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS1_HEIGHT=12067000 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS2_HEIGHT=14781000 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS3_HEIGHT=15540000 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS4_HEIGHT=17531500 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_VENUS5_HEIGHT=18861500 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_EARTH_HEIGHT=17364500 -X github.com/okex/exchain/libs/tendermint/types.MILESTONE_MARS_HEIGHT=0 -X github.com/okex/exchain/libs/tendermint/types.DBBackend=rocksdb -X github.com/okex/exchain/libs/cosmos-sdk/server.ChainID=exchain-65' -tags "netgo rocksdb muslc" ./cmd/exchaincli
chenrui333 commented 1 year ago

By the way, may I ask if you intend to run a testnet node or just need to start some test nodes locally without joining the testnet?

personally, I dont want to join the testnet due to the storage concern (I only have 80gb free space on my laptop), but I did not see any guides on how to deploy the contract into testnet (I am a newbie, any pointer on it?)

cwbhhjl commented 1 year ago

If you run "exchaind init", will it still report the previous error?

If you want to deploy a contract on the testnet, use https://exchaintestrpc.okex.org/ with chainid 65. Then you can use the testnet like any other EVM-compatible chain. The API documentation is available at https://www.okx.com/okc/docs/dev/api/okc-api/json-rpc-api.html. You can get test OKT tokens here: https://www.okx.com/okc/faucet.

chenrui333 commented 1 year ago

If you run "exchaind init", will it still report the previous error?

Yeah, even after the build I still have exchaind init, only after changing the chain id, I can get it working.

If you want to deploy a contract on the testnet, use https://exchaintestrpc.okex.org/ with chainid 65. Then you can use the testnet like any other EVM-compatible chain. The API documentation is available at https://www.okx.com/okc/docs/dev/api/okc-api/json-rpc-api.html. You can get test OKT tokens here: https://www.okx.com/okc/faucet.

I will check it out, I think I need that more than building my own, thanks!

Osub commented 11 months ago

如何修改 chainID exchain-65 为兼容evm的 1028等整数iD?