Skip to content

Commit

Permalink
adding filtration for state contract
Browse files Browse the repository at this point in the history
olegfomenko committed Mar 28, 2024

Verified

This commit was signed with the committer’s verified signature.
LinuxServer-CI LinuxServer.io CI
1 parent cc43ba6 commit 937bc5e
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
@@ -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
@@ -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 {
19 changes: 13 additions & 6 deletions internal/services/ingester/state_transfer.go
Original file line number Diff line number Diff line change
@@ -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,
}
}

@@ -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,

0 comments on commit 937bc5e

Please sign in to comment.