Skip to content

Commit

Permalink
Merge branch 'master' of github.com:synapsecns/sanguine into opbot-mi…
Browse files Browse the repository at this point in the history
…gration
  • Loading branch information
golangisfun123 committed Oct 21, 2024
2 parents 7835278 + 112a9ab commit 6c7c8f2
Show file tree
Hide file tree
Showing 105 changed files with 4,437 additions and 392 deletions.
13 changes: 13 additions & 0 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 @@ -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 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
}
8 changes: 8 additions & 0 deletions docs/bridge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
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
Expand Down
4 changes: 2 additions & 2 deletions docs/bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/bridge-docs",
"version": "0.4.4",
"version": "0.4.5",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down Expand Up @@ -34,7 +34,7 @@
"@docusaurus/utils-validation": "3.5.2",
"@easyops-cn/docusaurus-search-local": "^0.44.5",
"@mdx-js/react": "^3.0.0",
"@synapsecns/synapse-constants": "^1.7.0",
"@synapsecns/synapse-constants": "^1.8.0",
"clsx": "^2.0.0",
"docusaurus-plugin-openapi-docs": "^4.0.1",
"docusaurus-theme-openapi-docs": "^4.0.1",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"nohoist": [
"**/typechain",
"**/@typechain/*",
"**/@openzeppelin/contracts-upgradeable",
"**/@openzeppelin/contracts",
"**/@openzeppelin/*",
"**/@synapsecns/solidity-devops",
"**/ds-test",
"**/forge-std"
Expand Down
1 change: 1 addition & 0 deletions packages/contracts-rfq/.solhintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
contracts/FastBridge.sol
contracts/interfaces/IFastBridge.sol
contracts/legacy/**/*.sol
script/FastBridge.s.sol
test/FastBridge.t.sol
test/FastBridgeMock.sol
28 changes: 28 additions & 0 deletions packages/contracts-rfq/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

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

**Note:** Version bump only for package @synapsecns/contracts-rfq





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


### Features

* **contracts-rfq:** add version to `BridgeTransaction`, tight packing [SLT-328] [SLT-273] ([#3284](https://github.com/synapsecns/sanguine/issues/3284)) ([a0d8a39](https://github.com/synapsecns/sanguine/commit/a0d8a39013b1ae332a80a2a624b99b0e7bb50722))
* **contracts-rfq:** FastBridge v1 multicall [SLT-324] ([#3313](https://github.com/synapsecns/sanguine/issues/3313)) ([bd6bd2d](https://github.com/synapsecns/sanguine/commit/bd6bd2db4be4b2a8b43357f0293bceaef294039d))





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

**Note:** Version bump only for package @synapsecns/contracts-rfq





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

**Note:** Version bump only for package @synapsecns/contracts-rfq
Expand Down
4 changes: 3 additions & 1 deletion packages/contracts-rfq/contracts/FastBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {UniversalTokenLib} from "./libs/UniversalToken.sol";
import {Admin} from "./Admin.sol";
import {IFastBridge} from "./interfaces/IFastBridge.sol";

contract FastBridge is IFastBridge, Admin {
import {MulticallTarget} from "./utils/MulticallTarget.sol";

contract FastBridge is IFastBridge, MulticallTarget, Admin {
using SafeERC20 for IERC20;
using UniversalTokenLib for address;

Expand Down
Loading

0 comments on commit 6c7c8f2

Please sign in to comment.