-
Notifications
You must be signed in to change notification settings - Fork 17
Dev #98
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
Open
nann-cheng
wants to merge
4
commits into
fystack:dev
Choose a base branch
from
nann-cheng:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+116
−36
Open
Dev #98
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,8 @@ func (ec *eventConsumer) handleKeyGenEvent(natMsg *nats.Msg) { | |
baseCtx, baseCancel := context.WithTimeout(context.Background(), KeyGenTimeOut) | ||
defer baseCancel() | ||
|
||
logger.Info("[KEY GEN] Key generation result") | ||
|
||
raw := natMsg.Data | ||
var msg types.GenerateKeyMessage | ||
if err := json.Unmarshal(raw, &msg); err != nil { | ||
|
@@ -167,6 +169,9 @@ func (ec *eventConsumer) handleKeyGenEvent(natMsg *nats.Msg) { | |
} | ||
|
||
walletID := msg.WalletID | ||
|
||
logger.Info("[KEY GEN] Key generation result", "walletID", walletID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unecessary logging |
||
|
||
ecdsaSession, err := ec.node.CreateKeyGenSession(mpc.SessionTypeECDSA, walletID, ec.mpcThreshold, ec.genKeyResultQueue) | ||
if err != nil { | ||
ec.handleKeygenSessionError(walletID, err, "Failed to create ECDSA key generation session", natMsg) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ func (sc *keygenConsumer) waitForAllPeersReadyToGenKey(ctx context.Context) erro | |
} | ||
} | ||
|
||
// Run subscribes to signing events and processes them until the context is canceled. | ||
// Run subscribes to keygen events and processes them until the context is canceled. | ||
func (sc *keygenConsumer) Run(ctx context.Context) error { | ||
// Wait for sufficient peers before starting to consume messages | ||
if err := sc.waitForAllPeersReadyToGenKey(ctx); err != nil { | ||
|
@@ -110,7 +110,7 @@ func (sc *keygenConsumer) Run(ctx context.Context) error { | |
return fmt.Errorf("failed to subscribe to keygen events: %w", err) | ||
} | ||
sc.jsSub = sub | ||
logger.Info("SigningConsumer: Subscribed to keygen events") | ||
logger.Info("KeygenConsumer: Subscribed to keygen events") | ||
|
||
// Block until context cancellation. | ||
<-ctx.Done() | ||
|
@@ -140,9 +140,11 @@ func (sc *keygenConsumer) handleKeygenEvent(msg jetstream.Msg) { | |
return | ||
} | ||
|
||
// Create a reply inbox to receive the signing event response. | ||
// Create a reply inbox to receive the keygen event response. | ||
replyInbox := nats.NewInbox() | ||
|
||
logger.Info("Newreplybox id", "topic", replyInbox) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this debug logging |
||
|
||
// Use a synchronous subscription for the reply inbox. | ||
replySub, err := sc.natsConn.SubscribeSync(replyInbox) | ||
if err != nil { | ||
|
@@ -156,12 +158,12 @@ func (sc *keygenConsumer) handleKeygenEvent(msg jetstream.Msg) { | |
} | ||
}() | ||
|
||
// Publish the signing event with the reply inbox. | ||
// Publish the keygen event with the reply inbox. | ||
headers := map[string]string{ | ||
"SessionID": uuid.New().String(), | ||
} | ||
if err := sc.pubsub.PublishWithReply(MPCGenerateEvent, replyInbox, msg.Data(), headers); err != nil { | ||
logger.Error("KeygenConsumer: Failed to publish signing event with reply", err) | ||
logger.Error("KeygenConsumer: Failed to publish keygen event with reply", err) | ||
_ = msg.Nak() | ||
return | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package messaging | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nats-io/nats.go" | ||
) | ||
|
||
type Subscription interface { | ||
Unsubscribe() error | ||
} | ||
|
||
// a subscription can be made by pubsub or dicrectmessaging | ||
type natsSubscription struct { | ||
subscription *nats.Subscription | ||
topic string | ||
pubSub *natsPubSub | ||
direct *natsDirectMessaging | ||
} | ||
|
||
func (ns *natsSubscription) Unsubscribe() error { | ||
if ns.topic == "" { | ||
return fmt.Errorf("cannot cleanup handlers: topic is empty") | ||
} | ||
|
||
if ns.pubSub != nil { | ||
ns.pubSub.cleanupHandlers(ns.topic) | ||
} | ||
|
||
if ns.direct != nil { | ||
ns.direct.cleanupHandlers(ns.topic) | ||
} | ||
return ns.subscription.Unsubscribe() | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
unecessary logging