mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-05 07:23:10 +00:00
fix: store id committment as little endian
This commit is contained in:
parent
021265eba4
commit
6a270a4218
@ -98,7 +98,10 @@ func (gm *DynamicGroupManager) handler(events []*contracts.RLNMemberRegistered)
|
||||
// this is not a fatal error, hence we don't raise an exception
|
||||
gm.log.Warn("failed to persist rln metadata", zap.Error(err))
|
||||
} else {
|
||||
gm.log.Debug("rln metadata persisted", zap.Uint64("lastBlockProcessed", gm.lastBlockProcessed), zap.Uint64("chainID", gm.web3Config.ChainID.Uint64()), logging.HexBytes("contractAddress", gm.web3Config.RegistryContract.Address.Bytes()))
|
||||
gm.log.Debug("rln metadata persisted", zap.Uint64("lastBlockProcessed", gm.lastBlockProcessed),
|
||||
zap.Uint64("chainID", gm.web3Config.ChainID.Uint64()),
|
||||
logging.HexBytes("contractAddress", gm.web3Config.RegistryContract.Address.Bytes()),
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -216,6 +219,13 @@ func (gm *DynamicGroupManager) loadCredential(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ConvertToLittleEndian(b []byte) [32]byte {
|
||||
for i := 0; i < len(b)/2; i++ {
|
||||
b[i], b[len(b)-i-1] = b[len(b)-i-1], b[i]
|
||||
}
|
||||
return rln.Bytes32(b)
|
||||
}
|
||||
|
||||
func (gm *DynamicGroupManager) InsertMembers(toInsert *om.OrderedMap) error {
|
||||
for pair := toInsert.Oldest(); pair != nil; pair = pair.Next() {
|
||||
events := pair.Value.([]*contracts.RLNMemberRegistered) // TODO: should these be sortered by index? we assume all members arrive in order
|
||||
@ -225,7 +235,11 @@ func (gm *DynamicGroupManager) InsertMembers(toInsert *om.OrderedMap) error {
|
||||
if oldestIndexInBlock == nil {
|
||||
oldestIndexInBlock = evt.Index
|
||||
}
|
||||
idCommitments = append(idCommitments, rln.BigIntToBytes32(evt.IdCommitment))
|
||||
convertedIdCommittment := rln.BigIntToBytes32(evt.IdCommitment)
|
||||
leIdCommittment := ConvertToLittleEndian(convertedIdCommittment[:])
|
||||
idCommitments = append(idCommitments, leIdCommittment)
|
||||
|
||||
gm.log.Debug("processed committment", logging.HexBytes("id-committment", leIdCommittment[:]))
|
||||
}
|
||||
|
||||
if len(idCommitments) == 0 {
|
||||
@ -235,6 +249,8 @@ func (gm *DynamicGroupManager) InsertMembers(toInsert *om.OrderedMap) error {
|
||||
// TODO: should we track indexes to identify missing?
|
||||
startIndex := rln.MembershipIndex(uint(oldestIndexInBlock.Int64()))
|
||||
start := time.Now()
|
||||
gm.log.Debug("inserting members at index", zap.Uint("index", startIndex))
|
||||
|
||||
err := gm.rln.InsertMembers(startIndex, idCommitments)
|
||||
if err != nil {
|
||||
gm.log.Error("inserting members into merkletree", zap.Error(err))
|
||||
|
||||
@ -75,6 +75,7 @@ func (mf *MembershipFetcher) HandleGroupUpdates(ctx context.Context, handler Reg
|
||||
return err
|
||||
}
|
||||
mf.log.Info("events loaded", zap.Duration("timeToLoad", time.Since(t)))
|
||||
//TODO: Set latest block in gm to latestBlockNumber???
|
||||
|
||||
errCh := make(chan error)
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"sync"
|
||||
|
||||
"github.com/waku-org/go-waku/logging"
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
"github.com/waku-org/go-zerokit-rln/rln"
|
||||
"go.uber.org/zap"
|
||||
@ -109,7 +110,7 @@ func (m *MerkleRootTracker) UpdateLatestRoot(blockNumber uint64) rln.MerkleNode
|
||||
if err != nil {
|
||||
utils.Logger().Named("root-tracker").Panic("could not retrieve merkle root", zap.Error(err))
|
||||
}
|
||||
|
||||
utils.Logger().Named("root-tracker").Debug("pushing root", logging.HexBytes("root", root[:]))
|
||||
m.pushRoot(blockNumber, root)
|
||||
|
||||
return root
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user