Skip to content

Commit

Permalink
Merge pull request #57 from wemixarchive/dev
Browse files Browse the repository at this point in the history
gwemix: merge 0.10.4 to master
  • Loading branch information
wm-jsong1230 authored May 31, 2023
2 parents e7f0653 + 08ab37d commit 3ae3514
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 26 deletions.
2 changes: 1 addition & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ func (s *PublicBlockChainAPI) GetReceiptsByHash(ctx context.Context, blockHash c

fields := map[string]interface{}{
"blockHash": blockHash,
"blockNumber": bigblock,
"blockNumber": hexutil.Uint64(block.NumberU64()),
"transactionHash": receipt.TxHash,
"transactionIndex": hexutil.Uint64(index),
"from": from,
Expand Down
1 change: 1 addition & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
PangyoBlock: big.NewInt(0),
ApplepieBlock: big.NewInt(20_476_911),
Ethash: new(EthashConfig),
}

Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 3 // Patch version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionMeta = "stable" // Version metadata to append to the version string
)

Expand Down
20 changes: 18 additions & 2 deletions wemix/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,23 @@ func signBlock(height *big.Int, hash common.Hash) (coinbase common.Address, sig
prvKey := admin.stack.Server().PrivateKey
sig, err = crypto.Sign(data, prvKey)
if admin.self != nil {
coinbase = admin.self.Addr
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
}
Expand Down Expand Up @@ -1244,7 +1260,7 @@ func verifyBlockSig(height *big.Int, coinbase common.Address, nodeId []byte, has
data = append(height.Bytes(), hash.Bytes()...)
data = crypto.Keccak256(data)
} else {
if ok, err := enodeExists(ctx, height, gov, nodeId); err != nil || !ok {
if _, err := enodeExists(ctx, height, gov, nodeId); err != nil {
return false
}
data = hash.Bytes()
Expand Down
70 changes: 52 additions & 18 deletions wemix/contracts/WemixGovernance.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions wemix/miner_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sort"
"time"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -108,16 +109,16 @@ func coinbaseExists(ctx context.Context, height *big.Int, gov *metclient.RemoteC
}

// returns true if enode exists in governance at given height-1
func enodeExists(ctx context.Context, height *big.Int, gov *metclient.RemoteContract, enode []byte) (bool, error) {
func enodeExists(ctx context.Context, height *big.Int, gov *metclient.RemoteContract, enode []byte) (common.Address, error) {
e, err := getCoinbaseEnodeCache(ctx, new(big.Int).Sub(height, common.Big1), gov)
if err != nil {
return false, err
return common.Address{}, err
}
ix, ok := e.enode2index[string(enode)]
if !ok {
return false, nil
return common.Address{}, ethereum.NotFound
}
return ix >= 1, nil
return e.nodes[ix-1].Addr, nil
}

// returns wemix nodes at given height
Expand Down

0 comments on commit 3ae3514

Please sign in to comment.