From 5d83327660c612a868b962ea7c85711dac3f020b Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Tue, 20 Aug 2024 10:01:33 -0500 Subject: [PATCH 1/8] Add EigenLayer state tables --- .../202408200934_eigenlayerStateTables/up.go | 198 +++++++++++ internal/postgres/migrations/migrator.go | 2 + internal/storage/tables.go | 331 ++++++++++++++++++ tests/bin/bootstrapDb.sh | 2 +- 4 files changed, 532 insertions(+), 1 deletion(-) create mode 100644 internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go create mode 100644 internal/storage/tables.go diff --git a/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go b/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go new file mode 100644 index 00000000..2dd9c136 --- /dev/null +++ b/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go @@ -0,0 +1,198 @@ +package _202408200934_eigenlayerStateTables + +import ( + "database/sql" + "fmt" + "github.com/Layr-Labs/sidecar/internal/postgres" + "gorm.io/gorm" +) + +type Migration struct { +} + +func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { + queries := []string{ + `create table if not exists avs_operator_changes ( + id serial primary key, + operator varchar, + avs varchar, + registered boolean, + transaction_hash varchar, + log_index bigint, + block_number bigint + ) + `, + `create index if not exists idx_avs_operator_changes_avs_operator on avs_operator_changes (avs, operator)`, + `create index if not exists idx_avs_operator_changes_block on avs_operator_changes (block_number)`, + `create table if not exists operator_share_changes ( + id serial primary key, + operator varchar, + strategy varchar, + shares numeric, + transaction_hash varchar, + log_index bigint, + block_number bigint + ) + `, + `create index if not exists idx_operator_share_changes_operator_strat on operator_share_changes (operator, strategy)`, + `create index if not exists idx_operator_share_changes_block on operator_share_changes (block_number)`, + `create table if not exists staker_share_changes ( + id serial primary key, + staker varchar, + strategy varchar, + shares numeric, + transaction_hash varchar, + log_index bigint, + block_number bigint, + created_at timestamp with time zone + ); + `, + `create index if not exists idx_staker_share_changes_staker_strat on staker_share_changes (staker, strategy)`, + `create index if not exists idx_staker_share_changes_block on staker_share_changes (block_number)`, + `create table if not exists staker_delegation_changes ( + id serial primary key, + staker varchar, + operator varchar, + transaction_hash varchar, + log_index bigint, + block_number bigint, + created_at timestamp with time zone + ); + `, + `create index if not exists idx_staker_delegation_changes_staker_operator on staker_delegation_changes (staker, operator)`, + `create index if not exists idx_staker_delegation_changes_block on staker_delegation_changes (block_number)`, + `create table if not exists active_reward_submissions ( + id serial primary key, + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + transaction_hash varchar, + log_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone + ); + `, + `create index if not exists idx_active_reward_submissions_avs on active_reward_submissions (avs)`, + `create index if not exists idx_active_reward_submissions_block on active_reward_submissions (block_number)`, + `create table if not exists active_reward_for_all_submissions ( + id serial primary key, + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + transaction_hash varchar, + log_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone + ); + `, + `create index if not exists idx_active_reward_for_all_submissions_avs on active_reward_for_all_submissions (avs)`, + `create index if not exists idx_active_reward_for_all_submissions_block on active_reward_for_all_submissions (block_number)`, + `create table if not exists registered_avs_operators ( + operator varchar, + avs varchar, + block_number bigint, + created_at timestamp with time zone, + unique(operator, avs, block_number) + ); + `, + `create index if not exists idx_registered_avs_operators_avs_operator on registered_avs_operators (avs, operator)`, + `create index if not exists idx_registered_avs_operators_block on registered_avs_operators (block_number)`, + `create table if not exists operator_shares ( + operator varchar, + strategy varchar, + shares numeric, + block_number bigint, + created_at timestamp with time zone, + unique (operator, strategy, block_number) + )`, + `create index if not exists idx_operator_shares_operator_strategy on operator_shares (operator, strategy)`, + `create index if not exists idx_operator_shares_block on operator_shares (block_number)`, + `create table if not exists staker_shares ( + staker varchar, + strategy varchar, + shares numeric, + block_number bigint, + created_at timestamp with time zone, + unique(staker, strategy, block_number) + ) + `, + `create index if not exists idx_staker_shares_staker_strategy on staker_shares (staker, strategy)`, + `create index if not exists idx_staker_shares_block on staker_shares (block_number)`, + `create table if not exists delegated_stakers ( + staker varchar, + operator varchar, + block_number bigint, + created_at timestamp with time zone, + unique(staker, operator, block_number) + )`, + `create index if not exists idx_delegated_stakers_staker_operator on delegated_stakers (staker, operator)`, + `create index if not exists idx_delegated_stakers_block on delegated_stakers (block_number)`, + `create table if not exists active_rewards ( + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone + )`, + `create index if not exists idx_active_rewards_avs on active_rewards (avs)`, + `create index if not exists idx_active_rewards_block on active_rewards (block_number)`, + `create table if not exists active_reward_for_all ( + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone + )`, + `create index if not exists idx_active_reward_for_all_avs on active_reward_for_all (avs)`, + `create index if not exists idx_active_reward_for_all_block on active_reward_for_all (block_number)`, + } + + // Wrap the queries in a transaction so they all create or fail atomically + _, err := postgres.WrapTxAndCommit[interface{}](func(tx *gorm.DB) (interface{}, error) { + p, err := tx.DB() + if err != nil { + return nil, err + } + for _, query := range queries { + _, err := p.Exec(query) + if err != nil { + fmt.Printf("Failed to execute query: %s\n", query) + return nil, err + } + } + return nil, nil + }, grm, nil) + return err +} + +func (m *Migration) GetName() string { + return "202408200934_eigenlayerStateTables" +} diff --git a/internal/postgres/migrations/migrator.go b/internal/postgres/migrations/migrator.go index e3d57d0b..8cf98e6b 100644 --- a/internal/postgres/migrations/migrator.go +++ b/internal/postgres/migrations/migrator.go @@ -25,6 +25,7 @@ import ( _202407110946_addBlockTimeToRestakedStrategies "github.com/Layr-Labs/sidecar/internal/postgres/migrations/202407110946_addBlockTimeToRestakedStrategies" _202407111116_addAvsDirectoryAddress "github.com/Layr-Labs/sidecar/internal/postgres/migrations/202407111116_addAvsDirectoryAddress" _202407121407_updateProxyContractIndex "github.com/Layr-Labs/sidecar/internal/postgres/migrations/202407121407_updateProxyContractIndex" + _202408200934_eigenlayerStateTables "github.com/Layr-Labs/sidecar/internal/postgres/migrations/202408200934_eigenlayerStateTables" "go.uber.org/zap" "gorm.io/gorm" "time" @@ -74,6 +75,7 @@ func (m *Migrator) MigrateAll() error { &_202407110946_addBlockTimeToRestakedStrategies.Migration{}, &_202407111116_addAvsDirectoryAddress.Migration{}, &_202407121407_updateProxyContractIndex.Migration{}, + &_202408200934_eigenlayerStateTables.Migration{}, } for _, migration := range migrations { diff --git a/internal/storage/tables.go b/internal/storage/tables.go new file mode 100644 index 00000000..dc9990ff --- /dev/null +++ b/internal/storage/tables.go @@ -0,0 +1,331 @@ +package storage + +import ( + "math/big" + "time" +) + +// ---------------------------------------------------------------------------- +// Append only tables of state +// ---------------------------------------------------------------------------- + +/* +create table if not exists avs_operator_changes ( + + id serial primary key, + operator varchar, + avs varchar, + registered boolean, + transaction_hash varchar, + log_index bigint, + block_number bigint + +); +*/ +type AvsOperatorChange struct { + Id uint64 `gorm:"type:serial"` + Operator string + Avs string + Registered bool + TransactionHash string + LogIndex uint64 + BlockNumber uint64 + CreatedAt time.Time +} + +/* +create table if not exists operator_share_changes ( + + id serial primary key, + operator varchar, + strategy varchar, + shares numeric, + transaction_hash varchar, + log_index bigint, + block_number bigint + +); +*/ +type OperatorShareChanges struct { + Id uint64 `gorm:"type:serial"` + Operator string + Strategy string + Shares big.Int `gorm:"type:numeric"` + TransactionHash string + LogIndex uint64 + BlockNumber uint64 + CreatedAt time.Time +} + +/* +create table if not exists staker_share_changes ( + + id serial primary key, + staker varchar, + strategy varchar, + shares numeric, + transaction_hash varchar, + log_index bigint, + block_number bigint, + created_at timestamp with time zone + +); +*/ +type StakerShareChanges struct { + Id uint64 `gorm:"type:serial"` + Staker string + Strategy string + Shares big.Int `gorm:"type:numeric"` + TransactionHash string + LogIndex uint64 + BlockNumber uint64 + CreatedAt time.Time +} + +/* +create table if not exists staker_delegation_changes ( + + id serial primary key, + staker varchar, + operator varchar, + transaction_hash varchar, + log_index bigint, + block_number bigint + created_at timestamp with time zone + +); +*/ +type StakerDelegationChanges struct { + Id uint64 `gorm:"type:serial"` + Staker string + Operator string + TransactionHash string + LogIndex uint64 + BlockNumber uint64 + Delegated bool + CreatedAt time.Time +} + +/* +create table if not exists active_reward_submissions ( + + id serial primary key, + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + transaction_hash varchar, + log_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint + created_at timestamp with time zone + +); +*/ +type ActiveRewardSubmissions struct { + Id uint64 `gorm:"type:serial"` + Avs string + RewardHash string + Token string + Amount big.Int `gorm:"type:numeric"` + Strategy string + Multiplier big.Int `gorm:"type:numeric"` + StrategyIndex uint64 + TransactionHash string + LogIndex uint64 + BlockNumber uint64 + StartTimestamp time.Time + EndTimestamp time.Time + Duration uint64 + CreatedAt time.Time +} + +/* +create table if not exists active_reward_for_all_submissions ( + + id serial primary key, + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + transaction_hash varchar, + log_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint + created_at timestamp with time zone + +); +*/ +type RewardForAllSubmissions struct { + Id uint64 `gorm:"type:serial"` + Avs string + RewardHash string + Token string + Amount big.Int `gorm:"type:numeric"` + Strategy string + Multiplier big.Int `gorm:"type:numeric"` + StrategyIndex uint64 + TransactionHash string + LogIndex uint64 + BlockNumber uint64 + StartTimestamp time.Time + EndTimestamp time.Time + Duration uint64 + CreatedAt time.Time +} + +// ---------------------------------------------------------------------------- +// Block-based "summary" tables +// ---------------------------------------------------------------------------- + +/* +create table if not exists registered_avs_operators ( + + operator varchar, + avs varchar, + block_number bigint, + created_at timestamp with time zone + unique idx_uniq_operator_abs_block (operator, avs, block_number) + +); +*/ +type RegisteredAvsOperators struct { + Operator string + Avs string + BlockNumber uint64 + CreatedAt time.Time +} + +/* +create table if not exists operator_shares ( + + operator varchar, + strategy varchar, + shares numeric, + block_number bigint, + created_at timestamp with time zone + unique idx_uniq_operator_shares_block (operator, strategy, block_number) + +) +*/ +type OperatorShares struct { + Operator string + Strategy string + Shares big.Int `gorm:"type:numeric"` + BlockNumber uint64 + CreatedAt time.Time +} + +/* +create table if not exists staker_shares ( + + staker varchar, + strategy varchar, + shares numeric, + block_number bigint, + created_at timestamp with time zone + unique idx_uniq_staker_shares_block (staker, strategy, block_number) + +) +*/ +type StakerShares struct { + Staker string + Straegy string + Shares big.Int `gorm:"type:numeric"` + BlockNumber uint64 + CreatedAt time.Time +} + +/* +create table if not exists delegated_stakers ( + + staker varchar, + operator varchar, + block_number bigint, + created_at timestamp with time zone + unique idx_uniq_delegated_stakers_block (staker, operator, block_number) + +) +*/ +type DelegatedStakers struct { + Staker string + Operator string + BlockNumber uint64 + CreatedAt time.Time +} + +/* +create table if not exists active_rewards ( + + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone + +) +*/ +type ActiveRewards struct { + Avs string + RewardHash string + Token string + Amount big.Int `gorm:"type:numeric"` + Strategy string + Multiplier big.Int `gorm:"type:numeric"` + StrategyIndex uint64 + BlockNumber uint64 + StartTimestamp time.Time + EndTimestamp time.Time + Duration uint64 + CreatedAt time.Time +} + +/* +create table if not exists active_reward_for_all ( + + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone + +) +*/ +type ActiveRewardForAll struct { + Avs string + RewardHash string + Token string + Amount big.Int `gorm:"type:numeric"` + Strategy string + Multiplier big.Int `gorm:"type:numeric"` + StrategyIndex uint64 + BlockNumber uint64 + StartTimestamp time.Time + EndTimestamp time.Time + Duration uint64 + CreatedAt time.Time +} diff --git a/tests/bin/bootstrapDb.sh b/tests/bin/bootstrapDb.sh index d7fabc3a..78d8d272 100755 --- a/tests/bin/bootstrapDb.sh +++ b/tests/bin/bootstrapDb.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -DATABASE=blocklake_test +DATABASE=sidecar_test echo 'Dropping database' dropdb $DATABASE || true From 17fdd2d10069df1945e9608f08a6b9662f9a0d09 Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Tue, 20 Aug 2024 11:41:26 -0500 Subject: [PATCH 2/8] Adding db queries and protos --- cmd/sidecar/main.go | 2 +- internal/config/config.go | 62 +- internal/storage/postgresql/stateTables.go | 82 ++ internal/storage/postgresql/storage.go | 15 +- protos/eigenlayer/blocklake/v1/api.pb.go | 60 +- protos/eigenlayer/blocklake/v1/api.pb.gw.go | 6 +- protos/eigenlayer/blocklake/v1/api_grpc.pb.go | 86 +- .../eigenlayer/blocklake/v1/blockchain.pb.go | 50 +- protos/eigenlayer/sidecar/v1/api.pb.go | 1312 +++++++++++++++++ protos/eigenlayer/sidecar/v1/api.pb.gw.go | 617 ++++++++ protos/eigenlayer/sidecar/v1/api.proto | 127 ++ protos/eigenlayer/sidecar/v1/api_grpc.pb.go | 309 ++++ 12 files changed, 2622 insertions(+), 106 deletions(-) create mode 100644 internal/storage/postgresql/stateTables.go create mode 100644 protos/eigenlayer/sidecar/v1/api.pb.go create mode 100644 protos/eigenlayer/sidecar/v1/api.pb.gw.go create mode 100644 protos/eigenlayer/sidecar/v1/api.proto create mode 100644 protos/eigenlayer/sidecar/v1/api_grpc.pb.go diff --git a/cmd/sidecar/main.go b/cmd/sidecar/main.go index 78586ac3..e01ff115 100644 --- a/cmd/sidecar/main.go +++ b/cmd/sidecar/main.go @@ -65,7 +65,7 @@ func main() { cm := contractManager.NewContractManager(contractStore, etherscanClient, client, sdc, l) - mds, err := postgresql.NewPostgresBlockStore(grm, l) + mds, err := postgresql.NewPostgresBlockStore(grm, cfg, l) if err != nil { log.Fatalln(err) } diff --git a/internal/config/config.go b/internal/config/config.go index 79e93e9e..3daae63f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -201,34 +201,58 @@ var AVSDirectoryAddresses = map[Environment]map[Network]string{ }, } -func (c *Config) GetInterestingAddressForConfigEnv() []string { +type ContractAddresses struct { + RewardsCoordinator string + EigenpodManager string + StrategyManager string + DelegationManager string + AvsDirectory string +} + +func (c *Config) GetContractsMapForEnvAndNetwork() *ContractAddresses { if c.Environment == Environment_PreProd { - return []string{ - "0xb22ef643e1e067c994019a4c19e403253c05c2b0", // rewards coordinator - "0xb8d8952f572e67b11e43bc21250967772fa883ff", // eigenpod manager - "0xf9fbf2e35d8803273e214c99bf15174139f4e67a", // strategy manager - "0x75dfe5b44c2e530568001400d3f704bc8ae350cc", // delegation manager - "0x141d6995556135d4997b2ff72eb443be300353bc", // avs directory + return &ContractAddresses{ + RewardsCoordinator: "0xb22ef643e1e067c994019a4c19e403253c05c2b0", + EigenpodManager: "0xb8d8952f572e67b11e43bc21250967772fa883ff", + StrategyManager: "0xf9fbf2e35d8803273e214c99bf15174139f4e67a", + DelegationManager: "0x75dfe5b44c2e530568001400d3f704bc8ae350cc", + AvsDirectory: "0x141d6995556135d4997b2ff72eb443be300353bc", } } else if c.Environment == Environment_Testnet { - return []string{ - "0xacc1fb458a1317e886db376fc8141540537e68fe", // rewards coordinator - "0x30770d7e3e71112d7a6b7259542d1f680a70e315", // eigenpod manager - "0xdfb5f6ce42aaa7830e94ecfccad411bef4d4d5b6", // strategy manager - "0xa44151489861fe9e3055d95adc98fbd462b948e7", // delegation manager - "0x055733000064333caddbc92763c58bf0192ffebf", // avs directory + return &ContractAddresses{ + RewardsCoordinator: "0xacc1fb458a1317e886db376fc8141540537e68fe", + EigenpodManager: "0x30770d7e3e71112d7a6b7259542d1f680a70e315", + StrategyManager: "0xdfb5f6ce42aaa7830e94ecfccad411bef4d4d5b6", + DelegationManager: "0xa44151489861fe9e3055d95adc98fbd462b948e7", + AvsDirectory: "0x055733000064333caddbc92763c58bf0192ffebf", } } else if c.Environment == Environment_Mainnet { - return []string{ - "0x7750d328b314effa365a0402ccfd489b80b0adda", // rewards coordinator - "0x91e677b07f7af907ec9a428aafa9fc14a0d3a338", // eigenpod manager - "0x858646372cc42e1a627fce94aa7a7033e7cf075a", // strategy manager - "0x39053d51b77dc0d36036fc1fcc8cb819df8ef37a", // delegation manager - "0x135dda560e946695d6f155dacafc6f1f25c1f5af", // avs directory + return &ContractAddresses{ + RewardsCoordinator: "0x7750d328b314effa365a0402ccfd489b80b0adda", + EigenpodManager: "0x91e677b07f7af907ec9a428aafa9fc14a0d3a338", + StrategyManager: "0x858646372cc42e1a627fce94aa7a7033e7cf075a", + DelegationManager: "0x39053d51b77dc0d36036fc1fcc8cb819df8ef37a", + AvsDirectory: "0x135dda560e946695d6f155dacafc6f1f25c1f5af", } } else { + return nil + } +} + +func (c *Config) GetInterestingAddressForConfigEnv() []string { + addresses := c.GetContractsMapForEnvAndNetwork() + + if addresses == nil { return []string{} } + + return []string{ + addresses.RewardsCoordinator, + addresses.EigenpodManager, + addresses.StrategyManager, + addresses.DelegationManager, + addresses.AvsDirectory, + } } func (c *Config) GetGenesisBlockNumber() uint64 { diff --git a/internal/storage/postgresql/stateTables.go b/internal/storage/postgresql/stateTables.go new file mode 100644 index 00000000..a5031835 --- /dev/null +++ b/internal/storage/postgresql/stateTables.go @@ -0,0 +1,82 @@ +package postgresql + +import ( + "go.uber.org/zap" + "golang.org/x/xerrors" +) + +func (p *PostgresBlockStore) InsertIntoAvsOperatorChangesForBlock(blockNumber uint64) error { + query := ` + SELECT + lower(t.arguments #>> '{0,Value}') as operator, + lower(t.arguments #>> '{1,Value}') as avs, + (case when (t.output_data -> 'status')::int = 1 then true else false) as registered, + t.transaction_hash, + t.log_index, + t.block_number + FROM transaction_logs t + WHERE t.address = ? + AND t.event_name = 'OperatorAVSRegistrationStatusUpdated' + ` + addressMap := p.GlobalConfig.GetContractsMapForEnvAndNetwork() + if addressMap == nil { + p.Logger.Sugar().Error("Failed to get contracts map for env and network") + return xerrors.New("failed to get contracts map for env and network") + } + result := p.Db.Raw(query, addressMap.AvsDirectory, blockNumber) + if result.Error != nil { + p.Logger.Sugar().Errorw("Failed to insert into avs operator changes for block", + zap.Error(result.Error), + zap.Uint64("blockNumber", blockNumber), + ) + } +} + +func (p *PostgresBlockStore) InsertIntoActiveRewardSubmissionsForBlock(blockNumber uint64) error { + query := ` + with rows_to_insert as ( + SELECT + lower(tl.arguments #>> '{0,Value}') AS avs, + lower(tl.arguments #>> '{2,Value}') AS reward_hash, + coalesce(lower(tl.output_data #>> '{rewardsSubmission}'), lower(tl.output_data #>> '{rangePayment}')) as rewards_submission, + coalesce(lower(tl.output_data #>> '{rewardsSubmission, token}'), lower(tl.output_data #>> '{rangePayment, token}')) as token, + coalesce(tl.output_data #>> '{rewardsSubmission,amount}', tl.output_data #>> '{rangePayment,amount}')::numeric(78,0) as amount, + to_timestamp(coalesce(tl.output_data #>> '{rewardsSubmission,startTimestamp}', tl.output_data #>> '{rangePayment,startTimestamp}')::bigint)::timestamp(6) as start_timestamp, + coalesce(tl.output_data #>> '{rewardsSubmission,duration}', tl.output_data #>> '{rangePayment,duration}')::bigint as duration, + to_timestamp( + coalesce(tl.output_data #>> '{rewardsSubmission,startTimestamp}', tl.output_data #>> '{rangePayment,startTimestamp}')::bigint + + coalesce(tl.output_data #>> '{rewardsSubmission,duration}', tl.output_data #>> '{rangePayment,duration}')::bigint + )::timestamp(6) as end_timestamp, + lower(t.entry ->> 'strategy') as strategy, + (t.entry ->> 'multiplier')::numeric(78,0) as multiplier, + t.strategy_index as strategy_index, + tl.transaction_hash, + tl.log_index, + tl.block_number + FROM transaction_logs tl + CROSS JOIN LATERAL jsonb_array_elements( + coalesce(tl.output_data #> '{rewardsSubmission,strategiesAndMultipliers}',tl.output_data #> '{rangePayment,strategiesAndMultipliers}') + ) WITH ORDINALITY AS t(entry, strategy_index) + WHERE address = ? + AND (event_name = 'AVSRewardsSubmissionCreated' or event_name = 'RangePaymentCreated') + AND block_number = ? + ) + select + * + into active_reward_submissions + from rows_to_insert + ` + addressMap := p.GlobalConfig.GetContractsMapForEnvAndNetwork() + if addressMap == nil { + p.Logger.Sugar().Error("Failed to get contracts map for env and network") + return xerrors.New("failed to get contracts map for env and network") + } + result := p.Db.Raw(query, addressMap.RewardsCoordinator, blockNumber) + if result.Error != nil { + p.Logger.Sugar().Errorw("Failed to insert into avs operator changes for block", + zap.Error(result.Error), + zap.Uint64("blockNumber", blockNumber), + ) + } + return nil +} diff --git a/internal/storage/postgresql/storage.go b/internal/storage/postgresql/storage.go index 998ff51f..20ca6be4 100644 --- a/internal/storage/postgresql/storage.go +++ b/internal/storage/postgresql/storage.go @@ -3,6 +3,7 @@ package postgresql import ( "encoding/json" "errors" + "github.com/Layr-Labs/sidecar/internal/config" "github.com/Layr-Labs/sidecar/internal/parser" pg "github.com/Layr-Labs/sidecar/internal/postgres" "github.com/Layr-Labs/sidecar/internal/storage" @@ -23,15 +24,17 @@ type PostgresBlockStoreConfig struct { } type PostgresBlockStore struct { - Db *gorm.DB - migrated bool - Logger *zap.Logger + Db *gorm.DB + migrated bool + Logger *zap.Logger + GlobalConfig *config.Config } -func NewPostgresBlockStore(db *gorm.DB, l *zap.Logger) (*PostgresBlockStore, error) { +func NewPostgresBlockStore(db *gorm.DB, cfg *config.Config, l *zap.Logger) (*PostgresBlockStore, error) { mds := &PostgresBlockStore{ - Db: db, - Logger: l, + Db: db, + Logger: l, + GlobalConfig: cfg, } mds.autoMigrate() diff --git a/protos/eigenlayer/blocklake/v1/api.pb.go b/protos/eigenlayer/blocklake/v1/api.pb.go index a4af0eec..8aebc1ff 100644 --- a/protos/eigenlayer/blocklake/v1/api.pb.go +++ b/protos/eigenlayer/blocklake/v1/api.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: eigenlayer/blocklake/v1/api.proto @@ -811,23 +811,23 @@ var file_eigenlayer_blocklake_v1_api_proto_rawDesc = []byte{ 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x3a, 0x01, 0x2a, 0x22, 0x1f, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2d, 0x72, 0x65, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x64, 0x2d, 0x73, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x69, 0x65, 0x73, 0x42, 0xf4, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x65, + 0x74, 0x65, 0x67, 0x69, 0x65, 0x73, 0x42, 0xf1, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x41, 0x70, 0x69, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6c, 0x61, 0x79, 0x72, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x2d, 0x6c, 0x61, 0x6b, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x65, - 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, - 0xa2, 0x02, 0x03, 0x45, 0x42, 0x41, 0xaa, 0x02, 0x1b, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, - 0x79, 0x65, 0x72, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x2e, 0x41, 0x70, - 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x1b, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, - 0x72, 0x5c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x5c, 0x41, 0x70, 0x69, 0x5c, - 0x56, 0x31, 0xe2, 0x02, 0x27, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5c, - 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x45, - 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x3a, 0x3a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x6c, 0x61, 0x6b, 0x65, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x4c, 0x61, 0x79, 0x72, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x73, 0x69, 0x64, + 0x65, 0x63, 0x61, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x65, 0x69, 0x67, 0x65, + 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, + 0x45, 0x42, 0x41, 0xaa, 0x02, 0x1b, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, + 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, + 0x31, 0xca, 0x02, 0x1b, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, + 0x02, 0x27, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x45, 0x69, 0x67, 0x65, + 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x3a, 0x3a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, + 0x65, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -844,7 +844,7 @@ func file_eigenlayer_blocklake_v1_api_proto_rawDescGZIP() []byte { var file_eigenlayer_blocklake_v1_api_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_eigenlayer_blocklake_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 13) -var file_eigenlayer_blocklake_v1_api_proto_goTypes = []interface{}{ +var file_eigenlayer_blocklake_v1_api_proto_goTypes = []any{ (BackfillType)(0), // 0: eigenlayer.blocklake.api.v1.BackfillType (*HelloRequest)(nil), // 1: eigenlayer.blocklake.api.v1.HelloRequest (*HelloResponse)(nil), // 2: eigenlayer.blocklake.api.v1.HelloResponse @@ -890,7 +890,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_eigenlayer_blocklake_v1_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*HelloRequest); i { case 0: return &v.state @@ -902,7 +902,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*HelloResponse); i { case 0: return &v.state @@ -914,7 +914,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*BackfillRange); i { case 0: return &v.state @@ -926,7 +926,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*BackfillRequest); i { case 0: return &v.state @@ -938,7 +938,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*BackfillResponse); i { case 0: return &v.state @@ -950,7 +950,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*PurgeQueuesRequest); i { case 0: return &v.state @@ -962,7 +962,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*PurgeQueuesResponse); i { case 0: return &v.state @@ -974,7 +974,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*IndexContractsRequest); i { case 0: return &v.state @@ -986,7 +986,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*IndexContractsResponse); i { case 0: return &v.state @@ -998,7 +998,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*ReIndexTransactionsForContractRequest); i { case 0: return &v.state @@ -1010,7 +1010,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*ReIndexTransactionsForContractResponse); i { case 0: return &v.state @@ -1022,7 +1022,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*ReIndexRestakedStrategiesRequest); i { case 0: return &v.state @@ -1034,7 +1034,7 @@ func file_eigenlayer_blocklake_v1_api_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_api_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_api_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*ReIndexRestakedStrategiesResponse); i { case 0: return &v.state diff --git a/protos/eigenlayer/blocklake/v1/api.pb.gw.go b/protos/eigenlayer/blocklake/v1/api.pb.gw.go index 47f94bc0..3464ee69 100644 --- a/protos/eigenlayer/blocklake/v1/api.pb.gw.go +++ b/protos/eigenlayer/blocklake/v1/api.pb.gw.go @@ -183,6 +183,7 @@ func local_request_Backfiller_ReIndexRestakedStrategies_0(ctx context.Context, m // UnaryRPC :call ApiServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterApiHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ApiServer) error { mux.Handle("POST", pattern_Api_SayHello_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -217,6 +218,7 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server // UnaryRPC :call BackfillerServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterBackfillerHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterBackfillerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server BackfillerServer) error { mux.Handle("POST", pattern_Backfiller_StartBackfill_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -382,7 +384,7 @@ func RegisterApiHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.C // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ApiClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ApiClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "ApiClient" to call the correct interceptors. +// "ApiClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ApiClient) error { mux.Handle("POST", pattern_Api_SayHello_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -453,7 +455,7 @@ func RegisterBackfillerHandler(ctx context.Context, mux *runtime.ServeMux, conn // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "BackfillerClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "BackfillerClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "BackfillerClient" to call the correct interceptors. +// "BackfillerClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterBackfillerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client BackfillerClient) error { mux.Handle("POST", pattern_Backfiller_StartBackfill_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/protos/eigenlayer/blocklake/v1/api_grpc.pb.go b/protos/eigenlayer/blocklake/v1/api_grpc.pb.go index f5c776a6..c484f9cb 100644 --- a/protos/eigenlayer/blocklake/v1/api_grpc.pb.go +++ b/protos/eigenlayer/blocklake/v1/api_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: eigenlayer/blocklake/v1/api.proto @@ -15,8 +15,12 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Api_SayHello_FullMethodName = "/eigenlayer.blocklake.api.v1.Api/SayHello" +) // ApiClient is the client API for Api service. // @@ -34,8 +38,9 @@ func NewApiClient(cc grpc.ClientConnInterface) ApiClient { } func (c *apiClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(HelloResponse) - err := c.cc.Invoke(ctx, "/eigenlayer.blocklake.api.v1.Api/SayHello", in, out, opts...) + err := c.cc.Invoke(ctx, Api_SayHello_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -44,18 +49,22 @@ func (c *apiClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc // ApiServer is the server API for Api service. // All implementations should embed UnimplementedApiServer -// for forward compatibility +// for forward compatibility. type ApiServer interface { SayHello(context.Context, *HelloRequest) (*HelloResponse, error) } -// UnimplementedApiServer should be embedded to have forward compatible implementations. -type UnimplementedApiServer struct { -} +// UnimplementedApiServer should be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedApiServer struct{} func (UnimplementedApiServer) SayHello(context.Context, *HelloRequest) (*HelloResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") } +func (UnimplementedApiServer) testEmbeddedByValue() {} // UnsafeApiServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ApiServer will @@ -65,6 +74,13 @@ type UnsafeApiServer interface { } func RegisterApiServer(s grpc.ServiceRegistrar, srv ApiServer) { + // If the following call pancis, it indicates UnimplementedApiServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Api_ServiceDesc, srv) } @@ -78,7 +94,7 @@ func _Api_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/eigenlayer.blocklake.api.v1.Api/SayHello", + FullMethod: Api_SayHello_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApiServer).SayHello(ctx, req.(*HelloRequest)) @@ -102,6 +118,14 @@ var Api_ServiceDesc = grpc.ServiceDesc{ Metadata: "eigenlayer/blocklake/v1/api.proto", } +const ( + Backfiller_StartBackfill_FullMethodName = "/eigenlayer.blocklake.api.v1.Backfiller/StartBackfill" + Backfiller_PurgeQueues_FullMethodName = "/eigenlayer.blocklake.api.v1.Backfiller/PurgeQueues" + Backfiller_IndexContracts_FullMethodName = "/eigenlayer.blocklake.api.v1.Backfiller/IndexContracts" + Backfiller_ReIndexTransactionsForContract_FullMethodName = "/eigenlayer.blocklake.api.v1.Backfiller/ReIndexTransactionsForContract" + Backfiller_ReIndexRestakedStrategies_FullMethodName = "/eigenlayer.blocklake.api.v1.Backfiller/ReIndexRestakedStrategies" +) + // BackfillerClient is the client API for Backfiller service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -122,8 +146,9 @@ func NewBackfillerClient(cc grpc.ClientConnInterface) BackfillerClient { } func (c *backfillerClient) StartBackfill(ctx context.Context, in *BackfillRequest, opts ...grpc.CallOption) (*BackfillResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(BackfillResponse) - err := c.cc.Invoke(ctx, "/eigenlayer.blocklake.api.v1.Backfiller/StartBackfill", in, out, opts...) + err := c.cc.Invoke(ctx, Backfiller_StartBackfill_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -131,8 +156,9 @@ func (c *backfillerClient) StartBackfill(ctx context.Context, in *BackfillReques } func (c *backfillerClient) PurgeQueues(ctx context.Context, in *PurgeQueuesRequest, opts ...grpc.CallOption) (*PurgeQueuesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PurgeQueuesResponse) - err := c.cc.Invoke(ctx, "/eigenlayer.blocklake.api.v1.Backfiller/PurgeQueues", in, out, opts...) + err := c.cc.Invoke(ctx, Backfiller_PurgeQueues_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -140,8 +166,9 @@ func (c *backfillerClient) PurgeQueues(ctx context.Context, in *PurgeQueuesReque } func (c *backfillerClient) IndexContracts(ctx context.Context, in *IndexContractsRequest, opts ...grpc.CallOption) (*IndexContractsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(IndexContractsResponse) - err := c.cc.Invoke(ctx, "/eigenlayer.blocklake.api.v1.Backfiller/IndexContracts", in, out, opts...) + err := c.cc.Invoke(ctx, Backfiller_IndexContracts_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -149,8 +176,9 @@ func (c *backfillerClient) IndexContracts(ctx context.Context, in *IndexContract } func (c *backfillerClient) ReIndexTransactionsForContract(ctx context.Context, in *ReIndexTransactionsForContractRequest, opts ...grpc.CallOption) (*ReIndexTransactionsForContractResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ReIndexTransactionsForContractResponse) - err := c.cc.Invoke(ctx, "/eigenlayer.blocklake.api.v1.Backfiller/ReIndexTransactionsForContract", in, out, opts...) + err := c.cc.Invoke(ctx, Backfiller_ReIndexTransactionsForContract_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -158,8 +186,9 @@ func (c *backfillerClient) ReIndexTransactionsForContract(ctx context.Context, i } func (c *backfillerClient) ReIndexRestakedStrategies(ctx context.Context, in *ReIndexRestakedStrategiesRequest, opts ...grpc.CallOption) (*ReIndexRestakedStrategiesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ReIndexRestakedStrategiesResponse) - err := c.cc.Invoke(ctx, "/eigenlayer.blocklake.api.v1.Backfiller/ReIndexRestakedStrategies", in, out, opts...) + err := c.cc.Invoke(ctx, Backfiller_ReIndexRestakedStrategies_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -168,7 +197,7 @@ func (c *backfillerClient) ReIndexRestakedStrategies(ctx context.Context, in *Re // BackfillerServer is the server API for Backfiller service. // All implementations should embed UnimplementedBackfillerServer -// for forward compatibility +// for forward compatibility. type BackfillerServer interface { StartBackfill(context.Context, *BackfillRequest) (*BackfillResponse, error) PurgeQueues(context.Context, *PurgeQueuesRequest) (*PurgeQueuesResponse, error) @@ -177,9 +206,12 @@ type BackfillerServer interface { ReIndexRestakedStrategies(context.Context, *ReIndexRestakedStrategiesRequest) (*ReIndexRestakedStrategiesResponse, error) } -// UnimplementedBackfillerServer should be embedded to have forward compatible implementations. -type UnimplementedBackfillerServer struct { -} +// UnimplementedBackfillerServer should be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedBackfillerServer struct{} func (UnimplementedBackfillerServer) StartBackfill(context.Context, *BackfillRequest) (*BackfillResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method StartBackfill not implemented") @@ -196,6 +228,7 @@ func (UnimplementedBackfillerServer) ReIndexTransactionsForContract(context.Cont func (UnimplementedBackfillerServer) ReIndexRestakedStrategies(context.Context, *ReIndexRestakedStrategiesRequest) (*ReIndexRestakedStrategiesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ReIndexRestakedStrategies not implemented") } +func (UnimplementedBackfillerServer) testEmbeddedByValue() {} // UnsafeBackfillerServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to BackfillerServer will @@ -205,6 +238,13 @@ type UnsafeBackfillerServer interface { } func RegisterBackfillerServer(s grpc.ServiceRegistrar, srv BackfillerServer) { + // If the following call pancis, it indicates UnimplementedBackfillerServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Backfiller_ServiceDesc, srv) } @@ -218,7 +258,7 @@ func _Backfiller_StartBackfill_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/eigenlayer.blocklake.api.v1.Backfiller/StartBackfill", + FullMethod: Backfiller_StartBackfill_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BackfillerServer).StartBackfill(ctx, req.(*BackfillRequest)) @@ -236,7 +276,7 @@ func _Backfiller_PurgeQueues_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/eigenlayer.blocklake.api.v1.Backfiller/PurgeQueues", + FullMethod: Backfiller_PurgeQueues_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BackfillerServer).PurgeQueues(ctx, req.(*PurgeQueuesRequest)) @@ -254,7 +294,7 @@ func _Backfiller_IndexContracts_Handler(srv interface{}, ctx context.Context, de } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/eigenlayer.blocklake.api.v1.Backfiller/IndexContracts", + FullMethod: Backfiller_IndexContracts_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BackfillerServer).IndexContracts(ctx, req.(*IndexContractsRequest)) @@ -272,7 +312,7 @@ func _Backfiller_ReIndexTransactionsForContract_Handler(srv interface{}, ctx con } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/eigenlayer.blocklake.api.v1.Backfiller/ReIndexTransactionsForContract", + FullMethod: Backfiller_ReIndexTransactionsForContract_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BackfillerServer).ReIndexTransactionsForContract(ctx, req.(*ReIndexTransactionsForContractRequest)) @@ -290,7 +330,7 @@ func _Backfiller_ReIndexRestakedStrategies_Handler(srv interface{}, ctx context. } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/eigenlayer.blocklake.api.v1.Backfiller/ReIndexRestakedStrategies", + FullMethod: Backfiller_ReIndexRestakedStrategies_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BackfillerServer).ReIndexRestakedStrategies(ctx, req.(*ReIndexRestakedStrategiesRequest)) diff --git a/protos/eigenlayer/blocklake/v1/blockchain.pb.go b/protos/eigenlayer/blocklake/v1/blockchain.pb.go index 91aa0658..29da4f5c 100644 --- a/protos/eigenlayer/blocklake/v1/blockchain.pb.go +++ b/protos/eigenlayer/blocklake/v1/blockchain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: eigenlayer/blocklake/v1/blockchain.proto @@ -906,26 +906,26 @@ var file_eigenlayer_blocklake_v1_blockchain_proto_rawDesc = []byte{ 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x4d, 0x41, 0x49, 0x4e, 0x4e, 0x45, 0x54, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, - 0x4b, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x4e, 0x45, 0x54, 0x10, 0x02, 0x42, 0xa4, 0x02, 0x0a, 0x26, + 0x4b, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x4e, 0x45, 0x54, 0x10, 0x02, 0x42, 0xa1, 0x02, 0x0a, 0x26, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x76, 0x31, 0x42, 0x0f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, - 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x61, 0x79, 0x72, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x6c, 0x61, 0x6b, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x73, 0x2f, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x45, 0x42, 0x42, 0xaa, - 0x02, 0x22, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, - 0x6e, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x22, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, - 0x72, 0x5c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x5c, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x2e, 0x45, 0x69, 0x67, 0x65, - 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, - 0x5c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5c, 0x56, 0x31, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x25, 0x45, 0x69, 0x67, - 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x3a, 0x3a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, - 0x6b, 0x65, 0x3a, 0x3a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4c, 0x61, 0x79, 0x72, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, + 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x65, + 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, + 0x61, 0x6b, 0x65, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x45, 0x42, 0x42, 0xaa, 0x02, 0x22, 0x45, + 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, + 0x61, 0x6b, 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x56, + 0x31, 0xca, 0x02, 0x22, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x5c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x2e, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, + 0x79, 0x65, 0x72, 0x5c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x5c, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x25, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, + 0x61, 0x79, 0x65, 0x72, 0x3a, 0x3a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x6c, 0x61, 0x6b, 0x65, 0x3a, + 0x3a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -942,7 +942,7 @@ func file_eigenlayer_blocklake_v1_blockchain_proto_rawDescGZIP() []byte { var file_eigenlayer_blocklake_v1_blockchain_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_eigenlayer_blocklake_v1_blockchain_proto_goTypes = []interface{}{ +var file_eigenlayer_blocklake_v1_blockchain_proto_goTypes = []any{ (Network)(0), // 0: eigenlayer.blocklake.blockchain.v1.Network (*BlockHeader)(nil), // 1: eigenlayer.blocklake.blockchain.v1.BlockHeader (*Transaction)(nil), // 2: eigenlayer.blocklake.blockchain.v1.Transaction @@ -970,7 +970,7 @@ func file_eigenlayer_blocklake_v1_blockchain_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*BlockHeader); i { case 0: return &v.state @@ -982,7 +982,7 @@ func file_eigenlayer_blocklake_v1_blockchain_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Transaction); i { case 0: return &v.state @@ -994,7 +994,7 @@ func file_eigenlayer_blocklake_v1_blockchain_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*TransactionReceipt); i { case 0: return &v.state @@ -1006,7 +1006,7 @@ func file_eigenlayer_blocklake_v1_blockchain_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Withdrawal); i { case 0: return &v.state @@ -1018,7 +1018,7 @@ func file_eigenlayer_blocklake_v1_blockchain_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Block); i { case 0: return &v.state @@ -1030,7 +1030,7 @@ func file_eigenlayer_blocklake_v1_blockchain_proto_init() { return nil } } - file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_eigenlayer_blocklake_v1_blockchain_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Transaction_SignatureValues); i { case 0: return &v.state diff --git a/protos/eigenlayer/sidecar/v1/api.pb.go b/protos/eigenlayer/sidecar/v1/api.pb.go new file mode 100644 index 00000000..4565b199 --- /dev/null +++ b/protos/eigenlayer/sidecar/v1/api.pb.go @@ -0,0 +1,1312 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: eigenlayer/sidecar/v1/api.proto + +package v1 + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GetBlockHeightRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetBlockHeightRequest) Reset() { + *x = GetBlockHeightRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockHeightRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockHeightRequest) ProtoMessage() {} + +func (x *GetBlockHeightRequest) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockHeightRequest.ProtoReflect.Descriptor instead. +func (*GetBlockHeightRequest) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{0} +} + +type GetBlockHeightResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockNumber uint64 `protobuf:"varint,1,opt,name=blockNumber,proto3" json:"blockNumber,omitempty"` + BlockHash []byte `protobuf:"bytes,2,opt,name=blockHash,proto3" json:"blockHash,omitempty"` +} + +func (x *GetBlockHeightResponse) Reset() { + *x = GetBlockHeightResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockHeightResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockHeightResponse) ProtoMessage() {} + +func (x *GetBlockHeightResponse) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockHeightResponse.ProtoReflect.Descriptor instead. +func (*GetBlockHeightResponse) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{1} +} + +func (x *GetBlockHeightResponse) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +func (x *GetBlockHeightResponse) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +type GetStateRootRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockNumber uint64 `protobuf:"varint,1,opt,name=blockNumber,proto3" json:"blockNumber,omitempty"` +} + +func (x *GetStateRootRequest) Reset() { + *x = GetStateRootRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetStateRootRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStateRootRequest) ProtoMessage() {} + +func (x *GetStateRootRequest) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStateRootRequest.ProtoReflect.Descriptor instead. +func (*GetStateRootRequest) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{2} +} + +func (x *GetStateRootRequest) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +type GetStateRootResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + StateRoot []byte `protobuf:"bytes,1,opt,name=stateRoot,proto3" json:"stateRoot,omitempty"` +} + +func (x *GetStateRootResponse) Reset() { + *x = GetStateRootResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetStateRootResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStateRootResponse) ProtoMessage() {} + +func (x *GetStateRootResponse) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStateRootResponse.ProtoReflect.Descriptor instead. +func (*GetStateRootResponse) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{3} +} + +func (x *GetStateRootResponse) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +type GetRewardsRootRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockNumber uint64 `protobuf:"varint,1,opt,name=blockNumber,proto3" json:"blockNumber,omitempty"` +} + +func (x *GetRewardsRootRequest) Reset() { + *x = GetRewardsRootRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRewardsRootRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRewardsRootRequest) ProtoMessage() {} + +func (x *GetRewardsRootRequest) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRewardsRootRequest.ProtoReflect.Descriptor instead. +func (*GetRewardsRootRequest) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{4} +} + +func (x *GetRewardsRootRequest) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +type GetRewardsRootResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RewardsRoot []byte `protobuf:"bytes,1,opt,name=rewardsRoot,proto3" json:"rewardsRoot,omitempty"` +} + +func (x *GetRewardsRootResponse) Reset() { + *x = GetRewardsRootResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRewardsRootResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRewardsRootResponse) ProtoMessage() {} + +func (x *GetRewardsRootResponse) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRewardsRootResponse.ProtoReflect.Descriptor instead. +func (*GetRewardsRootResponse) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{5} +} + +func (x *GetRewardsRootResponse) GetRewardsRoot() []byte { + if x != nil { + return x.RewardsRoot + } + return nil +} + +type GenerateClaimProofRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EarnerAddress string `protobuf:"bytes,1,opt,name=earner_address,json=earnerAddress,proto3" json:"earner_address,omitempty"` + Tokens []string `protobuf:"bytes,2,rep,name=tokens,proto3" json:"tokens,omitempty"` +} + +func (x *GenerateClaimProofRequest) Reset() { + *x = GenerateClaimProofRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenerateClaimProofRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenerateClaimProofRequest) ProtoMessage() {} + +func (x *GenerateClaimProofRequest) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GenerateClaimProofRequest.ProtoReflect.Descriptor instead. +func (*GenerateClaimProofRequest) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{6} +} + +func (x *GenerateClaimProofRequest) GetEarnerAddress() string { + if x != nil { + return x.EarnerAddress + } + return "" +} + +func (x *GenerateClaimProofRequest) GetTokens() []string { + if x != nil { + return x.Tokens + } + return nil +} + +type EarnerLeaf struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Earner string `protobuf:"bytes,1,opt,name=earner,proto3" json:"earner,omitempty"` + EarnerTokenRoot string `protobuf:"bytes,2,opt,name=earner_token_root,json=earnerTokenRoot,proto3" json:"earner_token_root,omitempty"` +} + +func (x *EarnerLeaf) Reset() { + *x = EarnerLeaf{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EarnerLeaf) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EarnerLeaf) ProtoMessage() {} + +func (x *EarnerLeaf) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EarnerLeaf.ProtoReflect.Descriptor instead. +func (*EarnerLeaf) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{7} +} + +func (x *EarnerLeaf) GetEarner() string { + if x != nil { + return x.Earner + } + return "" +} + +func (x *EarnerLeaf) GetEarnerTokenRoot() string { + if x != nil { + return x.EarnerTokenRoot + } + return "" +} + +type TokenLeaf struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + CumulativeEarnings string `protobuf:"bytes,2,opt,name=cumulative_earnings,json=cumulativeEarnings,proto3" json:"cumulative_earnings,omitempty"` +} + +func (x *TokenLeaf) Reset() { + *x = TokenLeaf{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TokenLeaf) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TokenLeaf) ProtoMessage() {} + +func (x *TokenLeaf) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TokenLeaf.ProtoReflect.Descriptor instead. +func (*TokenLeaf) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{8} +} + +func (x *TokenLeaf) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +func (x *TokenLeaf) GetCumulativeEarnings() string { + if x != nil { + return x.CumulativeEarnings + } + return "" +} + +type Proof struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` + RootIndex uint32 `protobuf:"varint,2,opt,name=root_index,json=rootIndex,proto3" json:"root_index,omitempty"` + EarnerIndex uint32 `protobuf:"varint,3,opt,name=earner_index,json=earnerIndex,proto3" json:"earner_index,omitempty"` + EarnerTreeProof string `protobuf:"bytes,4,opt,name=earner_tree_proof,json=earnerTreeProof,proto3" json:"earner_tree_proof,omitempty"` + EarnerLeaf *EarnerLeaf `protobuf:"bytes,5,opt,name=earner_leaf,json=earnerLeaf,proto3" json:"earner_leaf,omitempty"` + LeafIndices []uint32 `protobuf:"varint,6,rep,packed,name=leaf_indices,json=leafIndices,proto3" json:"leaf_indices,omitempty"` + TokenTreeProofs []string `protobuf:"bytes,7,rep,name=token_tree_proofs,json=tokenTreeProofs,proto3" json:"token_tree_proofs,omitempty"` + TokenLeaves []*TokenLeaf `protobuf:"bytes,8,rep,name=token_leaves,json=tokenLeaves,proto3" json:"token_leaves,omitempty"` +} + +func (x *Proof) Reset() { + *x = Proof{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Proof) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Proof) ProtoMessage() {} + +func (x *Proof) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Proof.ProtoReflect.Descriptor instead. +func (*Proof) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{9} +} + +func (x *Proof) GetRoot() string { + if x != nil { + return x.Root + } + return "" +} + +func (x *Proof) GetRootIndex() uint32 { + if x != nil { + return x.RootIndex + } + return 0 +} + +func (x *Proof) GetEarnerIndex() uint32 { + if x != nil { + return x.EarnerIndex + } + return 0 +} + +func (x *Proof) GetEarnerTreeProof() string { + if x != nil { + return x.EarnerTreeProof + } + return "" +} + +func (x *Proof) GetEarnerLeaf() *EarnerLeaf { + if x != nil { + return x.EarnerLeaf + } + return nil +} + +func (x *Proof) GetLeafIndices() []uint32 { + if x != nil { + return x.LeafIndices + } + return nil +} + +func (x *Proof) GetTokenTreeProofs() []string { + if x != nil { + return x.TokenTreeProofs + } + return nil +} + +func (x *Proof) GetTokenLeaves() []*TokenLeaf { + if x != nil { + return x.TokenLeaves + } + return nil +} + +type GenerateClaimProofResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Proof *Proof `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (x *GenerateClaimProofResponse) Reset() { + *x = GenerateClaimProofResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenerateClaimProofResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenerateClaimProofResponse) ProtoMessage() {} + +func (x *GenerateClaimProofResponse) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GenerateClaimProofResponse.ProtoReflect.Descriptor instead. +func (*GenerateClaimProofResponse) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{10} +} + +func (x *GenerateClaimProofResponse) GetProof() *Proof { + if x != nil { + return x.Proof + } + return nil +} + +type GetAvailableRewardsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EarnerAddress string `protobuf:"bytes,1,opt,name=earner_address,json=earnerAddress,proto3" json:"earner_address,omitempty"` +} + +func (x *GetAvailableRewardsRequest) Reset() { + *x = GetAvailableRewardsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetAvailableRewardsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAvailableRewardsRequest) ProtoMessage() {} + +func (x *GetAvailableRewardsRequest) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAvailableRewardsRequest.ProtoReflect.Descriptor instead. +func (*GetAvailableRewardsRequest) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{11} +} + +func (x *GetAvailableRewardsRequest) GetEarnerAddress() string { + if x != nil { + return x.EarnerAddress + } + return "" +} + +type Reward struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *Reward) Reset() { + *x = Reward{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Reward) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Reward) ProtoMessage() {} + +func (x *Reward) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Reward.ProtoReflect.Descriptor instead. +func (*Reward) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{12} +} + +func (x *Reward) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +func (x *Reward) GetAmount() string { + if x != nil { + return x.Amount + } + return "" +} + +type GetAvailableRewardsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rewards []*Reward `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards,omitempty"` +} + +func (x *GetAvailableRewardsResponse) Reset() { + *x = GetAvailableRewardsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetAvailableRewardsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAvailableRewardsResponse) ProtoMessage() {} + +func (x *GetAvailableRewardsResponse) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAvailableRewardsResponse.ProtoReflect.Descriptor instead. +func (*GetAvailableRewardsResponse) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{13} +} + +func (x *GetAvailableRewardsResponse) GetRewards() []*Reward { + if x != nil { + return x.Rewards + } + return nil +} + +type GetAvailableRewardsTokensRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EarnerAddress string `protobuf:"bytes,1,opt,name=earner_address,json=earnerAddress,proto3" json:"earner_address,omitempty"` +} + +func (x *GetAvailableRewardsTokensRequest) Reset() { + *x = GetAvailableRewardsTokensRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetAvailableRewardsTokensRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAvailableRewardsTokensRequest) ProtoMessage() {} + +func (x *GetAvailableRewardsTokensRequest) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAvailableRewardsTokensRequest.ProtoReflect.Descriptor instead. +func (*GetAvailableRewardsTokensRequest) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{14} +} + +func (x *GetAvailableRewardsTokensRequest) GetEarnerAddress() string { + if x != nil { + return x.EarnerAddress + } + return "" +} + +type GetAvailableRewardsTokensResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` +} + +func (x *GetAvailableRewardsTokensResponse) Reset() { + *x = GetAvailableRewardsTokensResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetAvailableRewardsTokensResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAvailableRewardsTokensResponse) ProtoMessage() {} + +func (x *GetAvailableRewardsTokensResponse) ProtoReflect() protoreflect.Message { + mi := &file_eigenlayer_sidecar_v1_api_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAvailableRewardsTokensResponse.ProtoReflect.Descriptor instead. +func (*GetAvailableRewardsTokensResponse) Descriptor() ([]byte, []int) { + return file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP(), []int{15} +} + +func (x *GetAvailableRewardsTokensResponse) GetTokens() []string { + if x != nil { + return x.Tokens + } + return nil +} + +var File_eigenlayer_sidecar_v1_api_proto protoreflect.FileDescriptor + +var file_eigenlayer_sidecar_v1_api_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x73, 0x69, 0x64, + 0x65, 0x63, 0x61, 0x72, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x19, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, + 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x17, 0x0a, 0x15, 0x47, 0x65, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x22, 0x58, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, + 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, + 0x1c, 0x0a, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x22, 0x37, 0x0a, + 0x13, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x34, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, + 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0x39, 0x0a, 0x15, + 0x47, 0x65, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x3a, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x52, 0x65, + 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x6f, 0x6f, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, + 0x6f, 0x6f, 0x74, 0x22, 0x5a, 0x0a, 0x19, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, + 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x25, 0x0a, 0x0e, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x22, + 0x50, 0x0a, 0x0a, 0x45, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x66, 0x12, 0x16, 0x0a, + 0x06, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, + 0x61, 0x72, 0x6e, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x11, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x5f, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0f, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x6f, 0x6f, + 0x74, 0x22, 0x52, 0x0a, 0x09, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x4c, 0x65, 0x61, 0x66, 0x12, 0x14, + 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x13, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, + 0x76, 0x65, 0x5f, 0x65, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x12, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x45, 0x61, 0x72, + 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x22, 0xe9, 0x02, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, + 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, + 0x6f, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, + 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x6f, 0x6f, 0x74, 0x49, 0x6e, 0x64, + 0x65, 0x78, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x64, + 0x65, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x2a, 0x0a, 0x11, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x5f, + 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0f, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x54, 0x72, 0x65, 0x65, 0x50, 0x72, 0x6f, 0x6f, + 0x66, 0x12, 0x46, 0x0a, 0x0b, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x61, 0x66, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, + 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x45, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x66, 0x52, 0x0a, 0x65, + 0x61, 0x72, 0x6e, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x66, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x65, 0x61, + 0x66, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0d, 0x52, + 0x0b, 0x6c, 0x65, 0x61, 0x66, 0x49, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x11, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, + 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x54, 0x72, + 0x65, 0x65, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x12, 0x47, 0x0a, 0x0c, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x5f, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, + 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, + 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x4c, 0x65, 0x61, 0x66, 0x52, 0x0b, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x4c, 0x65, 0x61, 0x76, 0x65, + 0x73, 0x22, 0x54, 0x0a, 0x1a, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x61, + 0x69, 0x6d, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x36, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, + 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, + 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, + 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x43, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x41, 0x76, + 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, + 0x61, 0x72, 0x6e, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x36, 0x0a, 0x06, + 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x16, 0x0a, 0x06, + 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6d, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x5a, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, + 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x07, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x07, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, + 0x22, 0x49, 0x0a, 0x20, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, + 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x72, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x61, + 0x72, 0x6e, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x3b, 0x0a, 0x21, 0x47, + 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, 0x61, 0x72, + 0x64, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x06, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x32, 0xec, 0x07, 0x0a, 0x0a, 0x53, 0x69, 0x64, + 0x65, 0x63, 0x61, 0x72, 0x52, 0x70, 0x63, 0x12, 0x92, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x30, 0x2e, 0x65, 0x69, 0x67, + 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x65, + 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, + 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x3a, 0x01, 0x2a, 0x22, 0x10, 0x2f, 0x76, 0x31, 0x2f, + 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x99, 0x01, 0x0a, + 0x0c, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2e, 0x2e, + 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, + 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, + 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, + 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22, 0x3a, 0x01, 0x2a, 0x22, 0x1d, 0x2f, 0x76, 0x31, 0x2f, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x2d, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x2f, 0x7b, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x7d, 0x12, 0xa1, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, + 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x30, 0x2e, 0x65, 0x69, + 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, + 0x64, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, + 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, + 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x77, + 0x61, 0x72, 0x64, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x2a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x3a, 0x01, 0x2a, 0x22, 0x1f, 0x2f, 0x76, 0x31, + 0x2f, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x2d, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x2f, 0x7b, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x7d, 0x12, 0x9d, 0x01, 0x0a, + 0x12, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, + 0x6f, 0x6f, 0x66, 0x12, 0x34, 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, + 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, 0x6f, + 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x65, 0x69, 0x67, 0x65, + 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6c, + 0x61, 0x69, 0x6d, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, + 0x2f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x2d, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0xa6, 0x01, 0x0a, + 0x13, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, + 0x61, 0x72, 0x64, 0x73, 0x12, 0x35, 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, + 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x65, 0x69, + 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, + 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, 0x22, 0x15, + 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x2d, 0x72, 0x65, + 0x77, 0x61, 0x72, 0x64, 0x73, 0x12, 0xbf, 0x01, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, + 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x73, 0x12, 0x3b, 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, + 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, 0x61, + 0x72, 0x64, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x3c, 0x2e, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, + 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, + 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x27, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x3a, 0x01, 0x2a, 0x22, 0x1c, 0x2f, 0x76, 0x31, 0x2f, 0x61, + 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x2d, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, + 0x2d, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x42, 0xe7, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, + 0x65, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x73, 0x69, 0x64, 0x65, 0x63, + 0x61, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x41, 0x70, 0x69, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x4c, 0x61, 0x79, 0x72, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x73, 0x69, 0x64, 0x65, + 0x63, 0x61, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x65, 0x69, 0x67, 0x65, 0x6e, + 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x45, + 0x53, 0x41, 0xaa, 0x02, 0x19, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, + 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, + 0x19, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x53, 0x69, 0x64, 0x65, + 0x63, 0x61, 0x72, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x25, 0x45, 0x69, 0x67, + 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x5c, + 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x1c, 0x45, 0x69, 0x67, 0x65, 0x6e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x3a, + 0x3a, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_eigenlayer_sidecar_v1_api_proto_rawDescOnce sync.Once + file_eigenlayer_sidecar_v1_api_proto_rawDescData = file_eigenlayer_sidecar_v1_api_proto_rawDesc +) + +func file_eigenlayer_sidecar_v1_api_proto_rawDescGZIP() []byte { + file_eigenlayer_sidecar_v1_api_proto_rawDescOnce.Do(func() { + file_eigenlayer_sidecar_v1_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_eigenlayer_sidecar_v1_api_proto_rawDescData) + }) + return file_eigenlayer_sidecar_v1_api_proto_rawDescData +} + +var file_eigenlayer_sidecar_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_eigenlayer_sidecar_v1_api_proto_goTypes = []any{ + (*GetBlockHeightRequest)(nil), // 0: eigenlayer.sidecar.api.v1.GetBlockHeightRequest + (*GetBlockHeightResponse)(nil), // 1: eigenlayer.sidecar.api.v1.GetBlockHeightResponse + (*GetStateRootRequest)(nil), // 2: eigenlayer.sidecar.api.v1.GetStateRootRequest + (*GetStateRootResponse)(nil), // 3: eigenlayer.sidecar.api.v1.GetStateRootResponse + (*GetRewardsRootRequest)(nil), // 4: eigenlayer.sidecar.api.v1.GetRewardsRootRequest + (*GetRewardsRootResponse)(nil), // 5: eigenlayer.sidecar.api.v1.GetRewardsRootResponse + (*GenerateClaimProofRequest)(nil), // 6: eigenlayer.sidecar.api.v1.GenerateClaimProofRequest + (*EarnerLeaf)(nil), // 7: eigenlayer.sidecar.api.v1.EarnerLeaf + (*TokenLeaf)(nil), // 8: eigenlayer.sidecar.api.v1.TokenLeaf + (*Proof)(nil), // 9: eigenlayer.sidecar.api.v1.Proof + (*GenerateClaimProofResponse)(nil), // 10: eigenlayer.sidecar.api.v1.GenerateClaimProofResponse + (*GetAvailableRewardsRequest)(nil), // 11: eigenlayer.sidecar.api.v1.GetAvailableRewardsRequest + (*Reward)(nil), // 12: eigenlayer.sidecar.api.v1.Reward + (*GetAvailableRewardsResponse)(nil), // 13: eigenlayer.sidecar.api.v1.GetAvailableRewardsResponse + (*GetAvailableRewardsTokensRequest)(nil), // 14: eigenlayer.sidecar.api.v1.GetAvailableRewardsTokensRequest + (*GetAvailableRewardsTokensResponse)(nil), // 15: eigenlayer.sidecar.api.v1.GetAvailableRewardsTokensResponse +} +var file_eigenlayer_sidecar_v1_api_proto_depIdxs = []int32{ + 7, // 0: eigenlayer.sidecar.api.v1.Proof.earner_leaf:type_name -> eigenlayer.sidecar.api.v1.EarnerLeaf + 8, // 1: eigenlayer.sidecar.api.v1.Proof.token_leaves:type_name -> eigenlayer.sidecar.api.v1.TokenLeaf + 9, // 2: eigenlayer.sidecar.api.v1.GenerateClaimProofResponse.proof:type_name -> eigenlayer.sidecar.api.v1.Proof + 12, // 3: eigenlayer.sidecar.api.v1.GetAvailableRewardsResponse.rewards:type_name -> eigenlayer.sidecar.api.v1.Reward + 0, // 4: eigenlayer.sidecar.api.v1.SidecarRpc.GetBlockHeight:input_type -> eigenlayer.sidecar.api.v1.GetBlockHeightRequest + 2, // 5: eigenlayer.sidecar.api.v1.SidecarRpc.GetStateRoot:input_type -> eigenlayer.sidecar.api.v1.GetStateRootRequest + 4, // 6: eigenlayer.sidecar.api.v1.SidecarRpc.GetRewardsRoot:input_type -> eigenlayer.sidecar.api.v1.GetRewardsRootRequest + 6, // 7: eigenlayer.sidecar.api.v1.SidecarRpc.GenerateClaimProof:input_type -> eigenlayer.sidecar.api.v1.GenerateClaimProofRequest + 11, // 8: eigenlayer.sidecar.api.v1.SidecarRpc.GetAvailableRewards:input_type -> eigenlayer.sidecar.api.v1.GetAvailableRewardsRequest + 14, // 9: eigenlayer.sidecar.api.v1.SidecarRpc.GetAvailableRewardsTokens:input_type -> eigenlayer.sidecar.api.v1.GetAvailableRewardsTokensRequest + 1, // 10: eigenlayer.sidecar.api.v1.SidecarRpc.GetBlockHeight:output_type -> eigenlayer.sidecar.api.v1.GetBlockHeightResponse + 3, // 11: eigenlayer.sidecar.api.v1.SidecarRpc.GetStateRoot:output_type -> eigenlayer.sidecar.api.v1.GetStateRootResponse + 5, // 12: eigenlayer.sidecar.api.v1.SidecarRpc.GetRewardsRoot:output_type -> eigenlayer.sidecar.api.v1.GetRewardsRootResponse + 10, // 13: eigenlayer.sidecar.api.v1.SidecarRpc.GenerateClaimProof:output_type -> eigenlayer.sidecar.api.v1.GenerateClaimProofResponse + 13, // 14: eigenlayer.sidecar.api.v1.SidecarRpc.GetAvailableRewards:output_type -> eigenlayer.sidecar.api.v1.GetAvailableRewardsResponse + 15, // 15: eigenlayer.sidecar.api.v1.SidecarRpc.GetAvailableRewardsTokens:output_type -> eigenlayer.sidecar.api.v1.GetAvailableRewardsTokensResponse + 10, // [10:16] is the sub-list for method output_type + 4, // [4:10] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_eigenlayer_sidecar_v1_api_proto_init() } +func file_eigenlayer_sidecar_v1_api_proto_init() { + if File_eigenlayer_sidecar_v1_api_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_eigenlayer_sidecar_v1_api_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*GetBlockHeightRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*GetBlockHeightResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*GetStateRootRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*GetStateRootResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*GetRewardsRootRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*GetRewardsRootResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*GenerateClaimProofRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*EarnerLeaf); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*TokenLeaf); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*Proof); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*GenerateClaimProofResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*GetAvailableRewardsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*Reward); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[13].Exporter = func(v any, i int) any { + switch v := v.(*GetAvailableRewardsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[14].Exporter = func(v any, i int) any { + switch v := v.(*GetAvailableRewardsTokensRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_eigenlayer_sidecar_v1_api_proto_msgTypes[15].Exporter = func(v any, i int) any { + switch v := v.(*GetAvailableRewardsTokensResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_eigenlayer_sidecar_v1_api_proto_rawDesc, + NumEnums: 0, + NumMessages: 16, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_eigenlayer_sidecar_v1_api_proto_goTypes, + DependencyIndexes: file_eigenlayer_sidecar_v1_api_proto_depIdxs, + MessageInfos: file_eigenlayer_sidecar_v1_api_proto_msgTypes, + }.Build() + File_eigenlayer_sidecar_v1_api_proto = out.File + file_eigenlayer_sidecar_v1_api_proto_rawDesc = nil + file_eigenlayer_sidecar_v1_api_proto_goTypes = nil + file_eigenlayer_sidecar_v1_api_proto_depIdxs = nil +} diff --git a/protos/eigenlayer/sidecar/v1/api.pb.gw.go b/protos/eigenlayer/sidecar/v1/api.pb.gw.go new file mode 100644 index 00000000..3ca0cb06 --- /dev/null +++ b/protos/eigenlayer/sidecar/v1/api.pb.gw.go @@ -0,0 +1,617 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: eigenlayer/sidecar/v1/api.proto + +/* +Package v1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package v1 + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +func request_SidecarRpc_GetBlockHeight_0(ctx context.Context, marshaler runtime.Marshaler, client SidecarRpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetBlockHeightRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetBlockHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SidecarRpc_GetBlockHeight_0(ctx context.Context, marshaler runtime.Marshaler, server SidecarRpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetBlockHeightRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetBlockHeight(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SidecarRpc_GetStateRoot_0(ctx context.Context, marshaler runtime.Marshaler, client SidecarRpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetStateRootRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["blockNumber"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "blockNumber") + } + + protoReq.BlockNumber, err = runtime.Uint64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "blockNumber", err) + } + + msg, err := client.GetStateRoot(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SidecarRpc_GetStateRoot_0(ctx context.Context, marshaler runtime.Marshaler, server SidecarRpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetStateRootRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["blockNumber"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "blockNumber") + } + + protoReq.BlockNumber, err = runtime.Uint64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "blockNumber", err) + } + + msg, err := server.GetStateRoot(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SidecarRpc_GetRewardsRoot_0(ctx context.Context, marshaler runtime.Marshaler, client SidecarRpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRewardsRootRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["blockNumber"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "blockNumber") + } + + protoReq.BlockNumber, err = runtime.Uint64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "blockNumber", err) + } + + msg, err := client.GetRewardsRoot(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SidecarRpc_GetRewardsRoot_0(ctx context.Context, marshaler runtime.Marshaler, server SidecarRpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRewardsRootRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["blockNumber"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "blockNumber") + } + + protoReq.BlockNumber, err = runtime.Uint64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "blockNumber", err) + } + + msg, err := server.GetRewardsRoot(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SidecarRpc_GenerateClaimProof_0(ctx context.Context, marshaler runtime.Marshaler, client SidecarRpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GenerateClaimProofRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GenerateClaimProof(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SidecarRpc_GenerateClaimProof_0(ctx context.Context, marshaler runtime.Marshaler, server SidecarRpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GenerateClaimProofRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GenerateClaimProof(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SidecarRpc_GetAvailableRewards_0(ctx context.Context, marshaler runtime.Marshaler, client SidecarRpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAvailableRewardsRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetAvailableRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SidecarRpc_GetAvailableRewards_0(ctx context.Context, marshaler runtime.Marshaler, server SidecarRpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAvailableRewardsRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetAvailableRewards(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SidecarRpc_GetAvailableRewardsTokens_0(ctx context.Context, marshaler runtime.Marshaler, client SidecarRpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAvailableRewardsTokensRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetAvailableRewardsTokens(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SidecarRpc_GetAvailableRewardsTokens_0(ctx context.Context, marshaler runtime.Marshaler, server SidecarRpcServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAvailableRewardsTokensRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetAvailableRewardsTokens(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterSidecarRpcHandlerServer registers the http handlers for service SidecarRpc to "mux". +// UnaryRPC :call SidecarRpcServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSidecarRpcHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterSidecarRpcHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SidecarRpcServer) error { + + mux.Handle("POST", pattern_SidecarRpc_GetBlockHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetBlockHeight", runtime.WithHTTPPathPattern("/v1/latest-block")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SidecarRpc_GetBlockHeight_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetBlockHeight_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GetStateRoot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetStateRoot", runtime.WithHTTPPathPattern("/v1/state-roots/{blockNumber}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SidecarRpc_GetStateRoot_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetStateRoot_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GetRewardsRoot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetRewardsRoot", runtime.WithHTTPPathPattern("/v1/rewards-roots/{blockNumber}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SidecarRpc_GetRewardsRoot_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetRewardsRoot_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GenerateClaimProof_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GenerateClaimProof", runtime.WithHTTPPathPattern("/v1/claim-proof")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SidecarRpc_GenerateClaimProof_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GenerateClaimProof_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GetAvailableRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetAvailableRewards", runtime.WithHTTPPathPattern("/v1/available-rewards")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SidecarRpc_GetAvailableRewards_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetAvailableRewards_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GetAvailableRewardsTokens_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetAvailableRewardsTokens", runtime.WithHTTPPathPattern("/v1/available-rewards-tokens")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SidecarRpc_GetAvailableRewardsTokens_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetAvailableRewardsTokens_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterSidecarRpcHandlerFromEndpoint is same as RegisterSidecarRpcHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterSidecarRpcHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterSidecarRpcHandler(ctx, mux, conn) +} + +// RegisterSidecarRpcHandler registers the http handlers for service SidecarRpc to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterSidecarRpcHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterSidecarRpcHandlerClient(ctx, mux, NewSidecarRpcClient(conn)) +} + +// RegisterSidecarRpcHandlerClient registers the http handlers for service SidecarRpc +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SidecarRpcClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SidecarRpcClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "SidecarRpcClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterSidecarRpcHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SidecarRpcClient) error { + + mux.Handle("POST", pattern_SidecarRpc_GetBlockHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetBlockHeight", runtime.WithHTTPPathPattern("/v1/latest-block")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SidecarRpc_GetBlockHeight_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetBlockHeight_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GetStateRoot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetStateRoot", runtime.WithHTTPPathPattern("/v1/state-roots/{blockNumber}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SidecarRpc_GetStateRoot_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetStateRoot_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GetRewardsRoot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetRewardsRoot", runtime.WithHTTPPathPattern("/v1/rewards-roots/{blockNumber}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SidecarRpc_GetRewardsRoot_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetRewardsRoot_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GenerateClaimProof_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GenerateClaimProof", runtime.WithHTTPPathPattern("/v1/claim-proof")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SidecarRpc_GenerateClaimProof_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GenerateClaimProof_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GetAvailableRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetAvailableRewards", runtime.WithHTTPPathPattern("/v1/available-rewards")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SidecarRpc_GetAvailableRewards_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetAvailableRewards_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SidecarRpc_GetAvailableRewardsTokens_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/eigenlayer.sidecar.api.v1.SidecarRpc/GetAvailableRewardsTokens", runtime.WithHTTPPathPattern("/v1/available-rewards-tokens")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SidecarRpc_GetAvailableRewardsTokens_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SidecarRpc_GetAvailableRewardsTokens_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_SidecarRpc_GetBlockHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "latest-block"}, "")) + + pattern_SidecarRpc_GetStateRoot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "state-roots", "blockNumber"}, "")) + + pattern_SidecarRpc_GetRewardsRoot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "rewards-roots", "blockNumber"}, "")) + + pattern_SidecarRpc_GenerateClaimProof_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "claim-proof"}, "")) + + pattern_SidecarRpc_GetAvailableRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "available-rewards"}, "")) + + pattern_SidecarRpc_GetAvailableRewardsTokens_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "available-rewards-tokens"}, "")) +) + +var ( + forward_SidecarRpc_GetBlockHeight_0 = runtime.ForwardResponseMessage + + forward_SidecarRpc_GetStateRoot_0 = runtime.ForwardResponseMessage + + forward_SidecarRpc_GetRewardsRoot_0 = runtime.ForwardResponseMessage + + forward_SidecarRpc_GenerateClaimProof_0 = runtime.ForwardResponseMessage + + forward_SidecarRpc_GetAvailableRewards_0 = runtime.ForwardResponseMessage + + forward_SidecarRpc_GetAvailableRewardsTokens_0 = runtime.ForwardResponseMessage +) diff --git a/protos/eigenlayer/sidecar/v1/api.proto b/protos/eigenlayer/sidecar/v1/api.proto new file mode 100644 index 00000000..45a4a094 --- /dev/null +++ b/protos/eigenlayer/sidecar/v1/api.proto @@ -0,0 +1,127 @@ +syntax = "proto3"; + +package eigenlayer.sidecar.api.v1; + +option go_package = "github.com/Layr-Labs/sidecar/protos/eigenlayer/api/v1"; + +import "google/api/annotations.proto"; + +message GetBlockHeightRequest { +} + +message GetBlockHeightResponse { + uint64 blockNumber = 1; + bytes blockHash = 2; +} + +message GetStateRootRequest { + uint64 blockNumber = 1; +} + +message GetStateRootResponse { + bytes stateRoot = 1; +} + +message GetRewardsRootRequest { + uint64 blockNumber = 1; +} + +message GetRewardsRootResponse { + bytes rewardsRoot = 1; +} + +message GenerateClaimProofRequest { + string earner_address = 1; + repeated string tokens = 2; +} + +message EarnerLeaf { + string earner = 1; + string earner_token_root = 2; +} + +message TokenLeaf { + string token = 1; + string cumulative_earnings = 2; +} + +message Proof { + string root = 1; + uint32 root_index = 2; + uint32 earner_index = 3; + string earner_tree_proof = 4; + EarnerLeaf earner_leaf = 5; + repeated uint32 leaf_indices = 6; + repeated string token_tree_proofs = 7; + repeated TokenLeaf token_leaves = 8; +} + +message GenerateClaimProofResponse { + Proof proof = 1; +} + +message GetAvailableRewardsRequest { + string earner_address = 1; +} + +message Reward { + string token = 1; + string amount = 2; +} + +message GetAvailableRewardsResponse { + repeated Reward rewards = 1; +} + +message GetAvailableRewardsTokensRequest { + string earner_address = 1; +} + +message GetAvailableRewardsTokensResponse { + repeated string tokens = 1; +} + +service SidecarRpc { + rpc GetBlockHeight(GetBlockHeightRequest) returns (GetBlockHeightResponse) { + option (google.api.http) = { + post: "/v1/latest-block" + body: "*" + }; + } + + rpc GetStateRoot(GetStateRootRequest) returns (GetStateRootResponse) { + option (google.api.http) = { + post: "/v1/state-roots/{blockNumber}" + body: "*" + }; + } + + rpc GetRewardsRoot(GetRewardsRootRequest) returns (GetRewardsRootResponse) { + option (google.api.http) = { + post: "/v1/rewards-roots/{blockNumber}" + body: "*" + }; + } + + rpc GenerateClaimProof(GenerateClaimProofRequest) returns (GenerateClaimProofResponse) { + option (google.api.http) = { + post: "/v1/claim-proof" + body: "*" + }; + } + + rpc GetAvailableRewards(GetAvailableRewardsRequest) returns (GetAvailableRewardsResponse) { + option (google.api.http) = { + post: "/v1/available-rewards" + body: "*" + }; + } + + rpc GetAvailableRewardsTokens(GetAvailableRewardsTokensRequest) returns (GetAvailableRewardsTokensResponse) { + option (google.api.http) = { + post: "/v1/available-rewards-tokens" + body: "*" + }; + } + +} diff --git a/protos/eigenlayer/sidecar/v1/api_grpc.pb.go b/protos/eigenlayer/sidecar/v1/api_grpc.pb.go new file mode 100644 index 00000000..bf3528fd --- /dev/null +++ b/protos/eigenlayer/sidecar/v1/api_grpc.pb.go @@ -0,0 +1,309 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: eigenlayer/sidecar/v1/api.proto + +package v1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + SidecarRpc_GetBlockHeight_FullMethodName = "/eigenlayer.sidecar.api.v1.SidecarRpc/GetBlockHeight" + SidecarRpc_GetStateRoot_FullMethodName = "/eigenlayer.sidecar.api.v1.SidecarRpc/GetStateRoot" + SidecarRpc_GetRewardsRoot_FullMethodName = "/eigenlayer.sidecar.api.v1.SidecarRpc/GetRewardsRoot" + SidecarRpc_GenerateClaimProof_FullMethodName = "/eigenlayer.sidecar.api.v1.SidecarRpc/GenerateClaimProof" + SidecarRpc_GetAvailableRewards_FullMethodName = "/eigenlayer.sidecar.api.v1.SidecarRpc/GetAvailableRewards" + SidecarRpc_GetAvailableRewardsTokens_FullMethodName = "/eigenlayer.sidecar.api.v1.SidecarRpc/GetAvailableRewardsTokens" +) + +// SidecarRpcClient is the client API for SidecarRpc service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type SidecarRpcClient interface { + GetBlockHeight(ctx context.Context, in *GetBlockHeightRequest, opts ...grpc.CallOption) (*GetBlockHeightResponse, error) + GetStateRoot(ctx context.Context, in *GetStateRootRequest, opts ...grpc.CallOption) (*GetStateRootResponse, error) + GetRewardsRoot(ctx context.Context, in *GetRewardsRootRequest, opts ...grpc.CallOption) (*GetRewardsRootResponse, error) + GenerateClaimProof(ctx context.Context, in *GenerateClaimProofRequest, opts ...grpc.CallOption) (*GenerateClaimProofResponse, error) + GetAvailableRewards(ctx context.Context, in *GetAvailableRewardsRequest, opts ...grpc.CallOption) (*GetAvailableRewardsResponse, error) + GetAvailableRewardsTokens(ctx context.Context, in *GetAvailableRewardsTokensRequest, opts ...grpc.CallOption) (*GetAvailableRewardsTokensResponse, error) +} + +type sidecarRpcClient struct { + cc grpc.ClientConnInterface +} + +func NewSidecarRpcClient(cc grpc.ClientConnInterface) SidecarRpcClient { + return &sidecarRpcClient{cc} +} + +func (c *sidecarRpcClient) GetBlockHeight(ctx context.Context, in *GetBlockHeightRequest, opts ...grpc.CallOption) (*GetBlockHeightResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetBlockHeightResponse) + err := c.cc.Invoke(ctx, SidecarRpc_GetBlockHeight_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sidecarRpcClient) GetStateRoot(ctx context.Context, in *GetStateRootRequest, opts ...grpc.CallOption) (*GetStateRootResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetStateRootResponse) + err := c.cc.Invoke(ctx, SidecarRpc_GetStateRoot_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sidecarRpcClient) GetRewardsRoot(ctx context.Context, in *GetRewardsRootRequest, opts ...grpc.CallOption) (*GetRewardsRootResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetRewardsRootResponse) + err := c.cc.Invoke(ctx, SidecarRpc_GetRewardsRoot_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sidecarRpcClient) GenerateClaimProof(ctx context.Context, in *GenerateClaimProofRequest, opts ...grpc.CallOption) (*GenerateClaimProofResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GenerateClaimProofResponse) + err := c.cc.Invoke(ctx, SidecarRpc_GenerateClaimProof_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sidecarRpcClient) GetAvailableRewards(ctx context.Context, in *GetAvailableRewardsRequest, opts ...grpc.CallOption) (*GetAvailableRewardsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetAvailableRewardsResponse) + err := c.cc.Invoke(ctx, SidecarRpc_GetAvailableRewards_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sidecarRpcClient) GetAvailableRewardsTokens(ctx context.Context, in *GetAvailableRewardsTokensRequest, opts ...grpc.CallOption) (*GetAvailableRewardsTokensResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetAvailableRewardsTokensResponse) + err := c.cc.Invoke(ctx, SidecarRpc_GetAvailableRewardsTokens_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SidecarRpcServer is the server API for SidecarRpc service. +// All implementations should embed UnimplementedSidecarRpcServer +// for forward compatibility. +type SidecarRpcServer interface { + GetBlockHeight(context.Context, *GetBlockHeightRequest) (*GetBlockHeightResponse, error) + GetStateRoot(context.Context, *GetStateRootRequest) (*GetStateRootResponse, error) + GetRewardsRoot(context.Context, *GetRewardsRootRequest) (*GetRewardsRootResponse, error) + GenerateClaimProof(context.Context, *GenerateClaimProofRequest) (*GenerateClaimProofResponse, error) + GetAvailableRewards(context.Context, *GetAvailableRewardsRequest) (*GetAvailableRewardsResponse, error) + GetAvailableRewardsTokens(context.Context, *GetAvailableRewardsTokensRequest) (*GetAvailableRewardsTokensResponse, error) +} + +// UnimplementedSidecarRpcServer should be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedSidecarRpcServer struct{} + +func (UnimplementedSidecarRpcServer) GetBlockHeight(context.Context, *GetBlockHeightRequest) (*GetBlockHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBlockHeight not implemented") +} +func (UnimplementedSidecarRpcServer) GetStateRoot(context.Context, *GetStateRootRequest) (*GetStateRootResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStateRoot not implemented") +} +func (UnimplementedSidecarRpcServer) GetRewardsRoot(context.Context, *GetRewardsRootRequest) (*GetRewardsRootResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRewardsRoot not implemented") +} +func (UnimplementedSidecarRpcServer) GenerateClaimProof(context.Context, *GenerateClaimProofRequest) (*GenerateClaimProofResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GenerateClaimProof not implemented") +} +func (UnimplementedSidecarRpcServer) GetAvailableRewards(context.Context, *GetAvailableRewardsRequest) (*GetAvailableRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAvailableRewards not implemented") +} +func (UnimplementedSidecarRpcServer) GetAvailableRewardsTokens(context.Context, *GetAvailableRewardsTokensRequest) (*GetAvailableRewardsTokensResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAvailableRewardsTokens not implemented") +} +func (UnimplementedSidecarRpcServer) testEmbeddedByValue() {} + +// UnsafeSidecarRpcServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SidecarRpcServer will +// result in compilation errors. +type UnsafeSidecarRpcServer interface { + mustEmbedUnimplementedSidecarRpcServer() +} + +func RegisterSidecarRpcServer(s grpc.ServiceRegistrar, srv SidecarRpcServer) { + // If the following call pancis, it indicates UnimplementedSidecarRpcServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&SidecarRpc_ServiceDesc, srv) +} + +func _SidecarRpc_GetBlockHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBlockHeightRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SidecarRpcServer).GetBlockHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SidecarRpc_GetBlockHeight_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SidecarRpcServer).GetBlockHeight(ctx, req.(*GetBlockHeightRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SidecarRpc_GetStateRoot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetStateRootRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SidecarRpcServer).GetStateRoot(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SidecarRpc_GetStateRoot_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SidecarRpcServer).GetStateRoot(ctx, req.(*GetStateRootRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SidecarRpc_GetRewardsRoot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRewardsRootRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SidecarRpcServer).GetRewardsRoot(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SidecarRpc_GetRewardsRoot_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SidecarRpcServer).GetRewardsRoot(ctx, req.(*GetRewardsRootRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SidecarRpc_GenerateClaimProof_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GenerateClaimProofRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SidecarRpcServer).GenerateClaimProof(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SidecarRpc_GenerateClaimProof_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SidecarRpcServer).GenerateClaimProof(ctx, req.(*GenerateClaimProofRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SidecarRpc_GetAvailableRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAvailableRewardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SidecarRpcServer).GetAvailableRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SidecarRpc_GetAvailableRewards_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SidecarRpcServer).GetAvailableRewards(ctx, req.(*GetAvailableRewardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SidecarRpc_GetAvailableRewardsTokens_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAvailableRewardsTokensRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SidecarRpcServer).GetAvailableRewardsTokens(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SidecarRpc_GetAvailableRewardsTokens_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SidecarRpcServer).GetAvailableRewardsTokens(ctx, req.(*GetAvailableRewardsTokensRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// SidecarRpc_ServiceDesc is the grpc.ServiceDesc for SidecarRpc service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SidecarRpc_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "eigenlayer.sidecar.api.v1.SidecarRpc", + HandlerType: (*SidecarRpcServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetBlockHeight", + Handler: _SidecarRpc_GetBlockHeight_Handler, + }, + { + MethodName: "GetStateRoot", + Handler: _SidecarRpc_GetStateRoot_Handler, + }, + { + MethodName: "GetRewardsRoot", + Handler: _SidecarRpc_GetRewardsRoot_Handler, + }, + { + MethodName: "GenerateClaimProof", + Handler: _SidecarRpc_GenerateClaimProof_Handler, + }, + { + MethodName: "GetAvailableRewards", + Handler: _SidecarRpc_GetAvailableRewards_Handler, + }, + { + MethodName: "GetAvailableRewardsTokens", + Handler: _SidecarRpc_GetAvailableRewardsTokens_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "eigenlayer/sidecar/v1/api.proto", +} From 7ef586224b07f118a71e447d924108884e4cde67 Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Tue, 20 Aug 2024 15:53:53 -0500 Subject: [PATCH 3/8] Adding more helper functions for state transitions --- .../202408200934_eigenlayerStateTables/up.go | 21 +- internal/storage/postgresql/blockTables.go | 131 ++++++++++ internal/storage/postgresql/stateTables.go | 241 +++++++++++++++++- internal/storage/tables.go | 2 +- 4 files changed, 374 insertions(+), 21 deletions(-) create mode 100644 internal/storage/postgresql/blockTables.go diff --git a/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go b/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go index 2dd9c136..21d1f3dc 100644 --- a/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go +++ b/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go @@ -44,7 +44,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { transaction_hash varchar, log_index bigint, block_number bigint, - created_at timestamp with time zone + created_at timestamp with time zone default current_timestamp ); `, `create index if not exists idx_staker_share_changes_staker_strat on staker_share_changes (staker, strategy)`, @@ -53,10 +53,11 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { id serial primary key, staker varchar, operator varchar, + delegated boolean, transaction_hash varchar, log_index bigint, block_number bigint, - created_at timestamp with time zone + created_at timestamp with time zone default current_timestamp ); `, `create index if not exists idx_staker_delegation_changes_staker_operator on staker_delegation_changes (staker, operator)`, @@ -76,7 +77,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { start_timestamp timestamp, end_timestamp timestamp, duration bigint, - created_at timestamp with time zone + created_at timestamp with time zone default current_timestamp ); `, `create index if not exists idx_active_reward_submissions_avs on active_reward_submissions (avs)`, @@ -96,7 +97,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { start_timestamp timestamp, end_timestamp timestamp, duration bigint, - created_at timestamp with time zone + created_at timestamp with time zone default current_timestamp ); `, `create index if not exists idx_active_reward_for_all_submissions_avs on active_reward_for_all_submissions (avs)`, @@ -105,7 +106,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { operator varchar, avs varchar, block_number bigint, - created_at timestamp with time zone, + created_at timestamp with time zone default current_timestamp, unique(operator, avs, block_number) ); `, @@ -116,7 +117,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { strategy varchar, shares numeric, block_number bigint, - created_at timestamp with time zone, + created_at timestamp with time zone default current_timestamp, unique (operator, strategy, block_number) )`, `create index if not exists idx_operator_shares_operator_strategy on operator_shares (operator, strategy)`, @@ -126,7 +127,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { strategy varchar, shares numeric, block_number bigint, - created_at timestamp with time zone, + created_at timestamp with time zone default current_timestamp, unique(staker, strategy, block_number) ) `, @@ -136,7 +137,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { staker varchar, operator varchar, block_number bigint, - created_at timestamp with time zone, + created_at timestamp with time zone default current_timestamp, unique(staker, operator, block_number) )`, `create index if not exists idx_delegated_stakers_staker_operator on delegated_stakers (staker, operator)`, @@ -153,7 +154,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { start_timestamp timestamp, end_timestamp timestamp, duration bigint, - created_at timestamp with time zone + created_at timestamp with time zone default current_timestamp )`, `create index if not exists idx_active_rewards_avs on active_rewards (avs)`, `create index if not exists idx_active_rewards_block on active_rewards (block_number)`, @@ -169,7 +170,7 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { start_timestamp timestamp, end_timestamp timestamp, duration bigint, - created_at timestamp with time zone + created_at timestamp with time zone default current_timestamp )`, `create index if not exists idx_active_reward_for_all_avs on active_reward_for_all (avs)`, `create index if not exists idx_active_reward_for_all_block on active_reward_for_all (block_number)`, diff --git a/internal/storage/postgresql/blockTables.go b/internal/storage/postgresql/blockTables.go new file mode 100644 index 00000000..d78e5a21 --- /dev/null +++ b/internal/storage/postgresql/blockTables.go @@ -0,0 +1,131 @@ +package postgresql + +import "database/sql" + +func (p *PostgresBlockStore) CloneRegisteredAvsOperatorsForNewBlock(newBlockNumber uint64) error { + query := ` + insert into registered_avs_operators (avs, operator, block_number) + select + operator, + avs, + @newBlockNumber as block_number + from registered_avs_operators where block_number = @previousBlockNumber + ` + results := p.Db.Exec(query, sql.Named("newBlockNumber", newBlockNumber), sql.Named("previousBlockNumber", newBlockNumber-1)) + if results.Error != nil { + return results.Error + } + return nil +} + +func (p *PostgresBlockStore) CloneOperatorSharesForNewBlock(newBlockNumber uint64) error { + query := ` + insert into operator_shares (operator, strategy, shares, block_number) + select + operator, + strategy, + shares, + @newBlockNumber as block_number + from operator_shares where block_number = @previousBlockNumber + ` + results := p.Db.Exec(query, sql.Named("newBlockNumber", newBlockNumber), sql.Named("previousBlockNumber", newBlockNumber-1)) + if results.Error != nil { + return results.Error + } + return nil +} + +func (p *PostgresBlockStore) CloneStakerSharesForNewBlock(newBlockNumber uint64) error { + query := ` + insert into staker_shares (staker, strategy, shares, block_number) + select + staker, + strategy, + shares, + @newBlockNumber as block_number + from staker_shares where block_number = @previousBlockNumber + ` + results := p.Db.Exec(query, sql.Named("newBlockNumber", newBlockNumber), sql.Named("previousBlockNumber", newBlockNumber-1)) + if results.Error != nil { + return results.Error + } + return nil +} + +func (p *PostgresBlockStore) CloneDelegatedStakersForNewBlock(newBlockNumber uint64) error { + query := ` + insert into delegated_stakers (staker, operator, block_number) + select + staker, + operator, + @blockNumber as block_number + from delegated_stakers where block_number = @previousBlockNumber + ` + results := p.Db.Exec(query, sql.Named("newBlockNumber", newBlockNumber), sql.Named("previousBlockNumber", newBlockNumber-1)) + if results.Error != nil { + return results.Error + } + return nil +} + +func (p *PostgresBlockStore) SetActiveRewardsForNewBlock(newBlockNumber uint64) error { + // At the given block, we want to store all rewards that have not yet met their end_timestamp. + // + // Once end_timestamp < current_block.timestamp, the reward is no longer active and should not be included in the active_rewards table. + query := ` + with current_block as ( + select * from blocks where number = @newBlockNumber limit 1 + ), + insert into active_rewards (avs, reward_hash, token, amount, strategy, multiplier, strategy_index, block_number, start_timestamp, end_timestamp, duration) + select + avs, + reward_hash, + token, + amount, + strategy, + multiplier, + strategy_index, + @newBlockNumber as block_number, + start_timestamp, + end_timestamp, + duration + from active_reward_submissions + where end_timestamp > current_block.timestamp + ` + results := p.Db.Exec(query, sql.Named("newBlockNumber", newBlockNumber)) + if results.Error != nil { + return results.Error + } + return nil +} + +func (p *PostgresBlockStore) SetActiveRewardForAllForNewBlock(newBlockNumber uint64) error { + // At the given block, we want to store all rewards that have not yet met their end_timestamp. + // + // Once end_timestamp < current_block.timestamp, the reward is no longer active and should not be included in the active_rewards table. + query := ` + with current_block as ( + select * from blocks where number = @newBlockNumber limit 1 + ), + insert into active_reward_for_all (avs, reward_hash, token, amount, strategy, multiplier, strategy_index, block_number, start_timestamp, end_timestamp, duration) + select + avs, + reward_hash, + token, + amount, + strategy, + multiplier, + strategy_index, + @newBlockNumber as block_number, + start_timestamp, + end_timestamp, + duration + from active_reward_for_all_submissions + where end_timestamp > current_block.timestamp + ` + results := p.Db.Exec(query, sql.Named("newBlockNumber", newBlockNumber)) + if results.Error != nil { + return results.Error + } + return nil +} diff --git a/internal/storage/postgresql/stateTables.go b/internal/storage/postgresql/stateTables.go index a5031835..edfbaabf 100644 --- a/internal/storage/postgresql/stateTables.go +++ b/internal/storage/postgresql/stateTables.go @@ -1,22 +1,30 @@ package postgresql import ( + "database/sql" "go.uber.org/zap" "golang.org/x/xerrors" ) func (p *PostgresBlockStore) InsertIntoAvsOperatorChangesForBlock(blockNumber uint64) error { query := ` - SELECT - lower(t.arguments #>> '{0,Value}') as operator, - lower(t.arguments #>> '{1,Value}') as avs, - (case when (t.output_data -> 'status')::int = 1 then true else false) as registered, - t.transaction_hash, - t.log_index, - t.block_number - FROM transaction_logs t - WHERE t.address = ? - AND t.event_name = 'OperatorAVSRegistrationStatusUpdated' + with avs_operator_changes as ( + SELECT + lower(t.arguments #>> '{0,Value}') as operator, + lower(t.arguments #>> '{1,Value}') as avs, + (case when (t.output_data -> 'status')::int = 1 then true else false) as registered, + t.transaction_hash, + t.log_index, + t.block_number + FROM transaction_logs t + WHERE t.address = ? + AND t.event_name = 'OperatorAVSRegistrationStatusUpdated' + AND t.block_number = ? + ) + select + * + into avs_operator_changes + from avs_operator_changes ` addressMap := p.GlobalConfig.GetContractsMapForEnvAndNetwork() if addressMap == nil { @@ -30,6 +38,219 @@ func (p *PostgresBlockStore) InsertIntoAvsOperatorChangesForBlock(blockNumber ui zap.Uint64("blockNumber", blockNumber), ) } + return nil +} + +func (p *PostgresBlockStore) InsertIntoOperatorShareChangesForBlock(blockNumber uint64) error { + query := ` + with operator_share_changes as ( + SELECT + lower(t.arguments #>> '{0,Value}') as operator, + lower(t.output_data ->> 'staker') as staker, + lower(t.output_data ->> 'strategy') as strategy, + case + (when t.event_name = 'OperatorSharesIncreased' then (t.output_data ->> 'shares')::numeric(78,0) + else (t.output_data ->> 'shares')::numeric(78,0) * -1) as shares, + t.transaction_hash, + t.log_index, + t.block_number + FROM transaction_logs t + WHERE t.address = ? + AND t.event_name in('OperatorSharesIncreased', 'OperatorSharesDecreased') + AND t.block_number = ? + ) + select + * + into operator_share_changes + from operator_share_changes + ` + addressMap := p.GlobalConfig.GetContractsMapForEnvAndNetwork() + if addressMap == nil { + p.Logger.Sugar().Error("Failed to get contracts map for env and network") + return xerrors.New("failed to get contracts map for env and network") + } + result := p.Db.Raw(query, addressMap.DelegationManager, blockNumber) + if result.Error != nil { + p.Logger.Sugar().Errorw("Failed to insert into operator share changes for block", + zap.Error(result.Error), + zap.Uint64("blockNumber", blockNumber), + ) + } + return nil +} + +func (p *PostgresBlockStore) InsertIntoStakerShareChangesForBlock(blockNumber uint64) error { + query := ` + with staker_deposits as ( + SELECT + lower(coalesce(t.output_data ->> 'depositor', t.output_data ->> 'staker')) as staker, + lower(t.output_data ->> 'strategy') as strategy, + (t.output_data ->> 'shares')::numeric(78,0) as shares, + t.transaction_hash, + t.log_index, + t.block_number + FROM transaction_logs as t + WHERE t.address = @strategyManagerAddress + AND t.event_name 'Deposit' + AND t.block_number = @blockNumber + ), + staker_m1_withdrawals as ( + SELECT + lower(coalesce(t.output_data ->> 'depositor', t.output_data ->> 'staker')) as staker, + lower(t.output_data ->> 'strategy') as strategy, + (t.output_data ->> 'shares')::numeric(78,0) * -1 as shares, + t.transaction_hash, + t.log_index, + t.block_number + FROM transaction_logs t + WHERE t.address = @strategyManagerAddress + AND t.event_name 'ShareWithdrawalQueued' + AND t.block_number = @blockNumber + -- Remove this transaction hash as it is the only withdrawal on m1 that was completed as shares. There is no corresponding deposit event. The withdrawal was completed to the same staker address. + AND t.transaction_hash != '0x62eb0d0865b2636c74ed146e2d161e39e42b09bac7f86b8905fc7a830935dc1e' + ), + staker_m2_withdrawals as ( + WITH migrations AS ( + SELECT + ( + SELECT lower(string_agg(lpad(to_hex(elem::int), 2, '0'), '')) + FROM jsonb_array_elements_text(t.output_data->'oldWithdrawalRoot') AS elem + ) AS m1_withdrawal_root, + ( + SELECT lower(string_agg(lpad(to_hex(elem::int), 2, '0'), '')) + FROM jsonb_array_elements_text(t.output_data->'newWithdrawalRoot') AS elem + ) AS m2_withdrawal_root + FROM transaction_logs t + WHERE t.address = @delegationManagerAddress + AND t.event_name = 'WithdrawalMigrated' + ), + full_m2_withdrawals AS ( + SELECT + lower(t.output_data #>> '{withdrawal}') as withdrawals, + ( + SELECT lower(string_agg(lpad(to_hex(elem::int), 2, '0'), '')) + FROM jsonb_array_elements_text(t.output_data ->'withdrawalRoot') AS elem + ) AS withdrawal_root, + lower(t.output_data #>> '{withdrawal, staker}') AS staker, + lower(t_strategy.strategy) AS strategy, + (t_share.share)::numeric(78,0) AS shares, + t_strategy.strategy_index, + t_share.share_index, + t.transaction_hash, + t.log_index, + t.block_number + FROM transaction_logs t + left join blocks as b on (t.block_sequence_id = b.id), + jsonb_array_elements_text(t.output_data #> '{withdrawal, strategies}') WITH ORDINALITY AS t_strategy(strategy, strategy_index), + jsonb_array_elements_text(t.output_data #> '{withdrawal, shares}') WITH ORDINALITY AS t_share(share, share_index) + WHERE t.address = @delegationManagerAddress + AND t.event_name = 'WithdrawalQueued' + AND t_strategy.strategy_index = t_share.share_index + AND t.block_number = @blockNumber + ) + -- Parse out the m2 withdrawals that were migrated from m1 + SELECT + full_m2_withdrawals.* + FROM + full_m2_withdrawals + LEFT JOIN + migrations + ON + full_m2_withdrawals.withdrawal_root = migrations.m2_withdrawal_root + WHERE + migrations.m2_withdrawal_root IS NULL + ), + eigenpod_shares as ( + SELECT + lower(t.arguments #>> '{0,Value}') AS staker, + (t.output_data ->> 'sharesDelta')::numeric(78,0) as shares, + t.transaction_hash, + t.log_index, + t.block_number + FROM transaction_logs t + WHERE t.address = @eigenpodManagerAddress + AND t.event_name = 'PodSharesUpdated' + AND t.block_number = @blockNumber + ) + combined_results as ( + SELECT staker, strategy, shares, 0 as strategy_index, transaction_hash, log_index, block_number + FROM staker_deposits + + UNION ALL + + -- Subtract m1 & m2 withdrawals + SELECT staker, strategy, shares * -1, 0 as strategy_index, transaction_hash, log_index, block_number + FROM staker_m1_withdrawals + + UNION ALL + + SELECT staker, strategy, shares * -1, strategy_index, transaction_hash, log_index, block_number + FROM staker_m2_withdrawals + + UNION all + + -- Shares in eigenpod are positive or negative, so no need to multiply by -1 + SELECT staker, '0xbeac0eeeeeeeeeeeeeeeeeeeeeeeeeeeeeebeac0' as strategy, shares, 0 as strategy_index, transaction_hash, log_index, block_number + FROM eigenpod_shares + ) + select + * + into staker_share_changes + from combined_results + ` + addressMap := p.GlobalConfig.GetContractsMapForEnvAndNetwork() + if addressMap == nil { + p.Logger.Sugar().Error("Failed to get contracts map for env and network") + return xerrors.New("failed to get contracts map for env and network") + } + result := p.Db.Raw(query, + sql.Named("strategyManagerAddress", addressMap.StrategyManager), + sql.Named("delegationManagerAddress", addressMap.DelegationManager), + sql.Named("eigenpodManagerAddress", addressMap.EigenpodManager), + sql.Named("blockNumber", blockNumber), + ) + if result.Error != nil { + p.Logger.Sugar().Errorw("Failed to insert into staker share changes for block", + zap.Error(result.Error), + zap.Uint64("blockNumber", blockNumber), + ) + } + return nil +} + +func (p *PostgresBlockStore) InsertIntoStakerDelegationChangesForBlock(blockNumber uint64) error { + query := ` + with staker_delegations as ( + SELECT + lower(t.arguments #>> '{0,Value}') as staker, + lower(t.output_data ->> 'strategy') as strategy, + case when t.event_name = 'StakerDelegated' then true else false end as delegated, + t.transaction_hash, + t.log_index, + t.block_number + FROM transaction_logs t + WHERE t.address = ? + AND t.event_name in('StakerDelegated', 'StakerUndelegated') + AND t.block_number = ? + ) + select + * + into staker_delegation_changes + from staker_delegations + ` + addressMap := p.GlobalConfig.GetContractsMapForEnvAndNetwork() + if addressMap == nil { + p.Logger.Sugar().Error("Failed to get contracts map for env and network") + return xerrors.New("failed to get contracts map for env and network") + } + result := p.Db.Raw(query, addressMap.DelegationManager, blockNumber) + if result.Error != nil { + p.Logger.Sugar().Errorw("Failed to insert into staker share changes for block", + zap.Error(result.Error), + zap.Uint64("blockNumber", blockNumber), + ) + } + return nil } func (p *PostgresBlockStore) InsertIntoActiveRewardSubmissionsForBlock(blockNumber uint64) error { diff --git a/internal/storage/tables.go b/internal/storage/tables.go index dc9990ff..2fcf9295 100644 --- a/internal/storage/tables.go +++ b/internal/storage/tables.go @@ -99,10 +99,10 @@ type StakerDelegationChanges struct { Id uint64 `gorm:"type:serial"` Staker string Operator string + Delegated bool TransactionHash string LogIndex uint64 BlockNumber uint64 - Delegated bool CreatedAt time.Time } From 8260c41cbe427d2c5b5a1fc7ee5ebb9c24ff52ac Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Tue, 20 Aug 2024 16:14:03 -0500 Subject: [PATCH 4/8] Getting tests working again --- block-lake/templates/_helpers.tpl | 2 +- cmd/sidecar/main.go | 2 +- cmd/transactionDebug/main.go | 22 +- internal/pipeline/pipeline.go | 47 +- internal/postgres/tests/postgres_test.go | 68 +++ internal/storage/storage.go | 15 + scripts/runMigrate.sh | 36 +- scripts/runTests.sh | 10 +- sql/schema.sql | 622 ++++++++++++++++++++++- 9 files changed, 766 insertions(+), 58 deletions(-) create mode 100644 internal/postgres/tests/postgres_test.go diff --git a/block-lake/templates/_helpers.tpl b/block-lake/templates/_helpers.tpl index 445828d8..f9860d39 100644 --- a/block-lake/templates/_helpers.tpl +++ b/block-lake/templates/_helpers.tpl @@ -27,5 +27,5 @@ {{- end -}} {{- define "formatEnvVarName" -}} -SIDE_CAR_{{ regexReplaceAll "\\." . "_" | upper }} +SIDECAR_{{ regexReplaceAll "\\." . "_" | upper }} {{- end -}} diff --git a/cmd/sidecar/main.go b/cmd/sidecar/main.go index e01ff115..7e3ed695 100644 --- a/cmd/sidecar/main.go +++ b/cmd/sidecar/main.go @@ -74,7 +74,7 @@ func main() { idxr := indexer.NewIndexer(mds, contractStore, etherscanClient, cm, client, fetchr, l, cfg) - p := pipeline.NewPipeline(fetchr, idxr, l) + p := pipeline.NewPipeline(fetchr, idxr, mds, l) sidecar := sidecar.NewSidecar(&sidecar.SidecarConfig{ GenesisBlockNumber: cfg.GetGenesisBlockNumber(), diff --git a/cmd/transactionDebug/main.go b/cmd/transactionDebug/main.go index 326ae06a..57d82188 100644 --- a/cmd/transactionDebug/main.go +++ b/cmd/transactionDebug/main.go @@ -1,25 +1,6 @@ package main -import ( - "context" - "fmt" - "github.com/Layr-Labs/sidecar/internal/clients/ethereum" - "github.com/Layr-Labs/sidecar/internal/clients/etherscan" - "github.com/Layr-Labs/sidecar/internal/config" - "github.com/Layr-Labs/sidecar/internal/contractManager" - "github.com/Layr-Labs/sidecar/internal/contractStore/pgContractStore" - "github.com/Layr-Labs/sidecar/internal/fetcher" - "github.com/Layr-Labs/sidecar/internal/indexer" - "github.com/Layr-Labs/sidecar/internal/logger" - "github.com/Layr-Labs/sidecar/internal/metrics" - "github.com/Layr-Labs/sidecar/internal/postgres" - "github.com/Layr-Labs/sidecar/internal/postgres/migrations" - "github.com/Layr-Labs/sidecar/internal/storage/postgresql" - "go.uber.org/zap" - "log" - "strings" -) - +/* func main() { ctx := context.Background() cfg := config.NewConfig() @@ -130,3 +111,4 @@ func main() { // fmt.Printf("Tree: %+v\n", tree) } +*/ diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go index 64ddc70a..af7ff0fb 100644 --- a/internal/pipeline/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -4,20 +4,23 @@ import ( "context" "github.com/Layr-Labs/sidecar/internal/fetcher" "github.com/Layr-Labs/sidecar/internal/indexer" + "github.com/Layr-Labs/sidecar/internal/storage" "go.uber.org/zap" ) type Pipeline struct { - Fetcher *fetcher.Fetcher - Indexer *indexer.Indexer - Logger *zap.Logger + Fetcher *fetcher.Fetcher + Indexer *indexer.Indexer + BlockStore storage.BlockStore + Logger *zap.Logger } -func NewPipeline(f *fetcher.Fetcher, i *indexer.Indexer, l *zap.Logger) *Pipeline { +func NewPipeline(f *fetcher.Fetcher, i *indexer.Indexer, bs storage.BlockStore, l *zap.Logger) *Pipeline { return &Pipeline{ - Fetcher: f, - Indexer: i, - Logger: l, + Fetcher: f, + Indexer: i, + Logger: l, + BlockStore: bs, } } @@ -122,6 +125,34 @@ func (p *Pipeline) RunForBlock(ctx context.Context, blockNumber uint64) error { return nil } -func (p *Pipeline) CalculateSomething() { +func (p *Pipeline) CloneAggregatedStateTablesFromPreviousblock(currentBlock uint64) error { + if err := p.BlockStore.CloneRegisteredAvsOperatorsForNewBlock(currentBlock); err != nil { + p.Logger.Sugar().Errorw("Failed to clone registered avs operators", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) + return err + } + if err := p.BlockStore.CloneOperatorSharesForNewBlock(currentBlock); err != nil { + p.Logger.Sugar().Errorw("Failed to clone operator shares", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) + return err + } + if err := p.BlockStore.CloneStakerSharesForNewBlock(currentBlock); err != nil { + p.Logger.Sugar().Errorw("Failed to clone staker shares", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) + return err + } + if err := p.BlockStore.CloneDelegatedStakersForNewBlock(currentBlock); err != nil { + p.Logger.Sugar().Errorw("Failed to clone delegated stakers", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) + return err + } + if err := p.BlockStore.SetActiveRewardsForNewBlock(currentBlock); err != nil { + p.Logger.Sugar().Errorw("Failed to set active rewards", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) + return err + } + if err := p.BlockStore.SetActiveRewardForAllForNewBlock(currentBlock); err != nil { + p.Logger.Sugar().Errorw("Failed to set active rewards for all", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) + return err + } + return nil +} +func (p *Pipeline) GenerateStateTransactionsFromLogs(currentBlock uint64) error { + return nil } diff --git a/internal/postgres/tests/postgres_test.go b/internal/postgres/tests/postgres_test.go new file mode 100644 index 00000000..0cc752a9 --- /dev/null +++ b/internal/postgres/tests/postgres_test.go @@ -0,0 +1,68 @@ +package tests + +import ( + "fmt" + "github.com/Layr-Labs/sidecar/internal/config" + "github.com/Layr-Labs/sidecar/internal/postgres" + "github.com/Layr-Labs/sidecar/internal/tests" + "github.com/stretchr/testify/assert" + "gorm.io/gorm" + "testing" +) + +func setup() ( + *config.Config, + *postgres.Postgres, + *gorm.DB, + error, +) { + cfg := tests.GetConfig() + + pg, grm, err := tests.GetDatabaseConnection(cfg) + + return cfg, pg, grm, err +} + +func TestDoesWrappedTransactionRollback(t *testing.T) { + _, pg, grm, err := setup() + if err != nil { + t.Fatal(err) + } + defer pg.Db.Close() + + query := `create table test_table (id int);` + _, err = pg.Db.Exec(query) + if err != nil { + t.Fatal(err) + } + + _, err = postgres.WrapTxAndCommit[interface{}](func(tx *gorm.DB) (interface{}, error) { + for i := 0; i < 10; i++ { + query := "INSERT INTO test_table (id) VALUES (?)" + res := tx.Exec(query, i) + if res.Error != nil { + return nil, err + } + } + t.Logf("Inserted 10 rows, simulating a failure") + return nil, fmt.Errorf("simulated failure") + }, grm, nil) + + assert.NotNil(t, err) + + selectQuery := `select count(*) from test_table;` + var count int + err = pg.Db.QueryRow(selectQuery).Scan(&count) + if err != nil { + t.Fatal(err) + } + t.Logf("Found '%d' rows", count) + assert.Equal(t, 0, count) + + dropQuery := `drop table test_table;` + _, err = pg.Db.Exec(dropQuery) + if err != nil { + t.Fatal(err) + } + +} diff --git a/internal/storage/storage.go b/internal/storage/storage.go index c27a2948..06b8baab 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -24,6 +24,21 @@ type BlockStore interface { // Less generic functions GetLatestActiveAvsOperators(blockNumber uint64, avsDirectoryAddress string) ([]*ActiveAvsOperator, error) + + // State change functions + InsertIntoAvsOperatorChangesForBlock(blockNumber uint64) error + InsertIntoOperatorShareChangesForBlock(blockNumber uint64) error + InsertIntoStakerShareChangesForBlock(blockNumber uint64) error + InsertIntoStakerDelegationChangesForBlock(blockNumber uint64) error + InsertIntoActiveRewardSubmissionsForBlock(blockNumber uint64) error + + // Aggregate table functions + CloneRegisteredAvsOperatorsForNewBlock(newBlockNumber uint64) error + CloneOperatorSharesForNewBlock(newBlockNumber uint64) error + CloneStakerSharesForNewBlock(newBlockNumber uint64) error + CloneDelegatedStakersForNewBlock(newBlockNumber uint64) error + SetActiveRewardsForNewBlock(newBlockNumber uint64) error + SetActiveRewardForAllForNewBlock(newBlockNumber uint64) error } // Tables diff --git a/scripts/runMigrate.sh b/scripts/runMigrate.sh index 41666b76..0b2ab5a2 100755 --- a/scripts/runMigrate.sh +++ b/scripts/runMigrate.sh @@ -1,22 +1,22 @@ #!/usr/bin/env bash -SIDE_CAR_DEBUG=true \ +SIDECAR_DEBUG=true \ AWS_PROFILE=AdministratorAccess-225727539677 \ -SIDE_CAR_BLOB_STORE_S3_BUCKET_NAME=eigenlayer-blocklake-test \ -SIDE_CAR_BLOB_STORE_S3_PREFIX=test \ -SIDE_CAR_BLOB_STORE_S3_REGION=us-east-2 \ -SIDE_CAR_BLOB_STORE_S3_ACCESS_KEY_ID="AKIATJDTI5HOQSTKOQ4W" \ -SIDE_CAR_BLOB_STORE_S3_SECRET_ACCESS_KEY="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" \ -SIDE_CAR_ETHEREUM_RPC_BASE_URL="http://54.198.82.217:8545" \ -SIDE_CAR_NETWORK="holesky" \ -SIDE_CAR_ENVIRONMENT="preprod" \ -SIDE_CAR_POSTGRES_HOST="localhost" \ -SIDE_CAR_POSTGRES_PORT="5432" \ -SIDE_CAR_POSTGRES_USERNAME="sidecar" \ -SIDE_CAR_POSTGRES_PASSWORD="sidecar" \ -SIDE_CAR_POSTGRES_DBNAME="sidecar" \ -SIDE_CAR_ETHERSCAN_API_KEYS="QIPXW3YCXPR5NQ9GXTRQ3TSXB9EKMGDE34" \ -SIDE_CAR_RABBITMQ_USERNAME="guest" \ -SIDE_CAR_RABBITMQ_PASSWORD="guest" \ -SIDE_CAR_RABBITMQ_HOST="localhost:5672" \ +SIDECAR_BLOB_STORE_S3_BUCKET_NAME=eigenlayer-blocklake-test \ +SIDECAR_BLOB_STORE_S3_PREFIX=test \ +SIDECAR_BLOB_STORE_S3_REGION=us-east-2 \ +SIDECAR_BLOB_STORE_S3_ACCESS_KEY_ID="AKIATJDTI5HOQSTKOQ4W" \ +SIDECAR_BLOB_STORE_S3_SECRET_ACCESS_KEY="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" \ +SIDECAR_ETHEREUM_RPC_BASE_URL="http://54.198.82.217:8545" \ +SIDECAR_NETWORK="holesky" \ +SIDECAR_ENVIRONMENT="preprod" \ +SIDECAR_POSTGRES_HOST="localhost" \ +SIDECAR_POSTGRES_PORT="5432" \ +SIDECAR_POSTGRES_USERNAME="sidecar" \ +SIDECAR_POSTGRES_PASSWORD="sidecar" \ +SIDECAR_POSTGRES_DBNAME="sidecar" \ +SIDECAR_ETHERSCAN_API_KEYS="QIPXW3YCXPR5NQ9GXTRQ3TSXB9EKMGDE34" \ +SIDECAR_RABBITMQ_USERNAME="guest" \ +SIDECAR_RABBITMQ_PASSWORD="guest" \ +SIDECAR_RABBITMQ_HOST="localhost:5672" \ go run cmd/migrate/migrate.go diff --git a/scripts/runTests.sh b/scripts/runTests.sh index 23f39f21..bc5c5971 100755 --- a/scripts/runTests.sh +++ b/scripts/runTests.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash -export SIDE_CAR_POSTGRES_HOST=localhost -export SIDE_CAR_POSTGRES_PORT=5432 -export SIDE_CAR_POSTGRES_USER="" -export SIDE_CAR_POSTGRES_PASSWORD="" -export SIDE_CAR_POSTGRES_DBNAME=blocklake_test +export SIDECAR_POSTGRES_HOST=localhost +export SIDECAR_POSTGRES_PORT=5432 +export SIDECAR_POSTGRES_USER="seanmcgary" +export SIDECAR_POSTGRES_PASSWORD="" +export SIDECAR_POSTGRES_DBNAME=sidecar_test echo 'Prepping database' ./tests/bin/bootstrapDb.sh diff --git a/sql/schema.sql b/sql/schema.sql index 37e86c99..b54b5b91 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -27,6 +27,167 @@ SET default_tablespace = ''; SET default_table_access_method = heap; +-- +-- Name: active_reward_for_all; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.active_reward_for_all ( + avs character varying, + reward_hash character varying, + token character varying, + amount numeric, + strategy character varying, + multiplier numeric, + strategy_index bigint, + block_number bigint, + start_timestamp timestamp without time zone, + end_timestamp timestamp without time zone, + duration bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +-- +-- Name: active_reward_for_all_submissions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.active_reward_for_all_submissions ( + id integer NOT NULL, + avs character varying, + reward_hash character varying, + token character varying, + amount numeric, + strategy character varying, + multiplier numeric, + strategy_index bigint, + transaction_hash character varying, + log_index bigint, + block_number bigint, + start_timestamp timestamp without time zone, + end_timestamp timestamp without time zone, + duration bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +-- +-- Name: active_reward_for_all_submissions_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.active_reward_for_all_submissions_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: active_reward_for_all_submissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.active_reward_for_all_submissions_id_seq OWNED BY public.active_reward_for_all_submissions.id; + + +-- +-- Name: active_reward_submissions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.active_reward_submissions ( + id integer NOT NULL, + avs character varying, + reward_hash character varying, + token character varying, + amount numeric, + strategy character varying, + multiplier numeric, + strategy_index bigint, + transaction_hash character varying, + log_index bigint, + block_number bigint, + start_timestamp timestamp without time zone, + end_timestamp timestamp without time zone, + duration bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +-- +-- Name: active_reward_submissions_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.active_reward_submissions_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: active_reward_submissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.active_reward_submissions_id_seq OWNED BY public.active_reward_submissions.id; + + +-- +-- Name: active_rewards; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.active_rewards ( + avs character varying, + reward_hash character varying, + token character varying, + amount numeric, + strategy character varying, + multiplier numeric, + strategy_index bigint, + block_number bigint, + start_timestamp timestamp without time zone, + end_timestamp timestamp without time zone, + duration bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +-- +-- Name: avs_operator_changes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.avs_operator_changes ( + id integer NOT NULL, + operator character varying, + avs character varying, + registered boolean, + transaction_hash character varying, + log_index bigint, + block_number bigint +); + + +-- +-- Name: avs_operator_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.avs_operator_changes_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: avs_operator_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.avs_operator_changes_id_seq OWNED BY public.avs_operator_changes.id; + + -- -- Name: blocks; Type: TABLE; Schema: public; Owner: - -- @@ -102,6 +263,18 @@ CREATE SEQUENCE public.contracts_id_seq ALTER SEQUENCE public.contracts_id_seq OWNED BY public.contracts.id; +-- +-- Name: delegated_stakers; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.delegated_stakers ( + staker character varying, + operator character varying, + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + -- -- Name: migrations; Type: TABLE; Schema: public; Owner: - -- @@ -126,7 +299,8 @@ CREATE TABLE public.operator_restaked_strategies ( created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, updated_at timestamp with time zone, deleted_at timestamp with time zone, - block_time timestamp with time zone NOT NULL + block_time timestamp with time zone NOT NULL, + avs_directory_address character varying ); @@ -150,6 +324,54 @@ CREATE SEQUENCE public.operator_restaked_strategies_id_seq ALTER SEQUENCE public.operator_restaked_strategies_id_seq OWNED BY public.operator_restaked_strategies.id; +-- +-- Name: operator_share_changes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.operator_share_changes ( + id integer NOT NULL, + operator character varying, + strategy character varying, + shares numeric, + transaction_hash character varying, + log_index bigint, + block_number bigint +); + + +-- +-- Name: operator_share_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.operator_share_changes_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: operator_share_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.operator_share_changes_id_seq OWNED BY public.operator_share_changes.id; + + +-- +-- Name: operator_shares; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.operator_shares ( + operator character varying, + strategy character varying, + shares numeric, + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + -- -- Name: proxy_contracts; Type: TABLE; Schema: public; Owner: - -- @@ -164,6 +386,103 @@ CREATE TABLE public.proxy_contracts ( ); +-- +-- Name: registered_avs_operators; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.registered_avs_operators ( + operator character varying, + avs character varying, + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +-- +-- Name: staker_delegation_changes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.staker_delegation_changes ( + id integer NOT NULL, + staker character varying, + operator character varying, + delegated boolean, + transaction_hash character varying, + log_index bigint, + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +-- +-- Name: staker_delegation_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.staker_delegation_changes_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: staker_delegation_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.staker_delegation_changes_id_seq OWNED BY public.staker_delegation_changes.id; + + +-- +-- Name: staker_share_changes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.staker_share_changes ( + id integer NOT NULL, + staker character varying, + strategy character varying, + shares numeric, + transaction_hash character varying, + log_index bigint, + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +-- +-- Name: staker_share_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.staker_share_changes_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: staker_share_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.staker_share_changes_id_seq OWNED BY public.staker_share_changes.id; + + +-- +-- Name: staker_shares; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.staker_shares ( + staker character varying, + strategy character varying, + shares numeric, + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + -- -- Name: transaction_logs; Type: TABLE; Schema: public; Owner: - -- @@ -215,6 +534,27 @@ CREATE TABLE public.unverified_contracts ( ); +-- +-- Name: active_reward_for_all_submissions id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_reward_for_all_submissions ALTER COLUMN id SET DEFAULT nextval('public.active_reward_for_all_submissions_id_seq'::regclass); + + +-- +-- Name: active_reward_submissions id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_reward_submissions ALTER COLUMN id SET DEFAULT nextval('public.active_reward_submissions_id_seq'::regclass); + + +-- +-- Name: avs_operator_changes id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.avs_operator_changes ALTER COLUMN id SET DEFAULT nextval('public.avs_operator_changes_id_seq'::regclass); + + -- -- Name: blocks id; Type: DEFAULT; Schema: public; Owner: - -- @@ -236,6 +576,51 @@ ALTER TABLE ONLY public.contracts ALTER COLUMN id SET DEFAULT nextval('public.co ALTER TABLE ONLY public.operator_restaked_strategies ALTER COLUMN id SET DEFAULT nextval('public.operator_restaked_strategies_id_seq'::regclass); +-- +-- Name: operator_share_changes id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.operator_share_changes ALTER COLUMN id SET DEFAULT nextval('public.operator_share_changes_id_seq'::regclass); + + +-- +-- Name: staker_delegation_changes id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.staker_delegation_changes ALTER COLUMN id SET DEFAULT nextval('public.staker_delegation_changes_id_seq'::regclass); + + +-- +-- Name: staker_share_changes id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.staker_share_changes ALTER COLUMN id SET DEFAULT nextval('public.staker_share_changes_id_seq'::regclass); + + +-- +-- Name: active_reward_for_all_submissions active_reward_for_all_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_reward_for_all_submissions + ADD CONSTRAINT active_reward_for_all_submissions_pkey PRIMARY KEY (id); + + +-- +-- Name: active_reward_submissions active_reward_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_reward_submissions + ADD CONSTRAINT active_reward_submissions_pkey PRIMARY KEY (id); + + +-- +-- Name: avs_operator_changes avs_operator_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.avs_operator_changes + ADD CONSTRAINT avs_operator_changes_pkey PRIMARY KEY (id); + + -- -- Name: blocks block_sequences_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -260,6 +645,14 @@ ALTER TABLE ONLY public.contracts ADD CONSTRAINT contracts_pkey PRIMARY KEY (contract_address); +-- +-- Name: delegated_stakers delegated_stakers_staker_operator_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.delegated_stakers + ADD CONSTRAINT delegated_stakers_staker_operator_block_number_key UNIQUE (staker, operator, block_number); + + -- -- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -276,6 +669,54 @@ ALTER TABLE ONLY public.operator_restaked_strategies ADD CONSTRAINT operator_restaked_strategies_pkey PRIMARY KEY (id); +-- +-- Name: operator_share_changes operator_share_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.operator_share_changes + ADD CONSTRAINT operator_share_changes_pkey PRIMARY KEY (id); + + +-- +-- Name: operator_shares operator_shares_operator_strategy_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.operator_shares + ADD CONSTRAINT operator_shares_operator_strategy_block_number_key UNIQUE (operator, strategy, block_number); + + +-- +-- Name: registered_avs_operators registered_avs_operators_operator_avs_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.registered_avs_operators + ADD CONSTRAINT registered_avs_operators_operator_avs_block_number_key UNIQUE (operator, avs, block_number); + + +-- +-- Name: staker_delegation_changes staker_delegation_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.staker_delegation_changes + ADD CONSTRAINT staker_delegation_changes_pkey PRIMARY KEY (id); + + +-- +-- Name: staker_share_changes staker_share_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.staker_share_changes + ADD CONSTRAINT staker_share_changes_pkey PRIMARY KEY (id); + + +-- +-- Name: staker_shares staker_shares_staker_strategy_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.staker_shares + ADD CONSTRAINT staker_shares_staker_strategy_block_number_key UNIQUE (staker, strategy, block_number); + + -- -- Name: transactions transactions_transaction_hash_sequence_id_key; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -292,6 +733,76 @@ ALTER TABLE ONLY public.unverified_contracts ADD CONSTRAINT unverified_contracts_pkey PRIMARY KEY (contract_address); +-- +-- Name: idx_active_reward_for_all_avs; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_active_reward_for_all_avs ON public.active_reward_for_all USING btree (avs); + + +-- +-- Name: idx_active_reward_for_all_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_active_reward_for_all_block ON public.active_reward_for_all USING btree (block_number); + + +-- +-- Name: idx_active_reward_for_all_submissions_avs; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_active_reward_for_all_submissions_avs ON public.active_reward_for_all_submissions USING btree (avs); + + +-- +-- Name: idx_active_reward_for_all_submissions_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_active_reward_for_all_submissions_block ON public.active_reward_for_all_submissions USING btree (block_number); + + +-- +-- Name: idx_active_reward_submissions_avs; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_active_reward_submissions_avs ON public.active_reward_submissions USING btree (avs); + + +-- +-- Name: idx_active_reward_submissions_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_active_reward_submissions_block ON public.active_reward_submissions USING btree (block_number); + + +-- +-- Name: idx_active_rewards_avs; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_active_rewards_avs ON public.active_rewards USING btree (avs); + + +-- +-- Name: idx_active_rewards_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_active_rewards_block ON public.active_rewards USING btree (block_number); + + +-- +-- Name: idx_avs_operator_changes_avs_operator; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_avs_operator_changes_avs_operator ON public.avs_operator_changes USING btree (avs, operator); + + +-- +-- Name: idx_avs_operator_changes_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_avs_operator_changes_block ON public.avs_operator_changes USING btree (block_number); + + -- -- Name: idx_bytecode_hash; Type: INDEX; Schema: public; Owner: - -- @@ -299,6 +810,48 @@ ALTER TABLE ONLY public.unverified_contracts CREATE INDEX idx_bytecode_hash ON public.contracts USING btree (bytecode_hash); +-- +-- Name: idx_delegated_stakers_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_delegated_stakers_block ON public.delegated_stakers USING btree (block_number); + + +-- +-- Name: idx_delegated_stakers_staker_operator; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_delegated_stakers_staker_operator ON public.delegated_stakers USING btree (staker, operator); + + +-- +-- Name: idx_operator_share_changes_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_operator_share_changes_block ON public.operator_share_changes USING btree (block_number); + + +-- +-- Name: idx_operator_share_changes_operator_strat; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_operator_share_changes_operator_strat ON public.operator_share_changes USING btree (operator, strategy); + + +-- +-- Name: idx_operator_shares_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_operator_shares_block ON public.operator_shares USING btree (block_number); + + +-- +-- Name: idx_operator_shares_operator_strategy; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_operator_shares_operator_strategy ON public.operator_shares USING btree (operator, strategy); + + -- -- Name: idx_proxy_contract_contract_address; Type: INDEX; Schema: public; Owner: - -- @@ -313,6 +866,62 @@ CREATE INDEX idx_proxy_contract_contract_address ON public.proxy_contracts USING CREATE INDEX idx_proxy_contract_proxy_contract_address ON public.proxy_contracts USING btree (proxy_contract_address); +-- +-- Name: idx_registered_avs_operators_avs_operator; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_registered_avs_operators_avs_operator ON public.registered_avs_operators USING btree (avs, operator); + + +-- +-- Name: idx_registered_avs_operators_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_registered_avs_operators_block ON public.registered_avs_operators USING btree (block_number); + + +-- +-- Name: idx_staker_delegation_changes_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_staker_delegation_changes_block ON public.staker_delegation_changes USING btree (block_number); + + +-- +-- Name: idx_staker_delegation_changes_staker_operator; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_staker_delegation_changes_staker_operator ON public.staker_delegation_changes USING btree (staker, operator); + + +-- +-- Name: idx_staker_share_changes_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_staker_share_changes_block ON public.staker_share_changes USING btree (block_number); + + +-- +-- Name: idx_staker_share_changes_staker_strat; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_staker_share_changes_staker_strat ON public.staker_share_changes USING btree (staker, strategy); + + +-- +-- Name: idx_staker_shares_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_staker_shares_block ON public.staker_shares USING btree (block_number); + + +-- +-- Name: idx_staker_shares_staker_strategy; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_staker_shares_staker_strategy ON public.staker_shares USING btree (staker, strategy); + + -- -- Name: idx_transaciton_logs_block_number; Type: INDEX; Schema: public; Owner: - -- @@ -363,17 +972,17 @@ CREATE INDEX idx_transactions_to_address ON public.transactions USING btree (to_ -- --- Name: idx_unique_operator_restaked_strategies; Type: INDEX; Schema: public; Owner: - +-- Name: idx_uniq_proxy_contract; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX idx_unique_operator_restaked_strategies ON public.operator_restaked_strategies USING btree (block_number, operator, avs, strategy); +CREATE UNIQUE INDEX idx_uniq_proxy_contract ON public.proxy_contracts USING btree (block_number, contract_address); -- --- Name: idx_unique_proxy_contract; Type: INDEX; Schema: public; Owner: - +-- Name: idx_unique_operator_restaked_strategies; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX idx_unique_proxy_contract ON public.proxy_contracts USING btree (block_number, contract_address, proxy_contract_address); +CREATE UNIQUE INDEX idx_unique_operator_restaked_strategies ON public.operator_restaked_strategies USING btree (block_number, operator, avs, strategy); -- @@ -461,6 +1070,9 @@ INSERT INTO public.migrations VALUES ('202406251424_addTransactionLogsOutputData INSERT INTO public.migrations VALUES ('202406251426_addTransactionIndexes', '2024-06-25 14:29:47.500543-05', NULL); INSERT INTO public.migrations VALUES ('202407101440_addOperatorRestakedStrategiesTable', '2024-07-11 09:48:48.933519-05', NULL); INSERT INTO public.migrations VALUES ('202407110946_addBlockTimeToRestakedStrategies', '2024-07-11 09:49:17.325774-05', NULL); +INSERT INTO public.migrations VALUES ('202407111116_addAvsDirectoryAddress', '2024-08-20 16:12:38.890285-05', NULL); +INSERT INTO public.migrations VALUES ('202407121407_updateProxyContractIndex', '2024-08-20 16:12:38.893514-05', NULL); +INSERT INTO public.migrations VALUES ('202408200934_eigenlayerStateTables', '2024-08-20 16:12:38.950484-05', NULL); -- From fb7a116c18683d063bc171428c5b3bfc3292b007 Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Tue, 20 Aug 2024 16:14:39 -0500 Subject: [PATCH 5/8] Remove unused stuff --- sdk/protoParser/block.go | 165 -------------------------------------- sdk/protoParser/txLogs.go | 1 - 2 files changed, 166 deletions(-) delete mode 100644 sdk/protoParser/block.go delete mode 100644 sdk/protoParser/txLogs.go diff --git a/sdk/protoParser/block.go b/sdk/protoParser/block.go deleted file mode 100644 index e14acb8e..00000000 --- a/sdk/protoParser/block.go +++ /dev/null @@ -1,165 +0,0 @@ -package protoParser - -import ( - "context" - "encoding/json" - "fmt" - "github.com/Layr-Labs/sidecar/protos/eigenlayer/blocklake/v1" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient" -) - -type Parser struct { - Client *ethclient.Client -} - -func NewParser(c *ethclient.Client) *Parser { - return &Parser{ - Client: c, - } -} - -type TransactionWithHash struct { - Transaction *types.Transaction - Receipt *types.Receipt - TxHash common.Hash -} - -func (p *Parser) FetchTransactionReceipts(transactionHashes []common.Hash) ([]*types.Receipt, error) { - var receipts = []*types.Receipt{} - for _, hash := range transactionHashes { - r, err := p.Client.TransactionReceipt(context.Background(), hash) - if err != nil { - fmt.Printf("Failed to get receipt for hash '%s'\n", hash.String()) - } - receipts = append(receipts, r) - } - return receipts, nil -} - -func (p *Parser) ParseTransactionReceiptToProto(receipt *types.Receipt) (*v1.TransactionReceipt, error) { - return &v1.TransactionReceipt{ - TransactionHash: receipt.TxHash.String(), - TransactionIndex: uint64(receipt.TransactionIndex), - BlockHash: receipt.BlockHash.String(), - BlockNumber: receipt.BlockNumber.Uint64(), - To: "", - From: "", - GasUsed: 0, - CumulativeGasUsed: 0, - ContractAddress: "", - LogsBloom: "", - Type: 0, - EffectiveGasPrice: 0, - Status: 0, - }, nil -} - -func (p *Parser) ParseTransactionsToProto(transactions []*types.Transaction) ([]*v1.Transaction, error) { - var parsedTransactions = []*v1.Transaction{} - - txHashes := make([]common.Hash, 0) - - for _, t := range transactions { - txHashes = append(txHashes, t.Hash()) - } - - receipts, err := p.FetchTransactionReceipts(txHashes) - if err != nil { - fmt.Printf("Error fetching receipts: %+v\n", err) - } - receiptsMap := make(map[common.Hash]*types.Receipt) - - for _, r := range receipts { - receiptsMap[r.TxHash] = r - } - - for i, t := range transactions { - v, r, s := t.RawSignatureValues() - - jsonBlock, _ := json.MarshalIndent(receiptsMap[t.Hash()], "", "\t") - - parsedTransaction := &v1.Transaction{ - Hash: t.Hash().String(), - Size: t.Size(), - From: "", - To: t.To().String(), - Gas: t.Gas(), - GasPrice: t.GasPrice().Uint64(), - Input: "", - Nonce: t.Nonce(), - Index: uint64(i), - Value: t.Value().String(), - Type: uint64(t.Type()), - SignatureValues: &v1.Transaction_SignatureValues{ - V: v.String(), - R: r.String(), - S: s.String(), - }, - } - parsedTransactions = append(parsedTransactions, parsedTransaction) - } - return parsedTransactions, nil -} - -func (p *Parser) ParseWithdrawalsToProto(withdrawals []*types.Withdrawal) ([]*v1.Withdrawal, error) { - var parsedWithdrawals = []*v1.Withdrawal{} - - for _, w := range withdrawals { - parsedWithdrawal := &v1.Withdrawal{ - Index: w.Index, - Validator: w.Validator, - Address: w.Address.String(), - Amount: w.Amount, - } - parsedWithdrawals = append(parsedWithdrawals, parsedWithdrawal) - } - return parsedWithdrawals, nil -} - -func (p *Parser) ParseBlockToProto(block *types.Block) (*v1.Block, error) { - parsedBlock := &v1.Block{ - Hash: block.Hash().String(), - Size: block.Size(), - Header: &v1.BlockHeader{ - ParentHash: block.ParentHash().String(), - Sha3Uncles: block.Header().UncleHash.String(), - Miner: block.Header().Coinbase.String(), - StateRoot: block.Header().Root.String(), - TransactionsRoot: block.Header().TxHash.String(), - ReceiptsRoot: block.Header().ReceiptHash.String(), - LogsBloom: block.Header().Bloom.Bytes(), - Difficulty: block.Header().Difficulty.Bytes(), - Number: block.Header().Number.String(), - GasLimit: block.Header().GasLimit, - GasUsed: block.Header().GasUsed, - Timestamp: block.Header().Time, - ExtraData: block.Header().Extra, - MixHash: block.Header().MixDigest.String(), - Nonce: block.Header().Nonce.Uint64(), - BaseFeePerGas: block.Header().BaseFee.Bytes(), - WithdrawalsRoot: block.Header().WithdrawalsHash.String(), - BlobGasUsed: *block.BlobGasUsed(), - ExcessBlobGas: *block.ExcessBlobGas(), - ParentBeaconBlockRoot: block.Header().ParentBeaconRoot.String(), - }, - Transactions: nil, - Withdrawals: nil, - Uncles: nil, - } - - parsedTransactions, err := p.ParseTransactionsToProto(block.Transactions()) - if err != nil { - return nil, fmt.Errorf("Failed to parse transactions - %+v", err) - } - parsedBlock.Transactions = parsedTransactions - - parsedWithdrawals, err := p.ParseWithdrawalsToProto(block.Withdrawals()) - if err != nil { - return nil, fmt.Errorf("Failed to parse withdrawals - %+v", err) - } - parsedBlock.Withdrawals = parsedWithdrawals - - return parsedBlock, nil -} diff --git a/sdk/protoParser/txLogs.go b/sdk/protoParser/txLogs.go deleted file mode 100644 index 0f6b665f..00000000 --- a/sdk/protoParser/txLogs.go +++ /dev/null @@ -1 +0,0 @@ -package protoParser From 31a6d0929435aa4e2cac5099f00a3d8d0b00cd32 Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Thu, 5 Sep 2024 16:31:36 -0500 Subject: [PATCH 6/8] First pass of EigenState model --- go.mod | 34 +- go.sum | 63 ++ internal/eigenState/avsOperators.go | 322 +++++++++++ internal/eigenState/avsOperators_test.go | 110 ++++ internal/eigenState/eigenstate.go | 84 +++ internal/pipeline/pipeline.go | 39 +- .../202408200934_eigenlayerStateTables/up.go | 287 +++++----- internal/postgres/tests/postgres_test.go | 83 +++ internal/sqlite/sqlite.go | 15 + internal/storage/postgresql/storage.go | 4 + internal/storage/sqlite/storage.go | 71 +++ internal/storage/storage.go | 29 +- internal/storage/tables.go | 42 -- scripts/runMigrate.sh | 6 +- sql/schema.sql | 536 +----------------- 15 files changed, 980 insertions(+), 745 deletions(-) create mode 100644 internal/eigenState/avsOperators.go create mode 100644 internal/eigenState/avsOperators_test.go create mode 100644 internal/eigenState/eigenstate.go create mode 100644 internal/sqlite/sqlite.go create mode 100644 internal/storage/sqlite/storage.go diff --git a/go.mod b/go.mod index 61eed927..9cf10add 100644 --- a/go.mod +++ b/go.mod @@ -22,42 +22,70 @@ require ( require ( github.com/Microsoft/go-winio v0.6.1 // indirect github.com/StackExchange/wmi v1.2.1 // indirect + github.com/apache/arrow/go/v17 v17.0.0 // indirect + github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect + github.com/buger/jsonparser v1.1.1 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/glebarez/go-sqlite v1.21.2 // indirect + github.com/glebarez/sqlite v1.11.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect + github.com/goccy/go-json v0.10.3 // indirect + github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/holiman/uint256 v1.2.4 // indirect + github.com/iden3/go-iden3-crypto v0.0.16 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgx/v5 v5.4.3 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/marcboeker/go-duckdb v1.7.1 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-sqlite3 v1.14.22 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/pierrec/lz4/v4 v4.1.21 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/supranational/blst v0.3.11 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect + github.com/wealdtech/go-merkletree/v2 v2.6.0 // indirect + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect + github.com/zeebo/xxh3 v1.0.2 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/crypto v0.24.0 // indirect - golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect - golang.org/x/mod v0.17.0 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect + golang.org/x/mod v0.18.0 // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.17.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + golang.org/x/tools v0.22.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + gorm.io/driver/sqlite v1.5.6 // indirect + modernc.org/libc v1.41.0 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.7.2 // indirect + modernc.org/sqlite v1.29.6 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index 666428ed..a42ee72f 100644 --- a/go.sum +++ b/go.sum @@ -9,6 +9,10 @@ github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDO github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= +github.com/apache/arrow/go/v17 v17.0.0 h1:RRR2bdqKcdbss9Gxy2NS/hK8i4LDMh23L6BbkN5+F54= +github.com/apache/arrow/go/v17 v17.0.0/go.mod h1:jR7QHkODl15PfYyjM2nU+yTLScZ/qfj7OSUZmJ8putc= +github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= +github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= @@ -17,6 +21,8 @@ github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPx github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -50,6 +56,8 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.14.0 h1:xRWC5NlB6g1x7vNy4HDBLuqVNbtLrc7v8S6+Uxim1LU= @@ -64,9 +72,15 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2Gihuqh github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= +github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo= +github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k= +github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw= +github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= +github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -78,6 +92,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/flatbuffers v24.3.25+incompatible h1:CX395cjN9Kke9mmalRoL3d81AtFUxJM+yDthflgJGkI= +github.com/google/flatbuffers v24.3.25+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= @@ -99,6 +115,8 @@ github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= +github.com/iden3/go-iden3-crypto v0.0.16 h1:zN867xiz6HgErXVIV/6WyteGcOukE9gybYTorBMEdsk= +github.com/iden3/go-iden3-crypto v0.0.16/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= @@ -111,8 +129,13 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -123,23 +146,37 @@ github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7 github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/marcboeker/go-duckdb v1.7.1 h1:m9/nKfP7cG9AptcQ95R1vfacRuhtrZE5pZF8BPUb/Iw= +github.com/marcboeker/go-duckdb v1.7.1/go.mod h1:2oV8BZv88S16TKGKM+Lwd0g7DX84x0jMxjTInThC8Is= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= +github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= +github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -154,6 +191,8 @@ github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0 github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw= github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= @@ -192,9 +231,15 @@ github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2n github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/wealdtech/go-merkletree/v2 v2.6.0 h1:/Qz2blWf+yblxWiudjSXPm5h6sBMgoL67+9Rq2IhfTE= +github.com/wealdtech/go-merkletree/v2 v2.6.0/go.mod h1:Ooz0/mhs/XF1iYfbowRawrkAI56YYZ+oUl5Dw2Tlnjk= +github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= +github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= +github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= @@ -207,9 +252,13 @@ golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No= golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= @@ -229,6 +278,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= @@ -245,6 +296,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -270,7 +323,17 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/postgres v1.5.7 h1:8ptbNJTDbEmhdr62uReG5BGkdQyeasu/FZHxI0IMGnM= gorm.io/driver/postgres v1.5.7/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA= +gorm.io/driver/sqlite v1.5.6 h1:fO/X46qn5NUEEOZtnjJRWRzZMe8nqJiQ9E+0hi+hKQE= +gorm.io/driver/sqlite v1.5.6/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4= gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s= gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk= +modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= +modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= +modernc.org/sqlite v1.29.6 h1:0lOXGrycJPptfHDuohfYgNqoe4hu+gYuN/pKgY5XjS4= +modernc.org/sqlite v1.29.6/go.mod h1:S02dvcmm7TnTRvGhv8IGYyLnIt7AS2KPaB1F/71p75U= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/internal/eigenState/avsOperators.go b/internal/eigenState/avsOperators.go new file mode 100644 index 00000000..55b17974 --- /dev/null +++ b/internal/eigenState/avsOperators.go @@ -0,0 +1,322 @@ +package eigenState + +import ( + "database/sql" + "fmt" + "github.com/Layr-Labs/sidecar/internal/config" + "github.com/Layr-Labs/sidecar/internal/storage" + "github.com/wealdtech/go-merkletree/v2" + "github.com/wealdtech/go-merkletree/v2/keccak256" + orderedmap "github.com/wk8/go-ordered-map/v2" + "go.uber.org/zap" + "gorm.io/gorm" + "gorm.io/gorm/clause" + "slices" + "sort" + "strings" + "time" +) + +// Schema for registered_avs_operators block state table +type RegisteredAvsOperators struct { + Operator string + Avs string + BlockNumber uint64 + CreatedAt time.Time +} + +// Schema for avs_operator_changes table +type AvsOperatorChange struct { + Id uint64 `gorm:"type:serial"` + Operator string + Avs string + Registered bool + TransactionHash string + TransactionIndex uint64 + LogIndex uint64 + BlockNumber uint64 + CreatedAt time.Time +} + +// EigenState model for AVS operators that implements IEigenStateModel +type AvsOperators struct { + BaseEigenState + StateTransitions StateTransitions[AvsOperatorChange] + Db *gorm.DB + Network config.Network + Environment config.Environment + logger *zap.Logger + globalConfig *config.Config +} + +// Create new instance of AvsOperators state model +func NewAvsOperators( + esm *EigenStateManager, + grm *gorm.DB, + Network config.Network, + Environment config.Environment, + logger *zap.Logger, + globalConfig *config.Config, +) (*AvsOperators, error) { + s := &AvsOperators{ + BaseEigenState: BaseEigenState{}, + Db: grm, + Network: Network, + Environment: Environment, + logger: logger, + globalConfig: globalConfig, + } + esm.RegisterState(s) + return s, nil +} + +// Get the state transitions for the AvsOperators state model +// +// Each state transition is function indexed by a block number. +// BlockNumber 0 is the catchall state +// +// Returns the map and a reverse sorted list of block numbers that can be traversed when +// processing a log to determine which state change to apply. +func (a *AvsOperators) GetStateTransitions() (StateTransitions[AvsOperatorChange], []uint64) { + stateChanges := make(StateTransitions[AvsOperatorChange]) + + // TODO(seanmcgary): make this not a closure so this function doesnt get big an messy... + stateChanges[0] = func(log *storage.TransactionLog) (*AvsOperatorChange, error) { + // TODO(seanmcgary): actually parse the log + change := &AvsOperatorChange{ + Operator: "operator", + Avs: "avs", + Registered: true, + TransactionHash: log.TransactionHash, + TransactionIndex: log.TransactionIndex, + LogIndex: log.LogIndex, + BlockNumber: log.BlockNumber, + } + return change, nil + } + + // Create an ordered list of block numbers + blockNumbers := make([]uint64, 0) + for blockNumber, _ := range stateChanges { + blockNumbers = append(blockNumbers, blockNumber) + } + sort.Slice(blockNumbers, func(i, j int) bool { + return blockNumbers[i] < blockNumbers[j] + }) + slices.Reverse(blockNumbers) + + return stateChanges, blockNumbers +} + +// Returns a map of contract addresses to event names that are interesting to the state model +func (a *AvsOperators) getContractAddressesForEnvironment() map[string][]string { + contracts := a.globalConfig.GetContractsMapForEnvAndNetwork() + return map[string][]string{ + contracts.AvsDirectory: []string{ + "OperatorAVSRegistrationStatusUpdated", + }, + } +} + +// Given a log, determine if it is interesting to the state model +func (a *AvsOperators) IsInterestingLog(log *storage.TransactionLog) bool { + addresses := a.getContractAddressesForEnvironment() + logAddress := strings.ToLower(log.Address) + if eventNames, ok := addresses[logAddress]; ok { + if slices.Contains(eventNames, log.EventName) { + return true + } + } + return false +} + +// Handle the state change for the given log +// +// Takes a log and iterates over the state transitions to determine which state change to apply based on block number. +func (a *AvsOperators) HandleStateChange(log *storage.TransactionLog) (interface{}, error) { + stateChanges, sortedBlockNumbers := a.GetStateTransitions() + + for _, blockNumber := range sortedBlockNumbers { + if log.BlockNumber >= blockNumber { + a.logger.Sugar().Debugw("Handling state change", zap.Uint64("blockNumber", blockNumber)) + + change, err := stateChanges[blockNumber](log) + if err != nil { + return nil, err + } + + if change != nil { + wroteChange, err := a.writeStateChange(change) + if err != nil { + return wroteChange, err + } + return wroteChange, nil + } + } + } + return nil, nil +} + +// Write the state change to the database +func (a *AvsOperators) writeStateChange(change *AvsOperatorChange) (*AvsOperatorChange, error) { + a.logger.Sugar().Debugw("Writing state change", zap.Any("change", change)) + res := a.Db.Model(&AvsOperatorChange{}).Clauses(clause.Returning{}).Create(change) + if res.Error != nil { + a.logger.Error("Failed to insert into avs_operator_changes", zap.Error(res.Error)) + return change, res.Error + } + return change, nil +} + +// Write the new final state to the database. +// +// 1. Get latest distinct change value for each avs/operator +// 2. Join the latest unique change value with the previous blocks state to overlay new changes +// 3. Filter joined set on registered = true to omit unregistered operators +// 3. Write the new state as the final state +func (a *AvsOperators) WriteFinalState(blockNumber uint64) error { + query := ` + with new_changes as ( + select + avs, + operator, + block_number, + max(transaction_index) as transaction_index, + max(log_index) as log_index + from avs_operator_changes + where block_number = @currentBlock + group by 1, 2, 3 + ), + unique_registrations as ( + select + nc.avs, + nc.operator, + aoc.log_index, + aoc.registered, + nc.block_number + from new_changes as nc + left join avs_operator_changes as aoc on ( + aoc.avs = nc.avs + and aoc.operator = nc.operator + and aoc.log_index = nc.log_index + and aoc.transaction_index = nc.transaction_index + ) + ), + unregistrations as ( + select + concat(avs, '_', operator) as operator_avs + from unique_registrations + where registered = false + ), + carryover as ( + select + rao.avs, + rao.operator, + @currentBlock as block_number + from registered_avs_operators as rao + where + rao.block_number = @previousBlock + and concat(rao.avs, '_', rao.operator) not in (select operator_avs from unregistrations) + ), + final_state as ( + (select avs, operator, block_number::bigint from carryover) + union all + (select avs, operator, block_number::bigint from unique_registrations where registered = true) + ) + insert into registered_avs_operators (avs, operator, block_number) + select avs, operator, block_number from final_state + ` + + res := a.Db.Exec(query, + sql.Named("currentBlock", blockNumber), + sql.Named("previousBlock", blockNumber-1), + ) + if res.Error != nil { + a.logger.Sugar().Errorw("Failed to insert into registered_avs_operators", zap.Error(res.Error)) + return res.Error + } + return nil +} + +// Generates a state root for the given block number. +// +// 1. Select all registered_avs_operators for the given block number ordered by avs and operator asc +// 2. Create an ordered map, with AVSs at the top level that point to an ordered map of operators and block numbers +// 3. Create a merkle tree for each AVS, with the operator:block_number pairs as leaves +// 4. Create a merkle tree for all AVS trees +// 5. Return the root of the full tree +func (a *AvsOperators) GenerateStateRoot(blockNumber uint64) (StateRoot, error) { + query := ` + select + avs, + operator, + block_number + from registered_avs_operators + where + block_number = @blockNumber + order by avs asc, operator asc + ` + results := make([]RegisteredAvsOperators, 0) + res := a.Db.Model(&results).Raw(query, sql.Named("blockNumber", blockNumber)) + + if res.Error != nil { + a.logger.Sugar().Errorw("Failed to fetch registered_avs_operators", zap.Error(res.Error)) + return "", res.Error + } + + // Avs -> operator:block_number + om := orderedmap.New[string, *orderedmap.OrderedMap[string, uint64]]() + + for _, result := range results { + existingAvs, found := om.Get(result.Avs) + if !found { + existingAvs = orderedmap.New[string, uint64]() + om.Set(result.Avs, existingAvs) + + prev := om.GetPair(result.Avs).Prev() + if prev != nil && strings.Compare(prev.Key, result.Avs) >= 0 { + om.Delete(result.Avs) + return "", fmt.Errorf("avs not in order") + } + } + existingAvs.Set(result.Operator, result.BlockNumber) + + prev := existingAvs.GetPair(result.Operator).Prev() + if prev != nil && strings.Compare(prev.Key, result.Operator) >= 0 { + existingAvs.Delete(result.Operator) + return "", fmt.Errorf("operator not in order") + } + } + + avsLeaves := make([][]byte, 0) + for avs := om.Oldest(); avs != nil; avs = avs.Next() { + + operatorLeafs := make([][]byte, 0) + for operator := avs.Value.Oldest(); operator != nil; operator = operator.Next() { + operatorAddr := operator.Key + block := operator.Value + operatorLeafs = append(operatorLeafs, []byte(fmt.Sprintf("%s:%d", operatorAddr, block))) + } + + avsTree, err := merkletree.NewTree( + merkletree.WithData(operatorLeafs), + merkletree.WithHashType(keccak256.New()), + ) + if err != nil { + return "", err + } + + avsBytes := []byte(avs.Key) + root := avsTree.Root() + avsLeaves = append(avsLeaves, append(avsBytes, root[:]...)) + } + + fullTree, err := merkletree.NewTree( + merkletree.WithData(avsLeaves), + merkletree.WithHashType(keccak256.New()), + ) + if err != nil { + return "", err + } + return StateRoot(fullTree.Root()), nil +} diff --git a/internal/eigenState/avsOperators_test.go b/internal/eigenState/avsOperators_test.go new file mode 100644 index 00000000..1022419e --- /dev/null +++ b/internal/eigenState/avsOperators_test.go @@ -0,0 +1,110 @@ +package eigenState + +import ( + "database/sql" + "fmt" + "github.com/Layr-Labs/sidecar/internal/config" + "github.com/Layr-Labs/sidecar/internal/logger" + "github.com/Layr-Labs/sidecar/internal/storage" + "github.com/Layr-Labs/sidecar/internal/tests" + "github.com/stretchr/testify/assert" + "go.uber.org/zap" + "gorm.io/gorm" + "testing" + "time" +) + +func setup() ( + *config.Config, + *gorm.DB, + *zap.Logger, + *EigenStateManager, + error, +) { + cfg := tests.GetConfig() + l, _ := logger.NewLogger(&logger.LoggerConfig{Debug: cfg.Debug}) + + _, grm, err := tests.GetDatabaseConnection(cfg) + + eigenState := NewEigenStateManager(l) + + return cfg, grm, l, eigenState, err +} + +func Test_AvsOperatorState(t *testing.T) { + cfg, grm, l, esm, err := setup() + + if err != nil { + t.Fatal(err) + } + + t.Run("Should create a new AvsOperatorState", func(t *testing.T) { + avsOperatorState, err := NewAvsOperators(esm, grm, cfg.Network, cfg.Environment, l, cfg) + assert.Nil(t, err) + assert.NotNil(t, avsOperatorState) + }) + t.Run("Should register AvsOperatorState", func(t *testing.T) { + log := storage.TransactionLog{ + TransactionHash: "some hash", + TransactionIndex: 100, + BlockNumber: 200, + BlockSequenceId: 300, + Address: "some address", + Arguments: "some arguments", + EventName: "OperatorAVSRegistrationStatusUpdated", + LogIndex: 400, + OutputData: "some output data", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + DeletedAt: time.Time{}, + } + + avsOperatorState, err := NewAvsOperators(esm, grm, cfg.Network, cfg.Environment, l, cfg) + fmt.Printf("avsOperatorState err: %+v\n", err) + + res, err := avsOperatorState.HandleStateChange(&log) + assert.Nil(t, err) + t.Logf("res_typed: %+v\n", res) + + avsOperatorState.Db.Raw("truncate table avs_operator_changes cascade").Scan(&res) + avsOperatorState.Db.Raw("truncate table registered_avs_operators cascade").Scan(&res) + }) + t.Run("Should register AvsOperatorState and generate the table for the block", func(t *testing.T) { + log := storage.TransactionLog{ + TransactionHash: "some hash", + TransactionIndex: 100, + BlockNumber: 200, + BlockSequenceId: 300, + Address: "some address", + Arguments: "some arguments", + EventName: "OperatorAVSRegistrationStatusUpdated", + LogIndex: 400, + OutputData: "some output data", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + DeletedAt: time.Time{}, + } + + avsOperatorState, err := NewAvsOperators(esm, grm, cfg.Network, cfg.Environment, l, cfg) + assert.Nil(t, err) + + stateChange, err := avsOperatorState.HandleStateChange(&log) + assert.Nil(t, err) + fmt.Printf("stateChange: %+v\n", stateChange) + + err = avsOperatorState.WriteFinalState(200) + assert.Nil(t, err) + + states := []RegisteredAvsOperators{} + statesRes := avsOperatorState.Db. + Model(&RegisteredAvsOperators{}). + Raw("select * from registered_avs_operators where block_number = @blockNumber", sql.Named("blockNumber", 200)). + Scan(&states) + + if statesRes.Error != nil { + t.Fatalf("Failed to fetch registered_avs_operators: %v", statesRes.Error) + } + assert.Equal(t, 1, len(states)) + fmt.Printf("states: %+v\n", states) + }) +} diff --git a/internal/eigenState/eigenstate.go b/internal/eigenState/eigenstate.go new file mode 100644 index 00000000..1198ae3b --- /dev/null +++ b/internal/eigenState/eigenstate.go @@ -0,0 +1,84 @@ +package eigenState + +import ( + "github.com/Layr-Labs/sidecar/internal/storage" + "go.uber.org/zap" +) + +type EigenStateManager struct { + StateModels []IEigenStateModel + logger *zap.Logger +} + +func NewEigenStateManager(logger *zap.Logger) *EigenStateManager { + return &EigenStateManager{ + StateModels: make([]IEigenStateModel, 0), + logger: logger, + } +} + +// Allows a model to register itself with the state manager +func (e *EigenStateManager) RegisterState(state IEigenStateModel) { + e.StateModels = append(e.StateModels, state) +} + +// Given a log, allow each state model to determine if/how to process it +func (e *EigenStateManager) HandleLogStateChange(log *storage.TransactionLog) error { + for _, state := range e.StateModels { + if state.IsInterestingLog(log) { + _, err := state.HandleStateChange(log) + if err != nil { + return err + } + } + } + return nil +} + +// With all transactions/logs processed for a block, commit the final state to the table +func (e *EigenStateManager) CommitFinalState(blockNumber uint64) error { + for _, state := range e.StateModels { + err := state.WriteFinalState(blockNumber) + if err != nil { + return err + } + } + return nil +} + +type StateRoot string + +func (e *EigenStateManager) GenerateStateRoot(blockNumber uint64) (StateRoot, error) { + roots := make([]StateRoot, len(e.StateModels)) + for i, state := range e.StateModels { + root, err := state.GenerateStateRoot(blockNumber) + if err != nil { + return "", err + } + roots[i] = root + } + // TODO: generate this + return "", nil +} + +type IEigenStateModel interface { + // Determine if the log is interesting to the state model + IsInterestingLog(log *storage.TransactionLog) bool + + // Allow the state model to handle the state change + // + // Returns the saved value. Listed as an interface because go generics suck + HandleStateChange(log *storage.TransactionLog) (interface{}, error) + + // Once all state changes are processed, calculate and write final state + WriteFinalState(blockNumber uint64) error + + // Generate the state root for the model + GenerateStateRoot(blockNumber uint64) (StateRoot, error) +} + +type BaseEigenState struct { +} + +// Map of block number to function that will transition the state to the next block +type StateTransitions[T interface{}] map[uint64]func(log *storage.TransactionLog) (*T, error) diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go index af7ff0fb..2c1ac9b3 100644 --- a/internal/pipeline/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -6,6 +6,7 @@ import ( "github.com/Layr-Labs/sidecar/internal/indexer" "github.com/Layr-Labs/sidecar/internal/storage" "go.uber.org/zap" + "gorm.io/gorm" ) type Pipeline struct { @@ -122,37 +123,23 @@ func (p *Pipeline) RunForBlock(ctx context.Context, blockNumber uint64) error { } p.Indexer.FindAndHandleContractCreationForTransactions(interestingTransactions, block.TxReceipts, block.ContractStorage, blockNumber) + // if err := p.CloneAggregatedStateTablesFromPreviousBlock(blockNumber); err != nil { + // p.Logger.Sugar().Errorw("Failed to clone aggregated state tables", zap.Uint64("blockNumber", blockNumber), zap.Error(err)) + // return err + // } + // if err := p.GenerateStateTransactionsFromLogs(blockNumber, nil, nil); err != nil { + // p.Logger.Sugar().Errorw("Failed to generate state transactions from logs", zap.Uint64("blockNumber", blockNumber), zap.Error(err)) + // return err + // } + return nil } -func (p *Pipeline) CloneAggregatedStateTablesFromPreviousblock(currentBlock uint64) error { - if err := p.BlockStore.CloneRegisteredAvsOperatorsForNewBlock(currentBlock); err != nil { - p.Logger.Sugar().Errorw("Failed to clone registered avs operators", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) - return err - } - if err := p.BlockStore.CloneOperatorSharesForNewBlock(currentBlock); err != nil { - p.Logger.Sugar().Errorw("Failed to clone operator shares", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) - return err - } - if err := p.BlockStore.CloneStakerSharesForNewBlock(currentBlock); err != nil { - p.Logger.Sugar().Errorw("Failed to clone staker shares", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) - return err - } - if err := p.BlockStore.CloneDelegatedStakersForNewBlock(currentBlock); err != nil { - p.Logger.Sugar().Errorw("Failed to clone delegated stakers", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) - return err - } - if err := p.BlockStore.SetActiveRewardsForNewBlock(currentBlock); err != nil { - p.Logger.Sugar().Errorw("Failed to set active rewards", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) - return err - } - if err := p.BlockStore.SetActiveRewardForAllForNewBlock(currentBlock); err != nil { - p.Logger.Sugar().Errorw("Failed to set active rewards for all", zap.Uint64("blockNumber", currentBlock), zap.Error(err)) - return err - } +func (p *Pipeline) CloneAggregatedStateTablesFromPreviousBlock(currentBlock uint64) error { return nil } -func (p *Pipeline) GenerateStateTransactionsFromLogs(currentBlock uint64) error { +func (p *Pipeline) GenerateStateTransactionsFromLogs(currentBlock uint64, db *gorm.DB, tx *gorm.DB) error { + return nil } diff --git a/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go b/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go index 21d1f3dc..f1e38d65 100644 --- a/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go +++ b/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go @@ -18,90 +18,14 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { avs varchar, registered boolean, transaction_hash varchar, + transaction_index bigint, log_index bigint, - block_number bigint + block_number bigint, + created_at timestamp with time zone default current_timestamp ) `, `create index if not exists idx_avs_operator_changes_avs_operator on avs_operator_changes (avs, operator)`, `create index if not exists idx_avs_operator_changes_block on avs_operator_changes (block_number)`, - `create table if not exists operator_share_changes ( - id serial primary key, - operator varchar, - strategy varchar, - shares numeric, - transaction_hash varchar, - log_index bigint, - block_number bigint - ) - `, - `create index if not exists idx_operator_share_changes_operator_strat on operator_share_changes (operator, strategy)`, - `create index if not exists idx_operator_share_changes_block on operator_share_changes (block_number)`, - `create table if not exists staker_share_changes ( - id serial primary key, - staker varchar, - strategy varchar, - shares numeric, - transaction_hash varchar, - log_index bigint, - block_number bigint, - created_at timestamp with time zone default current_timestamp - ); - `, - `create index if not exists idx_staker_share_changes_staker_strat on staker_share_changes (staker, strategy)`, - `create index if not exists idx_staker_share_changes_block on staker_share_changes (block_number)`, - `create table if not exists staker_delegation_changes ( - id serial primary key, - staker varchar, - operator varchar, - delegated boolean, - transaction_hash varchar, - log_index bigint, - block_number bigint, - created_at timestamp with time zone default current_timestamp - ); - `, - `create index if not exists idx_staker_delegation_changes_staker_operator on staker_delegation_changes (staker, operator)`, - `create index if not exists idx_staker_delegation_changes_block on staker_delegation_changes (block_number)`, - `create table if not exists active_reward_submissions ( - id serial primary key, - avs varchar, - reward_hash varchar, - token varchar, - amount numeric, - strategy varchar, - multiplier numeric, - strategy_index bigint, - transaction_hash varchar, - log_index bigint, - block_number bigint, - start_timestamp timestamp, - end_timestamp timestamp, - duration bigint, - created_at timestamp with time zone default current_timestamp - ); - `, - `create index if not exists idx_active_reward_submissions_avs on active_reward_submissions (avs)`, - `create index if not exists idx_active_reward_submissions_block on active_reward_submissions (block_number)`, - `create table if not exists active_reward_for_all_submissions ( - id serial primary key, - avs varchar, - reward_hash varchar, - token varchar, - amount numeric, - strategy varchar, - multiplier numeric, - strategy_index bigint, - transaction_hash varchar, - log_index bigint, - block_number bigint, - start_timestamp timestamp, - end_timestamp timestamp, - duration bigint, - created_at timestamp with time zone default current_timestamp - ); - `, - `create index if not exists idx_active_reward_for_all_submissions_avs on active_reward_for_all_submissions (avs)`, - `create index if not exists idx_active_reward_for_all_submissions_block on active_reward_for_all_submissions (block_number)`, `create table if not exists registered_avs_operators ( operator varchar, avs varchar, @@ -112,68 +36,149 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { `, `create index if not exists idx_registered_avs_operators_avs_operator on registered_avs_operators (avs, operator)`, `create index if not exists idx_registered_avs_operators_block on registered_avs_operators (block_number)`, - `create table if not exists operator_shares ( - operator varchar, - strategy varchar, - shares numeric, - block_number bigint, - created_at timestamp with time zone default current_timestamp, - unique (operator, strategy, block_number) - )`, - `create index if not exists idx_operator_shares_operator_strategy on operator_shares (operator, strategy)`, - `create index if not exists idx_operator_shares_block on operator_shares (block_number)`, - `create table if not exists staker_shares ( - staker varchar, - strategy varchar, - shares numeric, - block_number bigint, - created_at timestamp with time zone default current_timestamp, - unique(staker, strategy, block_number) - ) - `, - `create index if not exists idx_staker_shares_staker_strategy on staker_shares (staker, strategy)`, - `create index if not exists idx_staker_shares_block on staker_shares (block_number)`, - `create table if not exists delegated_stakers ( - staker varchar, - operator varchar, - block_number bigint, - created_at timestamp with time zone default current_timestamp, - unique(staker, operator, block_number) - )`, - `create index if not exists idx_delegated_stakers_staker_operator on delegated_stakers (staker, operator)`, - `create index if not exists idx_delegated_stakers_block on delegated_stakers (block_number)`, - `create table if not exists active_rewards ( - avs varchar, - reward_hash varchar, - token varchar, - amount numeric, - strategy varchar, - multiplier numeric, - strategy_index bigint, - block_number bigint, - start_timestamp timestamp, - end_timestamp timestamp, - duration bigint, - created_at timestamp with time zone default current_timestamp - )`, - `create index if not exists idx_active_rewards_avs on active_rewards (avs)`, - `create index if not exists idx_active_rewards_block on active_rewards (block_number)`, - `create table if not exists active_reward_for_all ( - avs varchar, - reward_hash varchar, - token varchar, - amount numeric, - strategy varchar, - multiplier numeric, - strategy_index bigint, - block_number bigint, - start_timestamp timestamp, - end_timestamp timestamp, - duration bigint, - created_at timestamp with time zone default current_timestamp - )`, - `create index if not exists idx_active_reward_for_all_avs on active_reward_for_all (avs)`, - `create index if not exists idx_active_reward_for_all_block on active_reward_for_all (block_number)`, + /* + `create table if not exists operator_share_changes ( + id serial primary key, + operator varchar, + strategy varchar, + shares numeric, + transaction_hash varchar, + log_index bigint, + block_number bigint, + created_at timestamp with time zone default current_timestamp + ) + `, + `create index if not exists idx_operator_share_changes_operator_strat on operator_share_changes (operator, strategy)`, + `create index if not exists idx_operator_share_changes_block on operator_share_changes (block_number)`, + `create table if not exists staker_share_changes ( + id serial primary key, + staker varchar, + strategy varchar, + shares numeric, + transaction_hash varchar, + log_index bigint, + block_number bigint, + created_at timestamp with time zone default current_timestamp + ); + `, + `create index if not exists idx_staker_share_changes_staker_strat on staker_share_changes (staker, strategy)`, + `create index if not exists idx_staker_share_changes_block on staker_share_changes (block_number)`, + `create table if not exists staker_delegation_changes ( + id serial primary key, + staker varchar, + operator varchar, + delegated boolean, + transaction_hash varchar, + log_index bigint, + block_number bigint, + created_at timestamp with time zone default current_timestamp + ); + `, + `create index if not exists idx_staker_delegation_changes_staker_operator on staker_delegation_changes (staker, operator)`, + `create index if not exists idx_staker_delegation_changes_block on staker_delegation_changes (block_number)`, + `create table if not exists active_reward_submissions ( + id serial primary key, + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + transaction_hash varchar, + log_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone default current_timestamp + ); + `, + `create index if not exists idx_active_reward_submissions_avs on active_reward_submissions (avs)`, + `create index if not exists idx_active_reward_submissions_block on active_reward_submissions (block_number)`, + `create table if not exists active_reward_for_all_submissions ( + id serial primary key, + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + transaction_hash varchar, + log_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone default current_timestamp + ); + `, + `create index if not exists idx_active_reward_for_all_submissions_avs on active_reward_for_all_submissions (avs)`, + `create index if not exists idx_active_reward_for_all_submissions_block on active_reward_for_all_submissions (block_number)`, + `create table if not exists operator_shares ( + operator varchar, + strategy varchar, + shares numeric, + block_number bigint, + created_at timestamp with time zone default current_timestamp, + unique (operator, strategy, block_number) + )`, + `create index if not exists idx_operator_shares_operator_strategy on operator_shares (operator, strategy)`, + `create index if not exists idx_operator_shares_block on operator_shares (block_number)`, + `create table if not exists staker_shares ( + staker varchar, + strategy varchar, + shares numeric, + block_number bigint, + created_at timestamp with time zone default current_timestamp, + unique(staker, strategy, block_number) + ) + `, + `create index if not exists idx_staker_shares_staker_strategy on staker_shares (staker, strategy)`, + `create index if not exists idx_staker_shares_block on staker_shares (block_number)`, + `create table if not exists delegated_stakers ( + staker varchar, + operator varchar, + block_number bigint, + created_at timestamp with time zone default current_timestamp, + unique(staker, operator, block_number) + )`, + `create index if not exists idx_delegated_stakers_staker_operator on delegated_stakers (staker, operator)`, + `create index if not exists idx_delegated_stakers_block on delegated_stakers (block_number)`, + `create table if not exists active_rewards ( + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone default current_timestamp + )`, + `create index if not exists idx_active_rewards_avs on active_rewards (avs)`, + `create index if not exists idx_active_rewards_block on active_rewards (block_number)`, + `create table if not exists active_reward_for_all ( + avs varchar, + reward_hash varchar, + token varchar, + amount numeric, + strategy varchar, + multiplier numeric, + strategy_index bigint, + block_number bigint, + start_timestamp timestamp, + end_timestamp timestamp, + duration bigint, + created_at timestamp with time zone default current_timestamp + )`, + `create index if not exists idx_active_reward_for_all_avs on active_reward_for_all (avs)`, + `create index if not exists idx_active_reward_for_all_block on active_reward_for_all (block_number)`, + */ } // Wrap the queries in a transaction so they all create or fail atomically diff --git a/internal/postgres/tests/postgres_test.go b/internal/postgres/tests/postgres_test.go index 0cc752a9..d3f3f245 100644 --- a/internal/postgres/tests/postgres_test.go +++ b/internal/postgres/tests/postgres_test.go @@ -66,3 +66,86 @@ func TestDoesWrappedTransactionRollback(t *testing.T) { } } + +func TestDoesWrappedNestedTransactionRollback(t *testing.T) { + _, pg, grm, err := setup() + if err != nil { + t.Fatal(err) + } + defer pg.Db.Close() + + query := `create table test_table (id int);` + _, err = pg.Db.Exec(query) + if err != nil { + t.Fatal(err) + } + + _, err = postgres.WrapTxAndCommit[interface{}](func(tx *gorm.DB) (interface{}, error) { + _, err = postgres.WrapTxAndCommit[interface{}](func(tx *gorm.DB) (interface{}, error) { + for i := 0; i < 10; i++ { + query := "INSERT INTO test_table (id) VALUES (?)" + res := tx.Exec(query, i) + if res.Error != nil { + return nil, err + } + } + t.Logf("Inserted 10 rows") + var count int + tx.Raw(`select count(*) from test_table;`).Scan(&count) + assert.Equal(t, 10, count) + t.Logf("Found '%d' rows", count) + return nil, nil + }, grm, tx) + _, err = postgres.WrapTxAndCommit[interface{}](func(tx *gorm.DB) (interface{}, error) { + for i := 0; i < 10; i++ { + query := "INSERT INTO test_table (id) VALUES (?)" + res := tx.Exec(query, i) + if res.Error != nil { + return nil, err + } + } + t.Logf("Inserted 10 rows") + var count int + tx.Raw(`select count(*) from test_table;`).Scan(&count) + t.Logf("Found '%d' rows", count) + assert.Equal(t, 20, count) + t.Logf("Inserted 10 rows") + return nil, nil + }, grm, tx) + return postgres.WrapTxAndCommit[interface{}](func(tx *gorm.DB) (interface{}, error) { + for i := 0; i < 10; i++ { + query := "INSERT INTO test_table (id) VALUES (?)" + res := tx.Exec(query, i) + if res.Error != nil { + return nil, err + } + } + t.Logf("Inserted 10 rows") + var count int + tx.Raw(`select count(*) from test_table;`).Scan(&count) + t.Logf("Found '%d' rows", count) + assert.Equal(t, 30, count) + t.Logf("Inserted 10 rows, simulating a failure") + return nil, fmt.Errorf("simulated failure") + }, grm, tx) + + }, grm, nil) + + assert.NotNil(t, err) + + selectQuery := `select count(*) from test_table;` + var count int + err = pg.Db.QueryRow(selectQuery).Scan(&count) + if err != nil { + t.Fatal(err) + } + t.Logf("Found '%d' rows", count) + assert.Equal(t, 0, count) + + dropQuery := `drop table test_table;` + _, err = pg.Db.Exec(dropQuery) + if err != nil { + t.Fatal(err) + } + +} diff --git a/internal/sqlite/sqlite.go b/internal/sqlite/sqlite.go new file mode 100644 index 00000000..4837f601 --- /dev/null +++ b/internal/sqlite/sqlite.go @@ -0,0 +1,15 @@ +package sqlite + +import ( + "gorm.io/driver/sqlite" + "gorm.io/gorm" +) + +func NewSqlite(path string) gorm.Dialector { + db := sqlite.Open(path) + return db +} + +func NewGormSqliteFromSqlite(sqlite gorm.Dialector) (*gorm.DB, error) { + return gorm.Open(sqlite, &gorm.Config{}) +} diff --git a/internal/storage/postgresql/storage.go b/internal/storage/postgresql/storage.go index 20ca6be4..8a79d908 100644 --- a/internal/storage/postgresql/storage.go +++ b/internal/storage/postgresql/storage.go @@ -42,6 +42,10 @@ func NewPostgresBlockStore(db *gorm.DB, cfg *config.Config, l *zap.Logger) (*Pos return mds, nil } +func (m *PostgresBlockStore) GetDb() *gorm.DB { + return m.Db +} + func (m *PostgresBlockStore) autoMigrate() { if m.migrated { return diff --git a/internal/storage/sqlite/storage.go b/internal/storage/sqlite/storage.go new file mode 100644 index 00000000..9f380ad8 --- /dev/null +++ b/internal/storage/sqlite/storage.go @@ -0,0 +1,71 @@ +package sqlite + +import ( + "github.com/Layr-Labs/sidecar/internal/config" + "go.uber.org/zap" + "gorm.io/gorm" +) + +type SqliteBlockStoreConfig struct { + DbLocation string +} + +type SqliteBlockStore struct { + Db *gorm.DB + migrated bool + Logger *zap.Logger + GlobalConfig *config.Config +} + +func NewSqliteBlockStore(db *gorm.DB, l *zap.Logger, cfg *config.Config) *SqliteBlockStore { + bs := &SqliteBlockStore{ + Db: db, + Logger: l, + GlobalConfig: cfg, + } + return bs +} + +/* +func (s *SqliteBlockStore) GetNextSequenceId() (uint64, error) { + +} +func (s *SqliteBlockStore) InsertBlockAtHeight(blockNumber uint64, hash string, blockTime uint64) (*storage.Block, error) { + +} +func (s *SqliteBlockStore) UpdateBlockPath(sequenceId uint64, blockNumber uint64, path string) (*storage.Block, error) { + +} +func (s *SqliteBlockStore) InsertBlockTransaction(sequenceId uint64, blockNumber uint64, txHash string, txIndex uint64, from string, to string, contractAddress string, bytecodeHash string) (*storage.Transaction, error) { + +} +func (s *SqliteBlockStore) InsertTransactionLog(txHash string, transactionIndex uint64, blockNumber uint64, blockSequenceId uint64, log *parser.DecodedLog, outputData map[string]interface{}) (*storage.Transaction, error) { + +} +func (s *SqliteBlockStore) BatchInsertBlockTransactions(sequenceId uint64, blockNumber uint64, transactions []storage.BatchTransaction) ([]*storage.Transaction, error) { + +} +func (s *SqliteBlockStore) BatchInsertTransactionLogs(transactions []*BatchInsertTransactionLogs) ([]*TransactionLog, error) { + +} +func (s *SqliteBlockStore) GetLatestBlock() (int64, error) { + +} +func (s *SqliteBlockStore) GetBlockByNumber(blockNumber uint64) (*Block, error) { + +} +func (s *SqliteBlockStore) DeleteTransactionLogsForBlock(blockNumber uint64) error { + +} +func (s *SqliteBlockStore) GetTransactionByHash(txHash string) (*Transaction, error) { + +} +func (s *SqliteBlockStore) ListTransactionsForContractAddress(contractAddress string) ([]*Transaction, error) { + +} +func (s *SqliteBlockStore) ListTransactionLogsForContractAddress(contractAddress string) ([]*TransactionLog, error) { + +} +func (s *SqliteBlockStore) InsertOperatorRestakedStrategies(avsDirectorAddress string, blockNumber uint64, blockTime time.Time, operator string, avs string, strategy string) (*OperatorRestakedStrategies, error) { + +}*/ diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 06b8baab..e033e8c5 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -3,6 +3,7 @@ package storage import ( "github.com/Layr-Labs/sidecar/internal/clients/ethereum" "github.com/Layr-Labs/sidecar/internal/parser" + "gorm.io/gorm" "time" ) @@ -22,23 +23,25 @@ type BlockStore interface { ListTransactionLogsForContractAddress(contractAddress string) ([]*TransactionLog, error) InsertOperatorRestakedStrategies(avsDirectorAddress string, blockNumber uint64, blockTime time.Time, operator string, avs string, strategy string) (*OperatorRestakedStrategies, error) + GetDb() *gorm.DB + // Less generic functions GetLatestActiveAvsOperators(blockNumber uint64, avsDirectoryAddress string) ([]*ActiveAvsOperator, error) // State change functions - InsertIntoAvsOperatorChangesForBlock(blockNumber uint64) error - InsertIntoOperatorShareChangesForBlock(blockNumber uint64) error - InsertIntoStakerShareChangesForBlock(blockNumber uint64) error - InsertIntoStakerDelegationChangesForBlock(blockNumber uint64) error - InsertIntoActiveRewardSubmissionsForBlock(blockNumber uint64) error - - // Aggregate table functions - CloneRegisteredAvsOperatorsForNewBlock(newBlockNumber uint64) error - CloneOperatorSharesForNewBlock(newBlockNumber uint64) error - CloneStakerSharesForNewBlock(newBlockNumber uint64) error - CloneDelegatedStakersForNewBlock(newBlockNumber uint64) error - SetActiveRewardsForNewBlock(newBlockNumber uint64) error - SetActiveRewardForAllForNewBlock(newBlockNumber uint64) error + // InsertIntoAvsOperatorChangesForBlock(blockNumber uint64) error + // InsertIntoOperatorShareChangesForBlock(blockNumber uint64) error + // InsertIntoStakerShareChangesForBlock(blockNumber uint64) error + // InsertIntoStakerDelegationChangesForBlock(blockNumber uint64) error + // InsertIntoActiveRewardSubmissionsForBlock(blockNumber uint64) error + // + // // Aggregate table functions + // CloneRegisteredAvsOperatorsForNewBlock(newBlockNumber uint64) error + // CloneOperatorSharesForNewBlock(newBlockNumber uint64) error + // CloneStakerSharesForNewBlock(newBlockNumber uint64) error + // CloneDelegatedStakersForNewBlock(newBlockNumber uint64) error + // SetActiveRewardsForNewBlock(newBlockNumber uint64) error + // SetActiveRewardForAllForNewBlock(newBlockNumber uint64) error } // Tables diff --git a/internal/storage/tables.go b/internal/storage/tables.go index 2fcf9295..e17e210f 100644 --- a/internal/storage/tables.go +++ b/internal/storage/tables.go @@ -9,30 +9,6 @@ import ( // Append only tables of state // ---------------------------------------------------------------------------- -/* -create table if not exists avs_operator_changes ( - - id serial primary key, - operator varchar, - avs varchar, - registered boolean, - transaction_hash varchar, - log_index bigint, - block_number bigint - -); -*/ -type AvsOperatorChange struct { - Id uint64 `gorm:"type:serial"` - Operator string - Avs string - Registered bool - TransactionHash string - LogIndex uint64 - BlockNumber uint64 - CreatedAt time.Time -} - /* create table if not exists operator_share_changes ( @@ -188,24 +164,6 @@ type RewardForAllSubmissions struct { // Block-based "summary" tables // ---------------------------------------------------------------------------- -/* -create table if not exists registered_avs_operators ( - - operator varchar, - avs varchar, - block_number bigint, - created_at timestamp with time zone - unique idx_uniq_operator_abs_block (operator, avs, block_number) - -); -*/ -type RegisteredAvsOperators struct { - Operator string - Avs string - BlockNumber uint64 - CreatedAt time.Time -} - /* create table if not exists operator_shares ( diff --git a/scripts/runMigrate.sh b/scripts/runMigrate.sh index 0b2ab5a2..d2ebfdf8 100755 --- a/scripts/runMigrate.sh +++ b/scripts/runMigrate.sh @@ -12,11 +12,11 @@ SIDECAR_NETWORK="holesky" \ SIDECAR_ENVIRONMENT="preprod" \ SIDECAR_POSTGRES_HOST="localhost" \ SIDECAR_POSTGRES_PORT="5432" \ -SIDECAR_POSTGRES_USERNAME="sidecar" \ -SIDECAR_POSTGRES_PASSWORD="sidecar" \ +SIDECAR_POSTGRES_USERNAME="seanmcgary" \ +SIDECAR_POSTGRES_PASSWORD="" \ SIDECAR_POSTGRES_DBNAME="sidecar" \ SIDECAR_ETHERSCAN_API_KEYS="QIPXW3YCXPR5NQ9GXTRQ3TSXB9EKMGDE34" \ SIDECAR_RABBITMQ_USERNAME="guest" \ SIDECAR_RABBITMQ_PASSWORD="guest" \ SIDECAR_RABBITMQ_HOST="localhost:5672" \ -go run cmd/migrate/migrate.go +go run cmd/migrate/main.go diff --git a/sql/schema.sql b/sql/schema.sql index b54b5b91..b0e9febd 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -3,7 +3,7 @@ -- -- Dumped from database version 14.11 (Homebrew) --- Dumped by pg_dump version 15.7 (Homebrew) +-- Dumped by pg_dump version 15.8 (Homebrew) SET statement_timeout = 0; SET lock_timeout = 0; @@ -27,132 +27,6 @@ SET default_tablespace = ''; SET default_table_access_method = heap; --- --- Name: active_reward_for_all; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.active_reward_for_all ( - avs character varying, - reward_hash character varying, - token character varying, - amount numeric, - strategy character varying, - multiplier numeric, - strategy_index bigint, - block_number bigint, - start_timestamp timestamp without time zone, - end_timestamp timestamp without time zone, - duration bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - --- --- Name: active_reward_for_all_submissions; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.active_reward_for_all_submissions ( - id integer NOT NULL, - avs character varying, - reward_hash character varying, - token character varying, - amount numeric, - strategy character varying, - multiplier numeric, - strategy_index bigint, - transaction_hash character varying, - log_index bigint, - block_number bigint, - start_timestamp timestamp without time zone, - end_timestamp timestamp without time zone, - duration bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - --- --- Name: active_reward_for_all_submissions_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.active_reward_for_all_submissions_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: active_reward_for_all_submissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.active_reward_for_all_submissions_id_seq OWNED BY public.active_reward_for_all_submissions.id; - - --- --- Name: active_reward_submissions; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.active_reward_submissions ( - id integer NOT NULL, - avs character varying, - reward_hash character varying, - token character varying, - amount numeric, - strategy character varying, - multiplier numeric, - strategy_index bigint, - transaction_hash character varying, - log_index bigint, - block_number bigint, - start_timestamp timestamp without time zone, - end_timestamp timestamp without time zone, - duration bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - --- --- Name: active_reward_submissions_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.active_reward_submissions_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: active_reward_submissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.active_reward_submissions_id_seq OWNED BY public.active_reward_submissions.id; - - --- --- Name: active_rewards; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.active_rewards ( - avs character varying, - reward_hash character varying, - token character varying, - amount numeric, - strategy character varying, - multiplier numeric, - strategy_index bigint, - block_number bigint, - start_timestamp timestamp without time zone, - end_timestamp timestamp without time zone, - duration bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - -- -- Name: avs_operator_changes; Type: TABLE; Schema: public; Owner: - -- @@ -163,8 +37,10 @@ CREATE TABLE public.avs_operator_changes ( avs character varying, registered boolean, transaction_hash character varying, + transaction_index bigint, log_index bigint, - block_number bigint + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP ); @@ -263,18 +139,6 @@ CREATE SEQUENCE public.contracts_id_seq ALTER SEQUENCE public.contracts_id_seq OWNED BY public.contracts.id; --- --- Name: delegated_stakers; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.delegated_stakers ( - staker character varying, - operator character varying, - block_number bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - -- -- Name: migrations; Type: TABLE; Schema: public; Owner: - -- @@ -324,54 +188,6 @@ CREATE SEQUENCE public.operator_restaked_strategies_id_seq ALTER SEQUENCE public.operator_restaked_strategies_id_seq OWNED BY public.operator_restaked_strategies.id; --- --- Name: operator_share_changes; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.operator_share_changes ( - id integer NOT NULL, - operator character varying, - strategy character varying, - shares numeric, - transaction_hash character varying, - log_index bigint, - block_number bigint -); - - --- --- Name: operator_share_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.operator_share_changes_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: operator_share_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.operator_share_changes_id_seq OWNED BY public.operator_share_changes.id; - - --- --- Name: operator_shares; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.operator_shares ( - operator character varying, - strategy character varying, - shares numeric, - block_number bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - -- -- Name: proxy_contracts; Type: TABLE; Schema: public; Owner: - -- @@ -398,91 +214,6 @@ CREATE TABLE public.registered_avs_operators ( ); --- --- Name: staker_delegation_changes; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.staker_delegation_changes ( - id integer NOT NULL, - staker character varying, - operator character varying, - delegated boolean, - transaction_hash character varying, - log_index bigint, - block_number bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - --- --- Name: staker_delegation_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.staker_delegation_changes_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: staker_delegation_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.staker_delegation_changes_id_seq OWNED BY public.staker_delegation_changes.id; - - --- --- Name: staker_share_changes; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.staker_share_changes ( - id integer NOT NULL, - staker character varying, - strategy character varying, - shares numeric, - transaction_hash character varying, - log_index bigint, - block_number bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - --- --- Name: staker_share_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.staker_share_changes_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: staker_share_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.staker_share_changes_id_seq OWNED BY public.staker_share_changes.id; - - --- --- Name: staker_shares; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.staker_shares ( - staker character varying, - strategy character varying, - shares numeric, - block_number bigint, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -); - - -- -- Name: transaction_logs; Type: TABLE; Schema: public; Owner: - -- @@ -518,7 +249,10 @@ CREATE TABLE public.transactions ( to_address character varying(255) DEFAULT NULL::character varying, block_sequence_id bigint NOT NULL, contract_address character varying(255) DEFAULT NULL::character varying, - bytecode_hash character varying(64) DEFAULT NULL::character varying + bytecode_hash character varying(64) DEFAULT NULL::character varying, + gas_used numeric, + cumulative_gas_used numeric, + effective_gas_price numeric ); @@ -534,20 +268,6 @@ CREATE TABLE public.unverified_contracts ( ); --- --- Name: active_reward_for_all_submissions id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.active_reward_for_all_submissions ALTER COLUMN id SET DEFAULT nextval('public.active_reward_for_all_submissions_id_seq'::regclass); - - --- --- Name: active_reward_submissions id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.active_reward_submissions ALTER COLUMN id SET DEFAULT nextval('public.active_reward_submissions_id_seq'::regclass); - - -- -- Name: avs_operator_changes id; Type: DEFAULT; Schema: public; Owner: - -- @@ -576,43 +296,6 @@ ALTER TABLE ONLY public.contracts ALTER COLUMN id SET DEFAULT nextval('public.co ALTER TABLE ONLY public.operator_restaked_strategies ALTER COLUMN id SET DEFAULT nextval('public.operator_restaked_strategies_id_seq'::regclass); --- --- Name: operator_share_changes id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.operator_share_changes ALTER COLUMN id SET DEFAULT nextval('public.operator_share_changes_id_seq'::regclass); - - --- --- Name: staker_delegation_changes id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.staker_delegation_changes ALTER COLUMN id SET DEFAULT nextval('public.staker_delegation_changes_id_seq'::regclass); - - --- --- Name: staker_share_changes id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.staker_share_changes ALTER COLUMN id SET DEFAULT nextval('public.staker_share_changes_id_seq'::regclass); - - --- --- Name: active_reward_for_all_submissions active_reward_for_all_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.active_reward_for_all_submissions - ADD CONSTRAINT active_reward_for_all_submissions_pkey PRIMARY KEY (id); - - --- --- Name: active_reward_submissions active_reward_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.active_reward_submissions - ADD CONSTRAINT active_reward_submissions_pkey PRIMARY KEY (id); - - -- -- Name: avs_operator_changes avs_operator_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -645,14 +328,6 @@ ALTER TABLE ONLY public.contracts ADD CONSTRAINT contracts_pkey PRIMARY KEY (contract_address); --- --- Name: delegated_stakers delegated_stakers_staker_operator_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.delegated_stakers - ADD CONSTRAINT delegated_stakers_staker_operator_block_number_key UNIQUE (staker, operator, block_number); - - -- -- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -669,22 +344,6 @@ ALTER TABLE ONLY public.operator_restaked_strategies ADD CONSTRAINT operator_restaked_strategies_pkey PRIMARY KEY (id); --- --- Name: operator_share_changes operator_share_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.operator_share_changes - ADD CONSTRAINT operator_share_changes_pkey PRIMARY KEY (id); - - --- --- Name: operator_shares operator_shares_operator_strategy_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.operator_shares - ADD CONSTRAINT operator_shares_operator_strategy_block_number_key UNIQUE (operator, strategy, block_number); - - -- -- Name: registered_avs_operators registered_avs_operators_operator_avs_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -693,30 +352,6 @@ ALTER TABLE ONLY public.registered_avs_operators ADD CONSTRAINT registered_avs_operators_operator_avs_block_number_key UNIQUE (operator, avs, block_number); --- --- Name: staker_delegation_changes staker_delegation_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.staker_delegation_changes - ADD CONSTRAINT staker_delegation_changes_pkey PRIMARY KEY (id); - - --- --- Name: staker_share_changes staker_share_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.staker_share_changes - ADD CONSTRAINT staker_share_changes_pkey PRIMARY KEY (id); - - --- --- Name: staker_shares staker_shares_staker_strategy_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.staker_shares - ADD CONSTRAINT staker_shares_staker_strategy_block_number_key UNIQUE (staker, strategy, block_number); - - -- -- Name: transactions transactions_transaction_hash_sequence_id_key; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -733,62 +368,6 @@ ALTER TABLE ONLY public.unverified_contracts ADD CONSTRAINT unverified_contracts_pkey PRIMARY KEY (contract_address); --- --- Name: idx_active_reward_for_all_avs; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_active_reward_for_all_avs ON public.active_reward_for_all USING btree (avs); - - --- --- Name: idx_active_reward_for_all_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_active_reward_for_all_block ON public.active_reward_for_all USING btree (block_number); - - --- --- Name: idx_active_reward_for_all_submissions_avs; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_active_reward_for_all_submissions_avs ON public.active_reward_for_all_submissions USING btree (avs); - - --- --- Name: idx_active_reward_for_all_submissions_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_active_reward_for_all_submissions_block ON public.active_reward_for_all_submissions USING btree (block_number); - - --- --- Name: idx_active_reward_submissions_avs; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_active_reward_submissions_avs ON public.active_reward_submissions USING btree (avs); - - --- --- Name: idx_active_reward_submissions_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_active_reward_submissions_block ON public.active_reward_submissions USING btree (block_number); - - --- --- Name: idx_active_rewards_avs; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_active_rewards_avs ON public.active_rewards USING btree (avs); - - --- --- Name: idx_active_rewards_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_active_rewards_block ON public.active_rewards USING btree (block_number); - - -- -- Name: idx_avs_operator_changes_avs_operator; Type: INDEX; Schema: public; Owner: - -- @@ -810,48 +389,6 @@ CREATE INDEX idx_avs_operator_changes_block ON public.avs_operator_changes USING CREATE INDEX idx_bytecode_hash ON public.contracts USING btree (bytecode_hash); --- --- Name: idx_delegated_stakers_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_delegated_stakers_block ON public.delegated_stakers USING btree (block_number); - - --- --- Name: idx_delegated_stakers_staker_operator; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_delegated_stakers_staker_operator ON public.delegated_stakers USING btree (staker, operator); - - --- --- Name: idx_operator_share_changes_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_operator_share_changes_block ON public.operator_share_changes USING btree (block_number); - - --- --- Name: idx_operator_share_changes_operator_strat; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_operator_share_changes_operator_strat ON public.operator_share_changes USING btree (operator, strategy); - - --- --- Name: idx_operator_shares_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_operator_shares_block ON public.operator_shares USING btree (block_number); - - --- --- Name: idx_operator_shares_operator_strategy; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_operator_shares_operator_strategy ON public.operator_shares USING btree (operator, strategy); - - -- -- Name: idx_proxy_contract_contract_address; Type: INDEX; Schema: public; Owner: - -- @@ -880,48 +417,6 @@ CREATE INDEX idx_registered_avs_operators_avs_operator ON public.registered_avs_ CREATE INDEX idx_registered_avs_operators_block ON public.registered_avs_operators USING btree (block_number); --- --- Name: idx_staker_delegation_changes_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_staker_delegation_changes_block ON public.staker_delegation_changes USING btree (block_number); - - --- --- Name: idx_staker_delegation_changes_staker_operator; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_staker_delegation_changes_staker_operator ON public.staker_delegation_changes USING btree (staker, operator); - - --- --- Name: idx_staker_share_changes_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_staker_share_changes_block ON public.staker_share_changes USING btree (block_number); - - --- --- Name: idx_staker_share_changes_staker_strat; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_staker_share_changes_staker_strat ON public.staker_share_changes USING btree (staker, strategy); - - --- --- Name: idx_staker_shares_block; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_staker_shares_block ON public.staker_shares USING btree (block_number); - - --- --- Name: idx_staker_shares_staker_strategy; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX idx_staker_shares_staker_strategy ON public.staker_shares USING btree (staker, strategy); - - -- -- Name: idx_transaciton_logs_block_number; Type: INDEX; Schema: public; Owner: - -- @@ -943,6 +438,13 @@ CREATE UNIQUE INDEX idx_transaction_hash ON public.transaction_logs USING btree CREATE INDEX idx_transaction_logs_address ON public.transaction_logs USING btree (address); +-- +-- Name: idx_transaction_logs_transaction_hash; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_transaction_logs_transaction_hash ON public.transaction_logs USING btree (transaction_hash); + + -- -- Name: idx_transactions_block_number; Type: INDEX; Schema: public; Owner: - -- @@ -1033,7 +535,7 @@ GRANT ALL ON SCHEMA public TO PUBLIC; -- -- Dumped from database version 14.11 (Homebrew) --- Dumped by pg_dump version 15.7 (Homebrew) +-- Dumped by pg_dump version 15.8 (Homebrew) SET statement_timeout = 0; SET lock_timeout = 0; @@ -1070,9 +572,9 @@ INSERT INTO public.migrations VALUES ('202406251424_addTransactionLogsOutputData INSERT INTO public.migrations VALUES ('202406251426_addTransactionIndexes', '2024-06-25 14:29:47.500543-05', NULL); INSERT INTO public.migrations VALUES ('202407101440_addOperatorRestakedStrategiesTable', '2024-07-11 09:48:48.933519-05', NULL); INSERT INTO public.migrations VALUES ('202407110946_addBlockTimeToRestakedStrategies', '2024-07-11 09:49:17.325774-05', NULL); -INSERT INTO public.migrations VALUES ('202407111116_addAvsDirectoryAddress', '2024-08-20 16:12:38.890285-05', NULL); -INSERT INTO public.migrations VALUES ('202407121407_updateProxyContractIndex', '2024-08-20 16:12:38.893514-05', NULL); -INSERT INTO public.migrations VALUES ('202408200934_eigenlayerStateTables', '2024-08-20 16:12:38.950484-05', NULL); +INSERT INTO public.migrations VALUES ('202407111116_addAvsDirectoryAddress', '2024-07-24 09:13:18.235218-05', NULL); +INSERT INTO public.migrations VALUES ('202407121407_updateProxyContractIndex', '2024-07-24 09:13:18.240594-05', NULL); +INSERT INTO public.migrations VALUES ('202408200934_eigenlayerStateTables', '2024-09-05 16:16:40.950631-05', NULL); -- From 71ea76f8aa11424a6973e71cd39b951bb36916fb Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Thu, 5 Sep 2024 16:36:56 -0500 Subject: [PATCH 7/8] Update comment to be accurate --- internal/eigenState/avsOperators.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/eigenState/avsOperators.go b/internal/eigenState/avsOperators.go index 55b17974..4245a3f3 100644 --- a/internal/eigenState/avsOperators.go +++ b/internal/eigenState/avsOperators.go @@ -172,8 +172,10 @@ func (a *AvsOperators) writeStateChange(change *AvsOperatorChange) (*AvsOperator // // 1. Get latest distinct change value for each avs/operator // 2. Join the latest unique change value with the previous blocks state to overlay new changes -// 3. Filter joined set on registered = true to omit unregistered operators -// 3. Write the new state as the final state +// 3. Filter joined set on registered = false to get unregistrations +// 4. Determine which rows from the previous block should be carried over and which shouldnt (i.e. deregistrations) +// 5. Geneate the final state by unioning the carryover and the new registrations +// 6. Insert the final state into the registered_avs_operators table func (a *AvsOperators) WriteFinalState(blockNumber uint64) error { query := ` with new_changes as ( From 136911c87d92f42a102972d4fdef34720e588969 Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Thu, 5 Sep 2024 19:51:14 -0500 Subject: [PATCH 8/8] Parse and store operator shares --- .../{ => avsOperators}/avsOperators.go | 19 +- .../{ => avsOperators}/avsOperators_test.go | 7 +- .../operatorShares/operatorShares.go | 358 ++++++++++++++++++ .../operatorShares/operatorShares_test.go | 124 ++++++ .../202408200934_eigenlayerStateTables/up.go | 23 -- .../202409051720_operatorShareChanges/up.go | 49 +++ internal/postgres/migrations/migrator.go | 2 + internal/storage/tables.go | 44 --- internal/utils/utils.go | 5 + sql/schema.sql | 102 +++++ 10 files changed, 654 insertions(+), 79 deletions(-) rename internal/eigenState/{ => avsOperators}/avsOperators.go (94%) rename internal/eigenState/{ => avsOperators}/avsOperators_test.go (95%) create mode 100644 internal/eigenState/operatorShares/operatorShares.go create mode 100644 internal/eigenState/operatorShares/operatorShares_test.go create mode 100644 internal/postgres/migrations/202409051720_operatorShareChanges/up.go diff --git a/internal/eigenState/avsOperators.go b/internal/eigenState/avsOperators/avsOperators.go similarity index 94% rename from internal/eigenState/avsOperators.go rename to internal/eigenState/avsOperators/avsOperators.go index 4245a3f3..876a1ae8 100644 --- a/internal/eigenState/avsOperators.go +++ b/internal/eigenState/avsOperators/avsOperators.go @@ -1,9 +1,10 @@ -package eigenState +package avsOperators import ( "database/sql" "fmt" "github.com/Layr-Labs/sidecar/internal/config" + "github.com/Layr-Labs/sidecar/internal/eigenState" "github.com/Layr-Labs/sidecar/internal/storage" "github.com/wealdtech/go-merkletree/v2" "github.com/wealdtech/go-merkletree/v2/keccak256" @@ -40,8 +41,8 @@ type AvsOperatorChange struct { // EigenState model for AVS operators that implements IEigenStateModel type AvsOperators struct { - BaseEigenState - StateTransitions StateTransitions[AvsOperatorChange] + eigenState.BaseEigenState + StateTransitions eigenState.StateTransitions[AvsOperatorChange] Db *gorm.DB Network config.Network Environment config.Environment @@ -51,7 +52,7 @@ type AvsOperators struct { // Create new instance of AvsOperators state model func NewAvsOperators( - esm *EigenStateManager, + esm *eigenState.EigenStateManager, grm *gorm.DB, Network config.Network, Environment config.Environment, @@ -59,7 +60,7 @@ func NewAvsOperators( globalConfig *config.Config, ) (*AvsOperators, error) { s := &AvsOperators{ - BaseEigenState: BaseEigenState{}, + BaseEigenState: eigenState.BaseEigenState{}, Db: grm, Network: Network, Environment: Environment, @@ -77,8 +78,8 @@ func NewAvsOperators( // // Returns the map and a reverse sorted list of block numbers that can be traversed when // processing a log to determine which state change to apply. -func (a *AvsOperators) GetStateTransitions() (StateTransitions[AvsOperatorChange], []uint64) { - stateChanges := make(StateTransitions[AvsOperatorChange]) +func (a *AvsOperators) GetStateTransitions() (eigenState.StateTransitions[AvsOperatorChange], []uint64) { + stateChanges := make(eigenState.StateTransitions[AvsOperatorChange]) // TODO(seanmcgary): make this not a closure so this function doesnt get big an messy... stateChanges[0] = func(log *storage.TransactionLog) (*AvsOperatorChange, error) { @@ -247,7 +248,7 @@ func (a *AvsOperators) WriteFinalState(blockNumber uint64) error { // 3. Create a merkle tree for each AVS, with the operator:block_number pairs as leaves // 4. Create a merkle tree for all AVS trees // 5. Return the root of the full tree -func (a *AvsOperators) GenerateStateRoot(blockNumber uint64) (StateRoot, error) { +func (a *AvsOperators) GenerateStateRoot(blockNumber uint64) (eigenState.StateRoot, error) { query := ` select avs, @@ -320,5 +321,5 @@ func (a *AvsOperators) GenerateStateRoot(blockNumber uint64) (StateRoot, error) if err != nil { return "", err } - return StateRoot(fullTree.Root()), nil + return eigenState.StateRoot(fullTree.Root()), nil } diff --git a/internal/eigenState/avsOperators_test.go b/internal/eigenState/avsOperators/avsOperators_test.go similarity index 95% rename from internal/eigenState/avsOperators_test.go rename to internal/eigenState/avsOperators/avsOperators_test.go index 1022419e..0de181d6 100644 --- a/internal/eigenState/avsOperators_test.go +++ b/internal/eigenState/avsOperators/avsOperators_test.go @@ -1,9 +1,10 @@ -package eigenState +package avsOperators import ( "database/sql" "fmt" "github.com/Layr-Labs/sidecar/internal/config" + "github.com/Layr-Labs/sidecar/internal/eigenState" "github.com/Layr-Labs/sidecar/internal/logger" "github.com/Layr-Labs/sidecar/internal/storage" "github.com/Layr-Labs/sidecar/internal/tests" @@ -18,7 +19,7 @@ func setup() ( *config.Config, *gorm.DB, *zap.Logger, - *EigenStateManager, + *eigenState.EigenStateManager, error, ) { cfg := tests.GetConfig() @@ -26,7 +27,7 @@ func setup() ( _, grm, err := tests.GetDatabaseConnection(cfg) - eigenState := NewEigenStateManager(l) + eigenState := eigenState.NewEigenStateManager(l) return cfg, grm, l, eigenState, err } diff --git a/internal/eigenState/operatorShares/operatorShares.go b/internal/eigenState/operatorShares/operatorShares.go new file mode 100644 index 00000000..b3e98c0c --- /dev/null +++ b/internal/eigenState/operatorShares/operatorShares.go @@ -0,0 +1,358 @@ +package operatorShares + +import ( + "database/sql" + "encoding/json" + "fmt" + "github.com/Layr-Labs/sidecar/internal/config" + "github.com/Layr-Labs/sidecar/internal/eigenState" + "github.com/Layr-Labs/sidecar/internal/parser" + "github.com/Layr-Labs/sidecar/internal/storage" + "github.com/Layr-Labs/sidecar/internal/utils" + "github.com/wealdtech/go-merkletree/v2" + "github.com/wealdtech/go-merkletree/v2/keccak256" + orderedmap "github.com/wk8/go-ordered-map/v2" + "go.uber.org/zap" + "gorm.io/gorm" + "gorm.io/gorm/clause" + "math/big" + "slices" + "sort" + "strings" + "time" +) + +// Changes table +type OperatorShareChange struct { + Id uint64 `gorm:"type:serial"` + Operator string + Strategy string + Shares string `gorm:"type:numeric"` + TransactionHash string + TransactionIndex uint64 + LogIndex uint64 + BlockNumber uint64 + CreatedAt time.Time +} + +// Block table +type OperatorShares struct { + Operator string + Strategy string + Shares string `gorm:"type:numeric"` + BlockNumber uint64 + CreatedAt time.Time +} + +// Implements IEigenStateModel +type OperatorSharesModel struct { + eigenState.BaseEigenState + StateTransitions eigenState.StateTransitions[OperatorShareChange] + Db *gorm.DB + Network config.Network + Environment config.Environment + logger *zap.Logger + globalConfig *config.Config +} + +func NewOperatorSharesModel( + esm *eigenState.EigenStateManager, + grm *gorm.DB, + Network config.Network, + Environment config.Environment, + logger *zap.Logger, + globalConfig *config.Config, +) (*OperatorSharesModel, error) { + model := &OperatorSharesModel{ + BaseEigenState: eigenState.BaseEigenState{}, + Db: grm, + Network: Network, + Environment: Environment, + logger: logger, + globalConfig: globalConfig, + } + + esm.RegisterState(model) + return model, nil +} + +func (osm *OperatorSharesModel) GetStateTransitions() (eigenState.StateTransitions[OperatorShareChange], []uint64) { + stateChanges := make(eigenState.StateTransitions[OperatorShareChange]) + + stateChanges[0] = func(log *storage.TransactionLog) (*OperatorShareChange, error) { + arguments := make([]parser.Argument, 0) + err := json.Unmarshal([]byte(log.Arguments), &arguments) + if err != nil { + osm.logger.Sugar().Errorw("Failed to unmarshal arguments", + zap.Error(err), + zap.String("transactionHash", log.TransactionHash), + zap.Uint64("transactionIndex", log.TransactionIndex), + ) + return nil, err + } + outputData := make(map[string]interface{}) + err = json.Unmarshal([]byte(log.OutputData), &outputData) + if err != nil { + osm.logger.Sugar().Errorw("Failed to unmarshal outputData", + zap.Error(err), + zap.String("transactionHash", log.TransactionHash), + zap.Uint64("transactionIndex", log.TransactionIndex), + ) + return nil, err + } + fmt.Printf("Outputdata: %+v\n", outputData) + shares := big.Int{} + sharesInt, _ := shares.SetString(outputData["shares"].(string), 10) + + if log.EventName == "OperatorSharesDecreased" { + sharesInt.Mul(sharesInt, big.NewInt(-1)) + } + + change := &OperatorShareChange{ + Operator: arguments[0].Value.(string), + Strategy: outputData["strategy"].(string), + Shares: sharesInt.String(), + TransactionHash: log.TransactionHash, + TransactionIndex: log.TransactionIndex, + LogIndex: log.LogIndex, + BlockNumber: log.BlockNumber, + } + fmt.Printf("Change: %+v\n", change) + return change, nil + } + + // Create an ordered list of block numbers + blockNumbers := make([]uint64, 0) + for blockNumber, _ := range stateChanges { + blockNumbers = append(blockNumbers, blockNumber) + } + sort.Slice(blockNumbers, func(i, j int) bool { + return blockNumbers[i] < blockNumbers[j] + }) + slices.Reverse(blockNumbers) + + return stateChanges, blockNumbers +} + +func (osm *OperatorSharesModel) getContractAddressesForEnvironment() map[string][]string { + contracts := osm.globalConfig.GetContractsMapForEnvAndNetwork() + return map[string][]string{ + contracts.DelegationManager: []string{ + "OperatorSharesIncreased", + "OperatorSharesDecreased", + }, + } +} + +func (osm *OperatorSharesModel) IsInterestingLog(log *storage.TransactionLog) bool { + addresses := osm.getContractAddressesForEnvironment() + logAddress := strings.ToLower(log.Address) + if eventNames, ok := addresses[logAddress]; ok { + if slices.Contains(eventNames, log.EventName) { + return true + } + } + return false +} + +func (osm *OperatorSharesModel) HandleStateChange(log *storage.TransactionLog) (interface{}, error) { + stateChanges, sortedBlockNumbers := osm.GetStateTransitions() + + for _, blockNumber := range sortedBlockNumbers { + if log.BlockNumber >= blockNumber { + osm.logger.Sugar().Debugw("Handling state change", zap.Uint64("blockNumber", blockNumber)) + + change, err := stateChanges[blockNumber](log) + if err != nil { + return nil, err + } + + if change != nil { + wroteChange, err := osm.writeStateChange(change) + if err != nil { + return wroteChange, err + } + return wroteChange, nil + } + } + } + return nil, nil +} + +func (osm *OperatorSharesModel) writeStateChange(change *OperatorShareChange) (interface{}, error) { + osm.logger.Sugar().Debugw("Writing state change", zap.Any("change", change)) + res := osm.Db.Model(&OperatorShareChange{}).Clauses(clause.Returning{}).Create(change) + if res.Error != nil { + osm.logger.Error("Failed to insert into avs_operator_changes", zap.Error(res.Error)) + return change, res.Error + } + return change, nil +} + +func (osm *OperatorSharesModel) WriteFinalState(blockNumber uint64) error { + query := ` + with new_sum as ( + select + operator, + strategy, + sum(shares) as shares + from + operator_share_changes + where + block_number = @currentBlock + group by 1, 2 + ), + previous_values as ( + select + operator, + strategy, + shares + from operator_shares + where block_number = @previousBlock + ), + unioned_values as ( + (select operator, strategy, shares from previous_values) + union + (select operator, strategy, shares from new_sum) + ), + final_values as ( + select + operator, + strategy, + sum(shares) as shares + from unioned_values + group by 1, 2 + ) + insert into operator_shares (operator, strategy, shares, block_number) + select operator, strategy, shares, @currentBlock as block_number from final_values + ` + + res := osm.Db.Exec(query, + sql.Named("currentBlock", blockNumber), + sql.Named("previousBlock", blockNumber-1), + ) + if res.Error != nil { + osm.logger.Sugar().Errorw("Failed to insert into operator_shares", zap.Error(res.Error)) + return res.Error + } + return nil +} + +func (osm *OperatorSharesModel) getDifferencesInStates(currentBlock uint64) ([]OperatorShares, error) { + query := ` + with new_states as ( + select + concat(operator, '_', strategy) as slot_id, + operator, + strategy, + shares + from operator_shares + where block_number = @currentBlock + ), + previous_states as ( + select + concat(operator, '_', strategy) as slot_id, + operator, + strategy, + shares + from operator_shares + where block_number = @previousBlock + ), + diffs as ( + select slot_id, operator, strategy, shares from new_states + except + select slot_id, operator, strategy, shares from previous_states + ) + select operator, strategy, shares from diffs + order by strategy asc, operator asc + ` + + diffs := make([]OperatorShares, 0) + res := osm.Db. + Raw(query, + sql.Named("currentBlock", currentBlock), + sql.Named("previousBlock", currentBlock-1), + ). + Scan(&diffs) + if res.Error != nil { + osm.logger.Sugar().Errorw("Failed to fetch operator_shares", zap.Error(res.Error)) + return nil, res.Error + } + return diffs, nil +} + +func (osm *OperatorSharesModel) GenerateStateRoot(blockNumber uint64) (eigenState.StateRoot, error) { + diffs, err := osm.getDifferencesInStates(blockNumber) + if err != nil { + return "", err + } + + fullTree, err := osm.merkelizeState(diffs) + if err != nil { + return "", err + } + return eigenState.StateRoot(utils.ConvertBytesToString(fullTree.Root())), nil +} + +func (osm *OperatorSharesModel) merkelizeState(diffs []OperatorShares) (*merkletree.MerkleTree, error) { + // Create a merkle tree with the structure: + // strategy: map[operators]: shares + om := orderedmap.New[string, *orderedmap.OrderedMap[string, string]]() + + for _, diff := range diffs { + existingStrategy, found := om.Get(diff.Strategy) + if !found { + existingStrategy = orderedmap.New[string, string]() + om.Set(diff.Strategy, existingStrategy) + + prev := om.GetPair(diff.Strategy).Prev() + if prev != nil && strings.Compare(prev.Key, diff.Strategy) >= 0 { + om.Delete(diff.Strategy) + return nil, fmt.Errorf("strategy not in order") + } + } + existingStrategy.Set(diff.Operator, diff.Shares) + + prev := existingStrategy.GetPair(diff.Operator).Prev() + if prev != nil && strings.Compare(prev.Key, diff.Operator) >= 0 { + existingStrategy.Delete(diff.Operator) + return nil, fmt.Errorf("operator not in order") + } + } + + leaves := make([][]byte, 0) + for strat := om.Oldest(); strat != nil; strat = strat.Next() { + + operatorLeaves := make([][]byte, 0) + for operator := strat.Value.Oldest(); operator != nil; operator = operator.Next() { + operatorAddr := operator.Key + shares := operator.Value + operatorLeaves = append(operatorLeaves, encodeOperatorSharesLeaf(operatorAddr, shares)) + } + + stratTree, err := merkletree.NewTree( + merkletree.WithData(operatorLeaves), + merkletree.WithHashType(keccak256.New()), + ) + if err != nil { + return nil, err + } + leaves = append(leaves, encodeStratTree(strat.Key, stratTree.Root())) + } + return merkletree.NewTree( + merkletree.WithData(leaves), + merkletree.WithHashType(keccak256.New()), + ) +} + +func encodeOperatorSharesLeaf(operator string, shares string) []byte { + operatorBytes := []byte(operator) + sharesBytes := []byte(shares) + + return append(operatorBytes, sharesBytes[:]...) +} + +func encodeStratTree(strategy string, operatorTreeRoot []byte) []byte { + strategyBytes := []byte(strategy) + return append(strategyBytes, operatorTreeRoot[:]...) +} diff --git a/internal/eigenState/operatorShares/operatorShares_test.go b/internal/eigenState/operatorShares/operatorShares_test.go new file mode 100644 index 00000000..c5894690 --- /dev/null +++ b/internal/eigenState/operatorShares/operatorShares_test.go @@ -0,0 +1,124 @@ +package operatorShares + +import ( + "database/sql" + "fmt" + "github.com/Layr-Labs/sidecar/internal/config" + "github.com/Layr-Labs/sidecar/internal/eigenState" + "github.com/Layr-Labs/sidecar/internal/logger" + "github.com/Layr-Labs/sidecar/internal/storage" + "github.com/Layr-Labs/sidecar/internal/tests" + "github.com/stretchr/testify/assert" + "go.uber.org/zap" + "gorm.io/gorm" + "math/big" + "testing" + "time" +) + +func setup() ( + *config.Config, + *gorm.DB, + *zap.Logger, + *eigenState.EigenStateManager, + error, +) { + cfg := tests.GetConfig() + l, _ := logger.NewLogger(&logger.LoggerConfig{Debug: cfg.Debug}) + + _, grm, err := tests.GetDatabaseConnection(cfg) + + eigenState := eigenState.NewEigenStateManager(l) + + return cfg, grm, l, eigenState, err +} + +func teardown(model *OperatorSharesModel) { + model.Db.Exec("truncate table operator_share_changes cascade") + model.Db.Exec("truncate table operator_shares cascade") +} + +func Test_OperatorSharesState(t *testing.T) { + cfg, grm, l, esm, err := setup() + + if err != nil { + t.Fatal(err) + } + + t.Run("Should create a new OperatorSharesState", func(t *testing.T) { + model, err := NewOperatorSharesModel(esm, grm, cfg.Network, cfg.Environment, l, cfg) + assert.Nil(t, err) + assert.NotNil(t, model) + }) + t.Run("Should register OperatorSharesState", func(t *testing.T) { + blockNumber := uint64(200) + log := storage.TransactionLog{ + TransactionHash: "some hash", + TransactionIndex: big.NewInt(100).Uint64(), + BlockNumber: blockNumber, + BlockSequenceId: big.NewInt(300).Uint64(), + Address: cfg.GetContractsMapForEnvAndNetwork().DelegationManager, + Arguments: `[{"Value": "0xdb9afbdcfeca94dfb25790c900c527969e78bd3c"}]`, + EventName: "OperatorSharesIncreased", + LogIndex: big.NewInt(400).Uint64(), + OutputData: `{"shares": "100", "strategy": "0x93c4b944d05dfe6df7645a86cd2206016c51564d"}`, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + DeletedAt: time.Time{}, + } + + model, err := NewOperatorSharesModel(esm, grm, cfg.Network, cfg.Environment, l, cfg) + + change, err := model.HandleStateChange(&log) + assert.Nil(t, err) + assert.NotNil(t, change) + + teardown(model) + }) + t.Run("Should register AvsOperatorState and generate the table for the block", func(t *testing.T) { + blockNumber := uint64(200) + log := storage.TransactionLog{ + TransactionHash: "some hash", + TransactionIndex: big.NewInt(100).Uint64(), + BlockNumber: blockNumber, + BlockSequenceId: big.NewInt(300).Uint64(), + Address: cfg.GetContractsMapForEnvAndNetwork().DelegationManager, + Arguments: `[{"Value": "0xdb9afbdcfeca94dfb25790c900c527969e78bd3c"}]`, + EventName: "OperatorSharesIncreased", + LogIndex: big.NewInt(400).Uint64(), + OutputData: `{"shares": "100", "strategy": "0x93c4b944d05dfe6df7645a86cd2206016c51564d"}`, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + DeletedAt: time.Time{}, + } + + model, err := NewOperatorSharesModel(esm, grm, cfg.Network, cfg.Environment, l, cfg) + assert.Nil(t, err) + + stateChange, err := model.HandleStateChange(&log) + assert.Nil(t, err) + assert.NotNil(t, stateChange) + + err = model.WriteFinalState(blockNumber) + assert.Nil(t, err) + + states := []OperatorShares{} + statesRes := model.Db. + Model(&OperatorShares{}). + Raw("select * from operator_shares where block_number = @blockNumber", sql.Named("blockNumber", blockNumber)). + Scan(&states) + + if statesRes.Error != nil { + t.Fatalf("Failed to fetch operator_shares: %v", statesRes.Error) + } + assert.Equal(t, 1, len(states)) + + assert.Equal(t, "100", states[0].Shares) + + stateRoot, err := model.GenerateStateRoot(blockNumber) + assert.Nil(t, err) + fmt.Printf("StateRoot: %s\n", stateRoot) + + teardown(model) + }) +} diff --git a/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go b/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go index f1e38d65..c31d66fc 100644 --- a/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go +++ b/internal/postgres/migrations/202408200934_eigenlayerStateTables/up.go @@ -37,19 +37,6 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { `create index if not exists idx_registered_avs_operators_avs_operator on registered_avs_operators (avs, operator)`, `create index if not exists idx_registered_avs_operators_block on registered_avs_operators (block_number)`, /* - `create table if not exists operator_share_changes ( - id serial primary key, - operator varchar, - strategy varchar, - shares numeric, - transaction_hash varchar, - log_index bigint, - block_number bigint, - created_at timestamp with time zone default current_timestamp - ) - `, - `create index if not exists idx_operator_share_changes_operator_strat on operator_share_changes (operator, strategy)`, - `create index if not exists idx_operator_share_changes_block on operator_share_changes (block_number)`, `create table if not exists staker_share_changes ( id serial primary key, staker varchar, @@ -116,16 +103,6 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { `, `create index if not exists idx_active_reward_for_all_submissions_avs on active_reward_for_all_submissions (avs)`, `create index if not exists idx_active_reward_for_all_submissions_block on active_reward_for_all_submissions (block_number)`, - `create table if not exists operator_shares ( - operator varchar, - strategy varchar, - shares numeric, - block_number bigint, - created_at timestamp with time zone default current_timestamp, - unique (operator, strategy, block_number) - )`, - `create index if not exists idx_operator_shares_operator_strategy on operator_shares (operator, strategy)`, - `create index if not exists idx_operator_shares_block on operator_shares (block_number)`, `create table if not exists staker_shares ( staker varchar, strategy varchar, diff --git a/internal/postgres/migrations/202409051720_operatorShareChanges/up.go b/internal/postgres/migrations/202409051720_operatorShareChanges/up.go new file mode 100644 index 00000000..b61ee8e0 --- /dev/null +++ b/internal/postgres/migrations/202409051720_operatorShareChanges/up.go @@ -0,0 +1,49 @@ +package _202409051720_operatorShareChanges + +import ( + "database/sql" + "gorm.io/gorm" +) + +type Migration struct { +} + +func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error { + queries := []string{ + `create table if not exists operator_share_changes ( + id serial primary key, + operator varchar, + strategy varchar, + shares numeric, + transaction_hash varchar, + transaction_index bigint, + log_index bigint, + block_number bigint, + created_at timestamp with time zone default current_timestamp, + unique(operator, strategy, transaction_hash, log_index) + ) + `, + `create index if not exists idx_operator_share_changes_operator_strat on operator_share_changes (operator, strategy)`, + `create index if not exists idx_operator_share_changes_block on operator_share_changes (block_number)`, + `create table if not exists operator_shares ( + operator varchar, + strategy varchar, + shares numeric, + block_number bigint, + created_at timestamp with time zone default current_timestamp, + unique (operator, strategy, block_number) + )`, + `create index if not exists idx_operator_shares_operator_strategy on operator_shares (operator, strategy)`, + `create index if not exists idx_operator_shares_block on operator_shares (block_number)`, + } + for _, query := range queries { + if _, err := db.Exec(query); err != nil { + return err + } + } + return nil +} + +func (m *Migration) GetName() string { + return "202409051720_operatorShareChanges" +} diff --git a/internal/postgres/migrations/migrator.go b/internal/postgres/migrations/migrator.go index 8cf98e6b..1a939f94 100644 --- a/internal/postgres/migrations/migrator.go +++ b/internal/postgres/migrations/migrator.go @@ -26,6 +26,7 @@ import ( _202407111116_addAvsDirectoryAddress "github.com/Layr-Labs/sidecar/internal/postgres/migrations/202407111116_addAvsDirectoryAddress" _202407121407_updateProxyContractIndex "github.com/Layr-Labs/sidecar/internal/postgres/migrations/202407121407_updateProxyContractIndex" _202408200934_eigenlayerStateTables "github.com/Layr-Labs/sidecar/internal/postgres/migrations/202408200934_eigenlayerStateTables" + _202409051720_operatorShareChanges "github.com/Layr-Labs/sidecar/internal/postgres/migrations/202409051720_operatorShareChanges" "go.uber.org/zap" "gorm.io/gorm" "time" @@ -76,6 +77,7 @@ func (m *Migrator) MigrateAll() error { &_202407111116_addAvsDirectoryAddress.Migration{}, &_202407121407_updateProxyContractIndex.Migration{}, &_202408200934_eigenlayerStateTables.Migration{}, + &_202409051720_operatorShareChanges.Migration{}, } for _, migration := range migrations { diff --git a/internal/storage/tables.go b/internal/storage/tables.go index e17e210f..0f87e6aa 100644 --- a/internal/storage/tables.go +++ b/internal/storage/tables.go @@ -9,30 +9,6 @@ import ( // Append only tables of state // ---------------------------------------------------------------------------- -/* -create table if not exists operator_share_changes ( - - id serial primary key, - operator varchar, - strategy varchar, - shares numeric, - transaction_hash varchar, - log_index bigint, - block_number bigint - -); -*/ -type OperatorShareChanges struct { - Id uint64 `gorm:"type:serial"` - Operator string - Strategy string - Shares big.Int `gorm:"type:numeric"` - TransactionHash string - LogIndex uint64 - BlockNumber uint64 - CreatedAt time.Time -} - /* create table if not exists staker_share_changes ( @@ -164,26 +140,6 @@ type RewardForAllSubmissions struct { // Block-based "summary" tables // ---------------------------------------------------------------------------- -/* -create table if not exists operator_shares ( - - operator varchar, - strategy varchar, - shares numeric, - block_number bigint, - created_at timestamp with time zone - unique idx_uniq_operator_shares_block (operator, strategy, block_number) - -) -*/ -type OperatorShares struct { - Operator string - Strategy string - Shares big.Int `gorm:"type:numeric"` - BlockNumber uint64 - CreatedAt time.Time -} - /* create table if not exists staker_shares ( diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 6265ef0c..d3408e0e 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -1,6 +1,7 @@ package utils import ( + "encoding/hex" "fmt" "strings" ) @@ -13,3 +14,7 @@ var ( func AreAddressesEqual(a, b string) bool { return strings.ToLower(a) == strings.ToLower(b) } + +func ConvertBytesToString(b []byte) string { + return "0x" + hex.EncodeToString(b[:]) +} diff --git a/sql/schema.sql b/sql/schema.sql index b0e9febd..b5353100 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -188,6 +188,56 @@ CREATE SEQUENCE public.operator_restaked_strategies_id_seq ALTER SEQUENCE public.operator_restaked_strategies_id_seq OWNED BY public.operator_restaked_strategies.id; +-- +-- Name: operator_share_changes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.operator_share_changes ( + id integer NOT NULL, + operator character varying, + strategy character varying, + shares numeric, + transaction_hash character varying, + transaction_index bigint, + log_index bigint, + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +-- +-- Name: operator_share_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.operator_share_changes_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: operator_share_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.operator_share_changes_id_seq OWNED BY public.operator_share_changes.id; + + +-- +-- Name: operator_shares; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.operator_shares ( + operator character varying, + strategy character varying, + shares numeric, + block_number bigint, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + -- -- Name: proxy_contracts; Type: TABLE; Schema: public; Owner: - -- @@ -296,6 +346,13 @@ ALTER TABLE ONLY public.contracts ALTER COLUMN id SET DEFAULT nextval('public.co ALTER TABLE ONLY public.operator_restaked_strategies ALTER COLUMN id SET DEFAULT nextval('public.operator_restaked_strategies_id_seq'::regclass); +-- +-- Name: operator_share_changes id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.operator_share_changes ALTER COLUMN id SET DEFAULT nextval('public.operator_share_changes_id_seq'::regclass); + + -- -- Name: avs_operator_changes avs_operator_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -344,6 +401,22 @@ ALTER TABLE ONLY public.operator_restaked_strategies ADD CONSTRAINT operator_restaked_strategies_pkey PRIMARY KEY (id); +-- +-- Name: operator_share_changes operator_share_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.operator_share_changes + ADD CONSTRAINT operator_share_changes_pkey PRIMARY KEY (id); + + +-- +-- Name: operator_shares operator_shares_operator_strategy_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.operator_shares + ADD CONSTRAINT operator_shares_operator_strategy_block_number_key UNIQUE (operator, strategy, block_number); + + -- -- Name: registered_avs_operators registered_avs_operators_operator_avs_block_number_key; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -389,6 +462,34 @@ CREATE INDEX idx_avs_operator_changes_block ON public.avs_operator_changes USING CREATE INDEX idx_bytecode_hash ON public.contracts USING btree (bytecode_hash); +-- +-- Name: idx_operator_share_changes_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_operator_share_changes_block ON public.operator_share_changes USING btree (block_number); + + +-- +-- Name: idx_operator_share_changes_operator_strat; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_operator_share_changes_operator_strat ON public.operator_share_changes USING btree (operator, strategy); + + +-- +-- Name: idx_operator_shares_block; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_operator_shares_block ON public.operator_shares USING btree (block_number); + + +-- +-- Name: idx_operator_shares_operator_strategy; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_operator_shares_operator_strategy ON public.operator_shares USING btree (operator, strategy); + + -- -- Name: idx_proxy_contract_contract_address; Type: INDEX; Schema: public; Owner: - -- @@ -575,6 +676,7 @@ INSERT INTO public.migrations VALUES ('202407110946_addBlockTimeToRestakedStrate INSERT INTO public.migrations VALUES ('202407111116_addAvsDirectoryAddress', '2024-07-24 09:13:18.235218-05', NULL); INSERT INTO public.migrations VALUES ('202407121407_updateProxyContractIndex', '2024-07-24 09:13:18.240594-05', NULL); INSERT INTO public.migrations VALUES ('202408200934_eigenlayerStateTables', '2024-09-05 16:16:40.950631-05', NULL); +INSERT INTO public.migrations VALUES ('202409051720_operatorShareChanges', '2024-09-05 19:14:07.595987-05', NULL); --