Is there a bug for the on-chain delegate registration? - Protocol Developers: We need your help
The Blockwatch/TzStats indexer maintains an internal representation of the full blockchain state which is constructed from replaying block receipts (plus pulling snapshot index and rights from context). Anything else like supply, consensus and voting rolls, balance and delegation history, etc is derived from these receipts.
This approach works for all balance updates, but diverges from a node's context for the active delegate set. Ideally, all events that lead to registration, deactivation and reactivation of a delegate should be observable in receipts and there should be a consistent set of rules. This issue tracks our research towards understanding these rules and how they changed across versions.
From available documentation here and here and some reverse engineering our current set of delegate activation rules is as follows:
a tz1/2/3 account sends a delegation operation and sets itself as delegate (example, example)
a tz1/2/3 account is defined as delegate in the genesis block, a.k.a. the 8 Foundation Bakers (example)
🔥 a tz1/2/3 account sends an origination operation and sets itself as delegate on the created contract (example)
🔥 a registered delegate is listed in the block header field metadata.deactivated which gets populated in the last block of a cycle (example)
an inactive delegate registers again using a delegation operation to self like above (example)
an inactive delegate receives a transaction operation (example)
Problems with the approach above 🔥
some deactivations are missing from block.metadata.deactivated (example, example, example, example)
all the examples are marked inactive in the context, but they were never signalled in block metadata; a full dump of all deactivations extracted from block headers until block 552,960 (cycle 134) is availabe at this Gist
Note: early protocol versions until block 200,704 created many duplicate deactivations, although that's not an issue here...
Dear Tezos community, We are very excited for Berlin Blockchain Week and especially TQuorum: Berlin. TQuorum: Paris was such an incredible event, I am sure that the Berlin edition will be terrific. In...