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

Login error on staging server: "hash() !== since" #2279

Closed taoeffect closed 3 months ago

taoeffect commented 3 months ago

Problem

The staging server represents a period copy of the production server.

I was logged in to it at one point and then somehow got logged out. When I tried logging back in I got these errors:

screenshot_2024-08-01_at_8 47 21___pm screenshot_2024-08-01_at_8 47 55___pm_720

Note: I can login in a private window, suggesting that this is an issue with the local vuex and/or chelonia state getting out of sync with the server and causing some sort of weird problem that shouldn't ever happen.

Solution

Diagnose and fix.

corrideat commented 3 months ago

@taoeffect Are you able to share the URLs from the network log when you get this error?

corrideat commented 3 months ago

It looks like this issue was caused by a fork in the chain, as state.contracts[identityContractID].HEAD has a value that doesn't exist as a hash on the server.

This could have been caused while copying the database from one server to the other.

taoeffect commented 3 months ago

So to elaborate, the theory that @corrideat came up is that my client performed some sort of operation on the identity contract, i.e. some opcode, whether a contract action or a key operation. This updated my local client state and specifically the value for recentHEAD here:

const { HEAD: recentHEAD, height: recentHeight } = state.contracts[contractID] || {}

Then when the database from production got copied over to staging, this resulted in a fork between my local client state and the server's, resulting in a 404 because recentHEAD was wrong when looking up eventsAfter.