-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for querying proofs and remove broadcasting #187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some high level questions first to get the context. thanks for your patience.
7a9ffd8
to
7a9301c
Compare
// GetProof implements api.PoetServer. | ||
func (r *rpcServer) GetProof(ctx context.Context, in *api.GetProofRequest) (*api.GetProofResponse, error) { | ||
if info, err := r.s.Info(ctx); err == nil { | ||
if info.OpenRoundID == in.RoundId || slices.Contains(info.ExecutingRoundsIds, in.RoundId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still finds this multiple rounds logic confusing. would appreciate (for future reviews) that we get rid of it if we know poet is not doing multiple rounds at the same time.
proof, err := r.proofsDb.Get(ctx, in.RoundId) | ||
switch { | ||
case errors.Is(err, service.ErrNotFound): | ||
return nil, status.Error(codes.NotFound, "proof not found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would printing err.Error() here be more informative for debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GRPC interceptor already prints requests and responses here 😉:
Lines 174 to 191 in c2c2e82
func loggerInterceptor() func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { | |
return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { | |
peer, _ := peer.FromContext(ctx) | |
logger := log.AppLog.WithName(info.FullMethod).WithFields(log.Field(zap.Stringer("request_id", uuid.New()))) | |
ctx = logging.NewContext(ctx, logger) | |
if msg, ok := req.(fmt.Stringer); ok { | |
logger.With().Debug("new GRPC", log.Field(zap.Stringer("from", peer.Addr)), log.Field(zap.Stringer("message", msg))) | |
} | |
resp, err := handler(ctx, req) | |
if err != nil { | |
logger.With().Info("FAILURE", log.Err(err)) | |
} | |
return resp, err | |
} | |
} |
The returned error will be visible in logs printed there.
## Motivation Part of spacemeshos/pm#173 Closes #3746 Closes #3814 ## Changes - removed broadcasting method from `GatewayService` - removed p2p listeners for broadcasted poet proofs - changed `NIPostBuilder` to query poets for proofs after the rounds end ## Test Plan - added a system test in which nodes use different poets to verify if poet proofs are properly propagated between nodes ## TODO - [ ] Bump poet to a released version in go.mod after spacemeshos/poet#187 is merged ## DevOps Notes - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [ ] ~This PR does not affect public APIs~ Proof broadcasting was removed - [ ] ~This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)~ - It relies on a new Poet version - [ ] ~This PR does not make changes to log messages (which monitoring infrastructure may rely on)~ Co-authored-by: moshababo <[email protected]>
## Motivation Part of spacemeshos/pm#173 Closes #3746 Closes #3814 ## Changes - removed broadcasting method from `GatewayService` - removed p2p listeners for broadcasted poet proofs - changed `NIPostBuilder` to query poets for proofs after the rounds end ## Test Plan - added a system test in which nodes use different poets to verify if poet proofs are properly propagated between nodes ## TODO - [ ] Bump poet to a released version in go.mod after spacemeshos/poet#187 is merged ## DevOps Notes - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [ ] ~This PR does not affect public APIs~ Proof broadcasting was removed - [ ] ~This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)~ - It relies on a new Poet version - [ ] ~This PR does not make changes to log messages (which monitoring infrastructure may rely on)~ Co-authored-by: moshababo <[email protected]>
## Motivation Part of spacemeshos/pm#173 Closes #3746 Closes #3814 ## Changes - removed broadcasting method from `GatewayService` - removed p2p listeners for broadcasted poet proofs - changed `NIPostBuilder` to query poets for proofs after the rounds end ## Test Plan - added a system test in which nodes use different poets to verify if poet proofs are properly propagated between nodes ## TODO - [ ] Bump poet to a released version in go.mod after spacemeshos/poet#187 is merged ## DevOps Notes - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [ ] ~This PR does not affect public APIs~ Proof broadcasting was removed - [ ] ~This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)~ - It relies on a new Poet version - [ ] ~This PR does not make changes to log messages (which monitoring infrastructure may rely on)~ Co-authored-by: moshababo <[email protected]>
## Motivation Part of spacemeshos/pm#173 Closes #3746 Closes #3814 ## Changes - removed broadcasting method from `GatewayService` - removed p2p listeners for broadcasted poet proofs - changed `NIPostBuilder` to query poets for proofs after the rounds end ## Test Plan - added a system test in which nodes use different poets to verify if poet proofs are properly propagated between nodes ## TODO - [ ] Bump poet to a released version in go.mod after spacemeshos/poet#187 is merged ## DevOps Notes - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [ ] ~This PR does not affect public APIs~ Proof broadcasting was removed - [ ] ~This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)~ - It relies on a new Poet version - [ ] ~This PR does not make changes to log messages (which monitoring infrastructure may rely on)~ Co-authored-by: moshababo <[email protected]>
## Motivation Part of spacemeshos/pm#173 Closes #3746 Closes #3814 ## Changes - removed broadcasting method from `GatewayService` - removed p2p listeners for broadcasted poet proofs - changed `NIPostBuilder` to query poets for proofs after the rounds end ## Test Plan - added a system test in which nodes use different poets to verify if poet proofs are properly propagated between nodes ## TODO - [ ] Bump poet to a released version in go.mod after spacemeshos/poet#187 is merged ## DevOps Notes - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [ ] ~This PR does not affect public APIs~ Proof broadcasting was removed - [ ] ~This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)~ - It relies on a new Poet version - [ ] ~This PR does not make changes to log messages (which monitoring infrastructure may rely on)~ Co-authored-by: moshababo <[email protected]>
## Motivation Part of spacemeshos/pm#173 Closes #3746 Closes #3814 ## Changes - removed broadcasting method from `GatewayService` - removed p2p listeners for broadcasted poet proofs - changed `NIPostBuilder` to query poets for proofs after the rounds end ## Test Plan - added a system test in which nodes use different poets to verify if poet proofs are properly propagated between nodes ## TODO - [ ] Bump poet to a released version in go.mod after spacemeshos/poet#187 is merged ## DevOps Notes - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [ ] ~This PR does not affect public APIs~ Proof broadcasting was removed - [ ] ~This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)~ - It relies on a new Poet version - [ ] ~This PR does not make changes to log messages (which monitoring infrastructure may rely on)~ Co-authored-by: moshababo <[email protected]>
Implements necessary poet changes for spacemeshos/pm#173
Closes #167
Closes #168
Closes #169
Notable changes:
Service
reports produced proofs via a channel instead of broadcasting them. The proofs are then picked up by consumers:removed the last
Mutex
from theService
struct. The actor event loop is now synchonous (started viaService::Run()
). It doesn't spawn a goroutine and finishes when the context is cancelled. It made the shutdown logic redundant.split server startup into:
server::New()
, where it configures itself and binds ports to listen onServer::Start
, where it actually starts to process incoming requestsIt allows writing tests that run on random ports and obtain ports the server listens on, which lets run parallel tests.
Submit()
GRPC returns duration till the end of the round that the challenge was submitted to. It gives two benefits for the node: