Skip to content

Commit

Permalink
Update usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mooselumph committed Oct 23, 2024
1 parent 8b9d015 commit dd7d9c5
Show file tree
Hide file tree
Showing 30 changed files with 61 additions and 60 deletions.
4 changes: 2 additions & 2 deletions disperser/apiserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type DispersalServer struct {
rateConfig RateConfig

blobStore disperser.BlobStore
tx core.Transactor
tx core.Reader
quorumConfig QuorumConfig

ratelimiter common.RateLimiter
Expand All @@ -65,7 +65,7 @@ type QuorumConfig struct {
func NewDispersalServer(
serverConfig disperser.ServerConfig,
store disperser.BlobStore,
tx core.Transactor,
tx core.Reader,
_logger logging.Logger,
metrics *disperser.Metrics,
ratelimiter common.RateLimiter,
Expand Down
6 changes: 3 additions & 3 deletions disperser/apiserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestDisperseBlobAuthTimeout(t *testing.T) {

func TestDisperseBlobWithRequiredQuorums(t *testing.T) {

transactor := &mock.MockTransactor{}
transactor := &mock.MockWriter{}
transactor.On("GetCurrentBlockNumber").Return(uint32(100), nil)
transactor.On("GetQuorumCount").Return(uint8(2), nil)
quorumParams := []core.SecurityParam{
Expand Down Expand Up @@ -595,7 +595,7 @@ func setup() {
panic("failed to deploy AWS resources")
}

transactor := &mock.MockTransactor{}
transactor := &mock.MockWriter{}
transactor.On("GetCurrentBlockNumber").Return(uint32(100), nil)
transactor.On("GetQuorumCount").Return(uint8(2), nil)
quorumParams := []core.SecurityParam{
Expand All @@ -618,7 +618,7 @@ func teardown() {
}
}

func newTestServer(transactor core.Transactor) *apiserver.DispersalServer {
func newTestServer(transactor core.Writer) *apiserver.DispersalServer {
logger := logging.NewNoopLogger()

bucketName := "test-eigenda-blobstore"
Expand Down
4 changes: 2 additions & 2 deletions disperser/batcher/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type Batcher struct {
AssignmentCoordinator core.AssignmentCoordinator
Aggregator core.SignatureAggregator
EncodingStreamer *EncodingStreamer
Transactor core.Transactor
Transactor core.Writer
TransactionManager TxnManager
Metrics *Metrics
HeartbeatChan chan time.Time
Expand All @@ -99,7 +99,7 @@ func NewBatcher(
aggregator core.SignatureAggregator,
ethClient common.EthClient,
finalizer Finalizer,
transactor core.Transactor,
transactor core.Writer,
txnManager TxnManager,
logger logging.Logger,
metrics *Metrics,
Expand Down
4 changes: 2 additions & 2 deletions disperser/batcher/batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (
)

type batcherComponents struct {
transactor *coremock.MockTransactor
transactor *coremock.MockWriter
txnManager *batchermock.MockTxnManager
blobStore *inmem.BlobStore
encoderClient *disperser.LocalEncoderClient
Expand Down Expand Up @@ -90,7 +90,7 @@ func makeBatcher(t *testing.T) (*batcherComponents, *bat.Batcher, func() []time.
assert.NoError(t, err)
cst.On("GetCurrentBlockNumber").Return(uint(10)+finalizationBlockDelay, nil)
asgn := &core.StdAssignmentCoordinator{}
transactor := &coremock.MockTransactor{}
transactor := &coremock.MockWriter{}
transactor.On("OperatorIDToAddress").Return(gethcommon.Address{}, nil)
agg, err := core.NewStdSignatureAggregator(logger, transactor)
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion disperser/cmd/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func RunDisperserServer(ctx *cli.Context) error {
return err
}

transactor, err := eth.NewTransactor(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
transactor, err := eth.NewReader(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion disperser/cmd/batcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func RunBatcher(ctx *cli.Context) error {
if err != nil {
return err
}
tx, err := coreeth.NewTransactor(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
tx, err := coreeth.NewWriter(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion disperser/cmd/dataapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func RunDataApi(ctx *cli.Context) error {
return err
}

tx, err := coreeth.NewTransactor(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
tx, err := coreeth.NewReader(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions disperser/dataapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ type (
blobstore disperser.BlobStore
promClient PrometheusClient
subgraphClient SubgraphClient
transactor core.Transactor
transactor core.Reader
chainState core.ChainState
indexedChainState core.IndexedChainState

Expand All @@ -212,7 +212,7 @@ func NewServer(
blobstore disperser.BlobStore,
promClient PrometheusClient,
subgraphClient SubgraphClient,
transactor core.Transactor,
transactor core.Reader,
chainState core.ChainState,
indexedChainState core.IndexedChainState,
logger logging.Logger,
Expand Down
2 changes: 1 addition & 1 deletion disperser/dataapi/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (

config = dataapi.Config{ServerMode: "test", SocketAddr: ":8080", AllowOrigins: []string{"*"}, DisperserHostname: "localhost:32007", ChurnerHostname: "localhost:32009"}

mockTx = &coremock.MockTransactor{}
mockTx = &coremock.MockWriter{}
metrics = dataapi.NewMetrics(nil, "9001", mockLogger)
opId0, _ = core.OperatorIDFromHex("e22dae12a0074f20b8fc96a0489376db34075e545ef60c4845d264a732568311")
opId1, _ = core.OperatorIDFromHex("e23cae12a0074f20b8fc96a0489376db34075e545ef60c4845d264b732568312")
Expand Down
2 changes: 1 addition & 1 deletion inabox/tests/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func setupRetrievalClient(testConfig *deploy.Config) error {
if err != nil {
log.Fatalln("could not start tcp listener", err)
}
tx, err := eth.NewTransactor(logger, client, testConfig.Retriever.RETRIEVER_BLS_OPERATOR_STATE_RETRIVER, testConfig.Retriever.RETRIEVER_EIGENDA_SERVICE_MANAGER)
tx, err := eth.NewWriter(logger, client, testConfig.Retriever.RETRIEVER_BLS_OPERATOR_STATE_RETRIVER, testConfig.Retriever.RETRIEVER_EIGENDA_SERVICE_MANAGER)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion node/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func newTestServerWithConfig(t *testing.T, mockValidator bool, config *node.Conf
}
noopMetrics := metrics.NewNoopMetrics()
reg := prometheus.NewRegistry()
tx := &coremock.MockTransactor{}
tx := &coremock.MockWriter{}

ratelimiter := &commonmock.NoopRatelimiter{}

Expand Down
2 changes: 1 addition & 1 deletion node/grpc/server_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func newTestServerV2WithConfig(t *testing.T, mockValidator bool, config *node.Co
}
noopMetrics := metrics.NewNoopMetrics()
reg := prometheus.NewRegistry()
tx := &coremock.MockTransactor{}
tx := &coremock.MockWriter{}

ratelimiter := &commonmock.NoopRatelimiter{}

Expand Down
4 changes: 2 additions & 2 deletions node/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ type Metrics struct {
socketAddr string
operatorId core.OperatorID
onchainMetricsInterval int64
tx core.Transactor
tx core.Reader
chainState core.ChainState
allQuorumCache map[core.QuorumID]bool
}

func NewMetrics(eigenMetrics eigenmetrics.Metrics, reg *prometheus.Registry, logger logging.Logger, socketAddr string, operatorId core.OperatorID, onchainMetricsInterval int64, tx core.Transactor, chainState core.ChainState) *Metrics {
func NewMetrics(eigenMetrics eigenmetrics.Metrics, reg *prometheus.Registry, logger logging.Logger, socketAddr string, operatorId core.OperatorID, onchainMetricsInterval int64, tx core.Reader, chainState core.ChainState) *Metrics {

// Add Go module collectors
reg.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type Node struct {
Store *Store
ChainState core.ChainState
Validator core.ShardValidator
Transactor core.Transactor
Transactor core.Writer
PubIPProvider pubip.Provider
OperatorSocketsFilterer indexer.OperatorSocketsFilterer
ChainID *big.Int
Expand Down Expand Up @@ -106,7 +106,7 @@ func NewNode(reg *prometheus.Registry, config *Config, pubIPProvider pubip.Provi
}

// Create Transactor
tx, err := eth.NewTransactor(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
tx, err := eth.NewWriter(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var opID = [32]byte{}

type components struct {
node *node.Node
tx *coremock.MockTransactor
tx *coremock.MockWriter
}

func newComponents(t *testing.T) *components {
Expand Down Expand Up @@ -53,7 +53,7 @@ func newComponents(t *testing.T) *components {
if err != nil {
panic("failed to create a directory for db")
}
tx := &coremock.MockTransactor{}
tx := &coremock.MockWriter{}

mockVal := coremock.NewMockShardValidator()
mockVal.On("ValidateBatch", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down
8 changes: 4 additions & 4 deletions node/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Operator struct {
}

// RegisterOperator operator registers the operator with the given public key for the given quorum IDs.
func RegisterOperator(ctx context.Context, operator *Operator, transactor core.Transactor, churnerClient ChurnerClient, logger logging.Logger) error {
func RegisterOperator(ctx context.Context, operator *Operator, transactor core.Writer, churnerClient ChurnerClient, logger logging.Logger) error {
if len(operator.QuorumIDs) > 1+core.MaxQuorumID {
return fmt.Errorf("cannot provide more than %d quorums", 1+core.MaxQuorumID)
}
Expand Down Expand Up @@ -94,7 +94,7 @@ func RegisterOperator(ctx context.Context, operator *Operator, transactor core.T

// DeregisterOperator deregisters the operator with the given public key from the specified quorums that it is registered with at the supplied block number.
// If the operator isn't registered with any of the specified quorums, this function will return error, and no quorum will be deregistered.
func DeregisterOperator(ctx context.Context, operator *Operator, KeyPair *core.KeyPair, transactor core.Transactor) error {
func DeregisterOperator(ctx context.Context, operator *Operator, KeyPair *core.KeyPair, transactor core.Writer) error {
if len(operator.QuorumIDs) > 1+core.MaxQuorumID {
return fmt.Errorf("cannot provide more than %d quorums", 1+core.MaxQuorumID)
}
Expand All @@ -106,12 +106,12 @@ func DeregisterOperator(ctx context.Context, operator *Operator, KeyPair *core.K
}

// UpdateOperatorSocket updates the socket for the given operator
func UpdateOperatorSocket(ctx context.Context, transactor core.Transactor, socket string) error {
func UpdateOperatorSocket(ctx context.Context, transactor core.Writer, socket string) error {
return transactor.UpdateOperatorSocket(ctx, socket)
}

// getQuorumIdsToRegister returns the quorum ids that the operator is not registered in.
func (c *Operator) getQuorumIdsToRegister(ctx context.Context, transactor core.Transactor) ([]core.QuorumID, error) {
func (c *Operator) getQuorumIdsToRegister(ctx context.Context, transactor core.Writer) ([]core.QuorumID, error) {
if len(c.QuorumIDs) == 0 {
return nil, fmt.Errorf("an operator should be in at least one quorum to be useful")
}
Expand Down
6 changes: 3 additions & 3 deletions node/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func TestRegisterOperator(t *testing.T) {
QuorumIDs: []core.QuorumID{0, 1},
RegisterNodeAtStart: false,
}
createMockTx := func(quorumIDs []uint8) *coremock.MockTransactor {
tx := &coremock.MockTransactor{}
createMockTx := func(quorumIDs []uint8) *coremock.MockWriter {
tx := &coremock.MockWriter{}
tx.On("GetRegisteredQuorumIdsForOperator").Return(quorumIDs, nil)
tx.On("GetOperatorSetParams", mock.Anything, mock.Anything).Return(&core.OperatorSetParam{
MaxOperatorCount: 1,
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestRegisterOperatorWithChurn(t *testing.T) {
OperatorId: operatorID,
QuorumIDs: []core.QuorumID{1},
}
tx := &coremock.MockTransactor{}
tx := &coremock.MockWriter{}
tx.On("GetRegisteredQuorumIdsForOperator").Return([]uint8{2}, nil)
tx.On("GetOperatorSetParams", mock.Anything, mock.Anything).Return(&core.OperatorSetParam{
MaxOperatorCount: 1,
Expand Down
2 changes: 1 addition & 1 deletion node/plugin/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func pluginOps(ctx *cli.Context) {
}
log.Printf("Info: ethclient created for url: %s", config.ChainRpcUrl)

tx, err := eth.NewTransactor(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
tx, err := eth.NewWriter(logger, client, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
if err != nil {
log.Printf("Error: failed to create EigenDA transactor: %v", err)
return
Expand Down
6 changes: 3 additions & 3 deletions node/plugin/tests/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func getOperatorId(t *testing.T, operator deploy.OperatorVars) [32]byte {
assert.NoError(t, err)
assert.NotNil(t, client)

transactor, err := eth.NewTransactor(logger, client, operator.NODE_BLS_OPERATOR_STATE_RETRIVER, operator.NODE_EIGENDA_SERVICE_MANAGER)
transactor, err := eth.NewWriter(logger, client, operator.NODE_BLS_OPERATOR_STATE_RETRIVER, operator.NODE_EIGENDA_SERVICE_MANAGER)
assert.NoError(t, err)
assert.NotNil(t, transactor)

Expand All @@ -214,7 +214,7 @@ func getOperatorId(t *testing.T, operator deploy.OperatorVars) [32]byte {
return keyPair.GetPubKeyG1().GetOperatorID()
}

func getTransactor(t *testing.T, operator deploy.OperatorVars) *eth.Transactor {
func getTransactor(t *testing.T, operator deploy.OperatorVars) *eth.Writer {
hexPk := strings.TrimPrefix(testConfig.Pks.EcdsaMap[testConfig.Deployers[0].Name].PrivateKey, "0x")
loggerConfig := common.DefaultLoggerConfig()
logger, err := common.NewLogger(loggerConfig)
Expand All @@ -230,7 +230,7 @@ func getTransactor(t *testing.T, operator deploy.OperatorVars) *eth.Transactor {
assert.NoError(t, err)
assert.NotNil(t, client)

transactor, err := eth.NewTransactor(logger, client, operator.NODE_BLS_OPERATOR_STATE_RETRIVER, operator.NODE_EIGENDA_SERVICE_MANAGER)
transactor, err := eth.NewWriter(logger, client, operator.NODE_BLS_OPERATOR_STATE_RETRIVER, operator.NODE_EIGENDA_SERVICE_MANAGER)
assert.NoError(t, err)
assert.NotNil(t, transactor)

Expand Down
2 changes: 1 addition & 1 deletion node/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func createStore(t *testing.T) *node.Store {
reg := prometheus.NewRegistry()
logger := logging.NewNoopLogger()
operatorId := [32]byte(hexutil.MustDecode("0x3fbfefcdc76462d2cdb7d0cea75f27223829481b8b4aa6881c94cb2126a316ad"))
tx := &coremock.MockTransactor{}
tx := &coremock.MockWriter{}
dat, _ := mock.MakeChainDataMock(map[uint8]int{
0: 6,
1: 3,
Expand Down
4 changes: 2 additions & 2 deletions operators/churner/churner.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type ChurnResponse struct {
type churner struct {
mu sync.Mutex
Indexer thegraph.IndexedChainState
Transactor core.Transactor
Transactor core.Writer
QuorumCount uint8

privateKey *ecdsa.PrivateKey
Expand All @@ -58,7 +58,7 @@ type churner struct {
func NewChurner(
config *Config,
indexer thegraph.IndexedChainState,
transactor core.Transactor,
transactor core.Writer,
logger logging.Logger,
metrics *Metrics,
) (*churner, error) {
Expand Down
2 changes: 1 addition & 1 deletion operators/churner/churner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

func TestProcessChurnRequest(t *testing.T) {
setupMockTransactor()
setupMockWriter()
mockIndexer := &indexermock.MockIndexedChainState{}
config := &churner.Config{
LoggerConfig: common.DefaultLoggerConfig(),
Expand Down
2 changes: 1 addition & 1 deletion operators/churner/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func run(ctx *cli.Context) error {
log.Fatalln("could not start tcp listener", err)
}

tx, err := eth.NewTransactor(logger, gethClient, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
tx, err := eth.NewWriter(logger, gethClient, config.BLSOperatorStateRetrieverAddr, config.EigenDAServiceManagerAddr)
if err != nil {
log.Fatalln("could not create new transactor", err)
}
Expand Down
6 changes: 3 additions & 3 deletions operators/churner/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
keyPair *dacore.KeyPair
quorumIds = []uint32{0, 1}
logger = logging.NewNoopLogger()
transactorMock = &coremock.MockTransactor{}
transactorMock = &coremock.MockWriter{}
mockIndexer = &indexermock.MockIndexedChainState{}
operatorAddr = gethcommon.HexToAddress("0x0000000000000000000000000000000000000001")
operatorToChurnInPrivateKeyHex = "0000000000000000000000000000000000000000000000000000000000000020"
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestChurnWithInvalidQuorum(t *testing.T) {
assert.Equal(t, err.Error(), "rpc error: code = InvalidArgument desc = invalid request: invalid request: the quorum_id must be in range [0, 1], but found 2")
}

func setupMockTransactor() {
func setupMockWriter() {
transactorMock.On("StakeRegistry").Return(gethcommon.HexToAddress("0x0000000000000000000000000000000000000001"), nil).Once()
transactorMock.On("OperatorIDToAddress").Return(operatorAddr, nil)
transactorMock.On("GetCurrentQuorumBitmapByOperatorId").Return(big.NewInt(0), nil)
Expand Down Expand Up @@ -179,7 +179,7 @@ func newTestServer(t *testing.T) *churner.Server {
t.Fatalf("Generating random BLS keys Error: %s", err.Error())
}

setupMockTransactor()
setupMockWriter()

metrics := churner.NewMetrics("9001", logger)
cn, err := churner.NewChurner(config, mockIndexer, transactorMock, logger, metrics)
Expand Down
Loading

0 comments on commit dd7d9c5

Please sign in to comment.