okTurtles / group-income

A decentralized and private (end-to-end encrypted) financial safety net for you and your friends.
https://groupincome.org
GNU Affero General Public License v3.0
331 stars 44 forks source link

Multiple issues signing up and joining a new account on testing site #2103

Closed taoeffect closed 4 months ago

taoeffect commented 4 months ago

Problem

Multiple different errors encountered when joining a new user to the existing group we have:

Error 1

UPDATE: ✅ Fixed in #2105

[pubsub] Connection re-established
main.js:66 VERSION_INFO received: {ourVersion: '0.5.3', theirVersion: '0.5.3', ourContractsVersion: '0.5.3', theirContractsVersion: '0.5.3'}
chunk-VWGY47Z6-cached.js:22 

       GET https://testing.groupincome.org/kv/z9brRu3VN2ftwkQsqJRf9HC2LLRf5KoCygAVeR2DqzRKBT6h3zpM/unreadMessages 404 (Not Found)
chelonia/kv/get @ chunk-VWGY47Z6-cached.js:22
u @ chunk-SSANYCJJ-cached.js:1
gi.actions/identity/fetchChatRoomUnreadMessages @ main.js:66
u @ chunk-SSANYCJJ-cached.js:1
(anonymous) @ main.js:66
okTurtles.eventQueue/queueEvent @ chunk-VWGY47Z6-cached.js:1
u @ chunk-SSANYCJJ-cached.js:1
gi.actions/identity/loadChatRoomUnreadMessages @ main.js:66
u @ chunk-SSANYCJJ-cached.js:1
gi.actions/identity/login @ main.js:66
await in gi.actions/identity/login (async)
u @ chunk-SSANYCJJ-cached.js:1
(anonymous) @ main.js:156
Promise.then (async)
mounted @ main.js:156
Nr @ chunk-SNGBA5T7-cached.js:1
De @ chunk-SNGBA5T7-cached.js:1
$u @ chunk-SNGBA5T7-cached.js:1
J.$mount @ chunk-SNGBA5T7-cached.js:3
J.$mount @ chunk-SNGBA5T7-cached.js:5
tl @ main.js:156
await in tl (async)
(anonymous) @ main.js:156
main.js:66 [chelonia] verifying signature for z9brRu3VJAmRnpebQd2mZCkYKzdDyBHfmEZqgLhchYbj7MehvJrx with an existing key
main.js:66 [chelonia] successful signature verification for z9brRu3VJAmRnpebQd2mZCkYKzdDyBHfmEZqgLhchYbj7MehvJrx (named gi.contracts/group) using the already-trusted key z2DrjgbCDg34SaBhFjNEF45AVodCUu7QwcFBksz3BDgN4BekrdN.
main.js:66 [chelonia] loading contract 'group-slim.js'@'0.5.0' from manifest: z9brRu3VJAmRnpebQd2mZCkYKzdDyBHfmEZqgLhchYbj7MehvJrx
main.js:66 [chelonia] ERROR 'TypeError' in internal side effect for <op_ks|z9brRu3VNLERrutyAXGGYv1iy6TZfieTieRLkWoZ6HprZ7qDHpz8 of z9brRu3VFRBRN8s26VQFVH6VtXCoHyjmo19LFQg1ARrAuie9ioSG>: Cannot read properties of undefined (reading '_volatile') TypeError: Cannot read properties of undefined (reading '_volatile')
    at chunk-VWGY47Z6-cached.js:19:8274
    at chunk-VWGY47Z6-cached.js:19:25202
    at Array.map (<anonymous>)
    at chelonia/private/in/handleEvent (chunk-VWGY47Z6-cached.js:19:25179)
    at async chelonia/private/in/syncContract (chunk-VWGY47Z6-cached.js:19:15777)
    at async okTurtles.eventQueue/queueEvent (chunk-VWGY47Z6-cached.js:1:2550)
    at async chunk-VWGY47Z6-cached.js:19:8258
    at async Promise.all (index 0)
    at async chelonia/private/in/handleEvent (chunk-VWGY47Z6-cached.js:19:25159)
    at async chunk-VWGY47Z6-cached.js:19:14499 {message: '{"_signedData":["[\\"z2DrjgbBQDqexiroiP6orRuqic16yG…JAmRnpebQd2mZCkYKzdDyBHfmEZqgLhchYbj7MehvJrx\\"}"}'}

The relevant code is related to OP_KEYSHARE processing in internals.js, where S here is undefined:

                    let $ = S._volatile;
                    a("chelonia/private/queueEvent", b.contractID, ["chelonia/private/postKeyShare", b.contractID, A ? $ : null, m]).then(()=>{
                        a("chelonia/private/queueEvent", c, ()=>{
                            a("okTurtles.events/emit", Je, {
                                contractID: b.contractID,
                                sharedWithContractID: c,
                                signingKeyId: u,
                                get signingKeyName() {
                                    return t._vm?.authorizedKeys?.[u]?.name
                                }
                            })
                        }
                        ).catch(T=>{
                            console.error(`[chelonia] Error while emitting the CONTRACT_HAS_RECEIVED_KEYS event for ${c}`, T)
                        }

This is the same as #2093.

Error 2

main.js:66 [chelonia] ERROR 'Error' in processMutation for <op_c|z9brRu3VXZTmkwXDw93mc3QHfDejTwTuPoUXiamkyfpgVAhy6zaM of z9brRu3VXZTmkwXDw93mc3QHfDejTwTuPoUXiamkyfpgVAhy6zaM>: Unable to determine the name for a contract and refusing to load it (contract ID was z9brRu3VXZTmkwXDw93mc3QHfDejTwTuPoUXiamkyfpgVAhy6zaM and its manifest hash was z9brRu3VWZWbL735YsaHWSmBtV8M6iMMmFxLLTp296Rnbs7B2GmE) 
Error: Unable to determine the name for a contract and refusing to load it (contract ID was z9brRu3VXZTmkwXDw93mc3QHfDejTwTuPoUXiamkyfpgVAhy6zaM and its manifest hash was z9brRu3VWZWbL735YsaHWSmBtV8M6iMMmFxLLTp296Rnbs7B2GmE)
    at chelonia/private/in/processMessage (chunk-VWGY47Z6-cached.js:19:13871)
    at u (chunk-SSANYCJJ-cached.js:1:222)
    at Object.processMutation (chunk-VWGY47Z6-cached.js:19:27553)
    at chelonia/private/in/handleEvent (chunk-VWGY47Z6-cached.js:19:24547)
    at u (chunk-SSANYCJJ-cached.js:1:222)
    at chelonia/private/in/syncContract (chunk-VWGY47Z6-cached.js:19:15783)
    at async okTurtles.eventQueue/queueEvent (chunk-VWGY47Z6-cached.js:1:2550)
    at async Promise.all (index 0)

Relevant code:

        if (!this.config.skipActionProcessing && !this.manifestToContract[l]) {
            let v = a(this.config.stateSelector)
              , E = K(v.contracts, c) ? v.contracts[c].type : r === w.OP_CONTRACT ? o.type : "";
            if (!E)
                throw new Error(`Unable to determine the name for a contract and refusing to load it (contract ID was ${c} and its manifest hash was ${l})`);
            await a("chelonia/private/loadManifest", E, l)
        }

Error 3

main.js:66 uncaught Vue error in render: TypeError: Cannot read properties of undefined (reading 'attributes')
    at main.js:66:80835
    at Array.forEach (<anonymous>)
    at ourContactProfilesById (main.js:66:80812)
    at t._wrappedGetters.<computed>.t._wrappedGetters.<computed> (chunk-V5QCG3P5-cached.js:1:8868)
    at J.<anonymous> (chunk-V5QCG3P5-cached.js:1:1322)
    at $e.get (chunk-SNGBA5T7-cached.js:3:7739)
    at $e.evaluate (chunk-SNGBA5T7-cached.js:3:8739)
    at J.ourContactProfilesById (chunk-SNGBA5T7-cached.js:1:25457)
    at Object.get [as ourContactProfilesById] (chunk-V5QCG3P5-cached.js:1:6862)
    at s.<anonymous> (main.js:66:80411)

Relevant code (e[o] is undefined):

    ourContactProfilesById(e, t) {
        let n = {};
        return Object.keys(e.contracts).filter(o=>e.contracts[o].type === "gi.contracts/identity").forEach(o=>{
            let a = e[o].attributes;
            if (a) {
                let s = Li(e, a.username, o);
                n[o] = {
                    ...a,
                    username: s,
                    contractID: o
                }
            }
        }
        ),
        n
    },

Error 4

main.js:66 [chelonia] ERROR in handleEvent: The event is not for a first message but the contract state is missing Error: The event is not for a first message but the contract state is missing
    at chelonia/private/in/handleEvent (chunk-VWGY47Z6-cached.js:19:24199)
    at u (chunk-SSANYCJJ-cached.js:1:222)
    at chelonia/private/in/syncContract (chunk-VWGY47Z6-cached.js:19:15783)
    at async okTurtles.eventQueue/queueEvent (chunk-VWGY47Z6-cached.js:1:2550)
    at async Promise.all (index 0)

Relevant code from handleEvent:

            if (!c.isFirstMessage() && (!K(n.contracts, e) || !K(n, e)))
                throw new Error("The event is not for a first message but the contract state is missing");
            if (r?.(c),

NOTE: I get this error now on the testing website when I attempt to login as greg into the existing group we have, after 0.5.4 update that fixed Error 1 above:

Screenshot 2024-06-21 at 12 47 37 PM

Error 5

main.js:66 Error at syncContractAndWatchKeys for contractID z9brRu3VXZTmkwXDw93mc3QHfDejTwTuPoUXiamkyfpgVAhy6zaM and externalContractID z9brRu3VFRBRN8s26VQFVH6VtXCoHyjmo19LFQg1ARrAuie9ioSG TypeError: Cannot read properties of undefined (reading '_vm')
    at io (chunk-D75JPBHH-cached.js:3:76862)
    at chunk-VWGY47Z6-cached.js:19:18081
    at Array.forEach (<anonymous>)
    at chelonia/private/in/syncContractAndWatchKeys (chunk-VWGY47Z6-cached.js:19:18057)
    at u (chunk-SSANYCJJ-cached.js:1:222)
    at chelonia/private/invoke (chunk-VWGY47Z6-cached.js:1:16068)
    at u (chunk-SSANYCJJ-cached.js:1:222)
    at okTurtles.eventQueue/queueEvent (chunk-VWGY47Z6-cached.js:1:2556)
    at u (chunk-SSANYCJJ-cached.js:1:222)
    at chelonia/private/queueEvent (chunk-VWGY47Z6-cached.js:1:16287)

Relevant code from (unknown), although I think we have an existing issue open for this, here t appears to be undefined:

var zf = Number.parseInt("", 10) || 1 / 0
  , io = (t,e)=>t._vm?.authorizedKeys && Object.values(t._vm.authorizedKeys).find(r=>r.name === e && r._notAfterHeight == null)?.id

More context:

var zf = Number.parseInt("", 10) || 1 / 0
  , io = (t,e)=>t._vm?.authorizedKeys && Object.values(t._vm.authorizedKeys).find(r=>r.name === e && r._notAfterHeight == null)?.id
  , za = (t,e)=>t._vm?.authorizedKeys && Object.values(t._vm.authorizedKeys).filter(r=>r._notAfterHeight == null && r.foreignKey?.includes(e)).map(r=>r.id)
  , Ma = (t,e)=>t._vm?.authorizedKeys && Object.values(t._vm.authorizedKeys || {}).filter(r=>r.name === e && r._notAfterHeight != null).map(r=>r.id)
  , oo = (t,e,r,i,f)=>t._vm?.authorizedKeys && Object.values(t._vm.authorizedKeys).filter(s=>s._notAfterHeight == null && s.ringLevel <= (i ?? Number.POSITIVE_INFINITY) && cr("chelonia/haveSecretKey", s.id) && (Array.isArray(e) ? e.reduce((u,l)=>u && (s.permissions === "*" || s.permissions.includes(l)), !0) : e === s.permissions) && r.reduce((u,l)=>u && s.purpose.includes(l), !0) && (Array.isArray(f) ? f.reduce((u,l)=>u && (s.allowedActions === "*" || s.allowedActions?.includes(l)), !0) : f ? f === s.allowedActions : !0)).sort((s,u)=>u.ringLevel - s.ringLevel)[0]?.id
  , Ya = (t,e,r,i)=>t._vm?.authorizedKeys && Object.values(t._vm.authorizedKeys).filter(f=>f._notAfterHeight == null && f.ringLevel <= (i ?? Number.POSITIVE_INFINITY) && (Array.isArray(e) ? e.reduce((s,u)=>s && (f.permissions === "*" || f.permissions.includes(u)), !0) : e === f.permissions) && r.reduce((s,u)=>s && f.purpose.includes(u), !0)).sort((f,s)=>s.ringLevel - f.ringLevel).map(f=>f.id)
  , no = (t,e,r,i,f)=>{
    let s = Lt(i) ? i.valueOf() : i;
    if (t.allowedActions !== "*" && (!Array.isArray(t.allowedActions) || !t.allowedActions.includes(s.action)))
        return console.error(`Signing key ${t.id} is not allowed for action ${s.action}`),
        !1;
    if (Lt(i)) {
        let u = i
          , l = e._vm?.authorizedKeys?.[u.signingKeyId];
        if (!l && f === "outgoing")
            return !0;
        if (!l || !Array.isArray(l.purpose) || !l.purpose.includes("sig") || l.permissions !== "*" && (!Array.isArray(l.permissions) || !l.permissions.includes(r + "#inner")))
            return console.error(`Signing key ${u.signingKeyId} is missing permissions for operation ${r}`),
            !1;
        if (l.allowedActions !== "*" && (!Array.isArray(l.allowedActions) || !l.allowedActions.includes(s.action + "#inner")))
            return console.error(`Signing key ${l.id} is not allowed for action ${s.action}`),
            !1
    }
    return !0
}

Error 6

Not really an error but an observation, that the new account doesn't appear for the existing use greg in the list of users:

Screenshot 2024-06-21 at 9 50 10 AM

No errors observed in console related to this either.

Solution

Fix all the errors.

dotmacro commented 4 months ago

I'm also running into errors when joining a new user to existing group (via invite link), but didn't see the error above. Let me know if you need more logs or if this should be a separate issue.

Everything looks ok to the existing user, but there are pubsub and chelonia warnings in the application logs:

2024-06-24T06:18:14.717Z [warn] "[pubsub] Received ERROR response for sub request to z9brRu3VJMcq5qdXv26sc5aRFbN44zZfTq9nowwiNvpmDk8Krivr"
2024-06-24T06:18:14.717Z [warn] "[pubsub] Could not subscribe to z9brRu3VJMcq5qdXv26sc5aRFbN44zZfTq9nowwiNvpmDk8Krivr: Unknown channel id: z9brRu3VJMcq5qdXv26sc5aRFbN44zZfTq9nowwiNvpmDk8Krivr"
2024-06-24T06:24:44.908Z [warn] "[chelonia] publish attempt 1 of 5 failed. Waiting 870 msec before resending <op_ae|z9brRu3VFD3P9sjDK5geXqh46LJnZDxhBHQ2HevAvBxtWKPW8MEP of z9brRu3VLVeJGQu1GsoC9HLiakSSZ4sL76Nh911X4pc33juWgJD3>"
2024-06-24T06:24:45.834Z [warn] "[chelonia] publish attempt 2 of 5 failed. Waiting 1336 msec before resending <op_ae|z9brRu3VEXBbVKTN9tPFhr1ckNCUajWL2Hi55ynQKCNU5LnfS3MC of z9brRu3VLVeJGQu1GsoC9HLiakSSZ4sL76Nh911X4pc33juWgJD3>"

The invited user is stuck on the "Waiting for approval to join!" view, even though someone is online to send the key. Console shows 404 and missing signing key

invitedLinkBorked—console
taoeffect commented 4 months ago

Re-opening because Error 5 is still likely an issue

taoeffect commented 4 months ago

OK, it seems like Ricardo's fix from yesterday fixed all the issues!