Search code examples
hyperledgerhyperledger-sawtooth

Hyperledger-Sawtooth: How consensus work?


Setting up a sawtooth network with 3 validators, each one is connected to a transaction processor. I'm testing consensus mechanism, so in my TransactionHandler did some intended mess up on setState. In 2 of processors I set the same object in the state and in the other one I set a different value. So every single transaction results in different state in validators.
Is it ok to have different states in different validators? So where is the consensus?


Solution

  • It seems to me if this is occuring, the validator nodes are not peering. The latter transaction will overwrite the former transaction in state. The 3 validator nodes need to be in a peer network. You only create a genesis block (block 0) in the first node. That node is copied to all other nodes in the Sawtooth network.

    You can verify the genesis node is the same on all nodes (and that all other nodes are the same) with the sawnet compare-chains command. Look for a different set of block(s) at the end of the chains.

    I recommend starting out creating a Sawtooth network with Docker using a pre-built configuration. For example, use the sawtooth-default-poet.yaml file found here: https://sawtooth.hyperledger.org/docs/core/nightly/master/app_developers_guide/creating_sawtooth_network.html Basically you start sawtooth-validator -vvv --peering dynamic --seeds tcp://validator-0:8800 The --seeds parameter specify initial network node(s) and the network dynamically peers with other peer nodes.