Skip to content

Commit

Permalink
update v1.4.20-p1
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhi committed Jun 30, 2024
1 parent 017e8a3 commit e0a7af9
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 50 deletions.
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: quilibrium
services:
node:
# image: ${QUILIBRIUM_IMAGE_NAME:-quilibrium}
image: eth2dev/quilibrium:v1.4.20-signed
image: eth2dev/quilibrium:v1.4.20-p1-signed
container_name: "quil"
restart: unless-stopped
# command: ["--signature-check=false"]
Expand Down
4 changes: 2 additions & 2 deletions go-libp2p-blossomsub/blossomsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ func NewBlossomSubWithRouter(ctx context.Context, h host.Host, rt PubSubRouter,
}

// NewBlossomSubRouter returns a new BlossomSubRouter with custom parameters.
func NewBlossomSubRouter(h host.Host, params BlossomSubParams) *BlossomSubRouter {
func NewBlossomSubRouter(h host.Host, params BlossomSubParams, addrBook peerstore.AddrBook) *BlossomSubRouter {
return &BlossomSubRouter{
peers: make(map[peer.ID]protocol.ID),
mesh: make(map[string]map[peer.ID]struct{}),
fanout: make(map[string]map[peer.ID]struct{}),
lastpub: make(map[string]int64),
gossip: make(map[peer.ID][]*pb.ControlIHave),
control: make(map[peer.ID]*pb.ControlMessage),
cab: pstoremem.NewAddrBook(),
cab: addrBook,
backoff: make(map[string]map[peer.ID]time.Time),
peerhave: make(map[peer.ID]int),
iasked: make(map[peer.ID]int),
Expand Down
2 changes: 1 addition & 1 deletion node/config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ func FormatVersion(version []byte) string {
}

func GetPatchNumber() byte {
return 0x00
return 0x01
}
28 changes: 15 additions & 13 deletions node/consensus/master/broadcast_messaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,17 @@ func (e *MasterClockConsensusEngine) handleSelfTestReport(
info.DifficultyMetric = report.DifficultyMetric
info.MasterHeadFrame = report.MasterHeadFrame

if info.Bandwidth <= 1048576 {
if info.Bandwidth == 0 {
go func() {
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Minute)
defer cancel()
ch := e.pubSub.GetMultiaddrOfPeerStream(ctx, peerID)
select {
case <-ch:
go func() {
e.bandwidthTestCh <- peerID
}()
select {
case e.bandwidthTestCh <- peerID:
default:
}
case <-ctx.Done():
}
}()
Expand All @@ -116,15 +117,16 @@ func (e *MasterClockConsensusEngine) handleSelfTestReport(
for i := 0; i < len(proofs); i++ {
proofs[i] = proof[i*516 : (i+1)*516]
}
go func() {
e.verifyTestCh <- verifyChallenge{
peerID: peerID,
challenge: challenge,
cores: report.Cores,
increment: report.Increment,
proof: proof,
}
}()
select {
case e.verifyTestCh <- verifyChallenge{
peerID: peerID,
challenge: challenge,
cores: report.Cores,
increment: report.Increment,
proof: proof,
}:
default:
}

return nil
}
Expand Down
44 changes: 15 additions & 29 deletions node/consensus/master/master_clock_consensus_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func NewMasterClockConsensusEngine(
report: report,
frameValidationCh: make(chan *protobufs.ClockFrame),
bandwidthTestCh: make(chan []byte),
verifyTestCh: make(chan verifyChallenge),
verifyTestCh: make(chan verifyChallenge, 4),
engineConfig: engineConfig,
}

Expand Down Expand Up @@ -192,29 +192,14 @@ func (e *MasterClockConsensusEngine) Start() <-chan error {
go func() {
for {
select {
case newFrame := <-e.frameValidationCh:
head, err := e.masterTimeReel.Head()
if err != nil {
panic(err)
}

if head.FrameNumber > newFrame.FrameNumber ||
newFrame.FrameNumber-head.FrameNumber > 128 {
e.logger.Debug(
"frame out of range, ignoring",
zap.Uint64("number", newFrame.FrameNumber),
)
continue
}

if err := e.frameProver.VerifyMasterClockFrame(newFrame); err != nil {
e.logger.Error("could not verify clock frame", zap.Error(err))
continue
}

e.masterTimeReel.Insert(newFrame, false)
case peerId := <-e.bandwidthTestCh:
e.performBandwidthTest(peerId)
}
}
}()
go func() {
for {
select {
case verifyTest := <-e.verifyTestCh:
e.performVerifyTest(verifyTest)
}
Expand Down Expand Up @@ -398,13 +383,14 @@ func (e *MasterClockConsensusEngine) Start() <-chan error {
panic(err)
}

e.logger.Info(
"broadcasting self-test info",
zap.Uint64("current_frame", e.report.MasterHeadFrame),
)

if err := e.publishMessage(e.filter, e.report); err != nil {
e.logger.Debug("error publishing message", zap.Error(err))
if increment%30 == 0 {
e.logger.Info(
"broadcasting self-test info",
zap.Uint64("current_frame", e.report.MasterHeadFrame),
)
if err := e.publishMessage(e.filter, e.report); err != nil {
e.logger.Debug("error publishing message", zap.Error(err))
}
}
} else {
skipStore = false
Expand Down
5 changes: 3 additions & 2 deletions node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func main() {
fmt.Println("Signature check disabled, skipping...")
}

if *memprofile != "" {
if *memprofile != "" && *core == 0 {
go func() {
for {
time.Sleep(5 * time.Minute)
Expand All @@ -241,7 +241,7 @@ func main() {
}()
}

if *cpuprofile != "" {
if *cpuprofile != "" && *core == 0 {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -438,6 +438,7 @@ func main() {
}

repair(*configDirectory, node)
runtime.GOMAXPROCS(1)

if nodeConfig.ListenGRPCMultiaddr != "" {
srv, err := rpc.NewRPCServer(
Expand Down
21 changes: 19 additions & 2 deletions node/p2p/blossomsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ func getPeerID(p2pConfig *config.P2PConfig) peer.ID {
return id
}

type realclock struct{}

func (rc realclock) Now() time.Time {
return time.Now()
}

func (rc realclock) After(d time.Duration) <-chan time.Time {
return time.After(d)
}

func NewBlossomSub(
p2pConfig *config.P2PConfig,
peerstore store.Peerstore,
Expand Down Expand Up @@ -126,7 +136,14 @@ func NewBlossomSub(
opts = append(opts, libp2p.Identity(privKey))
}

ps, err := pstoreds.NewPeerstore(ctx, peerstore, pstoreds.DefaultOpts())
ps, err := pstoreds.NewPeerstore(ctx, peerstore, pstoreds.Options{
CacheSize: 120000,
MaxProtocols: 1024,
GCPurgeInterval: 2 * time.Hour,
GCLookaheadInterval: 0,
GCInitialDelay: 60 * time.Second,
Clock: realclock{},
})
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -208,7 +225,7 @@ func NewBlossomSub(
}))

params := mergeDefaults(p2pConfig)
rt := blossomsub.NewBlossomSubRouter(h, params)
rt := blossomsub.NewBlossomSubRouter(h, params, ps)
pubsub, err := blossomsub.NewBlossomSubWithRouter(ctx, h, rt, blossomOpts...)
if err != nil {
panic(err)
Expand Down

0 comments on commit e0a7af9

Please sign in to comment.