Skip to content

Commit

Permalink
Merge pull request #881 from bnb-chain/develop
Browse files Browse the repository at this point in the history
Prepare for release v0.10.2
  • Loading branch information
unclezoro authored Sep 2, 2022
2 parents 021545a + ea00de9 commit 3e52402
Show file tree
Hide file tree
Showing 24 changed files with 248 additions and 161 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Docker

on:
push:
# Publish `v1.2.3` tags as releases.
tags:
- v*

env:
IMAGE_NAME: node

jobs:
# Push image to GitHub Packages.
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: |
docker build . \
--label "org.opencontainers.image.source=${{ secrets.IMAGE_SOURCE }}" \
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
--label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \
--label "org.opencontainers.image.licenses=MPL-2.0" \
-f ./Dockerfile -t "${IMAGE_NAME}"
- name: Log into registry
run: echo "${{ secrets.PACKAGE_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_ID:latest
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.10.2
FEATURES
* [\#878](https://github.com/bnb-chain/node/pull/878) [CI] Add ci script to build docker image
* [\#879](https://github.com/bnb-chain/node/pull/879) [Staking] Implement BEP153: Native Staking on BSC

## 0.10.1
IMPROVEMENTS
* [\#882](https://github.com/bnb-chain/node/pull/882) [DEX] Add BEP151 Mainnet Height
Expand Down
42 changes: 28 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
FROM golang:1.11-alpine AS build-env
FROM golang:1.17-alpine AS build-env

# Set up dependencies
ENV PACKAGES make git libc-dev bash gcc linux-headers eudev-dev curl ca-certificates ssh
ENV PACKAGES make git libc-dev bash gcc linux-headers eudev-dev curl ca-certificates

# Set working directory for the build
WORKDIR /go/src/github.com/bnb-chain/node

# Add source files
COPY . .

# Add ssh key to download private deps
COPY ~/.ssh/id_rsa /root/ssh/

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apk add --no-cache $PACKAGES && \
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh && \
make get_vendor_deps && \
make build-alpine && \
make build && \
make install

# Final image
FROM alpine:edge
# # Final image
FROM alpine:3.16.0

# Install dependencies
RUN apk add --update ca-certificates tini bash

ARG USER=bnbchain
ARG USER_UID=1000
ARG USER_GID=1000

# Install ca-certificates
RUN apk add --update ca-certificates
WORKDIR /root
ENV DEFAULT_CONFIG=/configs
ENV HOME=/data

RUN addgroup -g ${USER_GID} ${USER} \
&& adduser -u ${USER_UID} -G ${USER} --shell /sbin/nologin --no-create-home -D ${USER} \
&& addgroup ${USER} tty
RUN mkdir -p ${HOME} ${DEFAULT_CONFIG}
WORKDIR ${HOME}

# Copy over binaries from the build-env
COPY --from=build-env /go/bin/bnbchaind /usr/bin/bnbchaind
COPY --from=build-env /go/bin/bnbcli /usr/bin/bnbcli
COPY docker-entrypoint.sh /
COPY ./asset/ ${DEFAULT_CONFIG}/

RUN chown -R ${USER_UID}:${USER_GID} ${HOME} \
&& chmod +x /docker-entrypoint.sh

USER ${USER}:${USER}

# Run gaiad by default, omit entrypoint to ease using container with gaiacli
CMD ["bnbchaind"]
CMD ["/sbin/tini", "--", "/docker-entrypoint.sh"]
30 changes: 30 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"encoding/hex"
"encoding/json"
"fmt"
"io"
Expand All @@ -26,7 +27,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/sidechain"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake"
cStake "github.com/cosmos/cosmos-sdk/x/stake/cross_stake"
"github.com/cosmos/cosmos-sdk/x/stake/keeper"
sTypes "github.com/cosmos/cosmos-sdk/x/stake/types"

abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/tmhash"
Expand Down Expand Up @@ -171,6 +174,8 @@ func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseApp
common.StakeStoreKey, common.StakeRewardStoreKey, common.TStakeStoreKey,
app.CoinKeeper, app.Pool, app.ParamHub.Subspace(stake.DefaultParamspace),
app.RegisterCodespace(stake.DefaultCodespace),
sdk.ChainID(app.crossChainConfig.BscIbcChainId),
app.crossChainConfig.BscChainId,
)

app.ValAddrCache = NewValAddrCache(app.stakeKeeper)
Expand Down Expand Up @@ -329,6 +334,7 @@ func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) {
upgrade.Mgr.AddUpgradeHeight(upgrade.FixFailAckPackage, upgradeConfig.FixFailAckPackageHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP128, upgradeConfig.BEP128Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP151, upgradeConfig.BEP151Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP153, upgradeConfig.BEP153Height)

// register store keys of upgrade
upgrade.Mgr.RegisterStoreKeys(upgrade.BEP9, common.TimeLockStoreKey.Name())
Expand Down Expand Up @@ -536,6 +542,30 @@ func (app *BinanceChain) initStaking() {
params.RewardDistributionBatchSize = 1000
app.stakeKeeper.SetParams(newCtx, params)
})
upgrade.Mgr.RegisterBeginBlocker(sdk.BEP153, func(ctx sdk.Context) {
chainId := sdk.ChainID(ServerContext.BscIbcChainId)
app.scKeeper.SetChannelSendPermission(ctx, chainId, sTypes.CrossStakeChannelID, sdk.ChannelAllow)
stakeContractAddr := "0000000000000000000000000000000000002001"
stakeContractBytes, _ := hex.DecodeString(stakeContractAddr)
_, sdkErr := app.scKeeper.CreateNewChannelToIbc(ctx, chainId, sTypes.CrossStakeChannelID, sdk.RewardNotFromSystem, stakeContractBytes)
if sdkErr != nil {
panic(sdkErr.Error())
}
crossStakeApp := cStake.NewCrossStakeApp(app.stakeKeeper)
err := app.scKeeper.RegisterChannel(sTypes.CrossStakeChannel, sTypes.CrossStakeChannelID, crossStakeApp)
if err != nil {
panic(err)
}
})

if sdk.IsUpgrade(sdk.BEP153) {
crossStakeApp := cStake.NewCrossStakeApp(app.stakeKeeper)
err := app.scKeeper.RegisterChannel(sTypes.CrossStakeChannel, sTypes.CrossStakeChannelID, crossStakeApp)
if err != nil {
panic(err)
}
}

app.stakeKeeper.SubscribeParamChange(app.ParamHub)
app.stakeKeeper = app.stakeKeeper.WithHooks(app.slashKeeper.Hooks())
}
Expand Down
4 changes: 4 additions & 0 deletions app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ EnableAccountScriptsForCrossChainTransferHeight = {{ .UpgradeConfig.EnableAccoun
BEP128Height = {{ .UpgradeConfig.BEP128Height }}
# Block height of BEP151 upgrade
BEP151Height = {{ .UpgradeConfig.BEP151Height }}
# Block height of BEP153 upgrade
BEP153Height = {{ .UpgradeConfig.BEP153Height }}
[query]
# ABCI query interface black list, suggested value: ["custom/gov/proposals", "custom/timelock/timelocks", "custom/atomicSwap/swapcreator", "custom/atomicSwap/swaprecipient"]
Expand Down Expand Up @@ -529,6 +531,7 @@ type UpgradeConfig struct {
EnableAccountScriptsForCrossChainTransferHeight int64 `mapstructure:"EnableAccountScriptsForCrossChainTransferHeight"`
BEP128Height int64 `mapstructure:"BEP128Height"`
BEP151Height int64 `mapstructure:"BEP151Height"`
BEP153Height int64 `mapstructure:"BEP153Height"`
}

func defaultUpgradeConfig() *UpgradeConfig {
Expand All @@ -550,6 +553,7 @@ func defaultUpgradeConfig() *UpgradeConfig {
LaunchBscUpgradeHeight: 1,
BEP128Height: math.MaxInt64,
BEP151Height: math.MaxInt64,
BEP153Height: math.MaxInt64,
BEP82Height: math.MaxInt64,
BEP84Height: math.MaxInt64,
BEP87Height: math.MaxInt64,
Expand Down
2 changes: 1 addition & 1 deletion asset/mainnet/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ localMaxAge = 7
[log]

# Write logs to console instead of file
logToConsole = false
logToConsole = true

## The below parameters take effect only when logToConsole is false
# Log file root, if not set, use home path
Expand Down
4 changes: 3 additions & 1 deletion asset/testnet/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ EnableAccountScriptsForCrossChainTransferHeight = 7841000
BEP128Height = 23551600
#Block height of BEP151 upgrade
BEP151Height = 28250000
#Block height of BEP153 upgrade
BEP153Height = 30516226

[query]
# ABCI query interface black list, suggested value: ["custom/gov/proposals", "custom/timelock/timelocks", "custom/atomicSwap/swapcreator", "custom/atomicSwap/swaprecipient"]
Expand Down Expand Up @@ -169,7 +171,7 @@ kafkaVersion = "2.1.0"
[log]

# Write logs to console instead of file
logToConsole = false
logToConsole = true

## The below parameters take effect only when logToConsole is false
# Log file root, if not set, use home path
Expand Down
2 changes: 1 addition & 1 deletion asset/testnet/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ with_app_stat = true
[rpc]

# TCP or UNIX socket address for the RPC server to listen on
laddr = "tcp://0.0.0.0:26657"
laddr = "tcp://0.0.0.0:27147"

# A list of origins a cross-domain request can be executed from
# Default value '[]' disables cors support
Expand Down
1 change: 1 addition & 0 deletions common/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (

BEP128 = sdk.BEP128 // https://github.com/bnb-chain/BEPs/pull/128 Staking reward distribution upgrade
BEP151 = "BEP151" // https://github.com/bnb-chain/BEPs/pull/151 Decommission Decentralized Exchange
BEP153 = sdk.BEP153 // https://github.com/bnb-chain/BEPs/pull/153 Native Staking
)

func UpgradeBEP10(before func(), after func()) {
Expand Down
14 changes: 14 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

DEFAULT_NETWORK=("mainnet" "testnet")
NETWORK=${NETWORK:-mainnet}
HOME=${HOME:-/data}
DEFAULT_CONFIG=${DEFAULT_CONFIG:-/configs}

if echo ${DEFAULT_NETWORK[@]} | grep -q -w "${NETWORK}"
then
mkdir -p ${HOME}/config
cp ${DEFAULT_CONFIG}/${NETWORK}/* ${HOME}/config/
fi

exec "bnbchaind" "start" "--home" ${HOME} "$@"
27 changes: 27 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Docker Usage

### Image
```sh
docker pull ghcr.io/bnb-chain/node:latest
```

### Env

| env | desc | default|
|---|---|---|
| NETWORK | default network options, if `mainnet` or `testnet` is configured, the genesis file will be automatically configured | `mainnet`|
| HOME | directory for config and data | `/data` |

### Example
1. Start a testnet full node
```
docker run -p 27146:27146 -p 27147:27147 -e NETWORK=testnet ghcr.io/bnb-chain/node:latest
```

2. Start a mainnet full node with mounted volume
```
docker run -p 27146:27146 -p 27147:27147 -v /tmp/chain/data:/data ghcr.io/bnb-chain/node:latest
```



13 changes: 10 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.17

require (
github.com/Shopify/sarama v1.21.0
github.com/binance-chain/go-sdk v1.2.7
github.com/cosmos/cosmos-sdk v0.25.0
github.com/deathowl/go-metrics-prometheus v0.0.0-20200518174047-74482eab5bfb
github.com/eapache/go-resiliency v1.1.0
Expand All @@ -22,14 +23,17 @@ require (
github.com/tendermint/go-amino v0.15.0
github.com/tendermint/iavl v0.12.4
github.com/tendermint/tendermint v0.32.3
github.com/tidwall/gjson v1.14.3
go.uber.org/ratelimit v0.1.0
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f
)

require (
github.com/DataDog/zstd v1.3.5 // indirect
github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/binance-chain/ledger-cosmos-go v0.9.9-binance.1 // indirect
github.com/btcsuite/btcd v0.20.1-beta // indirect
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d // indirect
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d // indirect
Expand All @@ -43,7 +47,7 @@ require (
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/gorilla/websocket v1.4.0 // indirect
github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
Expand All @@ -65,10 +69,13 @@ require (
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d // indirect
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/zondax/hid v0.9.0 // indirect
github.com/zondax/ledger-cosmos-go v0.9.9 // indirect
github.com/zondax/ledger-go v0.9.0 // indirect
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
golang.org/x/net v0.0.0-20191021144547-ec77196f6094 // indirect
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
Expand All @@ -81,7 +88,7 @@ require (
)

replace (
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/bnc-cosmos-sdk v0.25.0-binance.28
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/bnc-cosmos-sdk v0.25.2
github.com/tendermint/go-amino => github.com/bnb-chain/bnc-go-amino v0.14.1-binance.2
github.com/tendermint/iavl => github.com/bnb-chain/bnc-tendermint-iavl v0.12.0-binance.4
github.com/tendermint/tendermint => github.com/bnb-chain/bnc-tendermint v0.32.3-binance.7
Expand Down
Loading

0 comments on commit 3e52402

Please sign in to comment.