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

M2 Mainnet w/ deneb proofs #24

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
893caee
initial commit, added new proofs, modified withdrawal params
Sidu28 Jan 7, 2024
e475195
changed file names
Sidu28 Jan 8, 2024
90342c9
Update README.md
Sidu28 Jan 8, 2024
51b01da
fixed block header sample file
Sidu28 Jan 8, 2024
743a827
removed validator balance proof logic
Sidu28 Jan 13, 2024
ab932f5
init commit
Sidu28 Jan 19, 2024
606a3f3
updated to deneb, code building
Sidu28 Jan 19, 2024
78815e8
proofs work
Sidu28 Jan 19, 2024
577b4ad
TestStateRootAgainstLatestBlockHeaderProof working
Sidu28 Jan 19, 2024
db912dc
fixed index
Sidu28 Jan 19, 2024
5873d71
removed zip files
Sidu28 Jan 19, 2024
5f3e0aa
pusing files
Sidu28 Jan 19, 2024
de93801
fixed CI yml file
Sidu28 Jan 19, 2024
7f5a813
added gitignore
Sidu28 Jan 19, 2024
049bd09
added missing header file
Sidu28 Jan 19, 2024
5353ed1
CI passing
Sidu28 Jan 19, 2024
92d2933
fixed HistoricalSummaries test
Sidu28 Jan 19, 2024
2cb60bb
added solidityProofGenTesting to eigenpodsproof generation with deneb
Sidu28 Jan 19, 2024
6679a8e
fixed yml
Sidu28 Jan 19, 2024
d64ebae
fixed yml
Sidu28 Jan 20, 2024
0aed185
fixed yml
Sidu28 Jan 20, 2024
9b4e3b7
removed unused file
Sidu28 Jan 23, 2024
f574e63
adding capella files back for capella withdrawals against deneb state…
Sidu28 Jan 23, 2024
23230bd
added new test
Sidu28 Jan 23, 2024
72f38e1
added TestGetHistoricalSummariesBlockRootsProofProofCapellaAgainstDeneb
Sidu28 Jan 23, 2024
b2d2bc4
added deneb and capella support
Sidu28 Jan 23, 2024
b590afb
added yml
Sidu28 Jan 23, 2024
6e5c93b
executionPayloadMerkleSubtreeNumLayers -> executionPayloadMerkleSubtr…
Sidu28 Jan 23, 2024
d36b83d
deleted extraneous files
Sidu28 Jan 23, 2024
55f6b8c
move low level proofs to separate folder
gpsanant Jan 23, 2024
b1c184b
make caching less specific
gpsanant Jan 23, 2024
92eecac
generation separated
gpsanant Jan 23, 2024
172b97e
get proofs compiling
gpsanant Jan 23, 2024
9498897
delete unused files
gpsanant Jan 23, 2024
ec85721
rm slot?
gpsanant Jan 23, 2024
012d80c
fix pkg name
mpjunior92 Jan 23, 2024
47a489a
group const
mpjunior92 Jan 23, 2024
1ae8fd9
remove duplicated constants file
mpjunior92 Jan 23, 2024
7d8a141
import constants from beacon pkg
mpjunior92 Jan 23, 2024
856ab6a
remove go mod from data folder
mpjunior92 Jan 23, 2024
6b01966
add missing slot
mpjunior92 Jan 23, 2024
3f98ddc
be explicit about beacon state hardfork type
mpjunior92 Jan 23, 2024
f642bc7
source state from header
gpsanant Jan 24, 2024
343de71
fix cache
gpsanant Jan 24, 2024
882b112
Merge pull request #22 from Layr-Labs/deneb-cleanup
Sidu28 Jan 25, 2024
4ebfb96
cleanup
Sidu28 Jan 25, 2024
cacf177
updated gitignore
Sidu28 Jan 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
6 changes: 4 additions & 2 deletions .github/workflows/go_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
- name: Install Unzip
run: sudo apt-get install unzip
- name: Unzip the File 1
run: unzip data/goerli_slot_6397852.json.zip -d ./data
run: unzip data/deneb_goerli_slot_7413760.json.zip -d ./data
- name: Unzip the File 2
run: unzip data/goerli_slot_6397952.json.zip -d ./data
- name: Unzip the File 3
run: unzip data/goerli_slot_6399998.json.zip -d ./data
run: unzip data/deneb_goerli_slot_7431952.json.zip -d ./data
- name: Unzip the File 3
run: unzip data/deneb_goerli_slot_7421952.json.zip -d ./data

- name: Set up Go 1.x
uses: actions/setup-go@v2
Expand Down
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
data/goerli_slot_6397852.json
data/goerli_slot_6397952.json
data/goerli_slot_6399998.json
data/goerli_slot_6399998.json
data/deneb_slot_7426414.json
data/deneb_goerli_slot_7416760.json
data/deneb_goerli_slot_7413760.json
data/deneb_goerli_slot_7421952.json
data/deneb_goerli_slot_7431952.json

generation/generation

solidityProofGen/solidityProofGen


test

**/.DS_Store
Binary file removed ProofGeneration
Binary file not shown.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This package allows you to generate withdrawal credential proofs, withdrawal pro
## Build the Executable

```
$cd proofGenCli
$go build
```

Expand All @@ -21,7 +22,7 @@ $ ./proof-gen -command ValidatorFieldsProof -oracleBlockHeaderFile [ORACLE_BLOCK
```
Here is an example of running this command with the sample state/block files in the `/data` folder
```
./proof-gen -command ValidatorFieldsProof -oracleBlockHeaderFile "data/goerli_block_header_6399998.json" -stateFile "data/goerli_slot_6399998.json" -validatorIndex 302913 -outputFile "withdrawal_credential_proof_302913.json" -chainID 5
./proof-gen -command ValidatorFieldsProof -oracleBlockHeaderFile "../data/goerli_block_header_6399998.json" -stateFile "../data/goerli_slot_6399998.json" -validatorIndex 302913 -outputFile "withdrawal_credential_proof_302913.json" -chainID 5
```
### Generate Withdrawal Proof
Here is the command:
Expand All @@ -31,7 +32,7 @@ $ ./proofGeneration -command WithdrawalFieldsProof -oracleBlockHeaderFile [ORACL
Here is an example of running this command with the sample state/block files in the `/data` folder

```
./proofGeneration -command WithdrawalFieldsProof -oracleBlockHeaderFile "data/goerli_block_header_6399998.json" -stateFile "data/goerli_slot_6399998.json" -validatorIndex 200240 -outputFile "withdrawal_proof_302913.json" -chainID 5 -historicalSummariesIndex 146 -blockHeaderIndex 8092 -historicalSummaryStateFile "data/goerli_slot_6397852.json" -blockHeaderFile "data/goerli_block_header_6397852.json" -blockBodyFile "data/goerli_block_6397852.json" -withdrawalIndex 0
./proofGeneration -command WithdrawalFieldsProof -oracleBlockHeaderFile "../data/goerli_block_header_6399998.json" -stateFile "../data/goerli_slot_6399998.json" -validatorIndex 200240 -outputFile "withdrawal_proof_302913.json" -chainID 5 -historicalSummariesIndex 146 -blockHeaderIndex 8092 -historicalSummaryStateFile "../data/goerli_slot_6397852.json" -blockHeaderFile "../data/goerli_block_header_6397852.json" -blockBodyFile "../data/goerli_block_6397852.json" -withdrawalIndex 0
```

### Generate a Balance Update Proof.
Expand All @@ -40,7 +41,7 @@ $ ./proofGeneration "BalanceUpdateProof" -oracleBlockHeaderFile [ORACLE_BLOCK_H
```
Here is an example of running this command with the sample state/block files in the `/data` folder:
```
./proof-gen -command BalanceUpdateProof -oracleBlockHeaderFile "data/goerli_block_header_6399998.json" -stateFile "data/goerli_slot_6399998.json" -validatorIndex 302913 -outputFile "withdrawal_credential_proof_302913.json" -chainID 5
./proof-gen -command BalanceUpdateProof -oracleBlockHeaderFile "../data/goerli_block_header_6399998.json" -stateFile "../data/goerli_slot_6399998.json" -validatorIndex 302913 -outputFile "withdrawal_credential_proof_302913.json" -chainID 5
```

# Proof Generation Input Glossary
Expand Down
56 changes: 56 additions & 0 deletions beacon/beacon_state_top_level_roots.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package beacon

import (
"reflect"

"github.com/Layr-Labs/eigenpod-proofs-generation/common"
"github.com/attestantio/go-eth2-client/spec/phase0"
)

type BeaconStateTopLevelRoots struct {
GenesisTimeRoot *phase0.Root
GenesisValidatorsRoot *phase0.Root
SlotRoot *phase0.Root
ForkRoot *phase0.Root
LatestBlockHeaderRoot *phase0.Root
BlockRootsRoot *phase0.Root
StateRootsRoot *phase0.Root
HistoricalRootsRoot *phase0.Root
ETH1DataRoot *phase0.Root
ETH1DataVotesRoot *phase0.Root
ETH1DepositIndexRoot *phase0.Root
ValidatorsRoot *phase0.Root
BalancesRoot *phase0.Root
RANDAOMixesRoot *phase0.Root
SlashingsRoot *phase0.Root
PreviousEpochParticipationRoot *phase0.Root
CurrentEpochParticipationRoot *phase0.Root
JustificationBitsRoot *phase0.Root
PreviousJustifiedCheckpointRoot *phase0.Root
CurrentJustifiedCheckpointRoot *phase0.Root
FinalizedCheckpointRoot *phase0.Root
InactivityScoresRoot *phase0.Root
CurrentSyncCommitteeRoot *phase0.Root
NextSyncCommitteeRoot *phase0.Root
LatestExecutionPayloadHeaderRoot *phase0.Root
NextWithdrawalIndexRoot *phase0.Root
NextWithdrawalValidatorIndexRoot *phase0.Root
HistoricalSummariesRoot *phase0.Root
}

func ProveBeaconTopLevelRootAgainstBeaconState(beaconTopLevelRoots *BeaconStateTopLevelRoots, index uint64) (common.Proof, error) {
v := reflect.ValueOf(*beaconTopLevelRoots)
beaconTopLevelRootsList := make([]interface{}, v.NumField())
for i := 0; i < v.NumField(); i++ {
r := v.Field(i).Interface()
typedR := r.(*phase0.Root)
beaconTopLevelRootsList[i] = *typedR

}
roots := make([]phase0.Root, len(beaconTopLevelRootsList))
for i, v := range beaconTopLevelRootsList {
roots[i] = v.(phase0.Root)
}

return common.GetProof(roots, index, beaconStateMerkleSubtreeNumLayers)
}
65 changes: 65 additions & 0 deletions beacon/block.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package beacon

import (
"github.com/Layr-Labs/eigenpod-proofs-generation/common"
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
)

func ProveBlockBodyAgainstBlockHeader(blockHeader *phase0.BeaconBlockHeader) (common.Proof, error) {
blockHeaderContainerRoots, err := GetBlockHeaderFieldRoots(blockHeader)

if err != nil {
return nil, err
}

return common.GetProof(blockHeaderContainerRoots, BeaconBlockBodyRootIndex, blockHeaderMerkleSubtreeNumLayers)
}

// refer to this: https://github.com/attestantio/go-eth2-client/blob/654ac05b4c534d96562329f988655e49e5743ff5/spec/phase0/beaconblockheader_encoding.go
func ProveStateRootAgainstBlockHeader(b *phase0.BeaconBlockHeader) (common.Proof, error) {

beaconBlockHeaderContainerRoots, err := GetBlockHeaderFieldRoots(b)
if err != nil {
return nil, err
}

return common.GetProof(beaconBlockHeaderContainerRoots, stateRootIndex, blockHeaderMerkleSubtreeNumLayers)
}

func ProveSlotAgainstBlockHeader(blockHeader *phase0.BeaconBlockHeader) (common.Proof, error) {
blockHeaderContainerRoots, err := GetBlockHeaderFieldRoots(blockHeader)
if err != nil {
return nil, err
}

return common.GetProof(blockHeaderContainerRoots, SlotIndex, blockHeaderMerkleSubtreeNumLayers)
}

func GetBlockHeaderFieldRoots(blockHeader *phase0.BeaconBlockHeader) ([]phase0.Root, error) {
blockHeaderContainerRoots := make([]phase0.Root, beaconBlockHeaderNumFields)

hh := ssz.NewHasher()

hh.PutUint64(uint64(blockHeader.Slot))
copy(blockHeaderContainerRoots[0][:], hh.Hash())
hh.Reset()

hh.PutUint64(uint64(blockHeader.ProposerIndex))
copy(blockHeaderContainerRoots[1][:], hh.Hash())
hh.Reset()

hh.PutBytes(blockHeader.ParentRoot[:])
copy(blockHeaderContainerRoots[2][:], hh.Hash())
hh.Reset()

hh.PutBytes(blockHeader.StateRoot[:])
copy(blockHeaderContainerRoots[3][:], hh.Hash())
hh.Reset()

hh.PutBytes(blockHeader.BodyRoot[:])
copy(blockHeaderContainerRoots[4][:], hh.Hash())
hh.Reset()

return blockHeaderContainerRoots, nil
}
Loading
Loading