mirror of https://github.com/status-im/go-waku.git
chore(rln-relay): confirm that the provided credential is correct using onchain query
This commit is contained in:
parent
7fbb9ebe42
commit
def745cfba
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
Subproject commit 63a7856eb29f08644d1e963e3edfc2c182469257
|
||||
Subproject commit 8f8dda5b7133aa8f99cbc46804972d02c22c0155
|
|
@ -135,6 +135,10 @@ func (gm *DynamicGroupManager) getMembershipFee(ctx context.Context) (*big.Int,
|
|||
return gm.web3Config.RLNContract.MEMBERSHIPDEPOSIT(&bind.CallOpts{Context: ctx})
|
||||
}
|
||||
|
||||
func (gm *DynamicGroupManager) memberExists(ctx context.Context, idCommitment rln.IDCommitment) (bool, error) {
|
||||
return gm.web3Config.RLNContract.MemberExists(&bind.CallOpts{Context: ctx}, rln.Bytes32ToBigInt(idCommitment))
|
||||
}
|
||||
|
||||
func (gm *DynamicGroupManager) Start(ctx context.Context, rlnInstance *rln.RLN, rootTracker *group_manager.MerkleRootTracker) error {
|
||||
if gm.cancel != nil {
|
||||
return errors.New("already started")
|
||||
|
@ -159,7 +163,7 @@ func (gm *DynamicGroupManager) Start(ctx context.Context, rlnInstance *rln.RLN,
|
|||
return err
|
||||
}
|
||||
|
||||
err = gm.loadCredential()
|
||||
err = gm.loadCredential(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -171,7 +175,7 @@ func (gm *DynamicGroupManager) Start(ctx context.Context, rlnInstance *rln.RLN,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (gm *DynamicGroupManager) loadCredential() error {
|
||||
func (gm *DynamicGroupManager) loadCredential(ctx context.Context) error {
|
||||
start := time.Now()
|
||||
|
||||
credentials, err := gm.appKeystore.GetMembershipCredentials(
|
||||
|
@ -187,6 +191,15 @@ func (gm *DynamicGroupManager) loadCredential() error {
|
|||
return errors.New("no credentials available")
|
||||
}
|
||||
|
||||
exists, err := gm.memberExists(ctx, credentials.IdentityCredential.IDCommitment)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !exists {
|
||||
return errors.New("the provided commitment does not have a membership")
|
||||
}
|
||||
|
||||
gm.identityCredential = credentials.IdentityCredential
|
||||
|
||||
return nil
|
||||
|
|
|
@ -217,7 +217,7 @@ func (s *WakuRLNRelayDynamicSuite) TestMerkleTreeConstruction() {
|
|||
credentials1 := s.generateCredentials(rlnInstance)
|
||||
credentials2 := s.generateCredentials(rlnInstance)
|
||||
|
||||
err = rlnInstance.InsertMembers(1, []rln.IDCommitment{credentials1.IDCommitment, credentials2.IDCommitment})
|
||||
err = rlnInstance.InsertMembers(0, []rln.IDCommitment{credentials1.IDCommitment, credentials2.IDCommitment})
|
||||
s.Require().NoError(err)
|
||||
|
||||
// get the Merkle root
|
||||
|
@ -298,8 +298,8 @@ func (s *WakuRLNRelayDynamicSuite) TestCorrectRegistrationOfPeers() {
|
|||
idx1 := rlnRelay1.groupManager.MembershipIndex()
|
||||
idx2 := rlnRelay2.groupManager.MembershipIndex()
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(rln.MembershipIndex(1), idx1)
|
||||
s.Require().Equal(rln.MembershipIndex(2), idx2)
|
||||
s.Require().Equal(rln.MembershipIndex(0), idx1)
|
||||
s.Require().Equal(rln.MembershipIndex(1), idx2)
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelayDynamicSuite) tmpKeystorePath() string {
|
||||
|
|
Loading…
Reference in New Issue