Skip to content

Commit 1649a46

Browse files
authored
Merge pull request #62 from wemixarchive/hotfix
consensus/ethash,miner: Fixed issue with coinbase setup.
2 parents 3ae3514 + 3ee6e07 commit 1649a46

5 files changed

Lines changed: 48 additions & 2 deletions

File tree

Dockerfile.wemix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
99
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
1010

1111
# golang
12-
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 && \
12+
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 && \
1313
pushd /usr/local/ && \
1414
tar xfz /tmp/go.tar.gz && \
1515
cd /usr/local/bin/ && \

miner/worker.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,11 @@ func (w *worker) commitWork(interrupt *int32, noempty bool, timestamp int64) {
16271627
timestamp: uint64(timestamp),
16281628
coinbase: coinbase,
16291629
})
1630+
if !wemixminer.IsPoW() { // Wemix
1631+
if coinbase, err := wemixminer.GetCoinbase(work.header.Number); err == nil {
1632+
work.coinbase = coinbase
1633+
}
1634+
}
16301635
if err != nil {
16311636
return
16321637
}

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
const (
2424
VersionMajor = 0 // Major version component of the current release
2525
VersionMinor = 10 // Minor version component of the current release
26-
VersionPatch = 4 // Patch version component of the current release
26+
VersionPatch = 5 // Patch version component of the current release
2727
VersionMeta = "stable" // Version metadata to append to the version string
2828
)
2929

wemix/admin.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,36 @@ func verifyRewards(num *big.Int, rewards string) error {
12041204
//return admin.verifyRewards(num, rewards)
12051205
}
12061206

1207+
func getCoinbase(height *big.Int) (coinbase common.Address, err error) {
1208+
if admin == nil {
1209+
err = wemixminer.ErrNotInitialized
1210+
return
1211+
}
1212+
prvKey := admin.stack.Server().PrivateKey
1213+
if admin.self != nil {
1214+
ctx, cancel := context.WithCancel(context.Background())
1215+
defer cancel()
1216+
1217+
num := new(big.Int).Sub(height, common.Big1)
1218+
_, gov, _, _, err2 := admin.getRegGovEnvContracts(ctx, num)
1219+
if err2 != nil {
1220+
err = err2
1221+
return
1222+
}
1223+
1224+
nodeId := crypto.FromECDSAPub(&prvKey.PublicKey)[1:]
1225+
if addr, err2 := enodeExists(ctx, height, gov, nodeId); err2 != nil {
1226+
err = err2
1227+
return
1228+
} else {
1229+
coinbase = addr
1230+
}
1231+
} else if admin.nodeInfo != nil && admin.nodeInfo.ID == admin.bootNodeId {
1232+
coinbase = admin.bootAccount
1233+
}
1234+
return
1235+
}
1236+
12071237
func signBlock(height *big.Int, hash common.Hash) (coinbase common.Address, sig []byte, err error) {
12081238
if admin == nil {
12091239
err = wemixminer.ErrNotInitialized
@@ -1787,6 +1817,7 @@ func init() {
17871817
wemixminer.SuggestGasPriceFunc = suggestGasPrice
17881818
wemixminer.CalculateRewardsFunc = calculateRewards
17891819
wemixminer.VerifyRewardsFunc = verifyRewards
1820+
wemixminer.GetCoinbaseFunc = getCoinbase
17901821
wemixminer.SignBlockFunc = signBlock
17911822
wemixminer.VerifyBlockSigFunc = verifyBlockSig
17921823
wemixminer.RequirePendingTxsFunc = requirePendingTxs

wemix/miner/miner.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var (
1818
AmHubFunc func(string) int
1919
CalculateRewardsFunc func(*big.Int, *big.Int, *big.Int, func(common.Address, *big.Int)) (*common.Address, []byte, error)
2020
VerifyRewardsFunc func(*big.Int, string) error
21+
GetCoinbaseFunc func(height *big.Int) (coinbase common.Address, err error)
2122
SignBlockFunc func(height *big.Int, hash common.Hash) (coinbase common.Address, sig []byte, err error)
2223
VerifyBlockSigFunc func(height *big.Int, coinbase common.Address, nodeId []byte, hash common.Hash, sig []byte, checkMinerLimit bool) bool
2324
RequirePendingTxsFunc func() bool
@@ -94,6 +95,15 @@ func VerifyRewards(num *big.Int, rewards string) error {
9495
}
9596
}
9697

98+
func GetCoinbase(height *big.Int) (coinbase common.Address, err error) {
99+
if GetCoinbaseFunc == nil {
100+
err = ErrNotInitialized
101+
} else {
102+
coinbase, err = GetCoinbaseFunc(height)
103+
}
104+
return
105+
}
106+
97107
func SignBlock(height *big.Int, hash common.Hash) (coinbase common.Address, sig []byte, err error) {
98108
if SignBlockFunc == nil {
99109
err = ErrNotInitialized

0 commit comments

Comments
 (0)