Skip to content

Instantly share code, notes, and snippets.

@echa
Created August 6, 2019 11:51
Show Gist options
  • Save echa/6824cfba4c2e684557ab5a4a409e7fba to your computer and use it in GitHub Desktop.
Save echa/6824cfba4c2e684557ab5a4a409e7fba to your computer and use it in GitHub Desktop.
Tezos delayed delegate registration by origination

Account tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA tzscan

History

  • sent activate_account operation in block 6,386 (1)
  • sent multiple originations with delegate set to self at
    • 15,794 (3) KT1Scmfx3oDBwTr17f1tnNnAvNoBQC5KP6wL (later funded in block 15,795 and delegated elsewhere in 15,803)
    • 24,713 (6) KT1K447xjtpP5KYXwTaq8rAggsiNKTnWY9CV (later funded in block 24,843 and delegated elsewhere in 24,850)
    • 26,341 (6) KT1HKXfHkwrAYQwmo4KhhXDJozsn7MxF2XmH (later funded in block 26,343, but not delegated elsewhere)
  • received delegations from its managed contracts at blocks
    • 29,949 (7) KT1Scmfx3oDBwTr17f1tnNnAvNoBQC5KP6wL
  • 29,953 (7) KT1K447xjtpP5KYXwTaq8rAggsiNKTnWY9CV
  • seems to have been active delegate in cycles 6-17, grace period 17
  • has baking/endorsing rights from cycle 13-24
  • /context/delegates/* calls return proto.001-PtCJ7pwo.tez.subtraction_underflow or other errors until block 28,082 (7) (see below)
  • after block 28,082 proper delegate info is returned
  • explicit deactivation at blocks 73728 (17), 77824, 81920, 86016, 90112, 94208, 98304, 102400, 106496, 110592, 114688, 118784, 122880, 126976, 131072, 135168, 139264, 143360, 147456, 151552, 155648, 159744, 163840, 167936, 172032, 176128, 180224, 184320, 188416, 192512, 196608, 200704 (48)

Detailed History

# after 1st origination of KT1Scmfx3oDBwTr17f1tnNnAvNoBQC5KP6wL account is not registered as delegate
curl https://mainnet.tezrpc.me/chains/main/blocks/15794/context/delegates/tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA
[
    {
        "amounts": [
            "0",
            "24999743000"
        ],
        "id": "proto.001-PtCJ7pwo.tez.subtraction_underflow",
        "kind": "temporary"
    }
]

# after sending tx (10 XTZ) to new KT1 from origination 1
curl https://mainnet.tezrpc.me/chains/main/blocks/15795/context/delegates/tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA
[
    {
        "amounts": [
            "10000000",
            "24989743000"
        ],
        "id": "proto.001-PtCJ7pwo.tez.subtraction_underflow",
        "kind": "temporary"
    }
]

# ... some more tx happened

# after 2nd origination of KT1K447xjtpP5KYXwTaq8rAggsiNKTnWY9CV account is still not registered as delegate
curl https://mainnet.tezrpc.me/chains/main/blocks/24713/context/delegates/tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA
[
    {
        "amounts": [
            "0",
            "9446000"
        ],
        "id": "proto.001-PtCJ7pwo.tez.subtraction_underflow",
        "kind": "temporary"
    }
]


# after sending tx to new KT1 from origination 2
curl https://mainnet.tezrpc.me/chains/main/blocks/24843/context/delegates/tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA
[
    {
        "function": "get",
        "id": "proto.001-PtCJ7pwo.context.storage_error",
        "kind": "permanent",
        "missing_key": [
            "contracts",
            "index",
            "ed25519",
            "d8",
            "f0",
            "65",
            "1b",
            "4e",
            "34772f0a06de64886a3dfeec1e55df",
            "delegate_desactivation"
        ]
    }
]

# ... some more tx happened

# after 3rd origination of KT1HKXfHkwrAYQwmo4KhhXDJozsn7MxF2XmH account is still not registered as delegate
curl https://mainnet.tezrpc.me/chains/main/blocks/26341/context/delegates/tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA
[
    {
        "amounts": [
            "0",
            "10008889000"
        ],
        "id": "proto.001-PtCJ7pwo.tez.subtraction_underflow",
        "kind": "temporary"
    }
]

# ... some more tx happened where account remains to be no delegate

# then suddenly at block 28,082 the third originated contract that still delegates here is finally listed
curl https://mainnet.tezrpc.me/chains/main/blocks/28082/context/delegates/tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA
{
    "balance": "15008889000",
    "deactivated": false,
    "delegated_balance": "0",
    "delegated_contracts": [
        "KT1HKXfHkwrAYQwmo4KhhXDJozsn7MxF2XmH"
    ],
    "frozen_balance": "0",
    "frozen_balance_by_cycle": [],
    "grace_period": 17,
    "staking_balance": "15008889000"
}


# then after receiving a re-delegation from source KT1Scmfx3oDBwTr17f1tnNnAvNoBQC5KP6wL
curl https://mainnet.tezrpc.me/chains/main/blocks/29949/context/delegates/tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA
{
    "balance": "15008889000",
    "deactivated": false,
    "delegated_balance": "0",
    "delegated_contracts": [
        "KT1Scmfx3oDBwTr17f1tnNnAvNoBQC5KP6wL",
        "KT1HKXfHkwrAYQwmo4KhhXDJozsn7MxF2XmH"
    ],
    "frozen_balance": "0",
    "frozen_balance_by_cycle": [],
    "grace_period": 17,
    "staking_balance": "15008889000"
}

# after receiving a re-delegation from another source KT1K447xjtpP5KYXwTaq8rAggsiNKTnWY9CV
curl https://mainnet.tezrpc.me/chains/main/blocks/29953/context/delegates/tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA
{
    "balance": "15008889000",
    "deactivated": false,
    "delegated_balance": "0",
    "delegated_contracts": [
        "KT1Scmfx3oDBwTr17f1tnNnAvNoBQC5KP6wL",
        "KT1K447xjtpP5KYXwTaq8rAggsiNKTnWY9CV",
        "KT1HKXfHkwrAYQwmo4KhhXDJozsn7MxF2XmH"
    ],
    "frozen_balance": "0",
    "frozen_balance_by_cycle": [],
    "grace_period": 17,
    "staking_balance": "15008889000"
}
  • how could tz1fR6d..iTBA become a delegate after all? there was no 'registration' (i.e. delegation to self)
  • what happened at block 28,082? it contains endorsements only!

Useful API Calls

Use the Blockwatch/TzStats API to fetch and filter on-chain data. We store all data in tables that are indexed/filterable by every field. Docu is at https://blockwatch.cc/docs/api

Hints for using the API

  • default limit for results is 500, to increase append limit=N as query arg (max is 50,000)
  • some results can be huge, so you may want to filter and pick only columns you need with columns=a,b,c
  • default is unkeyed JSON arrays, to insert field names add verbose=1
  • replace .json with .csv to download a CSV file
# fetch all operations sent by the account
https://api.tzstats.com/tables/op.json?sender=tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA&limit=10000

# fetch all operations received by the account
https://api.tzstats.com/tables/op.json?receiver=tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA&limit=10000

# fetch all baking/endorsing rights for the account
https://api.tzstats.com/tables/rights.json?delegate=tz1fR6dVH7fS58y2EdDGtM24ZcBuwDnaiTBA&limit=10000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment