Skip to content
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

Stale or published elsewhere ApplicationMetadataMessage_COMMUNITY_DESCRIPTION public messages #4922

Closed
6 tasks done
felicio opened this issue Mar 14, 2024 · 23 comments
Closed
6 tasks done
Assignees

Comments

@felicio
Copy link
Contributor

felicio commented Mar 14, 2024

Problem

  • In Store nodes, last ApplicationMetadataMessage_COMMUNITY_DESCRIPTION for zQ3shZeEJqTC1xhGUjxuS4rtHSrhJ8vUYp64v6qWkLpvdy9L9 (Status CC Community) is from around 2024-02-28T14:57:13.580Z
  • Another Community (zQ3shgz9XWZerfqsSpR2XKjfyiwtyiRNV6whj6BXREwnuLo5P) gets recent updates

Summary from comments below

Implementation

Known steps towards feature implementation.
What needs further specifying and investigating.

Acceptance Criteria

Rules for the future PR to be accepted.

Notes

  • pubsub topic: /waku/2/rs/16/32
  • content topic: /waku/1/0x13267e91/rfc26
  • fleet: shards.test

Future Steps

Steps which should be taken after this issue has been resolved.

@felicio
Copy link
Contributor Author

felicio commented Mar 14, 2024

Cc @osmaczko

@felicio
Copy link
Contributor Author

felicio commented Mar 14, 2024

Is it possible that a content topic format would change for certain Communities?

@jrainville
Copy link
Member

We changed fleet to use the new one called shards-test, so that might be it.

Also, that community is not really used anymore, so it's possible that Iuri shut down the control node for it cc @iurimatias

@felicio
Copy link
Contributor Author

felicio commented Mar 14, 2024

@jrainville the description mentions shards.test.

Which community is used then, please?

@felicio
Copy link
Contributor Author

felicio commented Mar 14, 2024

@jrainville again, that's what the description references.

Could you please have a closer look at the issue?

@jrainville
Copy link
Member

@jrainville again, that's what the description references.

Could you please have a closer look at the issue?

Sorry for the confusion, you named the community Status CC Community, which is the name of the old community, so I thought you were talking about that one.

I'm not sure what's going on here then. We clearly receive the latest updates in peer to peer, since I can see all the new channels.

Is it possible that a content topic format would change for certain Communities?

If we shard the community, yes that would be the case. I don't recall that we sharded this one however.

@iurimatias can you check the shard popup which topic it is using?

@felicio
Copy link
Contributor Author

felicio commented Mar 15, 2024

@jrainville thank you. One more thing to reiterate, however, this issue focuses primarily on Store nodes.

@osmaczko
Copy link
Contributor

The shard is not set, the pubSubTopic we fetch community info from is /waku/2/rs/16/64

func DefaultShard() *Shard {
return &Shard{
Cluster: MainStatusShardCluster,
Index: NonProtectedShardIndex,
}
}

const NonProtectedShardIndex = 64

@jrainville
Copy link
Member

pubsub topic: "/waku/2/rs/16/32"
we fetch community info from is /waku/2/rs/16/64

@felicio can you check if you update the topic if it works?

@osmaczko
Copy link
Contributor

Sorry, I might have misinterpreted the code (the code is misleading tbh - which one is the default? 😵 ). I just double-checked, and we publish CommunityDescription on /waku/2/rs/16/32. I got it mixed up with where we share ApplicationMetadataMessage_COMMUNITY_PUBLIC_SHARD_INFO.

@osmaczko
Copy link
Contributor

@felicio I am able to fetch CommunityDescription from today:

store node: store-01.do-ams3.shards.test
description envelope: 0xc06f05cb5f15eab1424c57acb8f05bb11484786cffdba97a4c79d73565a1e4cf
timestamp: 1710508493775973252 (2024-03-15 13:14:53.775973252 +0000 UTC)
size: 530204 bytes
contentTopic: /waku/1/0x13267e91/rfc26
pubsubTopic: /waku/2/rs/16/32

@felicio
Copy link
Contributor Author

felicio commented Mar 17, 2024

@osmaczko I saw some recent messages of similar sizes for that community, but again since around 2024-02-28T14:57:13.580Z they

  • don't have ProtocolMessage#public_message set
  • have ProtocolMessage#encrypted_message['none'].payload set but without any private material needed to decode it
  • aren't signed by the community's private key so cannot be verified

And as a side note

  • while CommunityDescription#chats are empty the CommunityDescription#categories are set
  • while CommunityDescription#members are empty the CommunityDescription#active_members_count isn't

@felicio felicio changed the title Stale or published elsewhere ApplicationMetadataMessage_COMMUNITY_DESCRIPTION updates Stale or published elsewhere ApplicationMetadataMessage_COMMUNITY_DESCRIPTION public updates Mar 17, 2024
@osmaczko
Copy link
Contributor

osmaczko commented Mar 17, 2024

  • don't have ProtocolMessage#public_message set
  • have ProtocolMessage#encrypted_message['none'].payload set but without any private material needed to decode it

We don't wrap CommunityDescription into ProtocolMessage when we publish the org 🤔 Not sure what is the logic in status-web, but I would expect ProtocolMessage to be skipped altogether due to protobuf unmarshaling fail.

However, if it used to work, I am pretty sure, it is not working now because of messages segmentation.

  • aren't signed by the community's private key so cannot be verified

Oh, I see. The behavior changed a few months ago. Once the owner-token is minted, the signer of the community is no longer the community's private key. The signer becomes the owner of the token. I'll send you a link to the presentation about that offline.

  • while CommunityDescription#chats are empty the CommunityDescription#categories are set
  • while CommunityDescription#members are empty the CommunityDescription#active_members_count isn't

Could you share the CommunityDescription protobuf you are referring to, please?

@felicio
Copy link
Contributor Author

felicio commented Mar 17, 2024

@osmaczko

We don't wrap CommunityDescription into ProtocolMessage

Step into

_, err = m.sender.SendPublic(context.Background(), org.IDString(), rawMessage)
if you can see the wrapping there.

However, if it used to work,

It still works the same for zQ3shgz9XWZerfqsSpR2XKjfyiwtyiRNV6whj6BXREwnuLo5P, but works unexpectedly, as listed above, for zQ3shZeEJqTC1xhGUjxuS4rtHSrhJ8vUYp64v6qWkLpvdy9L9.

The behavior changed a few months ago.

How do you validate the message then?

Could you share the CommunityDescription protobuf you are referring to, please?

Attaching the top-most waku (e.g. "ProtocolMessage > ApplicationMetadataMessage > CommunityDescription" message payload.txt – there's nothing specific about "status-web".

@osmaczko
Copy link
Contributor

Step into ... if you can see the wrapping there.

Message is wrapped only into ApplicationMetadataMessage. ProtocolMessage layer is skipped.

It still works the same for zQ3shgz9XWZerfqsSpR2XKjfyiwtyiRNV6whj6BXREwnuLo5P, but works unexpectedly, as listed above, for zQ3shZeEJqTC1xhGUjxuS4rtHSrhJ8vUYp64v6qWkLpvdy9L9.

That's most likely because zQ3shgz9XWZerfqsSpR2XKjfyiwtyiRNV6whj6BXREwnuLo5P is still small enough to stay unsegmented.

How do you validate the message then?

I sent you the link to the video with detailed explanations. Long story short, we queue CommunityDescription messages until we know the owner, then we validate the message against that known owner. Code paths:

@felicio
Copy link
Contributor Author

felicio commented Mar 17, 2024

@osmaczko

Message is wrapped only into ApplicationMetadataMessage.

So this

messageSpec, err := s.protocol.BuildPublicMessage(s.identity, wrappedMessage)
is not run?

ProtocolMessage layer is skipped.

So it would not fall into

if len(rawMessage.HashRatchetGroupID) != 0 {
because of
rawMessage.HashRatchetGroupID = org.ID()
?

is still small enough to stay unsegmented.

  • Isn't the limit for segmentation like 7 MB?
  • Wasn't the message you talked about like 500 KB?
  • Why would those messages be split?

That's most likely because

Let me point out again, even those types of messages for zQ3shZeEJqTC1xhGUjxuS4rtHSrhJ8vUYp64v6qWkLpvdy9L9 aren't split.

Also, based on what you've shared so far, I believe you might have got the description from COMMUNITY_EVENTS_MESSAGE_REJECTED instead of COMMUNITY_DESCRIPTION.


Let me know if you'd prefer a short meeting.

@osmaczko
Copy link
Contributor

I double checked and indeed we wrap the Description into ProtocolMessage 😓 It has changed recently for encrypted communities, we didn't do that before (public communities are not wrapped into ProtocolMessage I believe). The wrapping of ApplicationMetadataMessage happens here:

spec, err := s.protocol.BuildHashRatchetReKeyGroupMessage(s.identity, rawMessage.Recipients, rawMessage.HashRatchetGroupID, wrappedMessage, ratchet)

and that's how it is constructed exactly:
Message: &ProtocolMessage{
InstallationId: p.encryptor.config.InstallationID,
EncryptedMessage: map[string]*EncryptedMessageProtocol{noInstallationID: &EncryptedMessageProtocol{
HRHeader: &HRHeader{
SeqNo: 0,
GroupId: groupID,
Keys: keys,
},
Payload: payload,
},
},
},

I also checked how we exactly process the message and indeed it is not segmented.
Handling of description envelope 1: 0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12, timestamp: 1710530403844026612 (2024-03-15 19:20:03.844026612 +0000 UTC), size: 532508 bytes, contentTopic: /waku/1/0x13267e91/rfc26, pubsubTopic: /waku/2/rs/16/32:

2024-03-18T10:13:24.530+0100	INFO	user-waku-0	wakuv2/waku.go:1103	received waku2 store message	{"envelopeHash": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12", "pubsubTopic": "/waku/2/rs/16/32", "timestamp": 1710530403844026612}
2024-03-18T10:13:24.530+0100	DEBUG	user-waku-0	wakuv2/waku.go:1327	received new envelope	{"messageType": 1, "envelopeHash": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12", "contentTopic": "/waku/1/0x13267e91/rfc26", "timestamp": 1710530403844026612}

2024-03-18T10:13:24.568+0100	DEBUG	user-messenger-0	transport/transport.go:262	message not cached	{"Transport": {"site": "retrieveRawAll", "hash": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12"}}
2024-03-18T10:13:24.568+0100	DEBUG	user-messenger-0	common/message_sender.go:1362	handling message segment	{"site": "handleSegmentationLayer", "hash": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12", "EntireMessageHash": "0x", "Index": 0, "SegmentsCount": 0}
2024-03-18T10:13:24.568+0100	DEBUG	user-messenger-0	common/message_sender.go:902	failed to handle segmentation layer message	{"site": "handleMessage", "hash": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12", "error": "invalid segments count", "errorVerbose": "invalid segments count"}
2024-03-18T10:13:24.569+0100	DEBUG	user-messenger-0	encryption/protocol.go:714	received a protocol message	{"Protocol": {"site": "HandleMessage", "sender-public-key": "0x04953f5f0d355b37c39d1d6460a31ed1114455f8263b3fd1b84406c5f12c9eb7dfb76ba7513b92186010928254984fe98aee069b4c7e20f9ea3da497c3ae769477", "my-installation-id": "844ba546-7516-4c2e-b067-5d24f7a162df", "messageID": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12"}}
2024-03-18T10:13:24.569+0100	DEBUG	user-messenger-0	common/message_sender.go:927	failed to handle datasync message	{"site": "handleMessage", "hash": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12", "error": "handling non-datasync message"}

2024-03-18T10:13:24.577+0100	DEBUG	user-messenger-0	protocol/messenger.go:3904	processing messages further	{"site": "RetrieveAll", "hash": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12", "count": 1}
2024-03-18T10:13:24.577+0100	INFO	user-messenger-0	protocol/messenger.go:3908	processing message	{"site": "RetrieveAll", "hash": "0xf8e170716e3caa9d49e12b5ec1aa1ae680933dc5c973d6f23faa97c315c4cb12", "message-id": "0xe242e775379544c62a196b1b315fe8a9926eeb34eaf7997bab514aea3a55d52d"}
2024-03-18T10:13:24.577+0100	INFO	user-messenger-0	protocol/messenger.go:3920	processing message	{"type": "COMMUNITY_DESCRIPTION", "senderID": "0x04953f5f0d355b37c39d1d6460a31ed1114455f8263b3fd1b84406c5f12c9eb7dfb76ba7513b92186010928254984fe98aee069b4c7e20f9ea3da497c3ae769477"}
2024-03-18T10:13:24.578+0100	INFO	user-messenger-0	protocol/messenger_handlers.go:668	handling CommunityDescription
2024-03-18T10:13:24.579+0100	DEBUG	user-messenger-0	communities/manager.go:1708	HandleCommunityDescriptionMessage	{"communityID": "0x02b5bdaf5a25fcfe2ee14c501fab1836b8de57f61621080c3d52073d16de0d98d6", "clock": 1710529833209}
2024-03-18T10:13:24.579+0100	DEBUG	user-messenger-0	communities/community_description_encryption.go:83	failed to decrypt community private data	{"keyIDSeqNo": "618891d4ace09777ffd614ad998e91d5c5b37123c2b7b61fe3886afd1d0bd1d1316", "error": "no ratchet key for given keyID", "errorVerbose": "no ratchet key for given keyID"}
2024-03-18T10:13:24.580+0100	DEBUG	user-messenger-0	communities/community_description_encryption.go:83	failed to decrypt community private data	{"keyIDSeqNo": "14cb119293e26251202d6036aebf6f870dfc92ff1e6d97adb40f751478be653e879", "error": "no ratchet key for given keyID", "errorVerbose": "no ratchet key for given keyID"}
2024-03-18T10:13:24.582+0100	INFO	user-messenger-0	communities/manager.go:1689	queuing community	{"id": "0x02b5bdaf5a25fcfe2ee14c501fab1836b8de57f61621080c3d52073d16de0d98d6", "name": "Status", "clock": 1710529833209, "signer": "0x04953f5f0d355b37c39d1d6460a31ed1114455f8263b3fd1b84406c5f12c9eb7dfb76ba7513b92186010928254984fe98aee069b4c7e20f9ea3da497c3ae769477"}

So going back to your points:

  • don't have ProtocolMessage#public_message set

Yes, that's the case. We don't set it.

  • have ProtocolMessage#encrypted_message['none'].payload set but without any private material needed to decode it

Paylod is unencrypted ApplicationMetadataMessage in that case. Since, we have HRHeader with seqNo==0 we return payload as is when decrypting:

// Key exchange message, nothing to decrypt
if seqNo == 0 {
return payload, nil
}

Hope this explains the missing bits, if not, please let me know, we'll do a short meeting.

@jrainville
Copy link
Member

Closing as the issue is on the Web side

@felicio felicio changed the title Stale or published elsewhere ApplicationMetadataMessage_COMMUNITY_DESCRIPTION public updates Stale or published elsewhere ApplicationMetadataMessage_COMMUNITY_DESCRIPTION public messages Mar 19, 2024
@felicio
Copy link
Contributor Author

felicio commented Mar 19, 2024

@jrainville

  • don't have ProtocolMessage#public_message set
  • have ProtocolMessage#encrypted_message['none'].payload set but without any private material needed to decode it

@osmaczko confirmed that's the behavior now, but don't you guys think these public messages that don't carry any keys nor require any other private information to be decoded should have the same data structure as those for public communities?

  • while CommunityDescription#chats are empty the CommunityDescription#categories are set
  • while CommunityDescription#members are empty the CommunityDescription#active_members_count isn't

Did you also confirm these? And are you going to create follow-up issues?

  • possible COMMUNITY_DESCRIPTION messages larger than 7MB

Given fast lookups, why would a message with public community metadata ever be larger than 7MB? And if some of it is not public, shouldn't it be sent on another content topic?

@felicio felicio reopened this Mar 19, 2024
@osmaczko
Copy link
Contributor

Given fast lookups, why would a message with public community metadata ever be larger than 7MB?

Waku message limit defined in status-go is 1MiB. Message payload is limited to 0.75MiB. We reached this limit in the past already: status-im/status-desktop#12188. Also please note that in the future, the maximum size of a message might be reduced dramatically from 1MiB to 150KiB: status-im/status-desktop#12188 (comment). Currently, the size of Status' CommunityDescription is ~0.5MiB - we are close to the limit.

And if some of it is not public, shouldn't it be sent on another content topic?

We wanted to avoid the complexity of reconstructing the Community state from data being spread across multiple messages/topics. I suppose we could consider sending only the public data on another content topic if needed.

@osmaczko
Copy link
Contributor

osmaczko commented Mar 19, 2024

Did you also confirm these? And are you going to create follow-up issues?

Indeed. Thanks for heads-up. Created issues: #4943, #4944

@felicio
Copy link
Contributor Author

felicio commented Mar 20, 2024

Thanks, clarified the data structure and if you decide not to create an issue for that too, I'll close this.

Also, this issue is not blocking.

@felicio felicio closed this as completed Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants