Skip to content

Instantly share code, notes, and snippets.

@nicolasochem
Last active July 19, 2022 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolasochem/28eed695ec9b20bf45dd8a0395477ef3 to your computer and use it in GitHub Desktop.
Save nicolasochem/28eed695ec9b20bf45dd8a0395477ef3 to your computer and use it in GitHub Desktop.
Dictator key test
accounts:
archive-baking-node-0:
bootstrap_balance: '4000000000000'
is_bootstrap_baker_account: true
key: edsk4X99zYzn5TLCbARNqggTxaCpJTma6k5j9VTXddwCktytV2q24R
type: secret
archive-baking-node-1:
bootstrap_balance: '4000000000000'
is_bootstrap_baker_account: true
key: edsk34DuVDY1wgvYGTLJpUZj4xDrJPiMzMXc7YoKkNXRYETtDHgocm
type: secret
activation:
protocol_hash: PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg
protocol_parameters:
preserved_cycles: 3
blocks_per_cycle: 32
blocks_per_commitment: 16
blocks_per_stake_snapshot: 16
cycles_per_voting_period: 1
hard_gas_limit_per_operation: '1040000'
hard_gas_limit_per_block: '5200000'
proof_of_work_threshold: '-1'
tokens_per_roll: '8000000000'
seed_nonce_revelation_tip: '125000'
baking_reward_fixed_portion: '10000000'
baking_reward_bonus_per_slot: '4286'
endorsing_reward_per_slot: '2857'
hard_storage_limit_per_operation: '60000'
origination_size: 257
cost_per_byte: '1000'
quorum_max: 7000
quorum_min: 2000
min_proposal_quorum: 500
liquidity_baking_subsidy: '2500000'
liquidity_baking_sunset_level: 525600
liquidity_baking_toggle_ema_threshold: 100000
max_operations_time_to_live: 120
minimal_block_delay: "5"
delay_increment_per_round: "15"
consensus_committee_size: 7000
consensus_threshold: 4667
minimal_participation_ratio:
numerator: 2
denominator: 3
max_slashing_period: 2
frozen_deposits_percentage: 10
double_baking_punishment: "640000000"
ratio_of_frozen_deposits_slashed_per_double_endorsement:
numerator: 1
denominator: 2
cache_script_size: 100000000
cache_stake_distribution_cycles: 8
cache_sampler_state_cycles: 8
nonce_revelation_threshold: 8
vdf_difficulty: '1000000000'
tx_rollup_enable: true
tx_rollup_origination_size: 60000
tx_rollup_hard_size_limit_per_inbox: 100000
tx_rollup_hard_size_limit_per_message: 5000
tx_rollup_max_withdrawals_per_batch: 255
tx_rollup_commitment_bond: "10000000000"
tx_rollup_finality_period: 2000
tx_rollup_withdraw_period: 60000
tx_rollup_max_messages_per_inbox: 1010
tx_rollup_cost_per_byte_ema_factor: 120
tx_rollup_max_inboxes_count: 15
tx_rollup_max_commitments_count: 30
tx_rollup_rejection_max_proof_size: 30000
tx_rollup_max_ticket_payload_size: 10240
tx_rollup_sunset_level: 2760
dal_parametric:
feature_enable: true
number_of_slots: 256
number_of_shards: 2048
endorsement_lag: 2
availability_threshold: 50
sc_rollup_enable: true
sc_rollup_origination_size: 6314
sc_rollup_challenge_window_in_blocks: 40
sc_rollup_stake_amount: "32000000"
sc_rollup_commitment_period_in_blocks: 20
sc_rollup_max_lookahead_in_blocks: 30000
sc_rollup_max_active_outbox_levels: 20160
sc_rollup_max_outbox_messages_per_level: 100
sc_rollup_max_available_messages: 222
testnet_dictator: tz1TAFTxbfhdxmMbQcoVPDekr5rqPmoREncv
archive_tarball_url: null
bootstrap_peers: []
expected_proof_of_work: 0
full_snapshot_url: null
tezos_k8s_images:
utils: localhost/tezos-k8s-utils:dev
images:
octez: tezos/tezos:v14.0-rc1
is_invitation: false
node_config_network:
activation_account_name: archive-baking-node-0
chain_name: nico
genesis:
block: BL3YCVQat6LT58pPqksa1vRE5ux8MgSHEjVnXKT1DgXXeznQWeP
protocol: Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P
timestamp: '2022-02-18T00:46:30.511911+00:00'
nodes:
archive-baking-node:
instances:
- bake_using_accounts:
- archive-baking-node-0
config:
shell:
history_mode: archive
is_bootstrap_node: true
- bake_using_accounts:
- archive-baking-node-1
config:
shell:
history_mode: archive
is_bootstrap_node: true
identity:
peer_id: idtHfozBsuCyYFrAhSu9MnDzcj4kHC
public_key: 04ace2cd862bcd8f3d5da8f768f757fe79b43b859f40fa012942844a42bfc216
secret_key: 51007841a2ffb943a9de807773149fe395a685eaf84fcd9a68e5d20a2114a5dd
proof_of_work_stamp: 6482e775ecf93ac9cf6c9a3f86b873bfb5ce2c6997a104ec
runs:
- octez_node
- baker
storage_size: 15Gi
rolling-node: null
rolling_snapshot_url: null
rolling_tarball_url: null
should_generate_unsafe_deterministic_data: false
#signers:
# tezos-signer-0:
# sign_for_accounts:
# - archive-baking-node-0
zerotier_config:
zerotier_network: null
zerotier_token: null
protocols:
- command: 014-PtKathma
vote:
liquidity_baking_toggle_vote: "pass"

Dictator key build

Note: this is specific to my setup with minikube and podman, written down here as a reference for myself.

Checkout the branch.

Start minikube with podman minikube start

Load podman-remote env vars eval $(minikube podman-env)

In tezos Makefile, replace @docker with podman-remote

Build docker container with make docker-image

The containers will be built and accessible with minikube.

Dictator key test

Then we are deploying tezos-k8s with a values file (see below) with:

  • 2 bakers (the first one is the dictator)
  • short cycle times (32 blocks)
  • cycles per voting period is set to 1
  • consequently, we change voting period every 32 blocks

The test regime is as follows:

Test 1: regular (non-dictator) gov update

We attempt to update to a protocol. The easiest is to update from alpha to ithaca (since we have the ithaca binaries available in the test environment). Actual upgrade fails. It is normal, and does not matter: what matters is the upgrade is triggered as predicted.

  • open a shell to non-dictator baker with k9s
  • submit proposal: tezos-client submit proposals for archive-baking-node-1 Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A
  • see the goverance status with tezos-client show voting period
  • then at next cycle, submit ballot: tezos-client submit ballot for archive-baking-node-1 Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A yay
  • then 2 cycles later, submit ballow again for adoption
  • at 2 cycles later, observe the transition to the new protocol (it fails)
│ Jul  5 21:42:56.079 - validator.block: pre-application of block at level 128 failed                                                                                               │
│ Jul  5 21:42:56.079 - validator.block: Request pushed on 2022-07-05T21:42:56.051-00:00, treated in 21.450us, completed in 27.490ms ,                                              │
│ Jul  5 21:42:56.079 - validator.block: Invalid block BKiHLREqU3Jk                                                                                                                 │
│ Jul  5 21:42:56.079 - validator.block:   Transition from protocol environment version V6 to V4 is not allowed.                             

This tests that the non-dictator governance works properly.

Test 2: dictator gov bypass

Now, repeat the same steps on dictator baker

  • submit proposal: tezos-client submit proposals for archive-baking-node-0 Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A

Observe that the proposal is now set to Adoption:

~ $ tezos-client show voting period
Current period: "adoption"
Blocks remaining until end of period: 3
Current proposal: Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A

Observe that at the end of the cycle, protocol upgrade immediately happens:

│ Jul  5 21:46:07.071 - validator.block: pre-application of block at level 16 failed                                                                                                │
│ Jul  5 21:46:07.071 - validator.block: Request pushed on 2022-07-05T21:46:07.046-00:00, treated in 14.178us, completed in 24.820ms ,                                              │
│ Jul  5 21:46:07.071 - validator.block: Invalid block BKiHLREqU3Jk                                                                                                                 │
│ Jul  5 21:46:07.071 - validator.block:   Transition from protocol environment version V6 to V4 is not allowed.    

This shows that the dictator is able to effectively bypass governance.

Test 3: dictator w/o rights can not vote

  • try to submit a proposal when the dictator key has no baking rights. Result:
There is an issue with the submission:
* Public-key-hash `tz1TAFTxbfhdxmMbQcoVPDekr5rqPmoREncv` from account
  `test` does not appear to have voting rights.

Fatal error:
  Submission failed because of invalid proposals.

This is as expected.

Test 4 cancel proposal

Submit:

~ $ tezos-client submit proposals for archive-baking-node-0 PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY                                                                      
Warning:                                                                                                                                                                             
                                                                                                                                                                                     
                 This is NOT the Tezos Mainnet.                                                                                                                                      
                                                                                                                                                                                     
           Do NOT use your fundraiser keys on this network.                                                                                                                          
                                                                                                                                                                                     
All proposals are valid.                                                                                                                                                             
Node is bootstrapped.                                                                                                                                                                
Operation successfully injected in the node.                                                                                                                                         
Operation hash is 'onos9jajdgacrXpzf2dQ6xJyM9A5pUwEFPZyuaV2Mw8UJ2Xe5iu'                                                                                                              
NOT waiting for the operation to be included.                                                                                                                                        
Use command                                                                                                                                                                          
  tezos-client wait for onos9jajdgacrXpzf2dQ6xJyM9A5pUwEFPZyuaV2Mw8UJ2Xe5iu to be included --confirmations 1 --branch BKjkF8QPTNmjUg3MAGdu1FTyUsT3Cmt5fDqXLFmAmz3TgqzVMw9            
and/or an external block explorer to make sure that it has been included.                                                                                                            
This sequence of operations was run:                                                                                                                                                 
  Proposals:                                                                                                                                                                         
    From: tz1TAFTxbfhdxmMbQcoVPDekr5rqPmoREncv                                                                                                                                       
    Period: 0                                                                                                                                                                        
    Protocols:                                                                                                                                                                       
      PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY                                                                     
      

Verify period:

~ $ tezos-client show voting period                                                                                                                                                  
Warning:                                                                                                                                                                             
                                                                                                                                                                                     
                 This is NOT the Tezos Mainnet.                                                                                                                                      
                                                                                                                                                                                     
           Do NOT use your fundraiser keys on this network.                                                                                                                          
                                                                                                                                                                                     
Current period: "adoption"                                                                                                                                                           
Blocks remaining until end of period: 7                                                                                                                                              
Current proposal: PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY                                  

Then cancel with --force:

~ $ tezos-client submit proposals for archive-baking-node-0  --force
Warning:
  
                 This is NOT the Tezos Mainnet.
  
           Do NOT use your fundraiser keys on this network.

Not in a proposal period
There is an issue with the submission:
* Empty proposal list.

Some proposals are not valid, but `--force` was used.
Node is bootstrapped.
Operation successfully injected in the node.
Operation hash is 'opaSfWgmfUAAg33mcGAH7GpkULEfDCL4Gxjjgar3kJL2DHA4Jyp'
NOT waiting for the operation to be included.
Use command
  tezos-client wait for opaSfWgmfUAAg33mcGAH7GpkULEfDCL4Gxjjgar3kJL2DHA4Jyp to be included --confirmations 1 --branch BLapp5cvp5y6xMYUdK927m5siqeHuFfjP91An1QNFtfuwfqhcYJ
and/or an external block explorer to make sure that it has been included.
This sequence of operations was run:
  Proposals:
    From: tz1TAFTxbfhdxmMbQcoVPDekr5rqPmoREncv
    Period: 0
    Protocols:
      

Verify we are back in proposal:

~ $ tezos-client show voting period
Warning:
  
                 This is NOT the Tezos Mainnet.
  
           Do NOT use your fundraiser keys on this network.

Current period: "proposal"
Blocks remaining until end of period: 4
Current proposals:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment