From 68f03431fdb27eb13e352bdaaee978da9741453d Mon Sep 17 00:00:00 2001 From: earl Date: Wed, 10 Jan 2024 22:21:18 +0100 Subject: [PATCH] Update api to 1.26 and add `until` to wait events --- activation/activation.go | 4 ++-- activation/nipost.go | 2 +- events/events.go | 15 +++++++++------ go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/activation/activation.go b/activation/activation.go index 3af939d975..ff07abc486 100644 --- a/activation/activation.go +++ b/activation/activation.go @@ -395,7 +395,7 @@ func (b *Builder) buildNIPostChallenge(ctx context.Context) (*types.NIPostChalle zap.Uint32("current epoch", current.Uint32()), zap.Duration("wait", time.Until(wait)), ) - events.EmitPoetWaitRound(current, current+1, time.Until(wait)) + events.EmitPoetWaitRound(current, current+1, wait) select { case <-ctx.Done(): return nil, ctx.Err() @@ -504,7 +504,7 @@ func (b *Builder) PublishActivationTx(ctx context.Context) error { events.EmitAtxPublished( atx.PublishEpoch, atx.TargetEpoch(), atx.ID(), - time.Until(b.layerClock.LayerToTime(atx.TargetEpoch().FirstLayer())), + b.layerClock.LayerToTime(atx.TargetEpoch().FirstLayer()), ) return nil } diff --git a/activation/nipost.go b/activation/nipost.go index e5be9fbc7b..ccff6e069d 100644 --- a/activation/nipost.go +++ b/activation/nipost.go @@ -250,7 +250,7 @@ func (nb *NIPostBuilder) BuildNIPost( ) } - events.EmitPoetWaitProof(challenge.PublishEpoch, challenge.TargetEpoch(), time.Until(poetRoundEnd)) + events.EmitPoetWaitProof(challenge.PublishEpoch, challenge.TargetEpoch(), poetRoundEnd) poetProofRef, membership, err = nb.getBestProof(ctx, challenge.Hash(), challenge.PublishEpoch) if err != nil { return nil, &PoetSvcUnstableError{msg: "getBestProof failed", source: err} diff --git a/events/events.go b/events/events.go index be353e4a55..fcf02e6d51 100644 --- a/events/events.go +++ b/events/events.go @@ -70,7 +70,7 @@ func EmitInitComplete() { ) } -func EmitPoetWaitRound(current, publish types.EpochID, wait time.Duration) { +func EmitPoetWaitRound(current, publish types.EpochID, wait time.Time) { const help = "Node is waiting for PoET registration window in current epoch to open. " + "After this it will submit challenge and wait until PoET round ends in publish epoch." emitUserEvent( @@ -79,7 +79,8 @@ func EmitPoetWaitRound(current, publish types.EpochID, wait time.Duration) { &pb.Event_PoetWaitRound{PoetWaitRound: &pb.EventPoetWaitRound{ Current: current.Uint32(), Publish: publish.Uint32(), - Wait: durationpb.New(wait), + Wait: durationpb.New(time.Until(wait)), + Until: timestamppb.New(wait), }}, ) } @@ -90,7 +91,7 @@ type EventPoetWaitEnd struct { Wait time.Duration `json:"wait"` } -func EmitPoetWaitProof(publish, target types.EpochID, wait time.Duration) { +func EmitPoetWaitProof(publish, target types.EpochID, wait time.Time) { const help = "Node is waiting for PoET to complete. " + "After it's complete, the node will fetch the PoET proof, generate a PoST proof, " + "and finally publish an ATX to establish eligibility for rewards in the target epoch." @@ -101,7 +102,8 @@ func EmitPoetWaitProof(publish, target types.EpochID, wait time.Duration) { PoetWaitProof: &pb.EventPoetWaitProof{ Publish: publish.Uint32(), Target: target.Uint32(), - Wait: durationpb.New(wait), + Wait: durationpb.New(time.Until(wait)), + Until: timestamppb.New(wait), }, }, ) @@ -164,7 +166,7 @@ func EmitInvalidPostProof() { func EmitAtxPublished( current, target types.EpochID, id types.ATXID, - wait time.Duration, + wait time.Time, ) { const help = "Node published activation for the current epoch. " + "It now needs to wait until the target epoch when it will be eligible for rewards." @@ -176,7 +178,8 @@ func EmitAtxPublished( Current: current.Uint32(), Target: target.Uint32(), Id: id[:], - Wait: durationpb.New(wait), + Wait: durationpb.New(time.Until(wait)), + Until: timestamppb.New(wait), }, }, ) diff --git a/go.mod b/go.mod index 994ff61b9c..856e48ddb7 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/quic-go/quic-go v0.41.0 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/seehuhn/mt19937 v1.0.0 - github.com/spacemeshos/api/release/go v1.25.0 + github.com/spacemeshos/api/release/go v1.26.0 github.com/spacemeshos/economics v0.1.2 github.com/spacemeshos/fixed v0.1.1 github.com/spacemeshos/go-scale v1.1.12 diff --git a/go.sum b/go.sum index a14986f2fd..6304c7f3b4 100644 --- a/go.sum +++ b/go.sum @@ -616,8 +616,8 @@ github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:Udh github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= -github.com/spacemeshos/api/release/go v1.25.0 h1:HqIykavooxUxZySiN7yiILRX+Kx6WxM1NF6w72PNmMc= -github.com/spacemeshos/api/release/go v1.25.0/go.mod h1:Ffvt8Zl5K6k0In0OF7PUJ2JoxrW8zBRXKF1kG0abigg= +github.com/spacemeshos/api/release/go v1.26.0 h1:wop4OoID/2o8BEwNP/wypCIy//CDTnv14perIZo0WOU= +github.com/spacemeshos/api/release/go v1.26.0/go.mod h1:cQXfRiIRPc8c6bh9+VAK/GwD0zYCu7jKcos/cPaDYcI= github.com/spacemeshos/economics v0.1.2 h1:kw8cE5SMa/7svHOGorCd2w8ef1y8iP0p47/2VDOK8Ns= github.com/spacemeshos/economics v0.1.2/go.mod h1:ngeWn5E/jy9dJP1MHyuk3ehF8NBMTYhchqVDhAHUUNk= github.com/spacemeshos/fixed v0.1.1 h1:N1y4SUpq1EV+IdJrWJwUCt1oBFzeru/VKVcBsvPc2Fk=