eth/protocols/eth/handshake_pow.go — Version Comparison
|
v1.17.3 |
v1.17.4 |
| Branch |
etc/v1.17.3-full-node |
etc/v1.17.4-full-node |
| Delta |
+88 -0 |
+82 -0 |
Diff between branches
diff --git a/eth/protocols/eth/handshake_pow.go b/eth/protocols/eth/handshake_pow.go
index a6d97a23d..1ac7d8582 100644
--- a/eth/protocols/eth/handshake_pow.go
+++ b/eth/protocols/eth/handshake_pow.go
@@ -17,14 +17,12 @@
package eth
import (
- "errors"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/forkid"
"github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/params"
)
// Handshake68PoW executes the eth/68 protocol handshake for perpetual PoW networks.
@@ -53,15 +51,6 @@ func (p *Peer) Handshake68PoW(networkID uint64, td *big.Int, head common.Hash, g
if err := waitForHandshake(errc, p); err != nil {
return err
}
- // Reject peers with TD >= ETH mainnet's TTD. Such high TD indicates the peer
- // is from ETH mainnet (which shares the same genesis hash but much higher TD).
- if status.TD != nil && status.TD.Cmp(params.MainnetTerminalTotalDifficulty) >= 0 {
- return fmt.Errorf("peer TD %v exceeds ETH TTD, likely wrong network", status.TD)
- }
- // Reject peers with nil TD - required for proper PoW sync
- if status.TD == nil {
- return errors.New("peer has nil TD, rejecting for PoW sync")
- }
// Initialize PoW extension with peer's head info directly
p.InitPoWExtension(status.Head, status.TD)
return nil
@@ -84,5 +73,10 @@ func (p *Peer) readStatus68(networkID uint64, status *StatusPacket68, genesis co
if err := forkFilter(status.ForkID); err != nil {
return fmt.Errorf("%w: %v", errForkIDRejected, err)
}
+ // TD at mainnet block #7753254 is 76 bits. If it becomes 100 million times
+ // larger, it will still fit within 100 bits
+ if tdlen := status.TD.BitLen(); tdlen > 100 {
+ return fmt.Errorf("too large total difficulty: bitlen %d", tdlen)
+ }
return nil
}
← Back to Version Comparison