Code Monkey home page Code Monkey logo

Comments (12)

tylobban avatar tylobban commented on May 18, 2024 4

Hi @trekdev

Private transactions cannot update public contracts since that would result in a consensus break on the public state as a result of execution of those transactions. In fact the EVM has been modified to specifically prevent private transactions from writing to public contracts. Please see this section in the wiki and this section in the docs for information. Note – we plan to move all documentation from /docs into the wiki to ensure no documentation is inadvertently hidden.

If public/private state mixing isn't possible this scenario also causes some confusion with a private contract between 2 parties, and a transaction changing the state shared with only 1 of those participants. So can someone query the contract's state in two ways: one with only public knowledge of the state, and another which includes any private knowledge?

Private State is not shared, so to speak, between parties. Rather, each party has state that is private/local to their node. In certain scenarios, the state of the private contract between 2 (or more) parties may be perfectly in sync (i.e. because future Transactions are always made private to both (all) parties concerned). Whereas in other scenarios there may be a need to make some part of the contract private to a subset of the original parties (through Transactions that are private to only those parties). In terms of querying the contract’s state, you can only query for ‘the state’ of a contract, i.e. the complete state that you are privy to.

If the later is the case, what would happen if the public contract could send ether to an address? If a private transaction calls sendEther, what would everyone think the contract's and the beneficiary's balances are?

It is not possible to send a private Transaction to a public contract. Note, however, that the original contract could be made pseudo-private but making it private for every participant on the network ( or those that you may care about). This has the effect of classifying the transaction as private, whilst giving visibility to many parties. You can then make value-updating calls from one party to another, although note that Quorum does not support Ether as a Token (but does use it for gas purposes - gas being priced at 0).

In the case that public contracts and private transactions can't be mixed, I'm not sure what would happen if the 2nd contract was created privately and a private transaction sent ether to another address. Could you check someone's "private balance" and have it behave like a private token?

Per the above, Ether as a Token is not supported in Quorum. However, in terms of your own Tokens, representing these in Quorum is fine but not if their transfer/ownership should be kept private. Enabling the transfer of a token that is private to one set of parties (A,B) to another (A,C) is on our product roadmap. Note too that if your example was updating a balance as opposed to sending a token, that could be achieved through the pseudo-private example above – see Section 6.1 in the Quorum Whitepaper for further info.

from quorum.

saradotramli avatar saradotramli commented on May 18, 2024 3

It is not possible to send a private Transaction to a public contract. Note, however, that the original contract could be made pseudo-private but making it private for every participant on the network ( or those that you may care about).

Seeing a lot of examples and tutorials following this pattern. However, in a typical Consortium scenario, where you might have to onboard participants at a later stage, making these existing private contract instances visible/accessible to them as well is not possible I believe. The only option is to deploy a duplicate private instance every time new nodes are onboarded, but then it would mean the existing parties have to keep track of multiple private instances of the same contract.

On a different note, when using the ContractFactory -- Contract Pattern, is it possible to make the Factory instance a public contract(for reasons quoted above) and make the Contract instantiated by it, private?
I have such a setup working in Ethereum (without the privacy bits) and have been trying to see if this can be made to work on Quorum (with the privacy bits). If not, what is the recommended alternative approach?

from quorum.

fixanoid avatar fixanoid commented on May 18, 2024 1

@cltsao thats currently possible -- once a private contract has been created between N parties, any subset of these could be used in follow up txns. That said, you need to ensure that this is the desired functionality in your use case.

from quorum.

fixanoid avatar fixanoid commented on May 18, 2024 1

@cltsao overall, we agree. At the moment, theres no enforcement of this on private txn manager side, but its an area we are working on at the moment and will have something in place by the end of the year. Please follow Quorum and Tessera releases.

from quorum.

jeremy-ellis-tech avatar jeremy-ellis-tech commented on May 18, 2024

@tylobban Thanks very much for clarifying. Just a small follow up question:

Whereas in other scenarios there may be a need to make some part of the contract private to a subset of the original parties (through Transactions that are private to only those parties)

Isn't this practically the same as sending a private transaction to a public contract (the transaction that alters the state of the contract is restricted to a subset of people that can see the contract).

from quorum.

tylobban avatar tylobban commented on May 18, 2024

Not quite - the key point here is 'altering the state'. Consensus must be reached on the state of all public contracts, thus if only a subset of participants were updating that state (as in your example of sending private transactions to a public contract), participants would end up with different public states and it would not be possible to achieve consensus. Making these contracts private has the effect of excluding them from the global state check during the consensus process.

from quorum.

jeremy-ellis-tech avatar jeremy-ellis-tech commented on May 18, 2024

@tylobban Thanks very much.

from quorum.

CLDH214 avatar CLDH214 commented on May 18, 2024

Enabling the transfer of a token that is private to one set of parties (A,B) to another (A,C) is on our product roadmap.
May I know if this is delivered? If no, which issue should I track?

from quorum.

tylobban avatar tylobban commented on May 18, 2024

@CLDH214 it is in progress but is not yet delivered. See Issue 152.

from quorum.

cltsao avatar cltsao commented on May 18, 2024

@tylobban Thank you for your clarification. One follow-up question. When I send a private transaction to a private contract, can I sent it to a subset of recipients of the private contract? Let's say a private contract is deployed on node A, B, and C. If A sends a private transaction only to B to modify a state on the private contract, does it make state inconsistent between A/B and C?

from quorum.

cltsao avatar cltsao commented on May 18, 2024

@fixanoid Thank you for your response. I feel allowing such inconsistency poses risk in using private contracts. Can Quorum force all follow-up transactions of a private contract to be sent to the same recipients? That will ensure that private state is always consistent among recipients of a private contract.

from quorum.

aalok05 avatar aalok05 commented on May 18, 2024

Private transactions cannot update public contracts since that would result in a consensus break on the public state as a result of execution of those transactions. In fact the EVM has been modified to specifically prevent private transactions from writing to public contracts. Please see this section in the wiki and this section in the docs for information. Note – we plan to move all documentation from /docs into the wiki to ensure no documentation is inadvertently hidden.

@tylobban
You mean "Private contracts cannot update public contracts." not "Private transactions cannot update public contracts " Huge difference.

from quorum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.