Skip to content

Commit

Permalink
Add inabox deployment (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
mooselumph authored Jul 3, 2023
1 parent 4ce6193 commit 54bacba
Show file tree
Hide file tree
Showing 31 changed files with 1,701 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test/testdata/*
test/resources/kzg/SRSTables/*
4 changes: 3 additions & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ out/
# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/*/40525/
/broadcast/**/dry-run/

# Docs
Expand All @@ -15,4 +16,5 @@ docs/

data/

script/output/*
script/output/*
script/eigenda_deploy_config.json
2 changes: 1 addition & 1 deletion contracts/lib/eigenlayer-contracts
Submodule eigenlayer-contracts updated 35 files
+0 −67 script/Allocate.s.sol
+200 −0 script/middleware/DeployOpenEigenLayer.s.sol
+12 −7 src/contracts/interfaces/IBLSPubkeyRegistry.sol
+34 −0 src/contracts/interfaces/IBLSRegistryCoordinatorWithIndices.sol
+18 −15 src/contracts/interfaces/IIndexRegistry.sol
+1 −1 src/contracts/interfaces/IQuorumRegistry.sol
+26 −4 src/contracts/interfaces/IRegistryCoordinator.sol
+36 −8 src/contracts/interfaces/IStakeRegistry.sol
+4 −4 src/contracts/interfaces/IVoteWeigher.sol
+20 −10 src/contracts/libraries/BitmapUtils.sol
+79 −7 src/contracts/middleware/BLSOperatorStateRetriever.sol
+29 −8 src/contracts/middleware/BLSPubkeyRegistry.sol
+0 −410 src/contracts/middleware/BLSRegistry.sol
+238 −64 src/contracts/middleware/BLSRegistryCoordinatorWithIndices.sol
+17 −11 src/contracts/middleware/BLSSignatureChecker.sol
+112 −79 src/contracts/middleware/IndexRegistry.sol
+0 −707 src/contracts/middleware/RegistryBase.sol
+99 −72 src/contracts/middleware/StakeRegistry.sol
+3 −1 src/contracts/middleware/StakeRegistryStorage.sol
+1 −1 src/contracts/middleware/VoteWeigherBase.sol
+0 −226 src/contracts/middleware/example/ECDSARegistry.sol
+0 −140 src/contracts/middleware/example/HashThreshold.sol
+480 −480 src/test/Delegation.t.sol
+88 −88 src/test/Registration.t.sol
+303 −306 src/test/Whitelister.t.sol
+349 −349 src/test/Withdrawals.t.sol
+9 −9 src/test/harnesses/BitmapUtilsWrapper.sol
+1 −9 src/test/harnesses/StakeRegistryHarness.sol
+0 −49 src/test/mocks/MiddlewareVoteWeigherMock.sol
+9 −1 src/test/mocks/RegistryCoordinatorMock.sol
+5 −5 src/test/unit/BLSPubkeyRegistryUnit.t.sol
+36 −36 src/test/unit/BitmapUtils.t.sol
+13 −14 src/test/unit/IndexRegistryUnit.t.sol
+1 −1 src/test/unit/StakeRegistryUnit.t.sol
+4 −4 src/test/unit/VoteWeigherBaseUnit.t.sol
2 changes: 1 addition & 1 deletion contracts/lib/openzeppelin-contracts
2 changes: 1 addition & 1 deletion contracts/lib/openzeppelin-contracts-upgradeable
2 changes: 2 additions & 0 deletions contracts/script/SetUpEigenDA.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ contract SetupEigenDA is EigenDADeployer, EigenLayerUtils {

// READ JSON CONFIG DATA
string memory config_data = vm.readFile(deployConfigPath);


uint8 numStrategies = uint8(stdJson.readUint(config_data, ".numStrategies"));
{
address eigenLayerCommunityMultisig = msg.sender;
Expand Down
20 changes: 0 additions & 20 deletions contracts/script/eigenda_deploy_config.json

This file was deleted.

7 changes: 4 additions & 3 deletions disperser/cmd/basic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/Layr-Labs/eigenda/common/logging"
"github.com/Layr-Labs/eigenda/core/encoding"
"github.com/Layr-Labs/eigenda/disperser"
"github.com/Layr-Labs/eigenda/disperser/cmd/basic/flags"
"github.com/Layr-Labs/eigenda/disperser/grpc"
"github.com/urfave/cli"
)
Expand All @@ -25,12 +26,12 @@ func NewConfig(ctx *cli.Context) Config {
EncoderConfig: encoding.ReadCLIConfig(ctx),
LoggerConfig: logging.ReadCLIConfig(ctx),
ServerConfig: grpc.ServerConfig{
GrpcPort: ctx.GlobalString(grpcPortFlag.Name),
GrpcPort: ctx.GlobalString(flags.GrpcPortFlag.Name),
},
BatcherConfig: disperser.BatcherConfig{
PullInterval: ctx.GlobalDuration(pullIntervalFlag.Name),
PullInterval: ctx.GlobalDuration(flags.PullIntervalFlag.Name),
},
Address: ctx.GlobalString(addressFlag.Name),
Address: ctx.GlobalString(flags.AddressFlag.Name),
}
return config
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package flags

import (
"github.com/Layr-Labs/eigenda/common"
Expand All @@ -12,19 +12,19 @@ const envVarPrefix = "DISPERSER"

var (
/* Required Flags */
pullIntervalFlag = cli.DurationFlag{
PullIntervalFlag = cli.DurationFlag{
Name: "pull-interval",
Usage: "Interval at which to pull from the queue",
Required: true,
EnvVar: common.PrefixEnvVar(envVarPrefix, "PULL_INTERVAL"),
}
grpcPortFlag = cli.StringFlag{
GrpcPortFlag = cli.StringFlag{
Name: "grpc-port",
Usage: "Port at which disperser listens for grpc calls",
Required: true,
EnvVar: common.PrefixEnvVar(envVarPrefix, "GRPC_PORT"),
}
addressFlag = cli.StringFlag{
AddressFlag = cli.StringFlag{
Name: "address",
Usage: "Address of the disperser",
Required: true,
Expand All @@ -33,9 +33,9 @@ var (
)

var requiredFlags = []cli.Flag{
pullIntervalFlag,
grpcPortFlag,
addressFlag,
PullIntervalFlag,
GrpcPortFlag,
AddressFlag,
}

var optionalFlags = []cli.Flag{}
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/consensys/gnark-crypto v0.8.0
github.com/ethereum/go-ethereum v1.10.26
github.com/golang/protobuf v1.5.3
github.com/joho/godotenv v1.5.1
github.com/onsi/ginkgo/v2 v2.9.7
github.com/onsi/gomega v1.27.7
github.com/prometheus/client_golang v1.16.0
Expand Down Expand Up @@ -69,6 +70,6 @@ require (
golang.org/x/tools v0.10.1-0.20230622221742-0622ad2359a7 // indirect
google.golang.org/protobuf v1.31.0
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v3 v3.0.1
rsc.io/tmplfunc v0.0.3 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down
Empty file removed test/.keep
Empty file.
16 changes: 16 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

setup-geth:
cd testbed/geth && rm -rf data && ./run.sh setup 40 ./secret/private-keys.txt ./secret/geth-account-password

start-chain:
cd testbed && docker compose up -d
cd testbed && ./wait-for http://0.0.0.0:8545 -- echo "Geth up"

stop-chain:
cd testbed && docker compose down

new-exp:
./new-exp.sh

run-exp:
./run-exp.sh
39 changes: 39 additions & 0 deletions test/deploy/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"
"os"

"flag"

"github.com/Layr-Labs/eigenda/test/deploy"
)

const (
pathFlagName = "path"
pathEnvName = "EIGENDA_TESTDATA_PATH"
)

var pathFlag string

func init() {
flag.StringVar(&pathFlag, pathFlagName, "", "path at which to read config. Alternatively, set the "+pathEnvName+" environment variable")
}

func main() {

flag.Parse()

if pathFlag == "" {
pathFlag = os.Getenv(pathEnvName)
}

if pathFlag == "" {
fmt.Println("No config path received. Exiting.")
return
}

testEnv := deploy.NewTestConfig(pathFlag)
testEnv.DeployExperiment()

}
105 changes: 105 additions & 0 deletions test/deploy/codegen/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package main

import (
"bytes"
"fmt"
"log"
"os"
"text/template"

dis "github.com/Layr-Labs/eigenda/disperser/cmd/basic/flags"
opr "github.com/Layr-Labs/eigenda/node/flags"

"github.com/urfave/cli"
)

var myTemplate = `
type {{.Name}} struct{
{{range $var := .Fields}}
{{$var.EnvVar}} string
{{end}}
}
func (vars {{.Name}}) getEnvMap() map[string]string {
v := reflect.ValueOf(vars)
envMap := make(map[string]string)
for i := 0; i < v.NumField(); i++ {
envMap[v.Type().Field(i).Name] = v.Field(i).String()
}
return envMap
}
`

type ServiceConfig struct {
Name string
Fields []Flag
}

type Flag struct {
Name string
EnvVar string
}

func getFlag(flag cli.Flag) Flag {
strFlag, ok := flag.(cli.StringFlag)
if ok {
return Flag{strFlag.Name, strFlag.EnvVar}
}
boolFlag, ok := flag.(cli.BoolFlag)
if ok {
return Flag{boolFlag.Name, boolFlag.EnvVar}
}
intFlag, ok := flag.(cli.IntFlag)
if ok {
return Flag{intFlag.Name, intFlag.EnvVar}
}
uint64Flag, ok := flag.(cli.Uint64Flag)
if ok {
return Flag{uint64Flag.Name, uint64Flag.EnvVar}
}
durationFlag, ok := flag.(cli.DurationFlag)
if ok {
return Flag{durationFlag.Name, durationFlag.EnvVar}
}
log.Fatalln("Type not found", flag)
return Flag{}
}

func genVars(name string, flags []cli.Flag) string {

t, err := template.New("vars").Parse(myTemplate)
if err != nil {
panic(err)
}

vars := make([]Flag, 0)
for _, flag := range flags {
vars = append(vars, getFlag(flag))
}

var doc bytes.Buffer
err = t.Execute(&doc, ServiceConfig{name, vars})
if err != nil {
panic(err)
}

return doc.String()

}

func main() {

configs := `package deploy
import "reflect"
`

configs += genVars("DisperserVars", dis.Flags)
configs += genVars("OperatorVars", opr.Flags)

fmt.Println(configs)

err := os.WriteFile("../env_vars.go", []byte(configs), 0644)
if err != nil {
log.Panicf("Failed to write file. Err: %s", err)
}
}
Loading

0 comments on commit 54bacba

Please sign in to comment.