Custom Policy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
global:
  policy:
    threshold: 67
    interval_broadcast_init_ballot_in_join: 5s
    timeout_wait_vote_result_in_join: 6s
    timeout_wait_ballot: 6s

conditions:
  all:
     # base state
     # {
     #   "level": "info",
     #   "node": "n0",
     #   "current_state": "booting",
     #   "new_state": "joining",
     #   "m": "state changed"
     # }
     - current_state="booting" AND new_state="joining"
     # {
     #   "level": "info",
     #   "node": "n0",
     #   "current_state": "joining",
     #   "new_state": "consensus",
     #   "m": "state changed"
     # }
     - current_state="joining" AND new_state="consensus"
  
     # new block created
     - m="new block created" and block.height="12" and block.round=0

In mitum, there are several factors for policy, these factors can control how mitum and consensus works.:

Note

The default value of each factor will be found at defaultPolicyConfig.

threshold
By default, threshold is 67 percent. This means how many nodes should agree on voting stage. 67 percent needs 2/3 of all nodes. If it is 100, nodes agree unanimously.
interval_broadcast_init_ballot_in_join
This factor can control how often node will send INIT ballot in join state. If 3s, node will send INIT ballot every 3 seconds.
timeout_wait_vote_result_in_join
Node is in join state and waits INIT ballots from others, but fails to get enough ballots within timeout_wait_vote_result_in_join time, node will analyze the exact situation of network.
timeout_wait_ballot
In consensus state, node will wait ballots for timeout_wait_ballot and if fails to get enough ballots within timeout_wait_ballot, node will move to next round.
timeout_wait_init_ballot
In consensus state, node will wait INIT ballots for timeout_wait_init_ballot and if fails to get enough ballots within timeout_wait_init_ballot, node will change it’s state to Joining, it means consensus process will be stopped and tries to check the health of network.

Note

You can find all the policy factors at PolicyConfig in source.

Note

By default, contest will set the latest block height to 11 with round 0.

Run contest:

1
2
3
4
 $ ./contest run custom-policy.yml \
     --log ./contest-sample \
     --number-of-nodes 4 \
     --exit-after 10s

If all the condition are matched, contest will exit with exit code, 0 with the matched logs.