-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy patheigen_pod_proofs_test.go
88 lines (74 loc) · 2.3 KB
/
eigen_pod_proofs_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package eigenpodproofs_test
import (
"os"
"testing"
eigenpodproofs "github.com/Layr-Labs/eigenpod-proofs-generation"
"github.com/Layr-Labs/eigenpod-proofs-generation/beacon"
BeaconChainProofsWrapper "github.com/Layr-Labs/eigenpod-proofs-generation/bindings/BeaconChainProofsWrapper"
"github.com/Layr-Labs/eigenpod-proofs-generation/common"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/joho/godotenv"
)
var BEACON_CHAIN_PROOFS_WRAPPER_ADDRESS = gethcommon.HexToAddress("0x874Be4b0CaC8D3F6286Eee6E6196553aabA8Cb85")
var (
beaconHeader *phase0.BeaconBlockHeader
beaconState *spec.VersionedBeaconState
beaconChainProofsWrapper *BeaconChainProofsWrapper.BeaconChainProofsWrapper
epp *eigenpodproofs.EigenPodProofs
)
func loadBeaconState(headerPath, statePath string, chainID uint64) error {
headerBytes, err := common.ReadFile(headerPath)
if err != nil {
return err
}
stateBytes, err := common.ReadFile(statePath)
if err != nil {
return err
}
beaconHeader = &phase0.BeaconBlockHeader{}
if err := beaconHeader.UnmarshalJSON(headerBytes); err != nil {
return err
}
beaconState, err = beacon.UnmarshalSSZVersionedBeaconState(stateBytes)
if err != nil {
return err
}
epp, err = eigenpodproofs.NewEigenPodProofs(chainID, 600)
return err
}
func TestMain(m *testing.M) {
// Load .env file
godotenv.Load()
rpcURL := os.Getenv("RPC_URL")
if rpcURL == "" {
panic("RPC_URL must be set in .env file")
}
ethClient, err := ethclient.Dial(rpcURL)
if err != nil {
panic(err)
}
beaconChainProofsWrapper, err = BeaconChainProofsWrapper.NewBeaconChainProofsWrapper(BEACON_CHAIN_PROOFS_WRAPPER_ADDRESS, ethClient)
if err != nil {
panic(err)
}
// Run tests for each hard fork type
if err := loadBeaconState(
"data/electra_mekong_beacon_headers_654719.json",
"data/electra_mekong_beacon_state_654719.ssz",
17000, // Use 17000 for Mekong, this check isn't relevant for Electra
); err != nil {
panic(err)
}
m.Run()
if err := loadBeaconState(
"data/deneb_holesky_beacon_headers_2227472.json",
"data/deneb_holesky_beacon_state_2227472.ssz",
17000,
); err != nil {
panic(err)
}
m.Run()
}