chore: bump go-waku
This commit is contained in:
parent
ea89a41d96
commit
3047521bd0
4
go.mod
4
go.mod
|
@ -80,7 +80,7 @@ require github.com/fogleman/gg v1.3.0
|
|||
require (
|
||||
github.com/gorilla/sessions v1.2.1
|
||||
github.com/meirf/gopart v0.0.0-20180520194036-37e9492a85a8
|
||||
github.com/waku-org/go-waku v0.2.3-0.20221122234656-5d7d05ca16a5
|
||||
github.com/waku-org/go-waku v0.2.3-0.20221126210912-041c7be67dfb
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -243,7 +243,7 @@ require (
|
|||
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
|
||||
github.com/urfave/cli/v2 v2.20.2 // indirect
|
||||
github.com/waku-org/go-discover v0.0.0-20221027130446-2f43d5f6c73f // indirect
|
||||
github.com/waku-org/go-zerokit-rln v0.1.6 // indirect
|
||||
github.com/waku-org/go-zerokit-rln v0.1.7-wakuorg // indirect
|
||||
github.com/waku-org/noise v1.0.2 // indirect
|
||||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
|
||||
|
|
8
go.sum
8
go.sum
|
@ -2065,10 +2065,10 @@ github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1
|
|||
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||
github.com/waku-org/go-discover v0.0.0-20221027130446-2f43d5f6c73f h1:YHIrSqs8Aot1exhwx0+uwdshCp3RfZu5OY6Hvt3Hk8g=
|
||||
github.com/waku-org/go-discover v0.0.0-20221027130446-2f43d5f6c73f/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
|
||||
github.com/waku-org/go-waku v0.2.3-0.20221122234656-5d7d05ca16a5 h1:fsDf8CcQZOIwgJ9OhEdX7FkYXP+JYlcYcOMWlY/id7w=
|
||||
github.com/waku-org/go-waku v0.2.3-0.20221122234656-5d7d05ca16a5/go.mod h1:QqlddKC5Q8ucWSnKQrHClWAkm6HszsQ1bUOXZYvt2UA=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.6 h1:r8B6S83WJIioxEj1wSruhx+eg47HpSrIwuhi6yaRvy0=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.6/go.mod h1:T1wLR/VuTcxLkDv0O7JvR0N/9y7GHM2IeU7LjnWZxek=
|
||||
github.com/waku-org/go-waku v0.2.3-0.20221126210912-041c7be67dfb h1:d/ZP7cofn3xdkGBWCuqtbIC6JlG+ytxscyeau3czQ5Y=
|
||||
github.com/waku-org/go-waku v0.2.3-0.20221126210912-041c7be67dfb/go.mod h1:tJGCjHrNc8JjOX0df15Uv4YiLQMNhWrotKHJeeVl3AE=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.7-wakuorg h1:2vVIBCtBih2w1K9ll8YnToTDZvbxcgbsClsPlJS/kkg=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.7-wakuorg/go.mod h1:GlyaVeEWNEBxVJrWC6jFTvb4LNb9d9qnjdS6EiWVUvk=
|
||||
github.com/waku-org/noise v1.0.2 h1:7WmlhpJ0eliBzwzKz6SoTqQznaEU2IuebHF3oCekqqs=
|
||||
github.com/waku-org/noise v1.0.2/go.mod h1:emThr8WZLeAtKqFW+/nXfHn9VucuXTh8aHap03UXP84=
|
||||
github.com/wealdtech/go-ens/v3 v3.5.0 h1:Huc9GxBgiGweCOGTYomvsg07K2QggAqZpZ5SuiZdC8o=
|
||||
|
|
|
@ -2,6 +2,7 @@ package metrics
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
"go.opencensus.io/stats"
|
||||
|
@ -11,6 +12,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
WakuVersion = stats.Int64("waku_version", "", stats.UnitDimensionless)
|
||||
Messages = stats.Int64("node_messages", "Number of messages received", stats.UnitDimensionless)
|
||||
Peers = stats.Int64("peers", "Number of connected peers", stats.UnitDimensionless)
|
||||
Dials = stats.Int64("dials", "Number of peer dials", stats.UnitDimensionless)
|
||||
|
@ -22,8 +24,9 @@ var (
|
|||
)
|
||||
|
||||
var (
|
||||
KeyType, _ = tag.NewKey("type")
|
||||
ErrorType, _ = tag.NewKey("error_type")
|
||||
KeyType, _ = tag.NewKey("type")
|
||||
ErrorType, _ = tag.NewKey("error_type")
|
||||
GitVersion, _ = tag.NewKey("git_version")
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -72,6 +75,13 @@ var (
|
|||
Aggregation: view.Count(),
|
||||
TagKeys: []tag.Key{ErrorType},
|
||||
}
|
||||
VersionView = &view.View{
|
||||
Name: "gowaku_version",
|
||||
Measure: WakuVersion,
|
||||
Description: "The gowaku version",
|
||||
Aggregation: view.LastValue(),
|
||||
TagKeys: []tag.Key{GitVersion},
|
||||
}
|
||||
)
|
||||
|
||||
func RecordLightpushError(ctx context.Context, tagType string) {
|
||||
|
@ -97,3 +107,10 @@ func RecordStoreError(ctx context.Context, tagType string) {
|
|||
utils.Logger().Error("failed to record with tags", zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
func RecordVersion(ctx context.Context, version string, commit string) {
|
||||
v := fmt.Sprintf("%s-%s", version, commit)
|
||||
if err := stats.RecordWithTags(ctx, []tag.Mutator{tag.Insert(GitVersion, v)}, WakuVersion.M(1)); err != nil {
|
||||
utils.Logger().Error("failed to record with tags", zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package node
|
||||
|
||||
// GitCommit is a commit hash.
|
||||
var GitCommit string
|
||||
|
||||
// Version is the version of go-waku at the time of compilation
|
||||
var Version string
|
|
@ -0,0 +1,32 @@
|
|||
package node
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// GitCommit is a commit hash.
|
||||
var GitCommit string
|
||||
|
||||
// Version is the version of go-waku at the time of compilation
|
||||
var Version string
|
||||
|
||||
type VersionInfo struct {
|
||||
Version string
|
||||
Commit string
|
||||
System string
|
||||
Golang string
|
||||
}
|
||||
|
||||
func GetVersionInfo() VersionInfo {
|
||||
return VersionInfo{
|
||||
Version: Version,
|
||||
Commit: GitCommit,
|
||||
System: runtime.GOARCH + "/" + runtime.GOOS,
|
||||
Golang: runtime.Version(),
|
||||
}
|
||||
}
|
||||
|
||||
func (v VersionInfo) String() string {
|
||||
return fmt.Sprintf("%s-%s", v.Version, v.Commit)
|
||||
}
|
|
@ -259,8 +259,6 @@ func (w *WakuNode) checkForAddressChanges() {
|
|||
|
||||
// Start initializes all the protocols that were setup in the WakuNode
|
||||
func (w *WakuNode) Start() error {
|
||||
w.log.Info("Version details ", zap.String("commit", GitCommit), zap.String("version", Version))
|
||||
|
||||
if w.opts.enableSwap {
|
||||
w.swap = swap.NewWakuSwap(w.log, []swap.SwapOption{
|
||||
swap.WithMode(w.opts.swapMode),
|
||||
|
@ -521,7 +519,7 @@ func (w *WakuNode) startStore() {
|
|||
case <-w.quit:
|
||||
return
|
||||
case <-ticker.C:
|
||||
_, err := utils.SelectPeer(w.host, string(store.StoreID_v20beta4), w.log)
|
||||
_, err := utils.SelectPeer(w.host, string(store.StoreID_v20beta4), nil, w.log)
|
||||
if err == nil {
|
||||
break peerVerif
|
||||
}
|
||||
|
|
15
vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/waku_filter_option.go
generated
vendored
15
vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/waku_filter_option.go
generated
vendored
|
@ -38,9 +38,12 @@ func WithPeer(p peer.ID) FilterSubscribeOption {
|
|||
}
|
||||
}
|
||||
|
||||
func WithAutomaticPeerSelection() FilterSubscribeOption {
|
||||
// WithAutomaticPeerSelection is an option used to randomly select a peer from the peer store.
|
||||
// If a list of specific peers is passed, the peer will be chosen from that list assuming it
|
||||
// supports the chosen protocol, otherwise it will chose a peer from the node peerstore
|
||||
func WithAutomaticPeerSelection(fromThesePeers ...peer.ID) FilterSubscribeOption {
|
||||
return func(params *FilterSubscribeParameters) {
|
||||
p, err := utils.SelectPeer(params.host, string(FilterID_v20beta1), params.log)
|
||||
p, err := utils.SelectPeer(params.host, string(FilterID_v20beta1), fromThesePeers, params.log)
|
||||
if err == nil {
|
||||
params.selectedPeer = *p
|
||||
} else {
|
||||
|
@ -49,9 +52,13 @@ func WithAutomaticPeerSelection() FilterSubscribeOption {
|
|||
}
|
||||
}
|
||||
|
||||
func WithFastestPeerSelection(ctx context.Context) FilterSubscribeOption {
|
||||
// WithFastestPeerSelection is an option used to select a peer from the peer store
|
||||
// with the lowest ping If a list of specific peers is passed, the peer will be chosen
|
||||
// from that list assuming it supports the chosen protocol, otherwise it will chose a
|
||||
// peer from the node peerstore
|
||||
func WithFastestPeerSelection(ctx context.Context, fromThesePeers ...peer.ID) FilterSubscribeOption {
|
||||
return func(params *FilterSubscribeParameters) {
|
||||
p, err := utils.SelectPeerWithLowestRTT(ctx, params.host, string(FilterID_v20beta1), params.log)
|
||||
p, err := utils.SelectPeerWithLowestRTT(ctx, params.host, string(FilterID_v20beta1), fromThesePeers, params.log)
|
||||
if err == nil {
|
||||
params.selectedPeer = *p
|
||||
} else {
|
||||
|
|
16
vendor/github.com/waku-org/go-waku/waku/v2/protocol/lightpush/waku_lightpush_option.go
generated
vendored
16
vendor/github.com/waku-org/go-waku/waku/v2/protocol/lightpush/waku_lightpush_option.go
generated
vendored
|
@ -27,10 +27,12 @@ func WithPeer(p peer.ID) LightPushOption {
|
|||
}
|
||||
|
||||
// WithAutomaticPeerSelection is an option used to randomly select a peer from the peer store
|
||||
// to push a waku message to
|
||||
func WithAutomaticPeerSelection() LightPushOption {
|
||||
// to push a waku message to. If a list of specific peers is passed, the peer will be chosen
|
||||
// from that list assuming it supports the chosen protocol, otherwise it will chose a peer
|
||||
// from the node peerstore
|
||||
func WithAutomaticPeerSelection(fromThesePeers ...peer.ID) LightPushOption {
|
||||
return func(params *LightPushParameters) {
|
||||
p, err := utils.SelectPeer(params.host, string(LightPushID_v20beta1), params.log)
|
||||
p, err := utils.SelectPeer(params.host, string(LightPushID_v20beta1), fromThesePeers, params.log)
|
||||
if err == nil {
|
||||
params.selectedPeer = *p
|
||||
} else {
|
||||
|
@ -40,10 +42,12 @@ func WithAutomaticPeerSelection() LightPushOption {
|
|||
}
|
||||
|
||||
// WithFastestPeerSelection is an option used to select a peer from the peer store
|
||||
// with the lowest ping
|
||||
func WithFastestPeerSelection(ctx context.Context) LightPushOption {
|
||||
// with the lowest ping. If a list of specific peers is passed, the peer will be chosen
|
||||
// from that list assuming it supports the chosen protocol, otherwise it will chose a peer
|
||||
// from the node peerstore
|
||||
func WithFastestPeerSelection(ctx context.Context, fromThesePeers ...peer.ID) LightPushOption {
|
||||
return func(params *LightPushParameters) {
|
||||
p, err := utils.SelectPeerWithLowestRTT(ctx, params.host, string(LightPushID_v20beta1), params.log)
|
||||
p, err := utils.SelectPeerWithLowestRTT(ctx, params.host, string(LightPushID_v20beta1), fromThesePeers, params.log)
|
||||
if err == nil {
|
||||
params.selectedPeer = *p
|
||||
} else {
|
||||
|
|
|
@ -25,10 +25,12 @@ func WithPeer(p peer.ID) PeerExchangeOption {
|
|||
}
|
||||
|
||||
// WithAutomaticPeerSelection is an option used to randomly select a peer from the peer store
|
||||
// to push a waku message to
|
||||
func WithAutomaticPeerSelection() PeerExchangeOption {
|
||||
// to obtains peers from. If a list of specific peers is passed, the peer will be chosen
|
||||
// from that list assuming it supports the chosen protocol, otherwise it will chose a peer
|
||||
// from the node peerstore
|
||||
func WithAutomaticPeerSelection(fromThesePeers ...peer.ID) PeerExchangeOption {
|
||||
return func(params *PeerExchangeParameters) {
|
||||
p, err := utils.SelectPeer(params.host, string(PeerExchangeID_v20alpha1), params.log)
|
||||
p, err := utils.SelectPeer(params.host, string(PeerExchangeID_v20alpha1), fromThesePeers, params.log)
|
||||
if err == nil {
|
||||
params.selectedPeer = *p
|
||||
} else {
|
||||
|
@ -38,10 +40,12 @@ func WithAutomaticPeerSelection() PeerExchangeOption {
|
|||
}
|
||||
|
||||
// WithFastestPeerSelection is an option used to select a peer from the peer store
|
||||
// with the lowest ping
|
||||
func WithFastestPeerSelection(ctx context.Context) PeerExchangeOption {
|
||||
// with the lowest ping. If a list of specific peers is passed, the peer will be chosen
|
||||
// from that list assuming it supports the chosen protocol, otherwise it will chose a peer
|
||||
// from the node peerstore
|
||||
func WithFastestPeerSelection(ctx context.Context, fromThesePeers ...peer.ID) PeerExchangeOption {
|
||||
return func(params *PeerExchangeParameters) {
|
||||
p, err := utils.SelectPeerWithLowestRTT(ctx, params.host, string(PeerExchangeID_v20alpha1), params.log)
|
||||
p, err := utils.SelectPeerWithLowestRTT(ctx, params.host, string(PeerExchangeID_v20alpha1), fromThesePeers, params.log)
|
||||
if err == nil {
|
||||
params.selectedPeer = *p
|
||||
} else {
|
||||
|
|
|
@ -229,9 +229,7 @@ func (rln *WakuRLNRelay) ValidateMessage(msg *pb.WakuMessage, optionalTime *time
|
|||
contentTopicBytes := []byte(msg.ContentTopic)
|
||||
input := append(msg.Payload, contentTopicBytes...)
|
||||
|
||||
// TODO: set window of roots
|
||||
roots := [][32]byte{}
|
||||
valid, err := rln.RLN.VerifyWithRoots(input, *msgProof, roots)
|
||||
valid, err := rln.RLN.VerifyWithRoots(input, *msgProof, rln.validMerkleRoots)
|
||||
if err != nil {
|
||||
rln.log.Debug("could not verify proof", zap.Error(err))
|
||||
return MessageValidationResult_Invalid, nil
|
||||
|
@ -312,7 +310,7 @@ func (r *WakuRLNRelay) MembershipContractAddress() common.Address {
|
|||
return r.membershipContractAddress
|
||||
}
|
||||
|
||||
func (r *WakuRLNRelay) insertMember(pubkey [32]byte) error {
|
||||
func (r *WakuRLNRelay) insertMember(pubkey r.IDCommitment) error {
|
||||
r.log.Debug("a new key is added", zap.Binary("pubkey", pubkey[:]))
|
||||
// assuming all the members arrive in order
|
||||
err := r.RLN.InsertMember(pubkey)
|
||||
|
|
|
@ -324,10 +324,12 @@ func WithPeer(p peer.ID) HistoryRequestOption {
|
|||
}
|
||||
|
||||
// WithAutomaticPeerSelection is an option used to randomly select a peer from the peer store
|
||||
// to request the message history
|
||||
func WithAutomaticPeerSelection() HistoryRequestOption {
|
||||
// to request the message history. If a list of specific peers is passed, the peer will be chosen
|
||||
// from that list assuming it supports the chosen protocol, otherwise it will chose a peer
|
||||
// from the node peerstore
|
||||
func WithAutomaticPeerSelection(fromThesePeers ...peer.ID) HistoryRequestOption {
|
||||
return func(params *HistoryRequestParameters) {
|
||||
p, err := utils.SelectPeer(params.s.h, string(StoreID_v20beta4), params.s.log)
|
||||
p, err := utils.SelectPeer(params.s.h, string(StoreID_v20beta4), fromThesePeers, params.s.log)
|
||||
if err == nil {
|
||||
params.selectedPeer = *p
|
||||
} else {
|
||||
|
@ -336,9 +338,13 @@ func WithAutomaticPeerSelection() HistoryRequestOption {
|
|||
}
|
||||
}
|
||||
|
||||
func WithFastestPeerSelection(ctx context.Context) HistoryRequestOption {
|
||||
// WithFastestPeerSelection is an option used to select a peer from the peer store
|
||||
// with the lowest ping. If a list of specific peers is passed, the peer will be chosen
|
||||
// from that list assuming it supports the chosen protocol, otherwise it will chose a peer
|
||||
// from the node peerstore
|
||||
func WithFastestPeerSelection(ctx context.Context, fromThesePeers ...peer.ID) HistoryRequestOption {
|
||||
return func(params *HistoryRequestParameters) {
|
||||
p, err := utils.SelectPeerWithLowestRTT(ctx, params.s.h, string(StoreID_v20beta4), params.s.log)
|
||||
p, err := utils.SelectPeerWithLowestRTT(ctx, params.s.h, string(StoreID_v20beta4), fromThesePeers, params.s.log)
|
||||
if err == nil {
|
||||
params.selectedPeer = *p
|
||||
} else {
|
||||
|
@ -481,7 +487,11 @@ func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryR
|
|||
q.PagingInfo.Direction = pb.PagingInfo_BACKWARD
|
||||
}
|
||||
|
||||
q.PagingInfo.PageSize = params.pageSize
|
||||
pageSize := params.pageSize
|
||||
if pageSize == 0 || pageSize > uint64(MaxPageSize) {
|
||||
pageSize = MaxPageSize
|
||||
}
|
||||
q.PagingInfo.PageSize = pageSize
|
||||
|
||||
response, err := store.queryFrom(ctx, q, params.selectedPeer, params.requestId)
|
||||
if err != nil {
|
||||
|
@ -676,7 +686,7 @@ func (store *WakuStore) Resume(ctx context.Context, pubsubTopic string, peerList
|
|||
}
|
||||
|
||||
if len(peerList) == 0 {
|
||||
p, err := utils.SelectPeer(store.h, string(StoreID_v20beta4), store.log)
|
||||
p, err := utils.SelectPeer(store.h, string(StoreID_v20beta4), nil, store.log)
|
||||
if err != nil {
|
||||
store.log.Info("selecting peer", zap.Error(err))
|
||||
return -1, ErrNoPeersAvailable
|
||||
|
|
|
@ -19,15 +19,23 @@ import (
|
|||
var ErrNoPeersAvailable = errors.New("no suitable peers found")
|
||||
|
||||
// SelectPeer is used to return a random peer that supports a given protocol.
|
||||
func SelectPeer(host host.Host, protocolId string, log *zap.Logger) (*peer.ID, error) {
|
||||
// If a list of specific peers is passed, the peer will be chosen from that list assuming
|
||||
// it supports the chosen protocol, otherwise it will chose a peer from the node peerstore
|
||||
func SelectPeer(host host.Host, protocolId string, specificPeers []peer.ID, log *zap.Logger) (*peer.ID, error) {
|
||||
// @TODO We need to be more strategic about which peers we dial. Right now we just set one on the service.
|
||||
// Ideally depending on the query and our set of peers we take a subset of ideal peers.
|
||||
// This will require us to check for various factors such as:
|
||||
// - which topics they track
|
||||
// - latency?
|
||||
// - default store peer?
|
||||
|
||||
peerSet := specificPeers
|
||||
if len(peerSet) == 0 {
|
||||
peerSet = host.Peerstore().Peers()
|
||||
}
|
||||
|
||||
var peers peer.IDSlice
|
||||
for _, peer := range host.Peerstore().Peers() {
|
||||
for _, peer := range peerSet {
|
||||
protocols, err := host.Peerstore().SupportsProtocols(peer, protocolId)
|
||||
if err != nil {
|
||||
log.Error("obtaining protocols supported by peers", zap.Error(err), logging.HostID("peer", peer))
|
||||
|
@ -53,9 +61,17 @@ type pingResult struct {
|
|||
}
|
||||
|
||||
// SelectPeerWithLowestRTT will select a peer that supports a specific protocol with the lowest reply time
|
||||
func SelectPeerWithLowestRTT(ctx context.Context, host host.Host, protocolId string, log *zap.Logger) (*peer.ID, error) {
|
||||
// If a list of specific peers is passed, the peer will be chosen from that list assuming
|
||||
// it supports the chosen protocol, otherwise it will chose a peer from the node peerstore
|
||||
func SelectPeerWithLowestRTT(ctx context.Context, host host.Host, protocolId string, specificPeers []peer.ID, log *zap.Logger) (*peer.ID, error) {
|
||||
var peers peer.IDSlice
|
||||
for _, peer := range host.Peerstore().Peers() {
|
||||
|
||||
peerSet := specificPeers
|
||||
if len(peerSet) == 0 {
|
||||
peerSet = host.Peerstore().Peers()
|
||||
}
|
||||
|
||||
for _, peer := range peerSet {
|
||||
protocols, err := host.Peerstore().SupportsProtocols(peer, protocolId)
|
||||
if err != nil {
|
||||
log.Error("error obtaining the protocols supported by peers", zap.Error(err))
|
||||
|
|
|
@ -5,13 +5,20 @@
|
|||
|
||||
#define TEST_PARAMETERS_INDEX 2
|
||||
|
||||
/**
|
||||
* The RLN object.
|
||||
*
|
||||
* It implements the methods required to update the internal Merkle Tree, generate and verify RLN ZK proofs.
|
||||
*
|
||||
* I/O is mostly done using writers and readers implementing `std::io::Write` and `std::io::Read`, respectively.
|
||||
*/
|
||||
typedef struct RLN RLN;
|
||||
|
||||
/**
|
||||
* Buffer struct is taken from
|
||||
* https://github.com/celo-org/celo-threshold-bls-rs/blob/master/crates/threshold-bls-ffi/src/ffi.rs
|
||||
* <https://github.com/celo-org/celo-threshold-bls-rs/blob/master/crates/threshold-bls-ffi/src/ffi.rs>
|
||||
*
|
||||
* Also heavily inspired by https://github.com/kilic/rln/blob/master/src/ffi.rs
|
||||
* Also heavily inspired by <https://github.com/kilic/rln/blob/master/src/ffi.rs>
|
||||
*/
|
||||
typedef struct Buffer {
|
||||
const uint8_t *ptr;
|
||||
|
@ -34,7 +41,9 @@ bool set_leaf(struct RLN *ctx, uintptr_t index, const struct Buffer *input_buffe
|
|||
|
||||
bool set_next_leaf(struct RLN *ctx, const struct Buffer *input_buffer);
|
||||
|
||||
bool set_leaves(struct RLN *ctx, const struct Buffer *input_buffer);
|
||||
bool set_leaves_from(struct RLN *ctx, uintptr_t index, const struct Buffer *input_buffer);
|
||||
|
||||
bool init_tree_with_leaves(struct RLN *ctx, const struct Buffer *input_buffer);
|
||||
|
||||
bool get_root(const struct RLN *ctx, struct Buffer *output_buffer);
|
||||
|
||||
|
|
|
@ -240,6 +240,23 @@ func serializeRoots(roots [][32]byte) []byte {
|
|||
return result
|
||||
}
|
||||
|
||||
func serializeCommitments(commitments []IDCommitment) []byte {
|
||||
// serializes a seq of IDCommitments to a byte seq
|
||||
// the serialization is based on https://github.com/status-im/nwaku/blob/37bd29fbc37ce5cf636734e7dd410b1ed27b88c8/waku/v2/protocol/waku_rln_relay/rln.nim#L142
|
||||
// the order of serialization is |id_commitment_len<8>|id_commitment<var>|
|
||||
var result []byte
|
||||
|
||||
inputLen := make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(inputLen, uint64(len(commitments)))
|
||||
result = append(result, inputLen...)
|
||||
|
||||
for _, idComm := range commitments {
|
||||
result = append(result, idComm[:]...)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (r *RLN) VerifyWithRoots(data []byte, proof RateLimitProof, roots [][32]byte) (bool, error) {
|
||||
proofBytes := proof.serialize(data)
|
||||
proofBuf := toCBufferPtr(proofBytes)
|
||||
|
@ -265,6 +282,18 @@ func (r *RLN) InsertMember(idComm IDCommitment) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Insert multiple members i.e., identity commitments starting from index
|
||||
// This proc is atomic, i.e., if any of the insertions fails, all the previous insertions are rolled back
|
||||
func (r *RLN) InsertMembers(index MembershipIndex, idComms []IDCommitment) error {
|
||||
idCommBytes := serializeCommitments(idComms)
|
||||
idCommBuffer := toCBufferPtr(idCommBytes)
|
||||
insertionSuccess := bool(C.set_leaves_from(r.ptr, C.uintptr_t(index), idCommBuffer))
|
||||
if !insertionSuccess {
|
||||
return errors.New("could not insert members")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteMember removes an IDCommitment key from the tree. The index
|
||||
// parameter is the position of the id commitment key to be deleted from the tree.
|
||||
// The deleted id commitment key is replaced with a zero leaf
|
||||
|
|
|
@ -990,7 +990,7 @@ github.com/vacp2p/mvds/transport
|
|||
github.com/waku-org/go-discover/discover
|
||||
github.com/waku-org/go-discover/discover/v4wire
|
||||
github.com/waku-org/go-discover/discover/v5wire
|
||||
# github.com/waku-org/go-waku v0.2.3-0.20221122234656-5d7d05ca16a5
|
||||
# github.com/waku-org/go-waku v0.2.3-0.20221126210912-041c7be67dfb
|
||||
## explicit; go 1.18
|
||||
github.com/waku-org/go-waku/logging
|
||||
github.com/waku-org/go-waku/waku/persistence
|
||||
|
@ -1013,8 +1013,8 @@ github.com/waku-org/go-waku/waku/v2/protocol/rln/contracts
|
|||
github.com/waku-org/go-waku/waku/v2/protocol/store
|
||||
github.com/waku-org/go-waku/waku/v2/protocol/swap
|
||||
github.com/waku-org/go-waku/waku/v2/utils
|
||||
# github.com/waku-org/go-zerokit-rln v0.1.6
|
||||
## explicit; go 1.17
|
||||
# github.com/waku-org/go-zerokit-rln v0.1.7-wakuorg
|
||||
## explicit; go 1.18
|
||||
github.com/waku-org/go-zerokit-rln/rln
|
||||
github.com/waku-org/go-zerokit-rln/rln/resources
|
||||
# github.com/waku-org/noise v1.0.2
|
||||
|
|
Loading…
Reference in New Issue