From 352f37620b19ffb457191a93a335ebecdfe459f1 Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Mon, 28 Feb 2022 18:33:02 -0500 Subject: [PATCH 1/3] Explicitly name all subscriptions Signed-off-by: Peter Broadhurst --- internal/blockchain/ethereum/ethereum.go | 3 ++- internal/blockchain/ethereum/eventstream.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/blockchain/ethereum/ethereum.go b/internal/blockchain/ethereum/ethereum.go index 85b070c4b7..c6aab31f50 100644 --- a/internal/blockchain/ethereum/ethereum.go +++ b/internal/blockchain/ethereum/ethereum.go @@ -615,7 +615,8 @@ func (e *Ethereum) AddSubscription(ctx context.Context, subscription *fftypes.Co return i18n.WrapError(ctx, err, i18n.MsgContractParamInvalid) } - result, err := e.streams.createSubscription(ctx, location, e.initInfo.stream.ID, abi) + subName := fmt.Sprintf("ff-sub-%s", subscription.ID) + result, err := e.streams.createSubscription(ctx, location, e.initInfo.stream.ID, subName, abi) if err != nil { return err } diff --git a/internal/blockchain/ethereum/eventstream.go b/internal/blockchain/ethereum/eventstream.go index be3788ec8f..a19b79d787 100644 --- a/internal/blockchain/ethereum/eventstream.go +++ b/internal/blockchain/ethereum/eventstream.go @@ -133,8 +133,9 @@ func (s *streamManager) getSubscriptions(ctx context.Context) (subs []*subscript return subs, nil } -func (s *streamManager) createSubscription(ctx context.Context, location *Location, stream string, abi ABIElementMarshaling) (*subscription, error) { +func (s *streamManager) createSubscription(ctx context.Context, location *Location, stream, subName string, abi ABIElementMarshaling) (*subscription, error) { sub := subscription{ + Name: subName, Stream: stream, FromBlock: "0", Address: location.Address, @@ -189,7 +190,7 @@ func (s *streamManager) ensureSubscription(ctx context.Context, instancePath, st } if sub == nil { - if sub, err = s.createSubscription(ctx, location, stream, abi); err != nil { + if sub, err = s.createSubscription(ctx, location, stream, subName, abi); err != nil { return nil, err } } From 323e6ba9ad8f3bad53651b98dd092c7a05ff7d51 Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Mon, 28 Feb 2022 18:34:56 -0500 Subject: [PATCH 2/3] Remove duplicate code block Signed-off-by: Peter Broadhurst --- internal/contracts/manager.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/internal/contracts/manager.go b/internal/contracts/manager.go index 81fc3eb771..50e6ea1a98 100644 --- a/internal/contracts/manager.go +++ b/internal/contracts/manager.go @@ -496,11 +496,6 @@ func (cm *contractManager) AddContractSubscription(ctx context.Context, ns strin if sub.Name == "" { sub.Name = sub.ProtocolID } - - if sub.Name == "" { - sub.Name = sub.ProtocolID - } - if err = cm.database.UpsertContractSubscription(ctx, &sub.ContractSubscription); err != nil { return nil, err } From 0422b76f0c6298c5e5ac321a2e944eb43f540c92 Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Mon, 28 Feb 2022 18:45:10 -0500 Subject: [PATCH 3/3] Include the topic name in logs Signed-off-by: Peter Broadhurst --- internal/blockchain/ethereum/ethereum.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/blockchain/ethereum/ethereum.go b/internal/blockchain/ethereum/ethereum.go index c6aab31f50..57b4521d84 100644 --- a/internal/blockchain/ethereum/ethereum.go +++ b/internal/blockchain/ethereum/ethereum.go @@ -212,7 +212,7 @@ func (e *Ethereum) Init(ctx context.Context, prefix config.Prefix, callbacks blo if e.initInfo.stream, err = e.streams.ensureEventStream(e.ctx, e.topic, batchSize, batchTimeout); err != nil { return err } - log.L(e.ctx).Infof("Event stream: %s", e.initInfo.stream.ID) + log.L(e.ctx).Infof("Event stream: %s (topic=%s)", e.initInfo.stream.ID, e.topic) if e.initInfo.sub, err = e.streams.ensureSubscription(e.ctx, e.instancePath, e.initInfo.stream.ID, batchPinEventABI); err != nil { return err }