Skip to content

Commit

Permalink
Merge branch 'master' into startup-config-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x committed Jul 28, 2024
2 parents 7a70d8e + 9332b15 commit 49a34f8
Show file tree
Hide file tree
Showing 50 changed files with 757 additions and 195 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/goreleaser-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'

- uses: docker://ghcr.io/synapsecns/sanguine/git-changes-action:latest
id: filter_go
Expand Down Expand Up @@ -140,8 +139,7 @@ jobs:
- name: Git Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
fetch-depth: ${{ github.ref == 'refs/heads/master' && '0' || '1' }}

- name: Set up cache
if: ${{ !contains(runner.name, 'nsc') }}
Expand Down Expand Up @@ -179,10 +177,12 @@ jobs:

-
name: Fetch all tags
if: steps.branch-name.outputs.is_default == 'true'
run: git fetch --force --tags

# get the tag we just created
- name: Git Fetch Unshallow
if: steps.branch-name.outputs.is_default == 'true'
run: git fetch

- name: Import GPG key
Expand Down
37 changes: 28 additions & 9 deletions contrib/screener-api/screener/screener.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/synapsecns/sanguine/core/metrics"
baseServer "github.com/synapsecns/sanguine/core/server"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"

swaggerfiles "github.com/swaggo/files"
Expand All @@ -40,6 +41,7 @@ import (
const (
okResponse = "OK"
errResponse = "ERROR"
meterName = "github.com/synapsecns/sanguine/contrib/screener-api"
)

// Screener is the interface for the screener.
Expand All @@ -48,15 +50,17 @@ type Screener interface {
}

type screenerImpl struct {
db db.DB
router *gin.Engine
metrics metrics.Handler
cfg config.Config
client chainalysis.Client
whitelist map[string]bool
blacklist map[string]bool
blacklistCacheMux sync.RWMutex
requestMux mapmutex.StringMapMutex
db db.DB
router *gin.Engine
metrics metrics.Handler
cfg config.Config
client chainalysis.Client
whitelist map[string]bool
blacklist map[string]bool
blacklistCacheMux sync.RWMutex
requestMux mapmutex.StringMapMutex
blockedAddressesMetric metric.Int64Counter
unblockedAddressesMetric metric.Int64Counter
}

var logger = log.Logger("screener")
Expand Down Expand Up @@ -93,6 +97,15 @@ func NewScreener(ctx context.Context, cfg config.Config, metricHandler metrics.H
return nil, fmt.Errorf("could not connect to rules db: %w", err)
}

meter := metricHandler.Meter(meterName)
if screener.blockedAddressesMetric, err = meter.Int64Counter("blocked_addresses"); err != nil {
return nil, fmt.Errorf("could not create blocked addresses metric: %w", err)
}

if screener.unblockedAddressesMetric, err = meter.Int64Counter("unblocked_addresses"); err != nil {
return nil, fmt.Errorf("could not create unblocked addresses metric: %w", err)
}

screener.router = ginhelper.New(logger)
screener.router.Use(screener.metrics.Gin()...)

Expand Down Expand Up @@ -235,6 +248,12 @@ func (s *screenerImpl) screenAddress(c *gin.Context) {
return
}

if isAPIBlocked || isDBBlocked {
s.blockedAddressesMetric.Add(ctx, 1)
} else {
s.unblockedAddressesMetric.Add(ctx, 1)
}

c.JSON(http.StatusOK, gin.H{"risk": isAPIBlocked || isDBBlocked})
}

Expand Down
17 changes: 11 additions & 6 deletions ethergo/listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ func NewChainListener(omnirpcClient client.EVM, store listenerDB.ChainListenerDB
option(c)
}

var err error
c.otelRecorder, err = newOtelRecorder(handler, int(c.chainID))
if err != nil {
return nil, fmt.Errorf("could not create otel recorder: %w", err)
}

return c, nil
}

Expand All @@ -99,6 +93,13 @@ func (c *chainListener) Listen(ctx context.Context, handler HandleLog) (err erro
return fmt.Errorf("could not get metadata: %w", err)
}

if c.otelRecorder == nil {
c.otelRecorder, err = newOtelRecorder(c.handler, int(c.chainID))
if err != nil {
return fmt.Errorf("could not create otel recorder: %w", err)
}
}

c.pollInterval = time.Duration(0)

for {
Expand Down Expand Up @@ -151,7 +152,11 @@ func (c *chainListener) doPoll(parentCtx context.Context, handler HandleLog) (er
}

// Check if latest block is the same as start block (for chains with slow block times)
didPoll := true
defer span.SetAttributes(attribute.Bool("did_poll", didPoll))
if c.latestBlock == c.startBlock {
//nolint:ineffassign
didPoll = false
return nil
}

Expand Down
6 changes: 6 additions & 0 deletions packages/explorer-ui/components/ChainChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ export const OverviewChart: React.FC<OverviewChartProps> = ({
stackId="a"
fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#FFEEDA'}
/>
<Bar
isAnimationActive={false}
dataKey="linea"
stackId="a"
fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#000000'}
/>
</>
)}
</BarChart>
Expand Down
1 change: 1 addition & 0 deletions packages/explorer-ui/graphql/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export const DAILY_STATISTICS_BY_CHAIN = gql`
base
blast
scroll
linea
total
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export * as moonbeamImg from './moonbeam.svg'
export * as moonriverImg from './moonriver.svg'
export * as optimismImg from './optimism.svg'
export * as polygonImg from './polygon.svg'
export * as lineaImg from './linea.svg'
3 changes: 3 additions & 0 deletions packages/synapse-constants/constants/assets/chains/linea.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/synapse-constants/constants/assets/explorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export * as moonbeamExplorerImg from './moonbeam.svg'
export * as moonriverExplorerImg from './moonriver.svg'
export * as dogeExplorerImg from './dogechain.svg'
export * as baseExplorerImg from './basescan.svg'
export * as scrollExplorerImg from './scroll.svg'
export * as lineaExplorerImg from './linea.svg'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 49a34f8

Please sign in to comment.