Skip to content

Commit

Permalink
post: update to latest version with inflight verification (#4716)
Browse files Browse the repository at this point in the history
## Motivation
Closes spacemeshos/post#181

## Changes
Updates PoST with inflight verification of labels

## Test Plan
n/a

## TODO
<!-- This section should be removed when all items are complete -->
- [x] Explain motivation or link existing issue(s)
- [x] Test changes and document test plan
- [x] Update documentation as needed

## DevOps Notes
<!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases -->
- [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources)
- [x] This PR does not affect public APIs
- [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)
- [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on)
  • Loading branch information
fasmat committed Jul 18, 2023
1 parent 618aae2 commit c418ee5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
9 changes: 8 additions & 1 deletion activation/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,27 @@ func (mgr *PostSetupManager) StartSession(ctx context.Context) error {
)
events.EmitInitStart(mgr.id, mgr.commitmentAtxId)
err = mgr.init.Initialize(ctx)
events.EmitInitComplete(err != nil)

mgr.mu.Lock()
defer mgr.mu.Unlock()
var errLabelMismatch initialization.ErrReferenceLabelMismatch
switch {
case errors.Is(err, context.Canceled):
mgr.logger.Info("post setup session was stopped")
mgr.state = PostSetupStateStopped
return err
case errors.As(err, &errLabelMismatch):
mgr.logger.With().Error("post setup session failed due to an issue with the initialization provider", log.Err(errLabelMismatch))
mgr.state = PostSetupStateError
events.EmitInitFailure(mgr.id, mgr.commitmentAtxId, errLabelMismatch)
return nil
case err != nil:
mgr.logger.With().Error("post setup session failed", log.Err(err))
mgr.state = PostSetupStateError
events.EmitInitFailure(mgr.id, mgr.commitmentAtxId, err)
return err
}
events.EmitInitComplete()

mgr.logger.With().Info("post setup completed",
log.String("node_id", mgr.id.String()),
Expand Down
19 changes: 17 additions & 2 deletions events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,26 @@ func EmitInitStart(smesher types.NodeID, commitment types.ATXID) {
)
}

func EmitInitComplete(failure bool) {
func EmitInitFailure(smesher types.NodeID, commitment types.ATXID, err error) {
const help = "Node failed post data initialization."
emitUserEvent(
help,
true,
&pb.Event_InitFailed{
InitFailed: &pb.EventInitFailed{
Smesher: smesher[:],
Commitment: commitment[:],
Error: err.Error(),
},
},
)
}

func EmitInitComplete() {
const help = "Node completed post data initialization."
emitUserEvent(
help,
failure,
false,
&pb.Event_InitComplete{
InitComplete: &pb.EventInitComplete{},
},
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ require (
github.com/pyroscope-io/pyroscope v0.37.2
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0
github.com/seehuhn/mt19937 v1.0.0
github.com/spacemeshos/api/release/go v1.16.0
github.com/spacemeshos/api/release/go v1.17.0
github.com/spacemeshos/economics v0.1.0
github.com/spacemeshos/fixed v0.1.0
github.com/spacemeshos/go-scale v1.1.10
github.com/spacemeshos/merkle-tree v0.2.2
github.com/spacemeshos/poet v0.8.6
github.com/spacemeshos/post v0.8.7
github.com/spacemeshos/post v0.8.8
github.com/spf13/afero v1.9.5
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/spacemeshos/api/release/go v1.16.0 h1:DcRjnD+UBU4nx5TljxcPairHlI/wrbFX2VPUmWTarTs=
github.com/spacemeshos/api/release/go v1.16.0/go.mod h1:aSK7c2PUsle+EpC9VPAsPnsjKWDbo+NzT7kZgmzIZeM=
github.com/spacemeshos/api/release/go v1.17.0 h1:GZT2foJ619pYLYbNGWkat8QSFJnH1u2eOWw8AwSlz/g=
github.com/spacemeshos/api/release/go v1.17.0/go.mod h1:aSK7c2PUsle+EpC9VPAsPnsjKWDbo+NzT7kZgmzIZeM=
github.com/spacemeshos/economics v0.1.0 h1:PJAKbhBKqbbdCYTB29pkmc8sYqK3pKUAiuAvQxuSJEg=
github.com/spacemeshos/economics v0.1.0/go.mod h1:Bz0wRDwCOUP1A6w3cPW6iuUBGME8Tz48sIriYiohsBg=
github.com/spacemeshos/fixed v0.1.0 h1:20KIGvxLlAsuidQrvuwwHe6PrvqeTKzbJIsScbmnUPQ=
Expand All @@ -606,8 +606,8 @@ github.com/spacemeshos/merkle-tree v0.2.2 h1:+zF+17CwVebq9UzShunUBXv16rEVKIJHh2C
github.com/spacemeshos/merkle-tree v0.2.2/go.mod h1:0Q/z4S5Kt9qz/c3qWa7hKA1yT7n7odyysbPIUTRu/xo=
github.com/spacemeshos/poet v0.8.6 h1:jMQ9HkJeCRqUMRTIk0HEP/5kvVdAH+OAkzOKQ0XlhJU=
github.com/spacemeshos/poet v0.8.6/go.mod h1:Ut/aR/1Sks6/I/+GDFLqCinXW6OIIS8z9uL/zjFTTP8=
github.com/spacemeshos/post v0.8.7 h1:aqzAQ6FrPJhm6pgLtisFWKV5E6I3+LVnlbEJ+CDdzPM=
github.com/spacemeshos/post v0.8.7/go.mod h1:LDj6XQht1ZvTZurBJ+LZNf17t92qIQymWgU2sY6V2Zs=
github.com/spacemeshos/post v0.8.8 h1:bGKq7XDTJIPcX/oPP1KZ51p0JmLA7rIElJoqRSiBVv8=
github.com/spacemeshos/post v0.8.8/go.mod h1:LDj6XQht1ZvTZurBJ+LZNf17t92qIQymWgU2sY6V2Zs=
github.com/spacemeshos/sha256-simd v0.1.0 h1:G7Mfu5RYdQiuE+wu4ZyJ7I0TI74uqLhFnKblEnSpjYI=
github.com/spacemeshos/sha256-simd v0.1.0/go.mod h1:O8CClVIilId7RtuCMV2+YzMj6qjVn75JsxOxaE8vcfM=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
Expand Down

0 comments on commit c418ee5

Please sign in to comment.