From 800ec03a54e95911be4dd1b02deaea225c96386c Mon Sep 17 00:00:00 2001 From: minh-bq <97180373+minh-bq@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:48:39 +0700 Subject: [PATCH] chainconfig: add Shillin and Antenna hardfork on mainnet (#365) * chainconfig: add Shillin and Antenna hardfork on mainnet * p2p: move ping handling into pingLoop goroutine (#27887) Moving the response sending there allows tracking all peer goroutines in the peer WaitGroup. * params/version: bump Ronin to version 2.6.2 --------- Co-authored-by: Felix Lange --- genesis/mainnet.json | 9 +++++++-- p2p/peer.go | 15 +++++++++++++-- params/version.go | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/genesis/mainnet.json b/genesis/mainnet.json index 13ffb4ae01..af7a471bca 100644 --- a/genesis/mainnet.json +++ b/genesis/mainnet.json @@ -22,11 +22,16 @@ "consortiumV2Contracts": { "roninValidatorSet": "0x617c5d73662282EA7FfD231E020eCa6D2B0D552f", "slashIndicator": "0xEBFFF2b32fA0dF9C5C8C5d5AAa7e8b51d5207bA3", - "stakingContract": "0x545edb750eB8769C868429BE9586F5857A768758" + "stakingContract": "0x545edb750eB8769C868429BE9586F5857A768758", + "profileContract": "0x840EBf1CA767CB690029E91856A357a43B85d035", + "finalityTracking": "0xA30B2932CD8b8A89E34551Cdfa13810af38dA576" }, "puffyBlock": 0, "bubaBlock": 0, - "olekBlock": 24935500 + "olekBlock": 24935500, + "shillinBlock": 28825400, + "antennaBlock": 28825400, + "whiteListDeployerContractV2Address": "0xc1876d5C4BFAF0eE325E4226B2bdf216D9896AE1" }, "alloc": { "0x0000000000000000000000000000000000000011": { diff --git a/p2p/peer.go b/p2p/peer.go index 0751900588..99c92d27cd 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -112,6 +112,7 @@ type Peer struct { wg sync.WaitGroup protoErr chan error closed chan struct{} + pingRecv chan struct{} disc chan DiscReason // events receives message send / receive events if set @@ -244,6 +245,7 @@ func newPeer(log log.Logger, conn *conn, protocols []Protocol) *Peer { disc: make(chan DiscReason), protoErr: make(chan error, len(protomap)+1), // protocols + pingLoop closed: make(chan struct{}), + pingRecv: make(chan struct{}, 16), log: log.New("id", conn.node.ID(), "conn", conn.flags), } return p @@ -304,9 +306,11 @@ loop: } func (p *Peer) pingLoop() { - ping := time.NewTimer(pingInterval) defer p.wg.Done() + + ping := time.NewTimer(pingInterval) defer ping.Stop() + for { select { case <-ping.C: @@ -315,6 +319,10 @@ func (p *Peer) pingLoop() { return } ping.Reset(pingInterval) + + case <-p.pingRecv: + SendItems(p.rw, pongMsg) + case <-p.closed: return } @@ -341,7 +349,10 @@ func (p *Peer) handle(msg Msg) error { switch { case msg.Code == pingMsg: msg.Discard() - go SendItems(p.rw, pongMsg) + select { + case p.pingRecv <- struct{}{}: + case <-p.closed: + } case msg.Code == discMsg: // This is the last message. We don't need to discard or // check errors because, the connection will be closed after it. diff --git a/params/version.go b/params/version.go index 11339aab4d..8d44b19d40 100644 --- a/params/version.go +++ b/params/version.go @@ -23,7 +23,7 @@ import ( const ( VersionMajor = 2 // Major version component of the current release VersionMinor = 6 // Minor version component of the current release - VersionPatch = 0 // Patch version component of the current release + VersionPatch = 2 // Patch version component of the current release VersionMeta = "" // Version metadata to append to the version string )