Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Withdrawals #4552

Closed
wants to merge 32 commits into from
Closed

Conversation

gezero
Copy link
Contributor

@gezero gezero commented Oct 22, 2022

Signed-off-by: Jiri Peinlich jiri.peinlich@gmail.com

No tests so far, It compiles....

@gezero gezero force-pushed the eip-4895-withdrawals branch 12 times, most recently from 76a06b2 to 15ae2db Compare October 24, 2022 09:42
@non-fungible-nelson non-fungible-nelson added EIP Ethereum Improvement Proposal mainnet labels Nov 7, 2022
@garyschulte
Copy link
Contributor

Marius' withdrawals test vectors:
https://hackmd.io/PqZgMpnkSWCWv5joJoFymQ

@siladu siladu added the TeamGroot GH issues worked on by Groot Team label Nov 10, 2022
@siladu siladu self-assigned this Nov 10, 2022
@siladu
Copy link
Contributor

siladu commented Nov 10, 2022

This is forkchoice request I used to test, adapted from the data in https://hackmd.io/PqZgMpnkSWCWv5joJoFymQ
I had to change the headBlockHash to match what besu thought it should be: either our config is wrong or the hash in the hackmd's fcU is wrong w.r.t. the provided genesis.
That different block hash is carried through to the other API calls in the comments below.

Currently the index, validatorIndex and amount values don't conform to the spec as they should be in hex.

{
  "jsonrpc": "2.0",
  "method": "engine_forkchoiceUpdatedV2",
  "params": [
    {
      "headBlockHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a",
      "safeBlockHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a",
      "finalizedBlockHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a"
    },
    {
      "timestamp": "0x50",
      "prevRandao": "0xff00000000000000000000000000000000000000000000000000000000000000",
      "suggestedFeeRecipient": "0xaa00000000000000000000000000000000000000",
      "withdrawals": [
        {
          "index": "0x0",
          "validatorIndex": "0xFFFF",
          "address": "0x0000000000000000000000000000000000000000",
          "amount": "0"
        },
        {
          "index": "0x1",
          "validatorIndex": "0x10000",
          "address": "0x0100000000000000000000000000000000000000",
          "amount": "0x100000000000000000000000000000000000000000000000000000000000000"
        },
        {
          "index": "0x2",
          "validatorIndex": "0x10001",
          "address": "0x0200000000000000000000000000000000000000",
          "amount": "0x200000000000000000000000000000000000000000000000000000000000000"
        },
        {
          "index": "0x3",
          "validatorIndex": "0x10002",
          "address": "0x0300000000000000000000000000000000000000",
          "amount": "0x300000000000000000000000000000000000000000000000000000000000000"
        },
        {
          "index": "0x4",
          "validatorIndex": "0x10003",
          "address": "0x0400000000000000000000000000000000000000",
          "amount": "0x400000000000000000000000000000000000000000000000000000000000000"
        },
        {
          "index": "0x5",
          "validatorIndex": "0x10004",
          "address": "0x0500000000000000000000000000000000000000",
          "amount": "0x500000000000000000000000000000000000000000000000000000000000000"
        },
        {
          "index": "0x6",
          "validatorIndex": "0x10005",
          "address": "0x0600000000000000000000000000000000000000",
          "amount": "0x600000000000000000000000000000000000000000000000000000000000000"
        },
        {
          "index": "0x7",
          "validatorIndex": "0x10006",
          "address": "0x0700000000000000000000000000000000000000",
          "amount": "0x700000000000000000000000000000000000000000000000000000000000000"
        }
      ]
    }
  ],
  "id": 68
}

@siladu
Copy link
Contributor

siladu commented Nov 11, 2022

Get Payload V2

{
    "jsonrpc": "2.0",
    "method": "engine_getPayloadV2",
    "params": [
      "0x0077c12559db3bb0"
    ],
    "id": 67
}

@siladu
Copy link
Contributor

siladu commented Nov 11, 2022

New Payload V2

{
    "jsonrpc": "2.0",
    "method": "engine_newPayloadV2",
    "params": [
        {
            "parentHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a",
            "feeRecipient": "0xaa00000000000000000000000000000000000000",
            "stateRoot": "0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45",
            "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
            "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
            "prevRandao": "0xff00000000000000000000000000000000000000000000000000000000000000",
            "blockNumber": "0x1",
            "gasLimit": "0x1c9c380",
            "gasUsed": "0x0",
            "timestamp": "0x13",
            "extraData": "0x",
            "baseFeePerGas": "0x7",
            "blockHash": "0x306a3844fc9b13239d1ea616e19c4991bb87cafef6c5c6dc0bae3d5b0b73d98e",
            "transactions": [],
            "withdrawals": [
                {
                    "index": "0x0",
                    "validatorIndex": "0xFFFF",
                    "address": "0x0000000000000000000000000000000000000000",
                    "amount": "0"
                },
                {
                    "index": "0x1",
                    "validatorIndex": "0x10000",
                    "address": "0x0100000000000000000000000000000000000000",
                    "amount": "0x100000000000000000000000000000000000000000000000000000000000000"
                },
                {
                    "index": "0x2",
                    "validatorIndex": "0x10001",
                    "address": "0x0200000000000000000000000000000000000000",
                    "amount": "0x200000000000000000000000000000000000000000000000000000000000000"
                },
                {
                    "index": "0x3",
                    "validatorIndex": "0x10002",
                    "address": "0x0300000000000000000000000000000000000000",
                    "amount": "0x300000000000000000000000000000000000000000000000000000000000000"
                },
                {
                    "index": "0x4",
                    "validatorIndex": "0x10003",
                    "address": "0x0400000000000000000000000000000000000000",
                    "amount": "0x400000000000000000000000000000000000000000000000000000000000000"
                },
                {
                    "index": "0x5",
                    "validatorIndex": "0x10004",
                    "address": "0x0500000000000000000000000000000000000000",
                    "amount": "0x500000000000000000000000000000000000000000000000000000000000000"
                },
                {
                    "index": "0x6",
                    "validatorIndex": "0x10005",
                    "address": "0x0600000000000000000000000000000000000000",
                    "amount": "0x600000000000000000000000000000000000000000000000000000000000000"
                },
                {
                    "index": "0x7",
                    "validatorIndex": "0x10006",
                    "address": "0x0700000000000000000000000000000000000000",
                    "amount": "0x700000000000000000000000000000000000000000000000000000000000000"
                }
            ]
        }
    ],
    "id": 67
}

@siladu
Copy link
Contributor

siladu commented Nov 11, 2022

fcU V2 following newPayload

{
  "jsonrpc": "2.0",
  "method": "engine_forkchoiceUpdatedV2",
  "params": [
    {
      "headBlockHash": "0x306a3844fc9b13239d1ea616e19c4991bb87cafef6c5c6dc0bae3d5b0b73d98e",
      "safeBlockHash": "0x306a3844fc9b13239d1ea616e19c4991bb87cafef6c5c6dc0bae3d5b0b73d98e",
      "finalizedBlockHash": "0x306a3844fc9b13239d1ea616e19c4991bb87cafef6c5c6dc0bae3d5b0b73d98e"
    }
  ],
  "id": 69
}

@JsonProperty("prevRandao") final String prevRandao,
@JsonProperty("suggestedFeeRecipient") final String suggestedFeeRecipient,
@JsonProperty("withdrawals") final List<WithdrawalParameter> withdrawals) {
this.timestamp = Long.decode(timestamp);

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
gezero and others added 5 commits November 15, 2022 08:49
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
jframe and others added 5 commits November 15, 2022 08:49
Signed-off-by: Jason Frame <jason.frame@consensys.net>
…hortHexString)

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
This is probably temporary measure and we will need to detect the block using a timestamp in the future
The shanghai.json is useless probably now

Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
gezero and others added 9 commits November 15, 2022 09:23
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
…pella.

This commit might break post-shanghai V2 until I switch the validation depending on the fork.

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Hacky pre/post shanghai validation

Serialize UInt64 toQuantityHexString instead of toShortHexString so 0 is returned as "0x0" instead of "0x"

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
…t contain null withdrawals

This means shanghai can be activated before capella which makes devnets a lot smoother, rather than having to perfectly align capella timestamp with shanghaiBlock

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
…n rules

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
…that contain null withdrawals

This was previously allowed to help with interop with clients that sometimes sent fcuV1 post-capella, but it was off-spec.

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
…bled at genesis

Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
@siladu
Copy link
Contributor

siladu commented Dec 21, 2022

Will likely close this in favour of #4758 since it is more up to date (has shanghaiTime merged in with fixes). Will leave open for now until @gezero confirms it's OK to close.

@siladu siladu removed the TeamGroot GH issues worked on by Groot Team label Dec 22, 2022
@siladu siladu closed this Jan 4, 2023
@siladu siladu mentioned this pull request Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EIP Ethereum Improvement Proposal mainnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants