Skip to content

Commit

Permalink
Update indexer M2 mainnet contracts (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
mooselumph authored Jan 25, 2024
1 parent 8ccb524 commit ca28ca1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 39 deletions.
47 changes: 17 additions & 30 deletions core/indexer/operator_pubkeys_filterer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"sort"

"github.com/Layr-Labs/eigenda/common"
blspubkeyreg "github.com/Layr-Labs/eigenda/contracts/bindings/BLSPubkeyRegistry"
blspubkeycompendium "github.com/Layr-Labs/eigenda/contracts/bindings/BLSPublicKeyCompendium"
blsapkreg "github.com/Layr-Labs/eigenda/contracts/bindings/BLSApkRegistry"
eigendasrvmg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDAServiceManager"
"github.com/Layr-Labs/eigenda/indexer"

Expand All @@ -18,8 +17,8 @@ import (
)

type PubKeyAddedEvent struct {
AddedEvent *blspubkeyreg.ContractBLSPubkeyRegistryOperatorAddedToQuorums
RegEvent *blspubkeycompendium.ContractBLSPublicKeyCompendiumNewPubkeyRegistration
AddedEvent *blsapkreg.ContractBLSApkRegistryOperatorAddedToQuorums
RegEvent *blsapkreg.ContractBLSApkRegistryNewPubkeyRegistration
}

type operatorPubKeysEvent struct {
Expand All @@ -32,7 +31,7 @@ type operatorPubKeysEvent struct {
}

type operatorPubKeysEventFilterer struct {
f *blspubkeyreg.ContractBLSPubkeyRegistryFilterer
f *blsapkreg.ContractBLSApkRegistryFilterer
cf *pubkeyRegistrationEventFilterer
}

Expand All @@ -41,7 +40,7 @@ func newOperatorPubKeysEventFilterer(
filterer bind.ContractFilterer,
regFilterer *pubkeyRegistrationEventFilterer,
) (*operatorPubKeysEventFilterer, error) {
f, err := blspubkeyreg.NewContractBLSPubkeyRegistryFilterer(addr, filterer)
f, err := blsapkreg.NewContractBLSApkRegistryFilterer(addr, filterer)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -83,7 +82,7 @@ func (f operatorPubKeysEventFilterer) filterPubKeyAddedToQuorums(
}

events, err := f.filterEvents(headers, it, func(it any) operatorPubKeysEvent {
event := it.(*blspubkeyreg.ContractBLSPubkeyRegistryOperatorAddedToQuorumsIterator).Event
event := it.(*blsapkreg.ContractBLSApkRegistryOperatorAddedToQuorumsIterator).Event
return operatorPubKeysEvent{
BlockHash: event.Raw.BlockHash,
BlockNumber: event.Raw.BlockNumber,
Expand Down Expand Up @@ -115,7 +114,7 @@ func (f operatorPubKeysEventFilterer) filterPubKeyRemovedFromQuorums(
return nil, err
}
return f.filterEvents(headers, it, func(it any) operatorPubKeysEvent {
event := it.(*blspubkeyreg.ContractBLSPubkeyRegistryOperatorRemovedFromQuorumsIterator).Event
event := it.(*blsapkreg.ContractBLSApkRegistryOperatorRemovedFromQuorumsIterator).Event
return operatorPubKeysEvent{
BlockHash: event.Raw.BlockHash,
BlockNumber: event.Raw.BlockNumber,
Expand Down Expand Up @@ -157,15 +156,15 @@ func (f operatorPubKeysEventFilterer) filterEvents(

type pubkeyRegistrationEventFilterer struct {
addr gethcommon.Address
f *blspubkeycompendium.ContractBLSPublicKeyCompendiumFilterer
f *blsapkreg.ContractBLSApkRegistryFilterer
filterer bind.ContractFilterer
}

func newPubkeyRegistrationEventFilterer(
addr gethcommon.Address,
filterer bind.ContractFilterer,
) (*pubkeyRegistrationEventFilterer, error) {
f, err := blspubkeycompendium.NewContractBLSPublicKeyCompendiumFilterer(addr, filterer)
f, err := blsapkreg.NewContractBLSApkRegistryFilterer(addr, filterer)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -215,7 +214,7 @@ func (f pubkeyRegistrationEventFilterer) addPubkeyRegistration(events []operator
return nil, errors.New("no pubkey registration events found")
}

eventMap := make(map[gethcommon.Address]*blspubkeycompendium.ContractBLSPublicKeyCompendiumNewPubkeyRegistration, len(vLogs))
eventMap := make(map[gethcommon.Address]*blsapkreg.ContractBLSApkRegistryNewPubkeyRegistration, len(vLogs))
for _, vLog := range vLogs {
event, err := f.f.ParseNewPubkeyRegistration(vLog)
if err != nil {
Expand All @@ -238,10 +237,9 @@ func (f pubkeyRegistrationEventFilterer) addPubkeyRegistration(events []operator
}

type OperatorPubKeysFilterer struct {
Logger common.Logger
Filterer bind.ContractFilterer
BlsRegAddress gethcommon.Address
PubKeyCompendiumAddress gethcommon.Address
Logger common.Logger
Filterer bind.ContractFilterer
BlsRegAddress gethcommon.Address

FastMode bool
}
Expand All @@ -253,25 +251,14 @@ func NewOperatorPubKeysFilterer(eigenDAServiceManagerAddr gethcommon.Address, cl
return nil, err
}

blsRegAddress, err := contractEigenDAServiceManager.BlsPubkeyRegistry(&bind.CallOpts{})
if err != nil {
return nil, err
}

blsRegistry, err := blspubkeyreg.NewContractBLSPubkeyRegistry(blsRegAddress, client)
if err != nil {
return nil, err
}

pubkeyCompendiumAddress, err := blsRegistry.PubkeyCompendium(&bind.CallOpts{})
blsRegAddress, err := contractEigenDAServiceManager.BlsApkRegistry(&bind.CallOpts{})
if err != nil {
return nil, err
}

return &OperatorPubKeysFilterer{
Filterer: client,
BlsRegAddress: blsRegAddress,
PubKeyCompendiumAddress: pubkeyCompendiumAddress,
Filterer: client,
BlsRegAddress: blsRegAddress,
}, nil
}

Expand All @@ -282,7 +269,7 @@ func (f *OperatorPubKeysFilterer) FilterHeaders(headers indexer.Headers) ([]inde
return nil, err
}

regFilterer, err := newPubkeyRegistrationEventFilterer(f.PubKeyCompendiumAddress, f.Filterer)
regFilterer, err := newPubkeyRegistrationEventFilterer(f.BlsRegAddress, f.Filterer)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions core/indexer/operator_sockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/gob"

"github.com/Layr-Labs/eigenda/common"
blsregcoord "github.com/Layr-Labs/eigenda/contracts/bindings/BLSRegistryCoordinatorWithIndices"
regcoord "github.com/Layr-Labs/eigenda/contracts/bindings/RegistryCoordinator"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/indexer"
)
Expand Down Expand Up @@ -40,7 +40,7 @@ func (a *OperatorSocketsAccumulator) UpdateObject(object indexer.AccumulatorObje
return object, ErrIncorrectEvent
}

payload, ok := event.Payload.(*blsregcoord.ContractBLSRegistryCoordinatorWithIndicesOperatorSocketUpdate)
payload, ok := event.Payload.(*regcoord.ContractRegistryCoordinatorOperatorSocketUpdate)
if !ok {
return object, ErrIncorrectEvent
}
Expand Down
8 changes: 4 additions & 4 deletions core/indexer/operator_sockets_filterer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"

"github.com/Layr-Labs/eigenda/common"
blsregcoord "github.com/Layr-Labs/eigenda/contracts/bindings/BLSRegistryCoordinatorWithIndices"
eigendasrvmg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDAServiceManager"
regcoord "github.com/Layr-Labs/eigenda/contracts/bindings/RegistryCoordinator"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/indexer"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -51,7 +51,7 @@ func (f *operatorSocketsFilterer) FilterHeaders(headers indexer.Headers) ([]inde
return nil, err
}

filterer, err := blsregcoord.NewContractBLSRegistryCoordinatorWithIndicesFilterer(f.Address, f.Filterer)
filterer, err := regcoord.NewContractRegistryCoordinatorFilterer(f.Address, f.Filterer)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -108,12 +108,12 @@ func (f *operatorSocketsFilterer) FilterFastMode(headers indexer.Headers) (*inde
}

func (f *operatorSocketsFilterer) WatchOperatorSocketUpdate(ctx context.Context, operatorId core.OperatorID) (chan string, error) {
filterer, err := blsregcoord.NewContractBLSRegistryCoordinatorWithIndicesFilterer(f.Address, f.Filterer)
filterer, err := regcoord.NewContractRegistryCoordinatorFilterer(f.Address, f.Filterer)
if err != nil {
return nil, err
}

sink := make(chan *blsregcoord.ContractBLSRegistryCoordinatorWithIndicesOperatorSocketUpdate)
sink := make(chan *regcoord.ContractRegistryCoordinatorOperatorSocketUpdate)
operatorID := []core.OperatorID{operatorId}
_, err = filterer.WatchOperatorSocketUpdate(&bind.WatchOpts{Context: ctx}, sink, operatorID)
if err != nil {
Expand Down
14 changes: 11 additions & 3 deletions core/indexer/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package indexer_test

import (
"context"
"crypto/rand"
"flag"
"fmt"
"math/big"
"os"
"path/filepath"
"time"
Expand All @@ -24,6 +26,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rpc"
)

Expand All @@ -49,12 +52,17 @@ func mustRegisterOperators(env *deploy.Config, logger common.Logger) {
keyPair, err := core.MakeKeyPairFromString(op.NODE_TEST_PRIVATE_BLS)
Expect(err).To(BeNil())

err = tx.RegisterBLSPublicKey(context.Background(), keyPair)
socket := fmt.Sprintf("%v:%v", op.NODE_HOSTNAME, op.NODE_DISPERSAL_PORT)

salt := [32]byte{}
_, err = rand.Read(salt[:])
Expect(err).To(BeNil())

socket := fmt.Sprintf("%v:%v", op.NODE_HOSTNAME, op.NODE_DISPERSAL_PORT)
expiry := big.NewInt(1000)
privKey, err := crypto.GenerateKey()
Expect(err).To(BeNil())

err = tx.RegisterOperator(context.Background(), keyPair.GetPubKeyG1(), socket, quorums)
err = tx.RegisterOperator(context.Background(), keyPair, socket, quorums, privKey, salt, expiry)
Expect(err).To(BeNil())
}
}
Expand Down

0 comments on commit ca28ca1

Please sign in to comment.