Skip to content

Commit

Permalink
initial commit, added new proofs, modified withdrawal params
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidu28 committed Jan 7, 2024
1 parent caa8123 commit 893caee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
Binary file modified data/.DS_Store
Binary file not shown.
31 changes: 4 additions & 27 deletions proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,33 +462,10 @@ func ProveExecutionPayloadAgainstBlockBody(beaconBlockBody *capella.BeaconBlockB
// refer to this: https://github.com/attestantio/go-eth2-client/blob/654ac05b4c534d96562329f988655e49e5743ff5/spec/phase0/beaconblockheader_encoding.go
func ProveStateRootAgainstBlockHeader(b *phase0.BeaconBlockHeader) (Proof, error) {

beaconBlockHeaderContainerRoots := make([]phase0.Root, 5)
hh := ssz.NewHasher()

// Field (0) 'Slot'
hh.PutUint64(uint64(b.Slot))
copy(beaconBlockHeaderContainerRoots[0][:], hh.Hash())
hh.Reset()

// Field (1) 'ProposerIndex'
hh.PutUint64(uint64(b.ProposerIndex))
copy(beaconBlockHeaderContainerRoots[1][:], hh.Hash())
hh.Reset()

// Field (2) 'ParentRoot'
hh.PutBytes(b.ParentRoot[:])
copy(beaconBlockHeaderContainerRoots[2][:], hh.Hash())
hh.Reset()

// Field (3) 'StateRoot'
hh.PutBytes(b.StateRoot[:])
copy(beaconBlockHeaderContainerRoots[3][:], hh.Hash())
hh.Reset()

// Field (4) 'BodyRoot'
hh.PutBytes(b.BodyRoot[:])
copy(beaconBlockHeaderContainerRoots[4][:], hh.Hash())
hh.Reset()
beaconBlockHeaderContainerRoots, err := GetBlockHeaderFieldRoots(b)
if err != nil {
return nil, err
}

return GetProof(beaconBlockHeaderContainerRoots, stateRootIndex, blockHeaderMerkleSubtreeNumLayers)
}
Expand Down
10 changes: 10 additions & 0 deletions prove_withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type WithdrawalProof struct {
type StateRootProof struct {
BeaconStateRoot phase0.Root `json:"beaconStateRoot"`
StateRootProof Proof `json:"stateRootProof"`
Slot phase0.Slot `json:"slot"`
SlotRootProof Proof `json:"slotRootProof"` //Note: this slot root is oracle block root being used to prove partial withdrawals is after the specified range of blocks requested by the user
}

const FIRST_CAPELLA_SLOT_GOERLI = uint64(5193728)
Expand Down Expand Up @@ -101,6 +103,14 @@ func (epp *EigenPodProofs) ProveWithdrawals(
return nil, err
}

// Note: this slot and slot root proof are used for partial withdrawal proofs to ensure that the oracle root slot is after the specified range of blocks requested by the user
verifyAndProcessWithdrawalCallParams.StateRootProof.Slot = oracleBlockHeader.Slot

verifyAndProcessWithdrawalCallParams.StateRootProof.SlotRootProof, err = ProveSlotAgainstBlockHeader(oracleBlockHeader)
if err != nil {
return nil, err
}

verifyAndProcessWithdrawalCallParams.OracleTimestamp = GetSlotTimestamp(oracleBeaconState, oracleBlockHeader)

verifyAndProcessWithdrawalCallParams.WithdrawalProofs = make([]*WithdrawalProof, len(withdrawalBlocks))
Expand Down

0 comments on commit 893caee

Please sign in to comment.