-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Design & Implement Contract Deletion (OP_CONTRACT_DELETE?) #1927
Comments
Looking through this, I think that we could do this very similarly to how we do it with files. I also don't think that we should use To illustrate this, imagine a contract (say, a group) with 3 members, Alice, Bob and Carol. Alice and Bob are online, and Carol is offline. Now, Alice issues From the server's perspective, So, I think we could just use the router with a
This is possible, but I'm not sure that we can guarantee this behaviour. For many reasons could a deleted contract result in 404 (loss of state, new server, federation, legal reasons, moral reasons, etc). I think that we challenging part of this task is deciding the correct client behaviour on notification of deletion / 404 / 410. While the contract is probably no longer usable, users might want to keep the data. Consider here too a malicious (or not) server that returns 410 for contracts that shouldn't be deleted, or contracts that are 'deleted' for non-payment. |
I do see this theory, however, it's only true if we decide to implement it that way. The thing is, for some apps, it might very well be useful to know whether or not a contract was deleted. After all, there's a difference between asking, "Hey, send contract XYZ", and the server saying, "That contract doesn't exist — AND NEVER EXISTED", and "that contract doesn't exist — ANYMORE (but it did at one point)". Some apps might need to be able to distinguish between these two cases for whatever reason. If we implement it as a separate API, then we won't be able to distinguish between those two cases, and we will artificially limit the types of apps that can be created with Chelonia because of it. What we could do instead is use
Then whenever someone goes to sync that contract, the server will either send back that last message, or it will detect that the last message was
|
I get the distinction between 404 and 410 and its usefulness (even though I made another point about how this information might get lost), but I think maybe something wasn't clear. I didn't say that the alternative to What I did say is that I don't see, neither from the perspective of clients, nor from the perspective of the server, a situation where
I considered this, and it'd mostly be a waste of storage over simply storing a boolean flag. This is because that last message contains no useful information without the entire chain. It can be entirely fabricated, so it's unverifiable, and it's much more verbose than So, to clarify my points were:
|
It's advantageous in that it's elegant. I just like how it looks. When writing out the documentation and description of the VM, we have something to pair
Using
|
In Note that with
The exact number of extra branches as it'd take to implement 410 in any way, and possibly fewer.
Not sure about this. I'd say opcodes are APIs too, and also require branches to handle.
Sure, if you're talking about when it's received. However, see my response to the previous point. If you were referring to the Even if we did store the
For processing, it's not too different from other approaches, true. For storage, it's utterly useless to store |
That's not true though. It can be verified by both the client and the server upon receiving it. It is signed using whatever are the latest keys, which both the server and the client have, so they can verify it if they've sync'd the contract before. That is unlike simply storing So, if it's not a big deal to you, can we go with |
But it can't be verified by the client unless the client is online. |
I don't think so, because I don't think that the server saying the contract is deleted and being able to somehow verify this is particularly useful information, even if it can be verified. Also, the server could unilaterally delete contracts for a variety of reasons and clients can do nothing about it, whether it can be verified or not. I think that we're conflating two distinct but somehow related issues.
I'm not opposed to the idea of creating an opcode for 1, but by necessity it can only be verified if the contract chain itself isn't deleted. I'm somewhat opposed to the idea of using an opcode for 2, because 'verifying' at this point isn't very useful (if at all possible) since the data are gone, and it's only done because of reasons that concern the server (or the use thereof), not the clients. If the server didn't exist at all, we'd probably have an opcode for 1 but not for 2, and maybe after some time clients would prune the entries from their cache, or they might not.
I wouldn't necessarily call deleting data malicious (depends on the circumstances (*)), and in any case it can't be reliably checked if it was 'malicious' or not (see, offline clients and the server claiming there was a key rotation; btw, the server can also make clients be 'offline'). Clients can verify already that a contract is gone, by getting a 404 or 410. (*) For example, if the server charges for storage and storage isn't paid, I wouldn't call deleting data after a while malicious. If the server room is accidentally flooded and contracts are lost, it wouldn't be malicious. The larger point is 'what can clients do with this information' and I don't think they can do very much. |
I think this is the strongest argument against needing |
Ok, so what about we do this:
|
@corrideat That sounds reasonable (with a vote in favor
Ideally we wouldn't have to maintain any separate list. When a contract is deleted, the info should be stored using the existing "list", or rather KV mapping, of either the I feel like we have enough lists to manage and don't need to overcomplicate the server with any more, especially as this can be done without a new list. |
Ideally, I agree with you, but I don't think we can do this here, regardless of implementation. Let me explain why. Currently, we store Now, let's say that a contract is deleted (at height If syncing using the Either way, implementing 410 requires at least a branch in each API endpoint that should return if (isContractDeleted(contractID)) {
return 410
} else {
// Existing logic
} |
Incidentally, this raises another question that we haven't discussed --- what deletion means. Say that I have a contract with messages with IDs So far, it's been strongly implied that fetching |
I think the answer is probably "no" to both questions. Requesting B and C directly should return 404, and |
Thanks for all of the feedback, @taoeffect! I think I've now got enough information to start working on this, but I'll make a brief proposal first just in case there's something to adjust. As we've discussed on Slack, we can postpone
|
@corrideat that sounds reasonable 👍 Some things to consider as you're implementing this:
|
File attachments are linked to chatrooms via the
Using a separate task would help with this, but if you read the comment, the new opcode was not meant as a replacement for the endpoint for file deletion.
Sure, I can look into that.
Yeah, I think it could be done that way. We'd want the delete action to be persisted across server restarts. |
I think that this could be a suitable algorithm to implement for deleting contracts:
Now, there are a few things that are non-optimal, which we don't need to handle right now, but that we should address at some point:
|
Regarding the "We don't have a global 'resource type' identifier." issue, there are two avenues for addressing this (which would also address #2115, or bring us close to that)
|
Yeah I think now's a good time to do this (2) |
Problem
Currently we have no way to delete a contract once it's been created.
This means unnecessary space will be used on the server.
Solution
Implement
OP_CONTRACT_DELETE
and use it when, for example, deleting chatrooms.This opcode will go through and delete every message in a contract and all state (except attachments) associated with it.
Clients trying to sync the contract again should get
410 Gone
errors and assume the contract has been deleted. Clients syncing contracts that never existed should return404 not found
.Note: in the case of deleted chatrooms, the attachments in that chatroom must be handled separately. Deleting a contract doesn't delete the attachments inside of it, so those must be deleted separately.
EDIT: note this comment that mentions that attachments could be deleted as well.
The text was updated successfully, but these errors were encountered: