Open echa opened 5 years ago
Concerning the second question: It is in the Athens release that receiving an incoming transaction did not anymore reactivate an inactive delegate. See diff in the credit
function of lib_protocol/contract_storage.ml
between proto_003_xxx
and proto_004_yyy
.
A little Internet archeology revealed that proto_002_xxx
fixed a bug where non-registered delegates would accept delegations in an origination operation (registration case 3 above).
I found a changelog extract in the Tezos Slack archive https://log.tezos.link/index.php?date=20-07-2018 published at 20-07-2018 15:45:31 (block 26,579 cycle 6) mentioning
- Fixed a bug in delegations, where contracts could delegate to unregistered
delegates. This will be enforced from now on, and the existing unregistered
delegates will be automatically registered (except for two empty addresses).
This explains the weird RPC error messages before block 28,082 and the magic activations at block 28,083 where protocol v002 activated. Problem 2 above seems to be solved. Many of these magically activated delegates are still active today.
I switched our indexer to track the grace period of each delegate in the hope that I wouldn't have to rely on the deactivated
list which is obviously buggy.
The idea is to deactivate delegates in the indexer when their grace period expires. Reverse engineered rules to set/update the grace period are as follows:
cycle+11
(this also applies to every subsequent re-registration by self-delegation independent of active/inactive status)cycle+11
(this does not apply to sending manager operations like transactions!)max(grace, cycle+6)
(this does not apply to sending transactions and originations, even reveal is unconfirmed here)Until proto_004_xxx
activated in cycle 111 the following additional conditions applied:
cycle+11
max(grace, cycle+6)
A bug fix in proto_002_xxx
also sets the grace period of all eligible delegates to 17 (6+11
). Eligible are all delegates with nono-zero balance that did not register through self-delegation, but were used as delegate in at least one origination operation.
When cross-checking this method another Tezos bug surfaced: against what's specified in the documentation, that one could extend the grace period by sending small meaningless transactions, that is not the case. Neither sent transactions nor sent originations (no matter using delegation or not) would update the grace period.
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:
metadata.deactivated
which gets populated in the last block of a cycle (example)Problems with the approach above 🔥
block.metadata.deactivated
(example, example, example, example)Open Questions