Skip to content
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

Fix consensus on private contract failure. #517

Merged
merged 1 commit into from
Sep 18, 2018
Merged

Conversation

joelburget
Copy link
Contributor

Previously we had populated the public receipt failed field with the
result of the transaction. This is correct for public transactions. It's
also correct for successful private transactions. But it's not correct
for failing private transactions, because their public receipt should
not indicate failure. The fix is straightforward.

Testing:

I used this contract:

contract RevertTest{
   uint public newValue;
   function revertFunction() public{
       uint a = 1;
       require(a == 0);
   }
}

After deploying the contract I sent in several failing transactions via

function sendBad() {
  eth.sendTransaction({
  from: eth.accounts[0],
  data: web3.sha3("revertFunction()"),
  gas: 0x47b760,
  privateFor: ["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="]
  });
}

Watching the logs (1.log and 2.log), I saw the TX-ACCEPTED events
scroll as I sent revertFunction transactions. I see 10 TX-ACCEPTED
events in both logs (1 for deploy and 9 tests via sendBad).

Via extra logging, in 1.log I see that the public receipts have status
1, whereas private receipts have status 0. In 2.log they all have
status 1.

All nodes stayed up the whole time.

Fixes #434

Previously we had populated the public receipt `failed` field with the
result of the transaction. This is correct for public transactions. It's
also correct for successful private transactions. But it's not correct
for failing private transactions, because their public receipt should
not indicate failure. The fix is straightforward.

Testing:

I used this contract:

    contract RevertTest{
       uint public newValue;
       function revertFunction() public{
           uint a = 1;
           require(a == 0);
       }
    }

After deploying the contract I sent in several failing transactions via

    function sendBad() {
      eth.sendTransaction({
      from: eth.accounts[0],
      data: web3.sha3("revertFunction()"),
      gas: 0x47b760,
      privateFor: ["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="]
      });
    }

Watching the logs (`1.log` and `2.log`), I saw the `TX-ACCEPTED` events
scroll as I sent `revertFunction` transactions. I see 10 `TX-ACCEPTED`
events in both logs (1 for deploy and 9 tests via `sendBad`).

Via extra logging, in `1.log` I see that the public receipts have status
`1`, whereas private receipts have status `0`. In `2.log` they all have
status `1`.

All nodes stayed up the whole time.

Fixes #434
@AldelopiomicA
Copy link

AldelopiomicA commented Sep 11, 2018

I can confirm, this PR fixed my problem. Both the test I've described in the issue #434, and so far so good in my developing project. (There is no Quorum node crash so far)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consensus fails on private txn that are intended to fail, such as revert op.
5 participants