diff --git a/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go b/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go index ddaa802a..cb1c2f30 100644 --- a/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go +++ b/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go @@ -8,13 +8,11 @@ import ( "strings" "time" - "github.com/Layr-Labs/sidecar/pkg/storage" - "github.com/Layr-Labs/sidecar/pkg/utils" - "github.com/Layr-Labs/sidecar/internal/config" "github.com/Layr-Labs/sidecar/pkg/eigenState/base" "github.com/Layr-Labs/sidecar/pkg/eigenState/stateManager" "github.com/Layr-Labs/sidecar/pkg/eigenState/types" + "github.com/Layr-Labs/sidecar/pkg/storage" "go.uber.org/zap" "golang.org/x/xerrors" "gorm.io/gorm" @@ -231,28 +229,28 @@ func (oas *OperatorAVSSplitModel) CommitFinalState(blockNumber uint64) error { } // GenerateStateRoot generates the state root for the given block number using the results of the state changes. -func (oas *OperatorAVSSplitModel) GenerateStateRoot(blockNumber uint64) (types.StateRoot, error) { +func (oas *OperatorAVSSplitModel) GenerateStateRoot(blockNumber uint64) ([]byte, error) { inserts, err := oas.prepareState(blockNumber) if err != nil { - return "", err + return nil, err } inputs := oas.sortValuesForMerkleTree(inserts) if len(inputs) == 0 { - return "", nil + return nil, nil } - fullTree, err := oas.MerkleizeState(blockNumber, inputs) + fullTree, err := oas.MerkleizeEigenState(blockNumber, inputs) if err != nil { oas.logger.Sugar().Errorw("Failed to create merkle tree", zap.Error(err), zap.Uint64("blockNumber", blockNumber), zap.Any("inputs", inputs), ) - return "", err + return nil, err } - return types.StateRoot(utils.ConvertBytesToString(fullTree.Root())), nil + return fullTree.Root(), nil } func (oas *OperatorAVSSplitModel) sortValuesForMerkleTree(splits []*OperatorAVSSplit) []*base.MerkleTreeInput { diff --git a/pkg/eigenState/operatorAVSSplits/operatorAVSSplits_test.go b/pkg/eigenState/operatorAVSSplits/operatorAVSSplits_test.go index f7dd2fe5..9e60db9d 100644 --- a/pkg/eigenState/operatorAVSSplits/operatorAVSSplits_test.go +++ b/pkg/eigenState/operatorAVSSplits/operatorAVSSplits_test.go @@ -31,7 +31,7 @@ func setup() ( l, _ := logger.NewLogger(&logger.LoggerConfig{Debug: true}) - dbname, _, grm, err := postgres.GetTestPostgresDatabase(cfg.DatabaseConfig, l) + dbname, _, grm, err := postgres.GetTestPostgresDatabase(cfg.DatabaseConfig, cfg, l) if err != nil { return dbname, nil, nil, nil, err } diff --git a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions_test.go b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions_test.go index 6081e2a4..03521787 100644 --- a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions_test.go +++ b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions_test.go @@ -31,7 +31,7 @@ func setup() ( l, _ := logger.NewLogger(&logger.LoggerConfig{Debug: true}) - dbname, _, grm, err := postgres.GetTestPostgresDatabase(cfg.DatabaseConfig, l) + dbname, _, grm, err := postgres.GetTestPostgresDatabase(cfg.DatabaseConfig, cfg, l) if err != nil { return dbname, nil, nil, nil, err } diff --git a/pkg/eigenState/operatorPISplits/operatorPISplits.go b/pkg/eigenState/operatorPISplits/operatorPISplits.go index baea18be..da147662 100644 --- a/pkg/eigenState/operatorPISplits/operatorPISplits.go +++ b/pkg/eigenState/operatorPISplits/operatorPISplits.go @@ -8,13 +8,11 @@ import ( "strings" "time" - "github.com/Layr-Labs/sidecar/pkg/storage" - "github.com/Layr-Labs/sidecar/pkg/utils" - "github.com/Layr-Labs/sidecar/internal/config" "github.com/Layr-Labs/sidecar/pkg/eigenState/base" "github.com/Layr-Labs/sidecar/pkg/eigenState/stateManager" "github.com/Layr-Labs/sidecar/pkg/eigenState/types" + "github.com/Layr-Labs/sidecar/pkg/storage" "go.uber.org/zap" "golang.org/x/xerrors" "gorm.io/gorm" @@ -229,28 +227,28 @@ func (ops *OperatorPISplitModel) CommitFinalState(blockNumber uint64) error { } // GenerateStateRoot generates the state root for the given block number using the results of the state changes. -func (ops *OperatorPISplitModel) GenerateStateRoot(blockNumber uint64) (types.StateRoot, error) { +func (ops *OperatorPISplitModel) GenerateStateRoot(blockNumber uint64) ([]byte, error) { inserts, err := ops.prepareState(blockNumber) if err != nil { - return "", err + return nil, err } inputs := ops.sortValuesForMerkleTree(inserts) if len(inputs) == 0 { - return "", nil + return nil, nil } - fullTree, err := ops.MerkleizeState(blockNumber, inputs) + fullTree, err := ops.MerkleizeEigenState(blockNumber, inputs) if err != nil { ops.logger.Sugar().Errorw("Failed to create merkle tree", zap.Error(err), zap.Uint64("blockNumber", blockNumber), zap.Any("inputs", inputs), ) - return "", err + return nil, err } - return types.StateRoot(utils.ConvertBytesToString(fullTree.Root())), nil + return fullTree.Root(), nil } func (ops *OperatorPISplitModel) sortValuesForMerkleTree(splits []*OperatorPISplit) []*base.MerkleTreeInput { diff --git a/pkg/eigenState/operatorPISplits/operatorPISplits_test.go b/pkg/eigenState/operatorPISplits/operatorPISplits_test.go index 97672bb9..acd1de4a 100644 --- a/pkg/eigenState/operatorPISplits/operatorPISplits_test.go +++ b/pkg/eigenState/operatorPISplits/operatorPISplits_test.go @@ -31,7 +31,7 @@ func setup() ( l, _ := logger.NewLogger(&logger.LoggerConfig{Debug: true}) - dbname, _, grm, err := postgres.GetTestPostgresDatabase(cfg.DatabaseConfig, l) + dbname, _, grm, err := postgres.GetTestPostgresDatabase(cfg.DatabaseConfig, cfg, l) if err != nil { return dbname, nil, nil, nil, err } diff --git a/pkg/postgres/migrations/202411191550_operatorAVSSplits/up.go b/pkg/postgres/migrations/202411191550_operatorAVSSplits/up.go index 15261d8f..34f2b084 100644 --- a/pkg/postgres/migrations/202411191550_operatorAVSSplits/up.go +++ b/pkg/postgres/migrations/202411191550_operatorAVSSplits/up.go @@ -2,6 +2,7 @@ package _202411191550_operatorAVSSplits import ( "database/sql" + "github.com/Layr-Labs/sidecar/internal/config" "gorm.io/gorm" ) @@ -9,7 +10,7 @@ import ( type Migration struct { } -func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { +func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { query := ` create table if not exists operator_avs_splits ( operator varchar not null, diff --git a/pkg/postgres/migrations/202411191708_operatorPISplits/up.go b/pkg/postgres/migrations/202411191708_operatorPISplits/up.go index a03d4148..4bae75ce 100644 --- a/pkg/postgres/migrations/202411191708_operatorPISplits/up.go +++ b/pkg/postgres/migrations/202411191708_operatorPISplits/up.go @@ -2,6 +2,7 @@ package _202411191708_operatorPISplits import ( "database/sql" + "github.com/Layr-Labs/sidecar/internal/config" "gorm.io/gorm" ) @@ -9,7 +10,7 @@ import ( type Migration struct { } -func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { +func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { query := ` create table if not exists operator_pi_splits ( operator varchar not null, diff --git a/pkg/postgres/migrations/202411221331_operatorAVSSplitSnapshots/up.go b/pkg/postgres/migrations/202411221331_operatorAVSSplitSnapshots/up.go index df50c321..18c9172f 100644 --- a/pkg/postgres/migrations/202411221331_operatorAVSSplitSnapshots/up.go +++ b/pkg/postgres/migrations/202411221331_operatorAVSSplitSnapshots/up.go @@ -2,6 +2,7 @@ package _202411221331_operatorAVSSplitSnapshots import ( "database/sql" + "github.com/Layr-Labs/sidecar/internal/config" "gorm.io/gorm" ) @@ -9,7 +10,7 @@ import ( type Migration struct { } -func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { +func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { queries := []string{ `CREATE TABLE IF NOT EXISTS operator_avs_split_snapshots ( operator varchar not null, diff --git a/pkg/postgres/migrations/202411221331_operatorPISplitSnapshots/up.go b/pkg/postgres/migrations/202411221331_operatorPISplitSnapshots/up.go index d350c1c0..ea86997c 100644 --- a/pkg/postgres/migrations/202411221331_operatorPISplitSnapshots/up.go +++ b/pkg/postgres/migrations/202411221331_operatorPISplitSnapshots/up.go @@ -2,6 +2,7 @@ package _202411221331_operatorPISplitSnapshots import ( "database/sql" + "github.com/Layr-Labs/sidecar/internal/config" "gorm.io/gorm" ) @@ -9,7 +10,7 @@ import ( type Migration struct { } -func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { +func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { queries := []string{ `CREATE TABLE IF NOT EXISTS operator_pi_split_snapshots ( operator varchar not null,