Skip to content

Commit

Permalink
adding filtration for state contract
Browse files Browse the repository at this point in the history
  • Loading branch information
olegfomenko committed Mar 28, 2024
1 parent cc43ba6 commit 937bc5e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ evm:

relay:
catchup_disabled: true
issuer_id: [ '', '' ]
disable_filtration: true
source_contract: 0x...
3 changes: 2 additions & 1 deletion internal/config/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
)

type RelayConfig struct {
CatchupDisabled bool `fig:"catchup_disabled"`
CatchupDisabled bool `fig:"catchup_disabled"`
SourceContract string `fig:"source_contract"`
}

func (c *config) Relay() RelayConfig {
Expand Down
19 changes: 13 additions & 6 deletions internal/services/ingester/state_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ import (
)

type stateIngester struct {
log *logan.Entry
rarimocore rarimocore.QueryClient
storage *pg.Storage
log *logan.Entry
rarimocore rarimocore.QueryClient
storage *pg.Storage
sourceContract string
}

var _ Processor = &stateIngester{}

func NewStateIngester(cfg config.Config) Processor {
return &stateIngester{
log: cfg.Log(),
rarimocore: rarimocore.NewQueryClient(cfg.Cosmos()),
storage: pg.New(cfg.DB()),
log: cfg.Log(),
rarimocore: rarimocore.NewQueryClient(cfg.Cosmos()),
storage: pg.New(cfg.DB()),
sourceContract: cfg.Relay().SourceContract,
}
}

Expand Down Expand Up @@ -106,6 +108,11 @@ func (s *stateIngester) trySave(ctx context.Context, operation rarimocore.Operat
})
}

if op.Contract != s.sourceContract {
s.log.WithField("operation_index", operation.Index).Info("Invalid state contract. Skipping")
return nil
}

err = s.storage.StateQ().UpsertCtx(ctx, &data.State{
ID: op.State,
Operation: operation.Index,
Expand Down

0 comments on commit 937bc5e

Please sign in to comment.