Add baking accounts
replaces !57 (closed)
implements #6 (closed), #7 (closed), #9 (closed), #10 (closed) , #18 (closed), #19 (closed), #21 (closed), #27 (closed), #67 (closed), #76 (closed), tezos/tezos#408 (closed)
depends on !40 (closed), !46 (merged), tezos/tezos!1671 (merged)
some changes are being split out into separate MRs, but are still included here !80 (merged), and tezos/tezos!1678 (merged)
!80 (merged) and !46 (merged))
Protocol commits starting from the oldest (skipping the commits from0c2589cd Proto: Add baker contract type
Module Baker_hash
represents baker's ID. Baker hashes start with the prefix
"SG1".
caf9dc9f Proto/Michelson: Add comparable baker_hash
type
79c4116a Proto: Factor out baker logic from Delegate
to Baker
module
fd3fe4b8 Proto: Update delegation logic for baker accounts
Also renames Delegate_storage
module to Delegation_storage
.
24638116 Proto: Add storage for baker consensus key
Baker consensus key is a public key that can be used for baking and endorsing blocks.
It's extended for compatibility with the current protocol version by establishing 1-to-1 mapping between baker contracts and consensus keys and enforcing that the implicit account of a consensus key must be unallocated (that is have no balance). Instead, transfers to and from a consensus key are mapped to the baker account that uses the given key.
This allows the consensus key to:
- sign operations using the consensus key
-
Transfer
operation from the baker contract -
Proposals
andBallot
operation
-
- allow the consensus key to continue to work as a target of
-
Delegation
operation andSET_DELEGATE
instruction -
Origination
operation andCREATE_CONTRACT
instruction
-
Each baker contract has an active consensus key and possibly a pending consensus key.
An active baker consensus key is stored in snapshot-able storage
(Storage.Baker.Consensus_key
) together with a reverse map
(Storage.Baker.Consensus_key_rev
). An active consensus key value is read from
a snapshot for the current cycle. The snapshots are cleared after
Constants.preserved_cycles
to allow the protocol to check historical values
for double baking and double endorsement evidence.
A pending consensus key is a paired with its activation cycle. It can be
updated at any point. This will set the key as pending for the given baker
(Storage.Baker.Pending_consensus_key
) and set its activation cycle
Constants.preserved_cycles + 2
in future.
A pending consensus key will become active in the beginning of the activation cycle.
If a new consensus key is set before the current one is activated, the current pending key will be overridden and its activation cycle is reset.
9f0c428d Proto: Refactor baker and baker related storage modules
Replaces public_key_hash
with baker_hash
in storage modules related to
bakers.
Storage changes (besides type changes also includes some module name and paths changes):
- Roll.Owner
- value type from
Signature.Public_key_hash
toBaker_hash
- value type from
- Contract.Delegate
- value type from
Signature.Public_key_hash
toBaker_hash
- value type from
- Vote.Listings
- key type from
Signature.Public_key_hash
toBaker_hash
- key type from
- Vote.Proposals
- value type from
Signature.Public_key_hash
toBaker_hash
- value type from
- Vote.Proposals_count
- key type from
Signature.Public_key_hash
toBaker_hash
- key type from
- Vote.Ballots
- key type from
Signature.Public_key_hash
toBaker_hash
- key type from
- Seed.unrevealed_nonce record type
- field name from
delegate
tobaker
and - type from
Signature.Public_key_hash
toBaker_hash
- field name from
- Roll.Delegate_roll_list
- moved to Roll.Baker_roll_list
- key type from
Signature.Public_key_hash
toBaker_hash
- Roll.Delegate_change
- move to Roll.Baker_change
- key type from
Signature.Public_key_hash
toBaker_hash
- Contract.Delegated
- move to Baker.Delegated
- value type from
Signature.Public_key_hash
toBaker_hash
- Delegates
- move to Baker.Registered
- value type from
Signature.Public_key_hash
toBaker_hash
- path from
delegates
tobaker/registered
- Active_delegates_with_rolls
- move to Baker.Active_with_rolls
- value type from
Signature.Public_key_hash
toBaker_hash
- path from
active_delegates_with_rolls
tobaker/active_with_rolls
- Delegates_with_frozen_balance
- move to Baker.With_frozen_balance
- value type from
Signature.Public_key_hash
toBaker_hash
- path from
delegates_with_frozen_balance
tobaker/with_frozen_balance
- Contract.Inactive_delegate
- move to Baker.Inactive
- value type from
Signature.Public_key_hash
toBaker_hash
- path from
contract/inactive_delegate
tobaker/inactive
- Contract.Delegate_desactivation
- move to Baker.Deactivation
- key type from
Signature.Public_key_hash
toBaker_hash
- path from
contract/delegate_desactivation
tobaker/deactivation
- Contract.Frozen_deposits
- move to Baker.Frozen_deposits
- key type from
Signature.Public_key_hash
toBaker_hash
- path from
contract/frozen_balance/deposits
tobaker/frozen_balance/deposits
- Contract.Frozen_fees
- move to Baker.Frozen_fees
- key type from
Signature.Public_key_hash
toBaker_hash
- path from
contract/frozen_balance/fees
tobaker/frozen_balance/fees
- Contract.Frozen_rewards
- move to Baker.Frozen_rewards
- key type from
Signature.Public_key_hash
toBaker_hash
- path from
contract/frozen_balance/rewards
tobaker/frozen_balance/rewards
7c51a6da Proto: Update and add consensus key logic to baker storage
Updates Baker_storage
module with the change of baker identifier from
Signature.Public_key_hash.t
to Baker_hash.t
.
Updates the baker registration function.
Adds the logic for reading and updating consensus key.
641edec6 Proto: Add storage for baker PVSS key
Bakers will be able to set their PVSS key, but the key is not currently being used.
b413599d Proto: Add baker registration operation
Added new type of manager operation Baker_registration
and its handler.
dc2c8c47 Proto: Make Origination
and Delegation
accept baker hash
The original operations are preserved as Origination_legacy
and
Delegation_legacy
for compatibility with the current operations. The public
key hash is mapped to the baker who is actively using this key as their
consensus key.
be5cc0ce Proto: Add type for baker operations
The baker operations can only be submitted internally (emitted from a script execution). The possible baker operations are:
- proposals
- ballot
- set baker active
- set baker consensus key
- set baker PVSS key
1f070e4c Proto/Michelson: Add baker_operation
type
f6f3111e Proto/Michelson: Add support for baker scripts
While originated scripts have return type list operation
, baker scripts return
pair (list operation) (list baker_operation)
. This is to prevent originated
scripts to emit baker operations.
d0eb7258 Proto/Michelson: Add comparable pvss_key
type
01e10092 Proto/Michelson: SET_DELEGATE
and CREATE_CONTRACT
with baker hash
The instructions SET_DELEGATE
and CREATE_CONTRACT
now accept baker hash for
delegate. The original instructions with pkhs are preserved as legacy.
cf6cae13 Proto/Michelson: VOTING_POWER
accepts baker hash instead of pkh
37d54358 Proto: Update type of delegate to baker hash
The references to delegate with PKH are replaced by baker hash.
The references to Delegate
module that were moved to Baker
module are also
updated.
9ff84879 Proto: Add default baker script
This adds Baker_script_repr
with code that is used as the default baker script.
The code is a generic multisig baker contract, similar to generic multisig with the difference that it can emit baker operations.
5e286824 Proto: Add built-in case encoding for "main" entrypoint
a150348c Proto: Update manager key and counter for baker contracts
For backwards compatibility, baker contract's consensus key may act as the manager key. Because consensus key account is required to be un-allocated, the counter of baker contract is being used for operations signed by consensus key.
7e71c4f5 Proto: Add handlers for applying baker operations
5fca334e Proto: Forbid transactions targeting pending consensus keys
To ensure that pending consensus key contracts are un-allocated, we forbid transactions targeting pending consensus keys that may allocate them.
cf2a1700 Proto: Allow to generate baker hash from origination nonce
42fe95cf Proto/Michelson: Add instructions for baker operations
Added instructions to create baker operations:
SUBMIT_PROPOSALS
SUBMIT_BALLOT
SET_BAKER_ACTIVE
SET_BAKER_CONSENSUS_KEY
SET_BAKER_PVSS_KEY
b28b6cd7 Proto: Handle Transaction
operation targeting baker contract
095db8d5 Proto: Compatibility for original Proposals
and Ballot
operation
To preserve compatibility with the original Proposals
and Ballot
operation,
the source is mapped to a baker as who uses it as an active consensus key.
f8e36c8e Proto: Map sources and destinations to baker consensus keys
Map operations' sources and destinations that refer to an active baker consensus key to the baker account that owns the key.
3f0582f7 Proto: Refactor Contract_storage
Replaces occurrences of context c
with ctxt
for consistency.
Removes unused error type Unspendable_contract
.
c1cf2883 Proto/RPC: Update voting services for baker hash
7a157a5d Proto/RPC: Update Forge Origination
and Delegation
to baker hash
ef6ddd15 Proto/RPC: Add helpers to run and trace baker script
875bbcce Proto/RPC: Add a helper to find baker with given consensus key
dfbba3d1 Proto/RPC: Update helper to apply operation
Updated:
- attempt to map the source to a baker's consensus key
- handle the legacy operations
- handle manager key and counter for baker contracts
67d2e7a7 Proto/RPC: Add "bakers" RPC to replace "delegates" RPC
The bakers RPC works with baker hash instead of PKH
9250651e Proto/RPC: Update "delegates" RPC for backward compatibility
This module has been deprecated and replaced by Baker_services
module.
The "delegates" RPC endpoints are kept for backwards compatibility and the
public key hashes that used to represent delegate are expected to be active
baker consensus keys instead.
725a5d8a Proto/RPC: Update contract services for baker contracts
The type of delegate is changed to baker hash. The "manager key" endpoint is replaced by "public key" endpoint, preserving the original for backward compatibility.
8514a899 Proto/Parameters: Add default bootstrap baker accounts
e3aa8203 Proto: Expose function to increment origination nonce for testing
182222d4 Proto: Initialize bootstrap bakers and baker storage from genesis
5e5852e0 Proto/Migration: Migrate all registered bakers to new accounts
All (valid) registered bakers and their associated storages are migrated to their new SG1 baker accounts. We move the balance of the original implicit baker accounts to the new baker accounts.
22192053 WIP Proto/Migration: Add migration logging
To be removed.
Sprinkled migration with some logging for testing.