VolumeFi / paloma

The fast blockchain messenger protocol
Apache License 2.0
3 stars 2 forks source link

[PF] 🚧 Handle skyway nonce mismatches between compass versions #1848

Closed byte-bandit closed 3 months ago

byte-bandit commented 4 months ago

During a compass upgrade, we'll have two versions of compass live, and well call the old version with the address of the new one in order to update ownership of tokens and this gas wallet.

If any third party makes calls to compass to send funds to Paloma, this will increase the nonce on the old compass.

We need a solution for this on the protocol side.

maharifu commented 3 months ago

@byte-bandit Just as a sanity check, this is what I'm thinking here:

This way we get independent nonces on every compass update, but we don't have to keep track of them all. This could also add the benefit that if something goes wrong, we can redeploy compass to restart the nonces and re-sync.

We could keep the current nonce in the new compass instead of restarting at 0, but that would force us to reset to an arbitrary number instead. This doesn't seem to add much and restarting at 0 seems cleaner.

Do you see any issues on this approach?

byte-bandit commented 3 months ago

AFAIU keeping the nonce is considered to be best practice, as each event will keep its unique ID without ever resetting. But other than that, I think your solution makes sense.

Paloma essentially blocks any skyway calls to compass during an upgrade, but we cannot prevent an external caller increasing the nonce. It's important that any events generated during an upgrade are still processed correctly, and only once the new contract is live, the nonce stored on Paloma is adapted to represent that value.

Given that we'd get duplicate events anyway due to the fact above, I don't see any downside just resetting to 0, as long as Pigeon and Paloma will be able to handle the desync.

maharifu commented 3 months ago

Closed with https://github.com/palomachain/paloma/pull/1251 and https://github.com/palomachain/pigeon/pull/420