mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
Fixed bug calculate reward and add unit test for it.
This commit is contained in:
parent
530f8e3656
commit
76153eea4a
6 changed files with 111 additions and 71 deletions
|
|
@ -19,6 +19,11 @@ const (
|
||||||
HexSignMethod = "2fb1b25f"
|
HexSignMethod = "2fb1b25f"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type rewardLog struct {
|
||||||
|
Sign uint64 `json:"sign"`
|
||||||
|
Reward *big.Int `json:"reward"`
|
||||||
|
}
|
||||||
|
|
||||||
// Get ethClient over IPC of current node.
|
// Get ethClient over IPC of current node.
|
||||||
func GetEthClient(ctx *node.ServiceContext) (*ethclient.Client, error) {
|
func GetEthClient(ctx *node.ServiceContext) (*ethclient.Client, error) {
|
||||||
conf := ctx.GetConfig()
|
conf := ctx.GetConfig()
|
||||||
|
|
@ -33,27 +38,29 @@ func GetEthClient(ctx *node.ServiceContext) (*ethclient.Client, error) {
|
||||||
|
|
||||||
// Send tx sign for block number to smart contract blockSigner.
|
// Send tx sign for block number to smart contract blockSigner.
|
||||||
func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, manager *accounts.Manager, block *types.Block) error {
|
func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, manager *accounts.Manager, block *types.Block) error {
|
||||||
// Find active account.
|
if chainConfig.Clique != nil {
|
||||||
account := accounts.Account{}
|
// Find active account.
|
||||||
var wallet accounts.Wallet
|
account := accounts.Account{}
|
||||||
if wallets := manager.Wallets(); len(wallets) > 0 {
|
var wallet accounts.Wallet
|
||||||
wallet = wallets[0]
|
if wallets := manager.Wallets(); len(wallets) > 0 {
|
||||||
if accts := wallets[0].Accounts(); len(accts) > 0 {
|
wallet = wallets[0]
|
||||||
account = accts[0]
|
if accts := wallets[0].Accounts(); len(accts) > 0 {
|
||||||
|
account = accts[0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Create and send tx to smart contract for sign validate block.
|
// Create and send tx to smart contract for sign validate block.
|
||||||
nonce := pool.State().GetNonce(account.Address)
|
nonce := pool.State().GetNonce(account.Address)
|
||||||
tx := CreateTxSign(block.Number(), nonce, common.HexToAddress(common.BlockSigners))
|
tx := CreateTxSign(block.Number(), nonce, common.HexToAddress(common.BlockSigners))
|
||||||
txSigned, err := wallet.SignTx(account, tx, chainConfig.ChainId)
|
txSigned, err := wallet.SignTx(account, tx, chainConfig.ChainId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to create tx sign", "error", err)
|
log.Error("Fail to create tx sign", "error", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add tx signed to local tx pool.
|
// Add tx signed to local tx pool.
|
||||||
pool.AddLocal(txSigned)
|
pool.AddLocal(txSigned)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -86,17 +93,11 @@ func GetSignersFromContract(addrBlockSigner common.Address, client bind.Contract
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate reward for reward checkpoint.
|
// Calculate reward for reward checkpoint.
|
||||||
func GetRewardForCheckpoint(chainReward *big.Int, blockSignerAddr common.Address, number uint64, rCheckpoint uint64, client bind.ContractBackend) (map[common.Address]*big.Int, error) {
|
func GetRewardForCheckpoint(blockSignerAddr common.Address, number uint64, rCheckpoint uint64, client bind.ContractBackend, totalSigner *uint64) (map[common.Address]*rewardLog, error) {
|
||||||
type rewardLog struct {
|
|
||||||
Sign uint64 `json:"sign"`
|
|
||||||
Reward *big.Int `json:"reward"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not reward for singer of genesis block and only calculate reward at checkpoint block.
|
// Not reward for singer of genesis block and only calculate reward at checkpoint block.
|
||||||
startBlockNumber := number - (rCheckpoint * 2) + 1
|
startBlockNumber := number - (rCheckpoint * 2) + 1
|
||||||
endBlockNumber := startBlockNumber + rCheckpoint - 1
|
endBlockNumber := startBlockNumber + rCheckpoint - 1
|
||||||
signers := make(map[common.Address]*rewardLog)
|
signers := make(map[common.Address]*rewardLog)
|
||||||
totalSigner := uint64(0)
|
|
||||||
|
|
||||||
for i := startBlockNumber; i <= endBlockNumber; i++ {
|
for i := startBlockNumber; i <= endBlockNumber; i++ {
|
||||||
addrs, err := GetSignersFromContract(blockSignerAddr, client, i)
|
addrs, err := GetSignersFromContract(blockSignerAddr, client, i)
|
||||||
|
|
@ -119,30 +120,35 @@ func GetRewardForCheckpoint(chainReward *big.Int, blockSignerAddr common.Address
|
||||||
} else {
|
} else {
|
||||||
signers[addr] = &rewardLog{1, new(big.Int)}
|
signers[addr] = &rewardLog{1, new(big.Int)}
|
||||||
}
|
}
|
||||||
totalSigner++
|
*totalSigner++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info("Calculate reward at checkpoint", "startBlock", startBlockNumber, "endBlock", endBlockNumber)
|
||||||
|
|
||||||
|
return signers, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate reward for signers.
|
||||||
|
func CalculateReward(chainReward *big.Int, signers map[common.Address]*rewardLog, totalSigner uint64) (map[common.Address]*big.Int, error) {
|
||||||
resultSigners := make(map[common.Address]*big.Int)
|
resultSigners := make(map[common.Address]*big.Int)
|
||||||
// Add reward for signer.
|
|
||||||
calcReward := new(big.Int)
|
|
||||||
// Add reward for signers.
|
// Add reward for signers.
|
||||||
for signer, rLog := range signers {
|
for signer, rLog := range signers {
|
||||||
calcReward.Mul(chainReward, new(big.Int).SetUint64(rLog.Sign))
|
// Add reward for signer.
|
||||||
calcReward.Div(calcReward, new(big.Int).SetUint64(totalSigner))
|
calcReward := new(big.Int)
|
||||||
|
calcReward.Div(chainReward, new(big.Int).SetUint64(totalSigner))
|
||||||
|
calcReward.Mul(calcReward, new(big.Int).SetUint64(rLog.Sign))
|
||||||
rLog.Reward = calcReward
|
rLog.Reward = calcReward
|
||||||
|
|
||||||
resultSigners[signer] = calcReward
|
resultSigners[signer] = calcReward
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonSigners, err := json.Marshal(signers)
|
jsonSigners, err := json.Marshal(signers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to parse json signers", "error", err)
|
log.Error("Fail to parse json signers", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
log.Info("Signers data", "signers", string(jsonSigners), "totalSigner", totalSigner, "totalReward", chainReward)
|
||||||
log.Info("Calculate reward at checkpoint", "startBlock", startBlockNumber, "endBlock", endBlockNumber, "signers", string(jsonSigners), "totalSigner", totalSigner, "totalReward", chainReward)
|
|
||||||
|
|
||||||
return resultSigners, nil
|
return resultSigners, nil
|
||||||
}
|
}
|
||||||
|
|
@ -20,11 +20,13 @@ func TestSendTxSign(t *testing.T) {
|
||||||
acc1Key, _ := crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
acc1Key, _ := crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
||||||
acc2Key, _ := crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
acc2Key, _ := crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
||||||
acc3Key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
acc3Key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
|
acc4Key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee04aefe388d1e14474d32c45c72ce7b7a")
|
||||||
acc1Addr := crypto.PubkeyToAddress(acc1Key.PublicKey)
|
acc1Addr := crypto.PubkeyToAddress(acc1Key.PublicKey)
|
||||||
acc2Addr := crypto.PubkeyToAddress(acc2Key.PublicKey)
|
acc2Addr := crypto.PubkeyToAddress(acc2Key.PublicKey)
|
||||||
acc3Addr := crypto.PubkeyToAddress(acc3Key.PublicKey)
|
acc3Addr := crypto.PubkeyToAddress(acc3Key.PublicKey)
|
||||||
accounts := []common.Address{acc2Addr, acc3Addr}
|
acc4Addr := crypto.PubkeyToAddress(acc4Key.PublicKey)
|
||||||
keys := []*ecdsa.PrivateKey{acc2Key, acc3Key}
|
accounts := []common.Address{acc2Addr, acc3Addr, acc4Addr}
|
||||||
|
keys := []*ecdsa.PrivateKey{acc2Key, acc3Key, acc4Key}
|
||||||
|
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.HomesteadSigner{}
|
||||||
genesis := core.GenesisAlloc{acc1Addr: {Balance: big.NewInt(1000000000)}}
|
genesis := core.GenesisAlloc{acc1Addr: {Balance: big.NewInt(1000000000)}}
|
||||||
|
|
@ -50,16 +52,19 @@ func TestSendTxSign(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tx sign for signer.
|
// Tx sign for signer.
|
||||||
|
signCount := uint64(0)
|
||||||
for i := uint64(0); i < 100; i++ {
|
for i := uint64(0); i < 100; i++ {
|
||||||
randIndex := rand.Intn(len(keys))
|
randIndex := rand.Intn(len(keys))
|
||||||
accKey := keys[randIndex]
|
accKey := keys[randIndex]
|
||||||
signTx(ctx, backend, signer, nonces, accKey, i)
|
signTx(ctx, backend, signer, nonces, accKey, i)
|
||||||
oldBlock[i] = accounts[randIndex]
|
oldBlock[i] = accounts[randIndex]
|
||||||
|
signCount++
|
||||||
|
|
||||||
// Tx sign for validators.
|
// Tx sign for validators.
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
if key != accKey {
|
if key != accKey {
|
||||||
signTx(ctx, backend, signer, nonces, key, i)
|
signTx(ctx, backend, signer, nonces, key, i)
|
||||||
|
signCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -80,21 +85,33 @@ func TestSendTxSign(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unit test for reward checkpoint.
|
// Unit test for reward checkpoint.
|
||||||
rCheckpoint := uint64(10)
|
rCheckpoint := uint64(5)
|
||||||
chainReward := new(big.Int).SetUint64(15 * params.Ether)
|
chainReward := new(big.Int).SetUint64(15 * params.Ether)
|
||||||
|
total := new(uint64)
|
||||||
for i := uint64(0); i < 100; i++ {
|
for i := uint64(0); i < 100; i++ {
|
||||||
if i > 0 && i%rCheckpoint == 0 && i-rCheckpoint > 0 {
|
if i > 0 && i%rCheckpoint == 0 && i-rCheckpoint > 0 {
|
||||||
signers, err := GetRewardForCheckpoint(chainReward, blockSignerAddr, i, rCheckpoint, backend)
|
_, err := GetRewardForCheckpoint(blockSignerAddr, i, rCheckpoint, backend, total)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Fail to get signers for reward checkpoint: %v", err)
|
t.Errorf("Fail to get signers for reward checkpoint: %v", err)
|
||||||
}
|
}
|
||||||
rewards := new(big.Int)
|
|
||||||
for _, reward := range signers {
|
|
||||||
rewards.Add(rewards, reward)
|
|
||||||
}
|
|
||||||
if rewards.Cmp(chainReward) != 0 {
|
|
||||||
t.Errorf("Total reward not same reward checkpoint: %v - %v", chainReward, rewards)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signers := make(map[common.Address]*rewardLog)
|
||||||
|
totalSigner := uint64(17)
|
||||||
|
signers[common.HexToAddress("0x12f588d7d03bb269b382b842fc15d874e8c055a7")] = &rewardLog{5, new(big.Int).SetUint64(0)}
|
||||||
|
signers[common.HexToAddress("0x1f9e122c0921a4504fc116d967baf7a7bf2604ef")] = &rewardLog{6, new(big.Int).SetUint64(0)}
|
||||||
|
signers[common.HexToAddress("0xea489e4e673c25ff0614617ebe88efd853efe00c")] = &rewardLog{6, new(big.Int).SetUint64(0)}
|
||||||
|
rewardSigners, err := CalculateReward(chainReward, signers, totalSigner)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Fail to calculate reward for signers: %v", err)
|
||||||
|
}
|
||||||
|
//t.Error("Reward", rewardSigners)
|
||||||
|
rewards := new(big.Int)
|
||||||
|
for _, reward := range rewardSigners {
|
||||||
|
rewards.Add(rewards, reward)
|
||||||
|
}
|
||||||
|
if rewards.Cmp(new(big.Int).SetUint64(14999999999999999996)) != 0 {
|
||||||
|
t.Errorf("Total reward not same reward checkpoint: %v - %v", chainReward, rewards)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,13 +180,25 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
}
|
}
|
||||||
eth.ApiBackend.gpo = gasprice.NewOracle(eth.ApiBackend, gpoParams)
|
eth.ApiBackend.gpo = gasprice.NewOracle(eth.ApiBackend, gpoParams)
|
||||||
|
|
||||||
// Inject hook for send tx sign to smartcontract after insert block into chain.
|
|
||||||
if eth.chainConfig.Clique != nil {
|
|
||||||
eth.protocolManager.fetcher.HookCreateTxSign(eth.chainConfig, eth.TxPool(), eth.AccountManager())
|
|
||||||
}
|
|
||||||
|
|
||||||
if eth.chainConfig.Clique != nil {
|
if eth.chainConfig.Clique != nil {
|
||||||
c := eth.engine.(*clique.Clique)
|
c := eth.engine.(*clique.Clique)
|
||||||
|
|
||||||
|
// Inject hook for send tx sign to smartcontract after insert block into chain.
|
||||||
|
importedHook := func(block *types.Block) {
|
||||||
|
snap, err := c.GetSnapshot(eth.blockchain, block.Header())
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Fail to get snapshot for sign tx validator.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, authorized := snap.Signers[eth.etherbase]; authorized {
|
||||||
|
if err := contracts.CreateTransactionSign(chainConfig, eth.txPool, eth.accountManager, block); err != nil {
|
||||||
|
log.Error("Fail to create tx sign for imported block", "error", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eth.protocolManager.fetcher.SetImportedHook(importedHook)
|
||||||
|
|
||||||
// Hook reward for clique validator.
|
// Hook reward for clique validator.
|
||||||
c.HookReward = func(chain consensus.ChainReader, state *state.StateDB, header *types.Header) error {
|
c.HookReward = func(chain consensus.ChainReader, state *state.StateDB, header *types.Header) error {
|
||||||
number := header.Number.Uint64()
|
number := header.Number.Uint64()
|
||||||
|
|
@ -200,15 +212,18 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
}
|
}
|
||||||
addr := common.HexToAddress(common.BlockSigners)
|
addr := common.HexToAddress(common.BlockSigners)
|
||||||
chainReward := new(big.Int).SetUint64(chain.Config().Clique.Reward * params.Ether)
|
chainReward := new(big.Int).SetUint64(chain.Config().Clique.Reward * params.Ether)
|
||||||
|
totalSigner := new(uint64)
|
||||||
signers, err := contracts.GetRewardForCheckpoint(chainReward, addr, number, rCheckpoint, client)
|
signers, err := contracts.GetRewardForCheckpoint(addr, number, rCheckpoint, client, totalSigner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to get signers for reward checkpoint", "error", err)
|
log.Error("Fail to get signers for reward checkpoint", "error", err)
|
||||||
}
|
}
|
||||||
|
rewardSigners, err := contracts.CalculateReward(chainReward, signers, *totalSigner)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Fail to calculate reward for signers", "error", err)
|
||||||
|
}
|
||||||
// Add reward for signers.
|
// Add reward for signers.
|
||||||
if len(signers) > 0 {
|
if len(signers) > 0 {
|
||||||
for signer, calcReward := range signers {
|
for signer, calcReward := range rewardSigners {
|
||||||
state.AddBalance(signer, calcReward)
|
state.AddBalance(signer, calcReward)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,11 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
|
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
|
||||||
"math/big"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -739,11 +735,7 @@ func (f *Fetcher) forgetBlock(hash common.Hash) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create tx for sign to smartcontract after import block into chain.
|
// Bind import hook when block imported into chain.
|
||||||
func (f *Fetcher) HookCreateTxSign(chainConfig *params.ChainConfig, pool *core.TxPool, manager *accounts.Manager) {
|
func (f *Fetcher) SetImportedHook(importedHook func(*types.Block)) {
|
||||||
f.importedHook = func(block *types.Block) {
|
f.importedHook = importedHook
|
||||||
if err := contracts.CreateTransactionSign(chainConfig, pool, manager, block); err != nil {
|
|
||||||
log.Error("Fail to create tx sign for imported block", "error", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -332,7 +332,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
|
||||||
// Status messages should never arrive after the handshake
|
// Status messages should never arrive after the handshake
|
||||||
return errResp(ErrExtraStatusMsg, "uncontrolled status message")
|
return errResp(ErrExtraStatusMsg, "uncontrolled status message")
|
||||||
|
|
||||||
// Block header query, collect the requested headers and reply
|
// Block header query, collect the requested headers and reply
|
||||||
case msg.Code == GetBlockHeadersMsg:
|
case msg.Code == GetBlockHeadersMsg:
|
||||||
// Decode the complex header query
|
// Decode the complex header query
|
||||||
var query getBlockHeadersData
|
var query getBlockHeadersData
|
||||||
|
|
@ -742,7 +742,7 @@ func (self *ProtocolManager) txBroadcastLoop() {
|
||||||
case event := <-self.txCh:
|
case event := <-self.txCh:
|
||||||
self.BroadcastTx(event.Tx.Hash(), event.Tx)
|
self.BroadcastTx(event.Tx.Hash(), event.Tx)
|
||||||
|
|
||||||
// Err() channel will be closed when unsubscribing.
|
// Err() channel will be closed when unsubscribing.
|
||||||
case <-self.txSub.Err():
|
case <-self.txSub.Err():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,13 +254,13 @@ func (self *worker) update() {
|
||||||
case <-self.chainHeadCh:
|
case <-self.chainHeadCh:
|
||||||
self.commitNewWork()
|
self.commitNewWork()
|
||||||
|
|
||||||
// Handle ChainSideEvent
|
// Handle ChainSideEvent
|
||||||
case ev := <-self.chainSideCh:
|
case ev := <-self.chainSideCh:
|
||||||
self.uncleMu.Lock()
|
self.uncleMu.Lock()
|
||||||
self.possibleUncles[ev.Block.Hash()] = ev.Block
|
self.possibleUncles[ev.Block.Hash()] = ev.Block
|
||||||
self.uncleMu.Unlock()
|
self.uncleMu.Unlock()
|
||||||
|
|
||||||
// Handle TxPreEvent
|
// Handle TxPreEvent
|
||||||
case ev := <-self.txCh:
|
case ev := <-self.txCh:
|
||||||
// Apply transaction to the pending state if we're not mining
|
// Apply transaction to the pending state if we're not mining
|
||||||
if atomic.LoadInt32(&self.mining) == 0 {
|
if atomic.LoadInt32(&self.mining) == 0 {
|
||||||
|
|
@ -278,7 +278,7 @@ func (self *worker) update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// System stopped
|
// System stopped
|
||||||
case <-self.txSub.Err():
|
case <-self.txSub.Err():
|
||||||
return
|
return
|
||||||
case <-self.chainHeadSub.Err():
|
case <-self.chainHeadSub.Err():
|
||||||
|
|
@ -341,6 +341,16 @@ func (self *worker) wait() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.config.Clique != nil {
|
if self.config.Clique != nil {
|
||||||
|
c := self.engine.(*clique.Clique)
|
||||||
|
snap, err := c.GetSnapshot(self.chain, block.Header())
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Fail to get snapshot for sign tx signer.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, authorized := snap.Signers[self.coinbase]; !authorized {
|
||||||
|
log.Error("Coinbase address not in snapshot signers.")
|
||||||
|
return
|
||||||
|
}
|
||||||
// Send tx sign to smart contract blockSigners.
|
// Send tx sign to smart contract blockSigners.
|
||||||
if err := contracts.CreateTransactionSign(self.config, self.eth.TxPool(), self.eth.AccountManager(), block); err != nil {
|
if err := contracts.CreateTransactionSign(self.config, self.eth.TxPool(), self.eth.AccountManager(), block); err != nil {
|
||||||
log.Error("Fail to create tx sign for signer", "error", "err")
|
log.Error("Fail to create tx sign for signer", "error", "err")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue