From cc1ebb7dd85ca266c7d8f49942d5aefb4efc2d99 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Wed, 26 Mar 2025 01:53:00 +0530 Subject: [PATCH] consensus/clique: undo changes --- consensus/clique/clique.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 6331dcaaee..6506174056 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -27,6 +27,7 @@ import ( "sync" "time" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/lru" @@ -50,6 +51,8 @@ const ( checkpointInterval = 1024 // Number of blocks after which to save the vote snapshot to the database inmemorySnapshots = 128 // Number of recent vote snapshots to keep in memory inmemorySignatures = 4096 // Number of recent block signatures to keep in memory + + wiggleTime = 500 * time.Millisecond // Random delay (per signer) to allow concurrent signers ) // Clique proof-of-authority protocol constants. @@ -138,6 +141,9 @@ var ( errRecentlySigned = errors.New("recently signed") ) +// SignerFn hashes and signs the data to be signed by a backing account. +type SignerFn func(signer accounts.Account, mimeType string, message []byte) ([]byte, error) + // ecrecover extracts the Ethereum account address from a signed header. func ecrecover(header *types.Header, sigcache *sigLRU) (common.Address, error) { // If the signature's already cached, return that @@ -179,6 +185,7 @@ type Clique struct { proposals map[common.Address]bool // Current list of proposals we are pushing signer common.Address // Ethereum address of the signing key + signFn SignerFn // Signer function to authorize hashes with lock sync.RWMutex // Protects the signer and proposals fields // The fields below are for testing only @@ -635,17 +642,17 @@ func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header * // Authorize injects a private key into the consensus engine to mint new blocks // with. -func (c *Clique) Authorize(signer common.Address) { +func (c *Clique) Authorize(signer common.Address, signFn SignerFn) { c.lock.Lock() defer c.lock.Unlock() c.signer = signer + c.signFn = signFn } // Seal implements consensus.Engine, attempting to create a sealed block using // the local signing credentials. func (c *Clique) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error { - // (PoS): Geth doesn't support sealing on clique but we'll keep it for running bor in dev mode. header := block.Header() // Sealing the genesis block is not supported