diff --git a/Dockerfile.wemix b/Dockerfile.wemix index a874b683b345..632e6ce193e0 100644 --- a/Dockerfile.wemix +++ b/Dockerfile.wemix @@ -9,7 +9,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential ca-certificates curl libjemalloc-dev liblz4-dev libsnappy-dev libzstd-dev libudev-dev git # golang -RUN curl -sL -o /tmp/go.tar.gz https://dl.google.com/go/$(curl -sL https://golang.org/VERSION?m=text).linux-amd64.tar.gz && \ +RUN curl -sL -o /tmp/go.tar.gz https://dl.google.com/go/$(curl -sL https://golang.org/VERSION?m=text | head -1).linux-amd64.tar.gz && \ pushd /usr/local/ && \ tar xfz /tmp/go.tar.gz && \ cd /usr/local/bin/ && \ diff --git a/miner/worker.go b/miner/worker.go index 7fab6c8f9210..c30d38ed10ed 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1627,6 +1627,11 @@ func (w *worker) commitWork(interrupt *int32, noempty bool, timestamp int64) { timestamp: uint64(timestamp), coinbase: coinbase, }) + if !wemixminer.IsPoW() { // Wemix + if coinbase, err := wemixminer.GetCoinbase(work.header.Number); err == nil { + work.coinbase = coinbase + } + } if err != nil { return } diff --git a/params/version.go b/params/version.go index 4cc85d7b01ad..b87c0955db2c 100644 --- a/params/version.go +++ b/params/version.go @@ -23,7 +23,7 @@ import ( const ( VersionMajor = 0 // Major version component of the current release VersionMinor = 10 // Minor version component of the current release - VersionPatch = 4 // Patch version component of the current release + VersionPatch = 5 // Patch version component of the current release VersionMeta = "stable" // Version metadata to append to the version string ) diff --git a/wemix/admin.go b/wemix/admin.go index d3986407d0b5..5441dfa14f65 100644 --- a/wemix/admin.go +++ b/wemix/admin.go @@ -1204,6 +1204,36 @@ func verifyRewards(num *big.Int, rewards string) error { //return admin.verifyRewards(num, rewards) } +func getCoinbase(height *big.Int) (coinbase common.Address, err error) { + if admin == nil { + err = wemixminer.ErrNotInitialized + return + } + prvKey := admin.stack.Server().PrivateKey + if admin.self != nil { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + num := new(big.Int).Sub(height, common.Big1) + _, gov, _, _, err2 := admin.getRegGovEnvContracts(ctx, num) + if err2 != nil { + err = err2 + return + } + + nodeId := crypto.FromECDSAPub(&prvKey.PublicKey)[1:] + if addr, err2 := enodeExists(ctx, height, gov, nodeId); err2 != nil { + err = err2 + return + } else { + coinbase = addr + } + } else if admin.nodeInfo != nil && admin.nodeInfo.ID == admin.bootNodeId { + coinbase = admin.bootAccount + } + return +} + func signBlock(height *big.Int, hash common.Hash) (coinbase common.Address, sig []byte, err error) { if admin == nil { err = wemixminer.ErrNotInitialized @@ -1787,6 +1817,7 @@ func init() { wemixminer.SuggestGasPriceFunc = suggestGasPrice wemixminer.CalculateRewardsFunc = calculateRewards wemixminer.VerifyRewardsFunc = verifyRewards + wemixminer.GetCoinbaseFunc = getCoinbase wemixminer.SignBlockFunc = signBlock wemixminer.VerifyBlockSigFunc = verifyBlockSig wemixminer.RequirePendingTxsFunc = requirePendingTxs diff --git a/wemix/miner/miner.go b/wemix/miner/miner.go index 148f63a13f14..45abda5a5c59 100644 --- a/wemix/miner/miner.go +++ b/wemix/miner/miner.go @@ -18,6 +18,7 @@ var ( AmHubFunc func(string) int CalculateRewardsFunc func(*big.Int, *big.Int, *big.Int, func(common.Address, *big.Int)) (*common.Address, []byte, error) VerifyRewardsFunc func(*big.Int, string) error + GetCoinbaseFunc func(height *big.Int) (coinbase common.Address, err error) SignBlockFunc func(height *big.Int, hash common.Hash) (coinbase common.Address, sig []byte, err error) VerifyBlockSigFunc func(height *big.Int, coinbase common.Address, nodeId []byte, hash common.Hash, sig []byte, checkMinerLimit bool) bool RequirePendingTxsFunc func() bool @@ -94,6 +95,15 @@ func VerifyRewards(num *big.Int, rewards string) error { } } +func GetCoinbase(height *big.Int) (coinbase common.Address, err error) { + if GetCoinbaseFunc == nil { + err = ErrNotInitialized + } else { + coinbase, err = GetCoinbaseFunc(height) + } + return +} + func SignBlock(height *big.Int, hash common.Hash) (coinbase common.Address, sig []byte, err error) { if SignBlockFunc == nil { err = ErrNotInitialized