diff --git a/README.md b/README.md index a644abc9..e24ba81a 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,29 @@ + + +# 0G Chain
-[![version](https://img.shields.io/github/tag/kava-labs/kava.svg)](https://github.com/kava-labs/kava/releases/latest) -[![CircleCI](https://circleci.com/gh/Kava-Labs/kava/tree/master.svg?style=shield)](https://circleci.com/gh/Kava-Labs/kava/tree/master) -[![Go Report Card](https://goreportcard.com/badge/github.com/kava-labs/kava)](https://goreportcard.com/report/github.com/kava-labs/kava) -[![API Reference](https://godoc.org/github.com/Kava-Labs/kava?status.svg)](https://godoc.org/github.com/Kava-Labs/kava) -[![GitHub](https://img.shields.io/github/license/kava-labs/kava.svg)](https://github.com/Kava-Labs/kava/blob/master/LICENSE.md) -[![Twitter Follow](https://img.shields.io/twitter/follow/KAVA_CHAIN.svg?label=Follow&style=social)](https://twitter.com/KAVA_CHAIN) -[![Discord Chat](https://img.shields.io/discord/704389840614981673.svg)](https://discord.com/invite/kQzh3Uv) +### [Telegram](https://t.me/web3_0glabs) | [Discord](https://discord.com/invite/0glabs)
-
- -### [Telegram](https://t.me/kavalabs) | [Medium](https://medium.com/kava-labs) | [Discord](https://discord.gg/JJYnuCx) - -
- -Reference implementation of Kava, a blockchain for cross-chain DeFi. Built using the [cosmos-sdk](https://github.com/cosmos/cosmos-sdk). +Reference implementation of 0G Chain, the first modular AI chain. Built using the [cosmos-sdk](https://github.com/cosmos/cosmos-sdk). + \ No newline at end of file diff --git a/go.mod b/go.mod index 9f4e4f35..e9b22d29 100644 --- a/go.mod +++ b/go.mod @@ -199,6 +199,7 @@ require ( google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect @@ -212,13 +213,13 @@ replace ( // Use rocksdb 7.9.2 github.com/cometbft/cometbft-db => github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-kava.1 // Use cosmos-sdk fork with backported fix for unsafe-reset-all, staking transfer events, and custom tally handler support - github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.46.11-0glabs.5 + github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.46.11-0glabs.8 // See https://github.com/cosmos/cosmos-sdk/pull/13093 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 // Use go-ethereum fork with precompiles github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2 // Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support - github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v2.0.2 + github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v2.0.4 // See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 // Use the cosmos modified protobufs diff --git a/go.sum b/go.sum index 227f3ecb..5965a295 100644 --- a/go.sum +++ b/go.sum @@ -204,10 +204,10 @@ git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFN git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= github.com/0glabs/cometbft v0.34.27-0glabs.0 h1:jErty8aVtp2RiU/59QTEhUCi3xCoc67NHHsmIqd7Xz4= github.com/0glabs/cometbft v0.34.27-0glabs.0/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw= -github.com/0glabs/cosmos-sdk v0.46.11-0glabs.5 h1:/7zqU8Az6n3UpKnypKQ92Yw8AgrE1v1AfatrL8elajs= -github.com/0glabs/cosmos-sdk v0.46.11-0glabs.5/go.mod h1:jwgWoeAWxqMF5pZUZ4N+G4rD3q6oOLulq3/dGCFLEX4= -github.com/0glabs/ethermint v0.21.0-0g.v2.0.2 h1:mFVOMra9lmeNk+CgL0UsBxqiXHx5JWVeiURJFgQmHzY= -github.com/0glabs/ethermint v0.21.0-0g.v2.0.2/go.mod h1:KPLRino6lVDPV/cZCbQf7dZdR1nsVgptr0Htf6ZxZe8= +github.com/0glabs/cosmos-sdk v0.46.11-0glabs.8 h1:zYkr1AaeyxIxrGyt/B/Xc4l/xWsdk71yo1CniPmrvuo= +github.com/0glabs/cosmos-sdk v0.46.11-0glabs.8/go.mod h1:4uTpR8WwpNKawdsPj5uyUS8DvKilc2OyFKe4RBm4oso= +github.com/0glabs/ethermint v0.21.0-0g.v2.0.4 h1:UFQflLvLk7uvJcKLvpKY6U3n5WU3Osphrf9VUSPgfBY= +github.com/0glabs/ethermint v0.21.0-0g.v2.0.4/go.mod h1:o5lh9adPdMNNAweyDYleu3FRAJyRIy1drdMcSpo1qy8= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= @@ -1898,6 +1898,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/localtestnet.sh b/localtestnet.sh index a5137590..2c1040f0 100755 --- a/localtestnet.sh +++ b/localtestnet.sh @@ -66,9 +66,12 @@ userKeyName="user" printf "$userMnemonic\n" | $BINARY keys add $userKeyName --eth --recover $BINARY add-genesis-account $userKeyName 1000000000000000000000ua0gi +VESTING_ACCOUNT_START_TIME=$(date -u +%s) +VESTING_ACCOUNT_END_TIME=$((VESTING_ACCOUNT_START_TIME + 30 * 60)) + vestingKeyName="vesting" printf "$vestingMnemonic\n" | $BINARY keys add $vestingKeyName --eth --recover -$BINARY add-genesis-account $vestingKeyName 1000000000000000000000ua0gi --vesting-amount 1000000000000000000000ua0gi --vesting-start-time 1717200000 --vesting-end-time 1719791999 +$BINARY add-genesis-account $vestingKeyName 1000000000000000000000ua0gi --vesting-amount 1000000000000000000000ua0gi --vesting-start-time $VESTING_ACCOUNT_START_TIME --vesting-end-time $VESTING_ACCOUNT_END_TIME storageContractAcc="0g1vsjpjgw8p5f4x0nwp8ernl9lkszewcqqss7r5d" $BINARY add-genesis-account $storageContractAcc 1000000000000000000000ua0gi diff --git a/networks/devnet/deploy.sh b/networks/devnet/deploy.sh index fce079e1..13507374 100755 --- a/networks/devnet/deploy.sh +++ b/networks/devnet/deploy.sh @@ -7,6 +7,7 @@ function help() { echo " -k Keyring password to create key (for Linux only)" echo " -n Network (default: devnet)" echo " -c Chain ID (default: \"zgtendermint_16600-1\")" + echo " -v schedule end time (unix epoch) for vesting accounts" echo "" } @@ -22,7 +23,9 @@ shift PEM_FLAG="" KEYRING_PASSWORD="" NETWORK="devnet" +TAG_OR_BRANCH="dev" INIT_GENESIS_ENV="" +VESTING_ACCOUNT_END_TIME=0 while [[ $# -gt 0 ]]; do case $1 in @@ -43,6 +46,10 @@ while [[ $# -gt 0 ]]; do INIT_GENESIS_ENV="$INIT_GENESIS_ENV export CHAIN_ID=$2;" shift; shift ;; + -v) + INIT_GENESIS_ENV="$INIT_GENESIS_ENV export VESTING_ACCOUNT_END_TIME=$2;" + shift; shift + ;; *) help echo "Unknown flag passed: \"$1\"" @@ -56,11 +63,11 @@ NUM_NODES=${#IPS[@]} # Install dependent libraries and binary for ((i=0; i<$NUM_NODES; i++)) do - ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0g-chain; git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; git checkout patch_testnet_1; ./networks/devnet/install.sh" + ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0g-chain; git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; git checkout $TAG_OR_BRANCH; ./networks/$NETWORK/install.sh" done # Create genesis config on node0 -ssh $PEM_FLAG ubuntu@${IPS[0]} "cd 0g-chain/networks/devnet; $INIT_GENESIS_ENV ./init-genesis.sh $IP_LIST $KEYRING_PASSWORD; tar czf ~/$NETWORK.tar.gz $NETWORK; rm -rf $NETWORK" +ssh $PEM_FLAG ubuntu@${IPS[0]} "cd 0g-chain/networks/$NETWORK; $INIT_GENESIS_ENV ./init-genesis.sh $IP_LIST $KEYRING_PASSWORD; tar czf ~/$NETWORK.tar.gz $NETWORK; rm -rf $NETWORK" scp $PEM_FLAG ubuntu@${IPS[0]}:$NETWORK.tar.gz . ssh $PEM_FLAG ubuntu@${IPS[0]} "rm $NETWORK.tar.gz" @@ -71,7 +78,7 @@ cd $NETWORK for ((i=0; i<$NUM_NODES; i++)) do tar czf node$i.tar.gz node$i scp $PEM_FLAG node$i.tar.gz ubuntu@${IPS[$i]}:~ - ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0gchaind-prod; tar xzf node$i.tar.gz; rm node$i.tar.gz; mv node$i 0gchaind-prod" + ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0gchaind-$NETWORK; tar xzf node$i.tar.gz; rm node$i.tar.gz; mv node$i 0gchaind-$NETWORK" rm node$i.tar.gz done diff --git a/networks/devnet/init-genesis.sh b/networks/devnet/init-genesis.sh index 66016681..760acbe3 100755 --- a/networks/devnet/init-genesis.sh +++ b/networks/devnet/init-genesis.sh @@ -33,9 +33,12 @@ set -e IFS=","; declare -a IPS=($1); unset IFS NUM_NODES=${#IPS[@]} -VLIDATOR_BALANCE=15000000000000000000ua0gi -FAUCET_BALANCE=40000000000000000000ua0gi -STAKING=10000000000000000000ua0gi +VALIDATOR_BALANCE=25000000000000ua0gi +FAUCET_BALANCE=500000000000000ua0gi +STAKING=5000000000000ua0gi +VESTING_BALANCE=400000000000000ua0gi + +VESTING_ACCOUNT_START_TIME=$(date -u +%s) # Init configs for ((i=0; i<$NUM_NODES; i++)) do @@ -77,6 +80,7 @@ for ((i=0; i<$NUM_NODES; i++)) do cat "$GENESIS" | jq '.app_state["slashing"]["params"]["signed_blocks_window"]="1000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" cat "$GENESIS" | jq '.app_state["consensus_params"]["block"]["time_iota_ms"]="3000"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + cat "$GENESIS" | jq '.app_state.gov.voting_params.voting_period = "300s"' >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # Change app.toml APP_TOML="$HOMEDIR"/config/app.toml @@ -85,7 +89,7 @@ for ((i=0; i<$NUM_NODES; i++)) do sed -i '/\[json-rpc\]/,/^\[/ s/address = "127.0.0.1:8545"/address = "0.0.0.0:8545"/' "$APP_TOML" # Set evm tracer to json - sed -in-place='' 's/tracer = ""/tracer = "json"/g' "$APP_TOML" + # sed -in-place='' 's/tracer = ""/tracer = "json"/g' "$APP_TOML" # Enable full error trace to be returned on tx failure sed -in-place='' '/iavl-cache-size/a\ @@ -146,12 +150,13 @@ fi for ((i=0; i<$NUM_NODES; i++)) do for ((j=0; j<$NUM_NODES; j++)) do if [[ "$OS_NAME" = "GNU/Linux" ]]; then - yes $PASSWORD | 0gchaind add-genesis-account "0gchain_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i" + yes $PASSWORD | 0gchaind add-genesis-account "0gchain_validator_$j" $VALIDATOR_BALANCE --home "$ROOT_DIR/node$i" else - 0gchaind add-genesis-account "0gchain_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i" + 0gchaind add-genesis-account "0gchain_validator_$j" $VALIDATOR_BALANCE --home "$ROOT_DIR/node$i" fi done - 0gchaind add-genesis-account 0g17n8707c20e8gge2tk2gestetjcs4536p4fhqcs $FAUCET_BALANCE --home "$ROOT_DIR/node$i" + 0gchaind add-genesis-account 0g1zyvrkyr8pmczkguxztxpp3qcd0uhkt0tfxjupt $FAUCET_BALANCE --home "$ROOT_DIR/node$i" + 0gchaind add-genesis-account 0g1jwuhghh6qrln4tthhqrdt3qrmjn9zm05xns46u $VESTING_BALANCE --vesting-amount $VESTING_BALANCE --vesting-start-time $VESTING_ACCOUNT_START_TIME --vesting-end-time $VESTING_ACCOUNT_END_TIME --home "$ROOT_DIR/node$i" done # Prepare genesis txs diff --git a/networks/devnet/install.sh b/networks/devnet/install.sh index 52f288c3..2211e8b5 100755 --- a/networks/devnet/install.sh +++ b/networks/devnet/install.sh @@ -13,6 +13,7 @@ if [[ $? -ne 0 ]]; then # Make under root dir SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` cd $SCRIPT_DIR/../.. + rm -rf $(go env GOPATH)/bin/0gchaind make install # Add gopath to path diff --git a/networks/testnet/deploy.sh b/networks/testnet/deploy.sh index a2723591..33745a39 100755 --- a/networks/testnet/deploy.sh +++ b/networks/testnet/deploy.sh @@ -7,6 +7,7 @@ function help() { echo " -k Keyring password to create key (for Linux only)" echo " -n Network (default: testnet)" echo " -c Chain ID (default: \"zgtendermint_16600-1\")" + echo " -v schedule end time (unix epoch) for vesting accounts" echo "" } @@ -23,6 +24,7 @@ PEM_FLAG="" KEYRING_PASSWORD="" NETWORK="testnet" INIT_GENESIS_ENV="" +VESTING_ACCOUNT_END_TIME=0 while [[ $# -gt 0 ]]; do case $1 in @@ -43,6 +45,10 @@ while [[ $# -gt 0 ]]; do INIT_GENESIS_ENV="$INIT_GENESIS_ENV export CHAIN_ID=$2;" shift; shift ;; + -v) + INIT_GENESIS_ENV="$INIT_GENESIS_ENV export VESTING_ACCOUNT_END_TIME=$2;" + shift; shift + ;; *) help echo "Unknown flag passed: \"$1\"" @@ -56,7 +62,7 @@ NUM_NODES=${#IPS[@]} # Install dependent libraries and binary for ((i=0; i<$NUM_NODES; i++)) do - ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0g-chain; git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; git checkout v0.1.0; ./networks/testnet/install.sh" + ssh $PEM_FLAG ubuntu@${IPS[$i]} "rm -rf 0g-chain; git clone https://github.com/0glabs/0g-chain.git; cd 0g-chain; git checkout v0.2.3; ./networks/testnet/install.sh" done # Create genesis config on node0 diff --git a/networks/testnet/init-genesis.sh b/networks/testnet/init-genesis.sh index 67a624e7..6c72fa77 100755 --- a/networks/testnet/init-genesis.sh +++ b/networks/testnet/init-genesis.sh @@ -33,9 +33,12 @@ set -e IFS=","; declare -a IPS=($1); unset IFS NUM_NODES=${#IPS[@]} -VLIDATOR_BALANCE=15000000000000000000ua0gi -FAUCET_BALANCE=40000000000000000000ua0gi -STAKING=10000000000000000000ua0gi +VALIDATOR_BALANCE=25000000000000ua0gi +FAUCET_BALANCE=500000000000000ua0gi +STAKING=5000000000000ua0gi +VESTING_BALANCE=400000000000000ua0gi + +VESTING_ACCOUNT_START_TIME=$(date -u +%s) # Init configs for ((i=0; i<$NUM_NODES; i++)) do @@ -85,7 +88,7 @@ for ((i=0; i<$NUM_NODES; i++)) do sed -i '/\[json-rpc\]/,/^\[/ s/address = "127.0.0.1:8545"/address = "0.0.0.0:8545"/' "$APP_TOML" # Set evm tracer to json - sed -in-place='' 's/tracer = ""/tracer = "json"/g' "$APP_TOML" + # sed -in-place='' 's/tracer = ""/tracer = "json"/g' "$APP_TOML" # Enable full error trace to be returned on tx failure sed -in-place='' '/iavl-cache-size/a\ @@ -146,12 +149,13 @@ fi for ((i=0; i<$NUM_NODES; i++)) do for ((j=0; j<$NUM_NODES; j++)) do if [[ "$OS_NAME" = "GNU/Linux" ]]; then - yes $PASSWORD | 0gchaind add-genesis-account "0gchain_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i" + yes $PASSWORD | 0gchaind add-genesis-account "0gchain_validator_$j" $VALIDATOR_BALANCE --home "$ROOT_DIR/node$i" else - 0gchaind add-genesis-account "0gchain_validator_$j" $VLIDATOR_BALANCE --home "$ROOT_DIR/node$i" + 0gchaind add-genesis-account "0gchain_validator_$j" $VALIDATOR_BALANCE --home "$ROOT_DIR/node$i" fi done - 0gchaind add-genesis-account 0g17n8707c20e8gge2tk2gestetjcs4536p4fhqcs $FAUCET_BALANCE --home "$ROOT_DIR/node$i" + 0gchaind add-genesis-account 0g1e4t48fq42tqxpapvpnuc9n9k998eex9rnyqzwm $FAUCET_BALANCE --home "$ROOT_DIR/node$i" + 0gchaind add-genesis-account 0g16yvxafe63uzuxu6xpvpxdz9agdvnh0zn8vnuj6 $VESTING_BALANCE --vesting-amount $VESTING_BALANCE --vesting-start-time $VESTING_ACCOUNT_START_TIME --vesting-end-time $VESTING_ACCOUNT_END_TIME --home "$ROOT_DIR/node$i" done # Prepare genesis txs diff --git a/networks/testnet/install.sh b/networks/testnet/install.sh index 52f288c3..2211e8b5 100755 --- a/networks/testnet/install.sh +++ b/networks/testnet/install.sh @@ -13,6 +13,7 @@ if [[ $? -ne 0 ]]; then # Make under root dir SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` cd $SCRIPT_DIR/../.. + rm -rf $(go env GOPATH)/bin/0gchaind make install # Add gopath to path