-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement signature validation #11
Conversation
// Insert into MongoDB if signature is valid | ||
for _, req := range requestsWithActiveValidators { | ||
// create a goroutine for each request | ||
wg.Add(1) |
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.
Im not sure this limits goroutiens to enter "validateAndInsertSignature" one by one, only one at a time. In oracle we use mutex to achieve this (see https://github.com/dappnode/mev-sp-oracle/blob/01cfadc41b4cbd7a334950e2b0e46a2901ee692c/oracle/oracle.go#L73).
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.
According to docs
sync.WaitGroup is used to wait for a collection of goroutines to finish executing. You increment the WaitGroup counter for each goroutine you launch and decrement it (wg.Done()) in each goroutine when it finishes its task.
sync.Mutex is used to ensure that only one goroutine accesses a particular section of code at a time. It's typically used to protect shared resources from concurrent access issues, such as race conditions.
It does not look like our case to use Mutex
return validRequests, nil | ||
} | ||
|
||
func validateAndInsertSignature(req types.SignatureRequestDecoded, dbCollection *mongo.Collection, wg *sync.WaitGroup) { |
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.
should these helper methods go somewhere else?
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 would leve them there as for now
Implement signature validation with go routines. Add testing to validation package.