Quorum 2.0.2 Istanbul Randomly Fails to Fire Events
System information
Geth version: geth version
Geth
Version: 1.7.2-stable
Git Commit: df4267a25637a5497a3db9fbde4603a3dcd6aa14
Quorum Version: 2.0.1
Architecture: amd64
Network Id: 1
Go Version: go1.10
Operating System: linux
GOPATH=
GOROOT=/usr/local/go
OS & Version:Linux
Expected behaviour
All nodes participating in a private transaction receive the contract's emitted events
Actual behaviour
Sometimes ok, all nodes received the expected event. Randomly there's time one node got fired event but the another didn't.
Steps to reproduce the behaviour
Deploy private quorum 2.0.2, istanbul consensus with examples 7 nodes. Actually in my case is 3 nodes only. https://github.com/jpmorganchase/quorum-examples/tree/zsl_geth1.6/examples/7nodes
Modify SimpleStorage to emit Debug(uint x) when trigger set
pragma solidity ^0.4.19;
contract simplestorage {
uint public storedData;
function simplestorage(uint initVal) {
storedData = initVal;
}
event Debug(uint x);
function set(uint x) {
storedData = x;
Debug(x);
}
function get() constant returns (uint retVal) {
return storedData;
}
}
Deploy contract privately between node1 and node 2. Watch for fired events & send several private Set transaction. Sample code to be executed with truffle
const Web3 = require('web3');
const assert = require('chai').assert;
const simplestorage = artifacts.require("simplestorage");
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const initWeb3 = (rpcAddr, name) => {
const provider = new Web3.providers.HttpProvider(rpcAddr);
const web3Sender = new Web3(provider);
assert.isOk(web3Sender.isConnected());
return {
w3: web3Sender,
name: name,
eventsCount: 0
}
}
const watchEvents = (node, contract) => {
contract = node.w3.eth.contract(contract.abi).at(contract.address)
const eventsWatcher = contract.Debug();
eventsWatcher.watch((error, result) => {
if (!error) {
console.log(`[${node.name}] >> Debug(${result['args'].x.toNumber()})`);
node.eventsCount++;
}
});
}
const node1 = initWeb3(<Node 1 RPC Address>, '1')
const node2 = initWeb3(<Node 2 RPC Address>, '2')
module.exports = async function() {
times = 5;
console.log(`Exec private 'SimpleStorage.Set' ${times} times`);
storage = await simplestorage.deployed();
watchEvents(node1, storage);
watchEvents(node2, storage);
for (let i=0; i < times; i++) {
await storage.set(i, {privateFor: [<Node 2 Public key>]});
}
// delay a while for all events fired
await sleep(times * 2000);
// rechecked fired Debug event times
if (node1.eventsCount != node2.eventsCount || node1.eventsCount < times || node2.eventsCount < times) {
console.log(`Failure !`)
} else {
console.log(`Success !`)
}
console.log(` Total run: ${times}\n node1: received ${node1.eventsCount} events\n node2: receved ${node2.eventsCount} events`);
}
Backtrace
Exec private 'SimpleStorage.Set' 5 times
[1] >> Debug(0)
[1] >> Debug(1)
[2] >> Debug(2)
[2] >> Debug(3)
[1] >> Debug(3)
[2] >> Debug(4)
Failure !
Total run: 5
node1: received 3 events
node2: receved 3 events
@meomap It seems that you are running 2.0.1 from your report Quorum Version: 2.0.1. Can you please upgrade to 2.0.2? We saw a similar issue in 2.0.1 that was fixed.
@jpmsam it was built from this version release https://github.com/jpmorganchase/quorum/releases/tag/v2.0.2
Note that git commit hash is the same df4267a
I inspected the sourcecode and found out the version patch number not updated yet https://github.com/jpmorganchase/quorum/blob/v2.0.2/params/version.go#L31
@meomap thanks for the update. Did you experience the same issue under raft or did you only run Istanbul?
hello @jpmsam thanks for suggestion, I tried with raft and the issue didn't happen. All participants node received same number of events.
[1] >> Debug(0)
[1] >> Debug(0)
[2] >> Debug(0)
[2] >> Debug(0)
[1] >> Debug(1)
[2] >> Debug(1)
[1] >> Debug(2)
[1] >> Debug(3)
[2] >> Debug(2)
[2] >> Debug(3)
[2] >> Debug(4)
[1] >> Debug(4)
Success !
Total run: 5
node1: received 6 events
node2: received 6 events
weird thing is that on new watcher, same event was received twice but it's a not a big deal as all subsequence ones correctly sent once.
Rerun same contract deploy & test with istanbul, issue of missing events among nodes happened:
Exec private 'SimpleStorage.Set' 5 times
[2] >> Debug(0)
[1] >> Debug(1)
[2] >> Debug(2)
[2] >> Debug(3)
[2] >> Debug(4)
Failure !
Total run: 5
node1: received 1 events
node2: received 4 events
It seems issue is related to istanbul consensus only
@yutelin @markya0616 can you please review for Istanbul ?
Duplicate, tracking via #400