Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dedupe commitee listener #2382

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions committee/db/base/block.go

This file was deleted.

6 changes: 0 additions & 6 deletions committee/db/base/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ import "github.com/synapsecns/sanguine/core/dbcommon"

func init() {
namer := dbcommon.NewNamer(GetAllModels())
chainIDFieldName = namer.GetConsistentName("ChainID")
blockNumberFieldName = namer.GetConsistentName("BlockNumber")
transactionIDFieldName = namer.GetConsistentName("TransactionID")
statusFieldName = namer.GetConsistentName("Status")
}

var (
// chainIDFieldName gets the chain id field name.
chainIDFieldName string
// blockNumberFieldName is the name of the block number field.
blockNumberFieldName string
// transactionIDFieldName is the name of the transaction field.
transactionIDFieldName string
// statusIDFieldName is the name of the status field.
Expand Down
10 changes: 7 additions & 3 deletions committee/db/base/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import (
"github.com/synapsecns/sanguine/committee/db/mysql/util"
"github.com/synapsecns/sanguine/core/dbcommon"
"github.com/synapsecns/sanguine/core/metrics"
listenerDB "github.com/synapsecns/sanguine/ethergo/listener/db"
submitterDB "github.com/synapsecns/sanguine/ethergo/submitter/db"
"github.com/synapsecns/sanguine/ethergo/submitter/db/txdb"
"gorm.io/gorm"
)

// Store implements the service.
type Store struct {
listenerDB.ChainListenerDB
db *gorm.DB
submitterStore submitterDB.Service
}
Expand All @@ -26,8 +28,9 @@ func NewStore(db *gorm.DB, metrics metrics.Handler) *Store {
txDB := txdb.NewTXStore(db, metrics)

return &Store{
db: db,
submitterStore: txDB,
ChainListenerDB: listenerDB.NewChainListenerStore(db, metrics),
db: db,
submitterStore: txDB,
}
}

Expand Down Expand Up @@ -91,7 +94,8 @@ func (s Store) makeDatastore(name string) (datastore.Batching, error) {
// GetAllModels gets all models to migrate
// see: https://medium.com/@SaifAbid/slice-interfaces-8c78f8b6345d for an explanation of why we can't do this at initialization time
func GetAllModels() (allModels []interface{}) {
allModels = append(txdb.GetAllModels(), &LastIndexed{}, &VerificationRequest{})
allModels = append(txdb.GetAllModels(), &VerificationRequest{})
allModels = append(allModels, listenerDB.GetAllModels()...)
return allModels
}

Expand Down
2 changes: 1 addition & 1 deletion committee/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ require (
github.com/ipfs/go-ds-sql v0.3.0
github.com/ipfs/go-log v1.0.5
github.com/ipfs/go-log/v2 v2.5.1
github.com/jpillora/backoff v1.0.0
github.com/libp2p/go-libp2p v0.33.0
github.com/libp2p/go-libp2p-kad-dht v0.25.2
github.com/libp2p/go-libp2p-pubsub v0.10.0
Expand Down Expand Up @@ -212,6 +211,7 @@ require (
github.com/jftuga/ellipsis v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.6 // indirect
Expand Down
2 changes: 0 additions & 2 deletions committee/listener/doc.go

This file was deleted.

218 changes: 0 additions & 218 deletions committee/listener/listener.go

This file was deleted.

9 changes: 7 additions & 2 deletions committee/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"github.com/synapsecns/sanguine/committee/contracts/synapsemodule"
"github.com/synapsecns/sanguine/committee/db"
"github.com/synapsecns/sanguine/committee/db/connect"
"github.com/synapsecns/sanguine/committee/listener"
"github.com/synapsecns/sanguine/committee/p2p"
"github.com/synapsecns/sanguine/core/dbcommon"
"github.com/synapsecns/sanguine/core/metrics"
"github.com/synapsecns/sanguine/ethergo/listener"
signerConfig "github.com/synapsecns/sanguine/ethergo/signer/config"
"github.com/synapsecns/sanguine/ethergo/signer/signer"
"github.com/synapsecns/sanguine/ethergo/submitter"
Expand Down Expand Up @@ -75,7 +75,12 @@
return nil, fmt.Errorf("could not get chain client: %w", err)
}

chainListener, err := listener.NewChainListener(chainClient, node.db, synapseModule, handler)
latestBlock, err := chainClient.BlockNumber(ctx)
if err != nil {
return nil, fmt.Errorf("could not get block number: %w", err)
}

Check warning on line 81 in committee/node/node.go

View check run for this annotation

Codecov / codecov/patch

committee/node/node.go#L80-L81

Added lines #L80 - L81 were not covered by tests

chainListener, err := listener.NewChainListener(chainClient, node.db, synapseModule, latestBlock, handler)
if err != nil {
return nil, fmt.Errorf("could not get chain listener: %w", err)
}
Expand Down
Loading