-
Notifications
You must be signed in to change notification settings - Fork 106
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
Is it Byzcoin's job to solve the problem of sharing instanceIDs of deferred contracts ? #2432
Comments
It all depends on what you want to do with ByzCoin ;)
TLDR: go with 2, if you think it's overkill, 3 is also OK with me. |
2 doesn't seem that more complicated compared to 3, so I would go for 2. If I understand well: Implement a If I summary this in picture: |
Yes, the problem with 2) is that if we're not adding other endpoints to the service, it will be a really lonely one ;) But let's go for 2) - this gives the hope for moving some of the byzcoin-endpoints over there. I don't remember the deferred transactions: are they stored in a block? Or only once they are fully signed? Also, there should probably be a 4) unregister, for deferred contracts that are fully signed. And where is 5) AddTx? The one with the additional signature? Does it go to the byzcoinproxy, or directly to byzcoin? Probably the latter, but it's still worth thinking about it. |
OK, that should probably be ordered differently: |
“We must accept finite disappointment, but never lose infinite hope.” – Martin Luther King, Jr. 😃
A "deferred transaction" will spawn an instance of the deferred smart contract.
Yes, true. Or I was also thinking about having a more complex registry that would store everything ("pending" and "executed" transactions) and let the user perform "rich" queries like "give me the instance IDs from contract X that have not been executed yet". But in any case Byzcoin must still be able to notify the Proxy once a deferred transaction has been executed.
Yes, that goes through a normal Byzcoin transaction. It corresponds to an Invoke:AddProof instruction on the deferred instance. So, to summary more formally: |
Some arrows missing to update either the instance through the proxy, or to get the instance from ByzCoin just before BTW: I really like https://plantuml.com/ to create diagrams like this, as it allows you to add the diagram directly as a text to git, and then re-create it as needed! Is that a plantuml diagram? |
True, the user needs the instance if it wants to sign it.
Yes, I like this way of creating diagrams. My favorite for sequence diagrams: https://sequencediagram.org/ Seems like we can agree on the system. At the end the proxy is pretty simple. Let's start. |
Now a day late I have another gripe: if both services are in the same node, all is OK. But what if the nodes are split? In fact the Sorry I missed that, looks like an important part of the architecture... |
Regarding sequencediagram.org - I did not find (search) for a way to create the documents offline, like you can do with plantuml. Is it possible? |
Is there a way to be notified by Byzcoin/Skipchain when a new block is added ? Or does it work by polling periodically the chain ?
At the time I didn't find any nice tool to do that (with a quick search, I would be surprised if there isn't any), but you can still generate a graph locally with a command line: https://plantuml.com/command-line |
I'm using this in the omniledger frontend, and it's working very well - you have to take care about reopening the connection, though: I think the following API call is the same in go (the naming is a bit unfortunate): https://github.com/dedis/cothority/blob/master/byzcoin/api.go#L544 For the proxy of c4dt/byzcoin I did a poll, because that was simpler (just calling |
Update on this issue. It comes that I was re-implementing the features offered by a relational database. At the end, we would like the proxy to answer questions like "Give the me the instance IDs of the deferred instances that have not been executed". Or "Give me all the blocks that contain an instruction about smart contract X". So, I'm currently implementing a proxy that stores the blockchain on an SQL database. The schema should be pretty straightforward: The service would then allow one to send an SQL query to the proxy service. To answer our questions from above. ie. getting all not executed deferred instanceIDs, we can run the following query: Select SmartContract.InstanceID from SmartContract
WHERE SmartContract.Name == 'DeferredContract' AND
SmartContract.InstanceID NOT IN (
SELECT SmartContract.InstanceID from SmartContract
INNER JOIN Instruction on SmartContract.smartcontract_id = Instruction.smartcontract_id
INNER JOIN Transaction on Transaction.transaction_id = Instruction.transaction_id
Where Instruction.type = 'Invoke' AND
Instruction.ContractID == 'DeferredContract' AND
Instruction.Action == 'ExecProposedTx' AND
Transaction.Accepted == True
) |
That brings up bad memories of my database classes. From what I understand, the SQL query looks good. I would be very interested to know how long this takes if there are 100k blocks with 10k DeferredContracts and half of them executed. This would probably also work as a generic proxy interface to byzcoin. I think you can reflect a lot of queries with that. One point where you could go crazy is to actually represent the state of the Instances at a given block-number and then let the user query that one. But for this you'd have to go down a rabbit hole of keeping the global state updated for every block... |
The deferred contract only works if we can successfully share its instanceID to the concerned people. Right now, this process must be handled by the user itself and is hard to do programmatically. How is someone supposed to know that a deferred instance is waiting for him to add its signature on it ? Either this information is given to him via a side channel, or it can be retrieved by browsing the entire chain.
Can/Should we help on that ? On the same way there is a singleton "name" contract that provides a handy way to name instances, should we also have a sort of handy "deferredRegistry" singleton contract, responsible for storing deferred instances waiting for signatures ?
I'm opening this issue to first discuss the "should we do it ?" principle, before entering into technical details.
The text was updated successfully, but these errors were encountered: