Skip to content

Commit

Permalink
Merge pull request #3296 from synapsecns/master
Browse files Browse the repository at this point in the history
FE Release 2024-10-24
  • Loading branch information
aureliusbtc authored Oct 24, 2024
2 parents 2f1565c + 6595fb4 commit 32c6d32
Show file tree
Hide file tree
Showing 212 changed files with 9,712 additions and 1,166 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- 'packages/contracts-rfq/**'
- '.github/workflows/solidity.yml'
- 'packages/solidity-devops/**'
branches:
# Solidity workflows are irrelevant for the FE release branch
- '!fe-release'
push:
paths:
- 'packages/contracts-core/**'
Expand Down Expand Up @@ -121,7 +124,7 @@ jobs:
cancel_others: 'true'
slither:
name: Slither
if: ${{ needs.changes.outputs.package_count > 0 }}
if: ${{ needs.changes.outputs.package_count > 0 && needs.changes.outputs.packages != '["solidity-devops"]' }}
# see https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/setting-up-code-scanning-for-a-repository
runs-on: ubuntu-latest
needs: changes
Expand Down Expand Up @@ -174,6 +177,7 @@ jobs:
with:
node-version: '${{steps.nvmrc.outputs.NVMRC}}'
target: './packages/${{matrix.package}}'
slither-config: './packages/${{matrix.package}}/slither.config.json'
ignore-compile: true
sarif: results.sarif
solc-version: 0.8.17
Expand Down Expand Up @@ -204,6 +208,9 @@ jobs:
- name: Installing dependencies
run: yarn install --immutable

- name: Install lcov
run: sudo apt-get update && sudo apt-get install -y lcov

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand All @@ -222,6 +229,12 @@ jobs:
env:
FOUNDRY_FUZZ_RUNS: 10

# Some of the packages may want to exclude certain files from the coverage report (legacy code, scripts, tests)
- name: Apply filters to coverage report
if: ${{ matrix.package != 'solidity-devops' }}
working-directory: './packages/${{matrix.package}}'
run: npm run coverage:filter --if-present

- name: Send Coverage (Codecov)
if: ${{ matrix.package != 'solidity-devops' }}
uses: Wandalen/[email protected]
Expand All @@ -239,7 +252,7 @@ jobs:
gas-diff:
runs-on: ubuntu-latest
name: Foundry Gas Diff
if: ${{ needs.changes.outputs.package_count > 0 }}
if: ${{ needs.changes.outputs.package_count > 0 && needs.changes.outputs.packages != '["solidity-devops"]' }}
needs: changes
strategy:
fail-fast: false
Expand Down Expand Up @@ -267,7 +280,9 @@ jobs:
- name: Run tests and generate gas report
working-directory: './packages/${{matrix.package}}'
# Run separate set of tests (no fuzzing) to get accurate average gas cost estimates
run: forge test --mc GasBenchmark --gas-report > "../../gas-report-${{ matrix.package }}.ansi"
# Note: we use `npm run` with `--if-present` flag, allows not to define a gas:bench script in every package
# This is not natively supported by yarn yet, see: https://github.com/yarnpkg/yarn/pull/7159
run: npm run gas:bench --if-present > "../../gas-report-${{ matrix.package }}.ansi"

- name: Compare gas reports
uses: Rubilmax/[email protected]
Expand All @@ -290,7 +305,7 @@ jobs:
size-check:
name: Foundry Size Check
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.package_count > 0 }}
if: ${{ needs.changes.outputs.package_count > 0 && needs.changes.outputs.packages != '["solidity-devops"]' }}
needs: changes
strategy:
fail-fast: false
Expand Down
13 changes: 12 additions & 1 deletion contrib/promexporter/internal/gql/dfk/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions core/ginhelper/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,24 @@ func NewWithExperimentalLogger(ctx context.Context, logger logger.ExperimentalLo
return server
}

// TODO: this is an anti-pattern and needs to be replaced by an option asap.
var CorsEnabled = true

func newBase() *gin.Engine {
server := gin.New()
// required for opentracing.
server.ContextWithFallback = true
server.Use(helmet.Default())

server.Use(gin.Recovery())
server.Use(cors.New(cors.Config{
AllowAllOrigins: true,
AllowHeaders: []string{"*"},
AllowMethods: []string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodPatch, http.MethodDelete, http.MethodOptions},
MaxAge: 12 * time.Hour,
}))
if CorsEnabled {
server.Use(helmet.Default())
server.Use(cors.New(cors.Config{
AllowAllOrigins: true,
AllowHeaders: []string{"*"},
AllowMethods: []string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodPatch, http.MethodDelete, http.MethodOptions},
MaxAge: 12 * time.Hour,
}))
}

// configure the request id
server.Use(requestid.New(
Expand Down
9 changes: 9 additions & 0 deletions core/metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ The metrics endpoint is exposed on `/metrics` on port `8080` by default and is c

**Note: this server failing to bind to `METRICS_PORT` will not cause the application to fail to start. The error will be logged.**

Most metrics come with a `# HELP` explanation that explains them, for example:

```promql
# HELP process_uptime_seconds The uptime of the process in seconds
# TYPE process_uptime_seconds gauge
process_uptime_seconds{otel_scope_name="standard_metrics",otel_scope_version=""} 24.241680459
```

## Logger

Currently, the entire sanguine codebase uses [ipfs go-log]("https://github.com/ipfs/go-log"). As pointed out in [#1521](https://github.com/synapsecns/sanguine/issues/1521), this is not a good long term solution since the logs are not currently appended to opentelemetry, and so new traces require telemtry.
Expand All @@ -80,3 +88,4 @@ Note: because both [ipfs go-log]("https://github.com/ipfs/go-log") and [otelzap
### Using the logger

Since the logger is dependent on the `context` to derive the current span, you need to always use `logger.Ctx(ctx)` or `logger.InfoCtx`. One thing under consideration is removing the non-ctx methods

8 changes: 5 additions & 3 deletions core/metrics/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package metrics
import (
"context"
"fmt"
"net/http"

"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/synapsecns/sanguine/core"
Expand All @@ -30,6 +28,7 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
"gorm.io/gorm"
"net/http"
)

const pyroscopeEndpoint = internal.PyroscopeEndpoint
Expand All @@ -44,7 +43,8 @@ type baseHandler struct {
tracer trace.Tracer
name string
propagator propagation.TextMapPropagator
meter MeterProvider
// Deprecated: will be removed in a future version
meter MeterProvider
// handler is an integrated handler for everything exported over http. This includes prometheus
// or http-based sampling methods for other providers.
handler http.Handler
Expand Down Expand Up @@ -78,6 +78,8 @@ func (b *baseHandler) Start(ctx context.Context) error {
otel.SetMeterProvider(b.meter)
b.handler = promhttp.Handler()

newStandardMetrics(ctx, b)

go func() {
<-ctx.Done()
// shutting down this way will not flush.
Expand Down
41 changes: 41 additions & 0 deletions core/metrics/standard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package metrics

import (
"context"
"go.opentelemetry.io/otel/metric"
"time"
)

// standardMetrics records metrics across any service using the metrics handler.
type standardMetrics struct {
metrics Handler
meter metric.Meter
uptimeGauge metric.Float64ObservableGauge
startTime time.Time
}

const processUptimeSecondsMetric = "process_uptime_seconds"

func newStandardMetrics(ctx context.Context, handler Handler) {
str := standardMetrics{
metrics: handler,
meter: handler.Meter("standard_metrics"),
startTime: time.Now(),
}

var err error
if str.uptimeGauge, err = str.meter.Float64ObservableGauge(processUptimeSecondsMetric, metric.WithDescription("The uptime of the process in seconds"), metric.WithUnit("seconds")); err != nil {
handler.ExperimentalLogger().Errorf(ctx, "failed to create %s gauge: %v", processUptimeSecondsMetric, err)
}

// Register callback
if _, err = str.meter.RegisterCallback(str.uptimeCallback, str.uptimeGauge); err != nil {
handler.ExperimentalLogger().Warnf(ctx, "failed to register callback: %v", err)
}
}

func (str *standardMetrics) uptimeCallback(_ context.Context, observer metric.Observer) error {
uptimeDuration := time.Since(str.startTime).Seconds()
observer.ObserveFloat64(str.uptimeGauge, uptimeDuration)
return nil
}
78 changes: 78 additions & 0 deletions docs/bridge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,84 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.4.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-21)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.4.4](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-15)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.4.3](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-15)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.4.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-12)


### Bug Fixes

* **docs:** Fixes gh link ([#3280](https://github.com/synapsecns/sanguine/issues/3280)) ([f1dfc82](https://github.com/synapsecns/sanguine/commit/f1dfc82bc26d60262a92feda671d44a6d54a3ce1))





## [0.4.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-12)

**Note:** Version bump only for package @synapsecns/bridge-docs





# [0.4.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-10)


### Features

* **synapse-constants:** adds preinstall step ([#3269](https://github.com/synapsecns/sanguine/issues/3269)) ([acd61de](https://github.com/synapsecns/sanguine/commit/acd61de4846d9b23d7aa834b8f2eefcaae486c7d))





## [0.3.11](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-10)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.3.10](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-08)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.3.9](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-08)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.3.8](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-07)

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
15 changes: 12 additions & 3 deletions docs/bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,35 @@ This website is built using [Docusaurus](https://docusaurus.io/), a modern stati
## Generating API Docs

<!--TODO: needs to be done from ci to ensure regenration is done.-->

`yarn docusaurus gen-api-docs all`.

### Installation

```
```bash
$ yarn
```

### Local Development

```
```bash
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
```bash
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Serve

This step is needed to create a searchable index.

```bash
$ yarn serve
```
Loading

0 comments on commit 32c6d32

Please sign in to comment.