Skip to content

Commit

Permalink
added chainID checks in prove_withdrawal.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddy J committed Dec 5, 2023
1 parent 67941b8 commit 862b58f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion generate_withdrawal_fields_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func GenerateWithdrawalFieldsProof(
if err != nil {
log.Debug().AnErr("GenerateWithdrawalFieldsProof: error with ComputeBeaconStateTopLevelRoots", err)
}
withdrawalProof, err := epp.ProveWithdrawal(&oracleBeaconBlockHeader, &state, oracleBeaconStateTopLevelRoots, historicalSummaryState.BlockRoots, &withdrawalBlock, uint64(validatorIndex), FIRST_CAPELLA_SLOT_GOERLI)
withdrawalProof, err := epp.ProveWithdrawal(&oracleBeaconBlockHeader, &state, oracleBeaconStateTopLevelRoots, historicalSummaryState.BlockRoots, &withdrawalBlock, uint64(validatorIndex))
if err != nil {
log.Debug().AnErr("GenerateWithdrawalFieldsProof: error with ProveWithdrawal", err)
}
Expand Down
17 changes: 8 additions & 9 deletions prove_withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,10 @@ func (epp *EigenPodProofs) ProveWithdrawals(
verifyAndProcessWithdrawalCallParams.ValidatorFieldsProofs = make([]Proof, len(withdrawalBlocks))
verifyAndProcessWithdrawalCallParams.ValidatorFields = make([][]Bytes32, len(withdrawalBlocks))

var FIRST_CAPELLA_SLOT uint64
if epp.chainID == 5 {
FIRST_CAPELLA_SLOT = FIRST_CAPELLA_SLOT_GOERLI
} else if epp.chainID == 1 {
FIRST_CAPELLA_SLOT = FIRST_CAPELLA_SLOT_MAINNET
}

for i, _ := range withdrawalBlocks {
start := time.Now()
// prove withdrawal
verifyAndProcessWithdrawalCallParams.WithdrawalProofs[i], err = epp.ProveWithdrawal(oracleBlockHeader, oracleBeaconState, oracleBeaconStateTopLevelRoots, historicalSummaryStateBlockRoots[i], withdrawalBlocks[i], validatorIndices[i], FIRST_CAPELLA_SLOT)
verifyAndProcessWithdrawalCallParams.WithdrawalProofs[i], err = epp.ProveWithdrawal(oracleBlockHeader, oracleBeaconState, oracleBeaconStateTopLevelRoots, historicalSummaryStateBlockRoots[i], withdrawalBlocks[i], validatorIndices[i])
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -152,7 +145,6 @@ func (epp *EigenPodProofs) ProveWithdrawal(
historicalSummaryStateBlockRoots []phase0.Root,
withdrawalBlock *capella.BeaconBlock,
validatorIndex uint64,
FIRST_CAPELLA_SLOT uint64,
) (*WithdrawalProof, error) {
withdrawalProof := &WithdrawalProof{}
withdrawalProof.WithdrawalIndex = math.MaxUint64 // max uint 64 value
Expand All @@ -166,6 +158,13 @@ func (epp *EigenPodProofs) ProveWithdrawal(
return nil, errors.New("validator index not found in withdrawal block")
}

var FIRST_CAPELLA_SLOT uint64
if epp.chainID == 5 {
FIRST_CAPELLA_SLOT = FIRST_CAPELLA_SLOT_GOERLI
} else if epp.chainID == 1 {
FIRST_CAPELLA_SLOT = FIRST_CAPELLA_SLOT_MAINNET
}

withdrawalSlotUint64 := uint64(withdrawalBlock.Slot)

// index of the historical summary in the array of historical_summaries
Expand Down
1 change: 1 addition & 0 deletions withdrawal_proof_302913.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"StateRootAgainstLatestBlockHeaderProof":["0x0000000000000000000000000000000000000000000000000000000000000000","0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b","0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71"],"beaconStateRoot":"0x9150ef194c1028ae7b938602b896a5c3649f8bb37943a0d742f0e675e1af71cf","WithdrawalProof":["0xa3d843f57c18ee3dac0eb263e446fe5d0110059137807d3cae4a2e60ccca013f","0x87441da495942a4af734cbca4dbcf0b96b2d83137ce595c9f29495aae6a8d99e","0xae0dc609ecbfb26abc191227a76efb332aaea29725253756f2cad136ef5837a6","0x765bcd075991ecad96203020d1576fdb9b45b41dad3b5adde11263ab9f6f56b8","0x1000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x9d9b56c23faa6a8abf0a49105eb12bbdfdf198a9c6c616b8f24f6e91ad79de92","0xac5e32ea973e990d191039e91c7d9fd9830599b8208675f159c3df128228e729","0x38914949a92dc9e402aee96301b080f769f06d752a32acecaa0458cba66cf471"],"SlotProof":["0x89c5010000000000000000000000000000000000000000000000000000000000","0xab4a015ca78ff722e478d047b19650dc6fc92a4270c6cd34401523d3d6a1d9f2","0xb25904ef9045e860747d260b8d0d8aea5b082430a72209fc43757c68b23d541a"],"ExecutionPayloadProof":["0xb6a435ffd17014d1dad214ba466aaa7fba5aa247945d2c29fd53e90d554f4474","0x336488033fe5f3ef4ccc12af07b9370b92e553e35ecb4a337a1b1c0e4afe1e0e","0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71","0x5ec9aaf0a3571602f4704d4471b9af564caf17e4d22a7c31017293cb95949053","0x0000000000000000000000000000000000000000000000000000000000000000","0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b","0xc1f7cb289e44e9f711d7d7c05b67b84b8c6dd0394b688922a490cfd3fe216db1"],"TimestampProof":["0x28a2c80000000000000000000000000000000000000000000000000000000000","0xa749df3368741198702798435eea361b1b1946aa9456587a2be377c8472ea2df","0x4d8ad7ffe6efda168a4d2a908228a88e5c03553d422e6e65e350b6fc4beea417","0x38914949a92dc9e402aee96301b080f769f06d752a32acecaa0458cba66cf471"],"HistoricalSummaryProof":["0x050b5923fe2e470849a7d467e4cbed4803d3a46d516b84552567976960ff4ccc","0x6ab9b5fc357c793cc5339398016c28ea21f0be4d56a68b554a29766dd312eeeb","0xb8c4c9f1dec537f4c4652e6bf519bac768e85b2590b7683e392aab698b50d529","0x1cae4e7facb6883024359eb1e9212d36e68a106a7733dc1c099017a74e5f465a","0x616439c1379e10fc6ad2fa192a2e49c2d5a7155fdde95911f37fcfb75952fcb2","0x301ab0d5d5ada4bd2e859658fc31743b5a502b26bc9b8b162e5a161e21218048","0x9d2bc97fffd61659313009e67a4c729a10274f2af26914a53bc7af6717da211e","0x4bdcbe543f9ef7348855aac43d6b6286f9c0c7be53de8a1300bea1ba5ba0758e","0xb6631640d626ea9523ae619a42633072614326cc9220462dffdeb63e804ef05f","0xf19a76e33ca189a8682ece523c2afda138db575955b7af31a427c9b8adb41e15","0x221b43ad87d7410624842cad296fc48360b5bf4e835f6ff610db736774d2f2d3","0x297c51f4ff236db943bebeb35538e207c8de6330d26aa8138a9ca206f42154bf","0x129a0644f33b9ee4e9a36a11dd59d1dedc64012fbb7a79263d07f82d647ffba8","0x763794c2042b9c8381ac7c4d7f4d38b0abb38069b2810b522f87951f25d9d2be","0x0000000000000000000000000000000000000000000000000000000000000000","0xee0639a2ada97368e8b3493f9d2141e16c3cd9fe54e13691bb7a2c376c56c7c8","0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71","0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c","0xba2bc704559c23541f0c9efa0b522454e8cd06cd504d0e45724709cf5672640f","0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30","0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1","0xff857f4c17c9fb2e544e496685ebd8e2258c761e4636cfb031ba73a4430061c7","0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193","0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1","0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b","0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220","0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f","0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e","0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784","0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb","0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb","0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab","0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4","0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f","0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa","0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c","0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167","0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7","0x9300000000000000000000000000000000000000000000000000000000000000","0xd9ed050000000000000000000000000000000000000000000000000000000000","0xd824a89a9d5dd329a069b394ddc6618c70ed784982061959ac77d58d48e9d7c8","0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71","0x8dc0b81ebe27fb91663a74713252d2eae5deb3b983374afc3c2d2f6b254128f1","0xe237bc62b6b5269da5f4093c292d0f3bf2cf4d2eb93b4f366dba675c4df9cc62"],"blockHeaderRootIndex":8092,"historicalSummaryIndex":146,"withdrawalIndex":0,"blockHeaderRoot":"0x602079191479eb9a5dce271b11aa16c5035795f44e3deb4bb02bc6f7f4fd15a6","slotRoot":"0x9c9f610000000000000000000000000000000000000000000000000000000000","timestampRoot":"0xb06fed6400000000000000000000000000000000000000000000000000000000","executionPayloadRoot":"0x7a882c601a1e6bb6d76fbff30cd46ec84bf7eccced88e085f1c5a291fd9c5c00","ValidatorProof":["0xa551043de43704c1ec4ea19cf0f78b0fd0435f8ed4b9239a4ecf45146c992055","0x7d00fbb77892999b9a3c9a59aae241405c7d28985ec1cf3bc4141371fde86236","0x578200ee4a0b0203db67a6d85bb6e826e2dda09c0e558099743800b805ee9d83","0xad3f688069225989095e1d4ba532d85f18812c26678f4ecd6ef9481f976ab112","0xee691172855dcfdaf3ac4fde83e16c81a8dc4bf1a936088245efce61ea62e7a1","0x6a421ff9e5121f54b9eab04758cfd01942079a7c6959b1c5fdad7972d8133ffd","0x8a631b87145c9ac69adc27a08b11e237c07458e889e183528e3852fc94b9ec4f","0xacab6be49023dadb3a2ab84c1b20e2abbaf92788091768178236a5fe5afe39d0","0x0759f08bd9d31971ada5f94a21e5a616871f10865893b0e4172e01178fb903db","0x87d65be424fb1debe7a20b26ef5f968d7961a1adaecb258540440d7cee3d4cdc","0x30e8565ca8cc1c1465b8a3342a79c4ea16e12ff46734bf5c6aeb2e4517e0f50b","0xd84dedf5932c76cca76fc185bb20af4ea0917fb45f79107c3444392eb1de949e","0x3c1735187981807ec62005c128ddbf1793c1a4d78c39e191249332452ebb9e14","0x5bd5dfe5ed45182bf45a7af5a4b088ed4408ec3018b2a5ca1f4cebbdead3164a","0x4eff245fad29ee570349a5001e3e62c7cb7e0fe0f49172e3bfa5b7b6c5c03b5e","0xe039e904678355d2de44d93ee3537061634425e41d243520d36129792852215d","0x7319b9f76b971853f0e6e2fe0cc559edb31c1370642be78f1d25a6c2bfb92103","0x036fd6439ae6e618ef00290144d95d21d71b9d6118bc72eb0af4e5d5a025941a","0xcce600acb536bbaf3ee8c74f9a573717eedb2756b9bf92983455b536084a6057","0x3d3aabf6c36de4242fef4b6e49441c24451ccf0e8e184a33bece69d3e3d40ac3","0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa","0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c","0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167","0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7","0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0","0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544","0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765","0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4","0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1","0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636","0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c","0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7","0xc6f67e02e6e4e1bdefb994c6098953f34636ba2b6ca20a4721d2b26a886722ff","0x1c9a7e5ff1cf48b4ad1582d3f4e4a1004f3b20d8c5a2b71387a4254ad933ebc5","0x2f075ae229646b6f6aed19a5e372cf295081401eb893ff599b3f9acc0c0d3e7d","0x328921deb59612076801e8cd61592107b5c67c79b846595cc6320c395b46362c","0xbfb909fdb236ad2411b4e4883810a074b840464689986c3f8a8091827e17c327","0x55d8fb3687ba3ba49f342c77f5a1f89bec83d811446e1a467139213d640b6a74","0xf7210d4f8e7e1039790e7bf4efa207555a10a6db1dd4b95da313aaa88b88fe76","0xad21b516cbc645ffe34ab5de1c8aef8cd4e7f8d2b51e8e1456adc7563cda206f","0x846b080000000000000000000000000000000000000000000000000000000000","0x5a6c050000000000000000000000000000000000000000000000000000000000","0x47314ebc95c63f3fd909af6442ed250d823b2ee8a6e48d8167d4dfdab96c8b5e","0xce3d1b002aa817e3718132b7ffe6cea677f81b1b3b690b8052732d8e1a70d06b","0x4715bf9a259680cd06827b30bddb27ad445506e9edeb72a3eab904d94dea816b","0x5ba049ff558dd0ff1eadf2cef346aac41b7059433f21925b345f1024af18057d"],"ValidatorFields":["0xf5636344319e7ca95ab4767480405cddbbbb7fcf437c5504fe336ae7995ce1fc","0x01000000000000000000000059b0d71688da01057c08e4c1baa8faa629819c2a","0x0040597307000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0xffffffffffffffff000000000000000000000000000000000000000000000000","0xffffffffffffffff000000000000000000000000000000000000000000000000"],"WithdrawalFields":["0x45cee50000000000000000000000000000000000000000000000000000000000","0x300e030000000000000000000000000000000000000000000000000000000000","0x59b0d71688da01057c08e4c1baa8faa629819c2a000000000000000000000000","0xbd56200000000000000000000000000000000000000000000000000000000000"]}
Loading

0 comments on commit 862b58f

Please sign in to comment.