Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FE Release July 17 2 #2886

Merged
merged 9 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions core/metrics/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ const pyroscopeEndpoint = internal.PyroscopeEndpoint
// baseHandler is a base metrics handler that implements the Handler interface.
// this is used to reduce the amount of boilerplate code needed to implement opentracing methods.
type baseHandler struct {
resource *resource.Resource
tp trace.TracerProvider
tracer trace.Tracer
name string
propagator propagation.TextMapPropagator
meter MeterProvider
resource *resource.Resource
// used only for shutdown, use tp for providing traces.
unwrappedTP *tracesdk.TracerProvider
tp trace.TracerProvider
tracer trace.Tracer
name string
propagator propagation.TextMapPropagator
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 @@ -206,16 +208,17 @@ func newBaseHandler(buildInfo config.BuildInfo, extraOpts ...tracesdk.TracerProv
opts := append([]tracesdk.TracerProviderOption{tracesdk.WithResource(rsr)}, extraOpts...)

// TODO: add a way for users to pass in extra pyroscope options
tp := PyroscopeWrapTracerProvider(tracesdk.NewTracerProvider(opts...), buildInfo)
unwrappedTP := tracesdk.NewTracerProvider(opts...)
tp := PyroscopeWrapTracerProvider(unwrappedTP, buildInfo)
// will do nothing if not enabled.
StartPyroscope(buildInfo)

propagator := b3.New(b3.WithInjectEncoding(b3.B3MultipleHeader | b3.B3SingleHeader))
return newBaseHandlerWithTracerProvider(rsr, buildInfo, tp, propagator)
return newBaseHandlerWithTracerProvider(rsr, buildInfo, unwrappedTP, tp, propagator)
}

// newBaseHandlerWithTracerProvider creates a new baseHandler for any opentelemtry tracer.
func newBaseHandlerWithTracerProvider(rsr *resource.Resource, buildInfo config.BuildInfo, tracerProvider trace.TracerProvider, propagator propagation.TextMapPropagator) *baseHandler {
func newBaseHandlerWithTracerProvider(rsr *resource.Resource, buildInfo config.BuildInfo, unwrappedTP *tracesdk.TracerProvider, tracerProvider trace.TracerProvider, propagator propagation.TextMapPropagator) *baseHandler {
// default tracer for server.
otel.SetTracerProvider(tracerProvider)
tracer := tracerProvider.Tracer(buildInfo.Name())
Expand All @@ -237,6 +240,7 @@ func newBaseHandlerWithTracerProvider(rsr *resource.Resource, buildInfo config.B
// note: meter purposely is not registered until startup.
return &baseHandler{
resource: rsr,
unwrappedTP: unwrappedTP,
tp: tracerProvider,
tracer: tracer,
name: buildInfo.Name(),
Expand Down
31 changes: 31 additions & 0 deletions core/metrics/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
tracesdk "go.opentelemetry.io/otel/sdk/trace"
"os"
"strings"
"time"
)

type otlpHandler struct {
Expand Down Expand Up @@ -51,13 +52,43 @@ func (n *otlpHandler) Start(ctx context.Context) (err error) {
return fmt.Errorf("could not start base handler: %w", err)
}

go func() {
handleShutdown(ctx, n.baseHandler.unwrappedTP)
}()

return nil
}

func (n *otlpHandler) Type() HandlerType {
return OTLP
}

// wait for the context to be canceled.
// then flush the traces and shutdown the exporter.
func handleShutdown(ctx context.Context, provider *tracesdk.TracerProvider) {
<-ctx.Done()

const spanWaitTime = time.Millisecond
const shutdownAllowance = time.Second * 10

// allow only 10 seconds for graceful shutdown.
// we use without cancel to copy the parents values while making sure our derived context is not canceled.
shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), shutdownAllowance)
defer cancel()

// don't shutdown immediately, wait for a bit to allow the last spans to be sent. This is in process and should be aymptotic to instant.
time.Sleep(spanWaitTime)

err := provider.ForceFlush(shutdownCtx)
if err != nil {
logger.Warnf("could not flush traces: %v", err)
}
err = provider.Shutdown(shutdownCtx)
if err != nil {
logger.Warnf("could not shutdown traces: %v", err)
}
}

const (
otlpTransportEnv = "OTEL_EXPORTER_OTLP_TRANSPORT"
)
Expand Down
8 changes: 8 additions & 0 deletions packages/contracts-rfq/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.2.12](https://github.com/synapsecns/sanguine/compare/[email protected]@0.2.12) (2024-07-17)

**Note:** Version bump only for package FastBridge





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

**Note:** Version bump only for package FastBridge
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-rfq/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "FastBridge",
"license": "UNLICENSED",
"version": "0.2.11",
"version": "0.2.12",
"description": "FastBridge contracts.",
"private": true,
"files": [
Expand All @@ -11,7 +11,7 @@
"@openzeppelin/contracts": "5.0.1"
},
"devDependencies": {
"@synapsecns/solidity-devops": "^0.4.3",
"@synapsecns/solidity-devops": "^0.4.4",
"prettier": "^2.5.1",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"solhint": "^3.3.6"
Expand Down
11 changes: 11 additions & 0 deletions packages/solidity-devops/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

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


### Bug Fixes

* **solidity-devops:** correctly save new deployments when script entry function is not `run()` ([#2883](https://github.com/synapsecns/sanguine/issues/2883)) ([fd337e9](https://github.com/synapsecns/sanguine/commit/fd337e9f90e4bb721679361d076548d292f1f162))





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

**Note:** Version bump only for package @synapsecns/solidity-devops
Expand Down
6 changes: 5 additions & 1 deletion packages/solidity-devops/js/forgeScriptRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ if (newDeployments.length === 0) {
logInfo('No new deployments found')
process.exit(0)
}
const newReceipts = getNewDeploymentReceipts(chainName, scriptFN)
const newReceipts = getNewDeploymentReceipts(
chainName,
scriptFN,
currentTimestamp
)
newDeployments.forEach((contractAlias) =>
saveNewDeployment(chainName, contractAlias, newReceipts)
)
25 changes: 22 additions & 3 deletions packages/solidity-devops/js/utils/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,30 @@ const getAllDeploymentReceipts = (chainName) => {
})
}

const getNewDeploymentReceipts = (chainName, scriptFN) => {
const getNewDeploymentReceipts = (chainName, scriptFN, timestamp) => {
const chainId = getChainId(chainName)
const scriptBaseName = path.basename(scriptFN)
const broadcastFN = `broadcast/${scriptBaseName}/${chainId}/run-latest.json`
return extractDeploymentReceipts(broadcastFN)
const broadcastDir = path.join('broadcast', scriptBaseName, chainId)
// Silent exit if the broadcast directory does not exist
if (!fs.existsSync(broadcastDir)) {
logError(
`No broadcast directory found for ${scriptBaseName} at ${broadcastDir}`
)
return []
}
// Look for "*-latest.json" files created after the given timestamp.
// These are named after the script entry function, which is usually "run", but could be different.
// In practice there should be only one file, but we implement a generic logic just in case.
return fs
.readdirSync(broadcastDir)
.filter((fn) => {
if (!fn.endsWith('-latest.json')) {
return false
}
const stats = fs.statSync(path.join(broadcastDir, fn))
return stats.mtimeMs > timestamp
})
.flatMap((fn) => extractDeploymentReceipts(path.join(broadcastDir, fn)))
}

const extractDeploymentReceipts = (broadcastFN) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/solidity-devops/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/solidity-devops",
"version": "0.4.3",
"version": "0.4.4",
"description": "A collection of utils to effortlessly test, deploy and maintain the smart contracts on EVM compatible blockchains",
"license": "MIT",
"repository": {
Expand Down
8 changes: 8 additions & 0 deletions packages/synapse-interface/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.28.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-07-17)

**Note:** Version bump only for package @synapsecns/synapse-interface





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

**Note:** Version bump only for package @synapsecns/synapse-interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react'
import Image from 'next/image'
import { Token } from '@/utils/types'
import { getParsedBalance } from '@/utils/getParsedBalance'
import { HoverTooltip } from '../../HoverTooltip'
import { HoverTooltip } from '@/components/HoverTooltip'
import { formatAmount } from '@/utils/formatAmount'
import GasIcon from '@/components/icons/GasIcon'

export const GasTokenAsset = ({
Expand All @@ -13,8 +14,7 @@ export const GasTokenAsset = ({
balance: bigint
}) => {
const { icon, symbol, decimals } = token
const parsedBalance = getParsedBalance(balance, decimals as number, 3)
const parsedBalanceLong = getParsedBalance(balance, decimals as number, 8)
const parsedBalance = getParsedBalance(balance, decimals as number)

return (
<div
Expand All @@ -34,12 +34,12 @@ export const GasTokenAsset = ({
<HoverTooltip
hoverContent={
<div className="whitespace-nowrap">
{parsedBalanceLong} {symbol}
{parsedBalance} {symbol}
</div>
}
>
<div>
{parsedBalance} {symbol}
{formatAmount(parsedBalance)} {symbol}
</div>
</HoverTooltip>
<HoverTooltip
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import Image from 'next/image'
import { TokenAndBalance } from '@/utils/actions/fetchPortfolioBalances'
import { HoverTooltip } from '../../HoverTooltip'
import { HoverTooltip } from '@/components/HoverTooltip'
import { getParsedBalance } from '@/utils/getParsedBalance'
import { formatAmount } from '@/utils/formatAmount'

export const PortfolioTokenVisualizer = ({
portfolioTokens,
portfolioChainId,
}: {
portfolioTokens: TokenAndBalance[]
portfolioChainId: number
}) => {
const hasNoTokens: boolean =
!portfolioTokens || (portfolioTokens && portfolioTokens.length === 0)
Expand All @@ -18,6 +22,15 @@ export const PortfolioTokenVisualizer = ({
const hasOnlyOneToken: boolean =
portfolioTokens && portfolioTokens.length === 1

const firstTokenBalance = getParsedBalance(
portfolioTokens?.[0]?.balance,
portfolioTokens?.[0]?.token?.decimals[portfolioChainId]
)
const secondTokenBalance = getParsedBalance(
portfolioTokens?.[1]?.balance,
portfolioTokens?.[1]?.token?.decimals[portfolioChainId]
)

if (hasNoTokens) {
return (
<div
Expand All @@ -28,6 +41,7 @@ export const PortfolioTokenVisualizer = ({
</div>
)
}

return (
<div
id="portfolio-token-visualizer"
Expand All @@ -38,7 +52,7 @@ export const PortfolioTokenVisualizer = ({
<HoverTooltip
hoverContent={
<div className="whitespace-nowrap">
{portfolioTokens[0]?.parsedBalance}{' '}
{formatAmount(firstTokenBalance)}{' '}
{portfolioTokens[0]?.token.symbol}
</div>
}
Expand All @@ -55,7 +69,7 @@ export const PortfolioTokenVisualizer = ({

{hasOnlyOneToken && (
<div className="text-white whitespace-nowrap">
{portfolioTokens[0].parsedBalance} {portfolioTokens[0].token.symbol}
{formatAmount(firstTokenBalance)} {portfolioTokens[0].token.symbol}
</div>
)}

Expand All @@ -64,7 +78,7 @@ export const PortfolioTokenVisualizer = ({
<HoverTooltip
hoverContent={
<div className="whitespace-nowrap">
{portfolioTokens[1]?.parsedBalance}{' '}
{formatAmount(secondTokenBalance)}{' '}
{portfolioTokens[1]?.token.symbol}
</div>
}
Expand All @@ -86,10 +100,13 @@ export const PortfolioTokenVisualizer = ({
(token: TokenAndBalance, key: number) => {
if (key > 1) {
const tokenSymbol = token.token.symbol
const balance = token.parsedBalance
const parsedBalance = getParsedBalance(
token.balance,
token.token.decimals[portfolioChainId]
)
return (
<div className="whitespace-nowrap" key={key}>
{balance} {tokenSymbol}
{formatAmount(parsedBalance)} {tokenSymbol}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export const SingleNetworkPortfolio = ({
/>
}
collapsedProps={
<PortfolioTokenVisualizer portfolioTokens={sortedTokens} />
<PortfolioTokenVisualizer
portfolioTokens={sortedTokens}
portfolioChainId={portfolioChainId}
/>
}
>
{isUnsupportedChain && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { joinClassNames } from '@/utils/joinClassNames'
import { formatAmount } from '@/utils/formatAmount'

export const AvailableBalance = ({
balance,
Expand Down Expand Up @@ -35,7 +36,7 @@ export const AvailableBalance = ({
return (
<label className={labelClassName} htmlFor="inputRow">
<span className="text-zinc-500 dark:text-zinc-400">Available: </span>
{maxBridgeableBalance?.toFixed(4) ?? balance ?? '0.0'}
{formatAmount(maxBridgeableBalance?.toString()) ?? balance ?? '0.0'}
</label>
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/synapse-interface/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/synapse-interface",
"version": "0.28.4",
"version": "0.28.5",
"private": true,
"engines": {
"node": ">=18.18.0"
Expand Down
4 changes: 3 additions & 1 deletion packages/synapse-interface/public/blacklist.json
Original file line number Diff line number Diff line change
Expand Up @@ -523,5 +523,7 @@
"0x8DB203F0A8a42dDeE2f6a76EE6aA321F84aBb1ef",
"0x5A7834dB0DCEEE1d6Ce756701B039Bc27098A3Ab",
"0xff7009d8310396FebE63C3D253D5a390aaf295F2",
"0x5E670A679E3ae2778D16614E3E54FF9DbF6a5094"
"0x5E670A679E3ae2778D16614E3E54FF9DbF6a5094",
"0x3a378daC2e05D437CA8dCd9C64eA7a3758053cF4",
"0x9e634c91366AfA315e498dA365dD98906754d7d1"
]
Loading