From 8331a12dd0941d51e13d3fb203b0d52e2deba171 Mon Sep 17 00:00:00 2001 From: Trajan0x Date: Wed, 17 Jul 2024 13:34:33 -0400 Subject: [PATCH 1/8] update bl [ci skip] --- packages/synapse-interface/public/blacklist.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/synapse-interface/public/blacklist.json b/packages/synapse-interface/public/blacklist.json index 1e1952d56a..594000ff72 100644 --- a/packages/synapse-interface/public/blacklist.json +++ b/packages/synapse-interface/public/blacklist.json @@ -523,5 +523,7 @@ "0x8DB203F0A8a42dDeE2f6a76EE6aA321F84aBb1ef", "0x5A7834dB0DCEEE1d6Ce756701B039Bc27098A3Ab", "0xff7009d8310396FebE63C3D253D5a390aaf295F2", - "0x5E670A679E3ae2778D16614E3E54FF9DbF6a5094" + "0x5E670A679E3ae2778D16614E3E54FF9DbF6a5094", + "0x3a378daC2e05D437CA8dCd9C64eA7a3758053cF4", + "0x9e634c91366AfA315e498dA365dD98906754d7d1" ] From 67e255fe85b2d5f1e33cfe30d6a4122e7d057b4d Mon Sep 17 00:00:00 2001 From: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:52:52 -0700 Subject: [PATCH 2/8] chore(synapse-interface): format portfolio balances (#2832) * Format dust amounts in Portfolio * Format available gas balance * Format gas token balance * Remove log --------- Co-authored-by: abtestingalpha --- .../Portfolio/components/GasTokenAsset.tsx | 10 +++---- .../components/PortfolioTokenVisualizer.tsx | 29 +++++++++++++++---- .../components/SingleNetworkPortfolio.tsx | 5 +++- .../StateManagedBridge/AvailableBalance.tsx | 3 +- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx b/packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx index cae8ccb317..43c327f3fe 100644 --- a/packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx +++ b/packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx @@ -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 = ({ @@ -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 (
- {parsedBalanceLong} {symbol} + {parsedBalance} {symbol}
} >
- {parsedBalance} {symbol} + {formatAmount(parsedBalance)} {symbol}
{ const hasNoTokens: boolean = !portfolioTokens || (portfolioTokens && portfolioTokens.length === 0) @@ -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 (
) } + return (
- {portfolioTokens[0]?.parsedBalance}{' '} + {formatAmount(firstTokenBalance)}{' '} {portfolioTokens[0]?.token.symbol}
} @@ -55,7 +69,7 @@ export const PortfolioTokenVisualizer = ({ {hasOnlyOneToken && (
- {portfolioTokens[0].parsedBalance} {portfolioTokens[0].token.symbol} + {formatAmount(firstTokenBalance)} {portfolioTokens[0].token.symbol}
)} @@ -64,7 +78,7 @@ export const PortfolioTokenVisualizer = ({ - {portfolioTokens[1]?.parsedBalance}{' '} + {formatAmount(secondTokenBalance)}{' '} {portfolioTokens[1]?.token.symbol}
} @@ -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 (
- {balance} {tokenSymbol} + {formatAmount(parsedBalance)} {tokenSymbol}
) } diff --git a/packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx b/packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx index 392edc169e..eba363e7d7 100644 --- a/packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx +++ b/packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx @@ -87,7 +87,10 @@ export const SingleNetworkPortfolio = ({ /> } collapsedProps={ - + } > {isUnsupportedChain && ( diff --git a/packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx b/packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx index da1ee49204..6b5faf50b3 100644 --- a/packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx +++ b/packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx @@ -1,5 +1,6 @@ import React from 'react' import { joinClassNames } from '@/utils/joinClassNames' +import { formatAmount } from '@/utils/formatAmount' export const AvailableBalance = ({ balance, @@ -35,7 +36,7 @@ export const AvailableBalance = ({ return ( ) } From d1328bb0a1cc8125197fec49422b0249030329fa Mon Sep 17 00:00:00 2001 From: Trajan0x Date: Wed, 17 Jul 2024 13:53:09 -0400 Subject: [PATCH 3/8] flush --- core/metrics/base.go | 22 +++++++++++++--------- core/metrics/otlp.go | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/core/metrics/base.go b/core/metrics/base.go index 38f01be5bd..e69c674e2d 100644 --- a/core/metrics/base.go +++ b/core/metrics/base.go @@ -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 @@ -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()) @@ -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(), diff --git a/core/metrics/otlp.go b/core/metrics/otlp.go index a55bd8a4ad..9db1c57a68 100644 --- a/core/metrics/otlp.go +++ b/core/metrics/otlp.go @@ -11,6 +11,7 @@ import ( tracesdk "go.opentelemetry.io/otel/sdk/trace" "os" "strings" + "time" ) type otlpHandler struct { @@ -51,6 +52,10 @@ 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 } @@ -58,6 +63,28 @@ 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 shutdownAllowance = time.Second * 10 + + // allow only 10 seconds for graceful shutdown. + // we use without cancel to copy the parents values while making sure are derived context is not canceled. + shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), shutdownAllowance) + defer cancel() + + 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" ) From 80b8e29370725b78fb1e02a64cb00abd63982c0d Mon Sep 17 00:00:00 2001 From: Trajan0x Date: Wed, 17 Jul 2024 13:55:57 -0400 Subject: [PATCH 4/8] [goreleaser] fix https://github.com/synapsecns/sanguine/pull/2882#discussion_r1681471161 --- core/metrics/otlp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/metrics/otlp.go b/core/metrics/otlp.go index 9db1c57a68..1057be5ea7 100644 --- a/core/metrics/otlp.go +++ b/core/metrics/otlp.go @@ -71,7 +71,7 @@ func handleShutdown(ctx context.Context, provider *tracesdk.TracerProvider) { const shutdownAllowance = time.Second * 10 // allow only 10 seconds for graceful shutdown. - // we use without cancel to copy the parents values while making sure are derived context is not canceled. + // 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() From 92b5efaa42fa1543274a4df90c96e4627fc4b669 Mon Sep 17 00:00:00 2001 From: abtestingalpha Date: Wed, 17 Jul 2024 17:57:04 +0000 Subject: [PATCH 5/8] Publish - @synapsecns/synapse-interface@0.28.5 --- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 18e1bca226..cd3638ecc3 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -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/synapse-interface@0.28.4...@synapsecns/synapse-interface@0.28.5) (2024-07-17) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + ## [0.28.4](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.28.3...@synapsecns/synapse-interface@0.28.4) (2024-07-17) **Note:** Version bump only for package @synapsecns/synapse-interface diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 521850c8fb..3556f7a5a8 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.28.4", + "version": "0.28.5", "private": true, "engines": { "node": ">=18.18.0" From 1397f8f8f146a512bfb2893e1b59ea54a1c667c0 Mon Sep 17 00:00:00 2001 From: Trajan0x Date: Wed, 17 Jul 2024 13:59:44 -0400 Subject: [PATCH 6/8] add a tiny span wait time to allow flushes to be reported --- core/metrics/otlp.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/metrics/otlp.go b/core/metrics/otlp.go index 1057be5ea7..f96f06dd43 100644 --- a/core/metrics/otlp.go +++ b/core/metrics/otlp.go @@ -68,6 +68,7 @@ func (n *otlpHandler) Type() HandlerType { 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. @@ -75,6 +76,9 @@ func handleShutdown(ctx context.Context, provider *tracesdk.TracerProvider) { 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) From fd337e9f90e4bb721679361d076548d292f1f162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:34:38 +0100 Subject: [PATCH 7/8] fix(solidity-devops): correctly save new deployments when script entry function is not `run()` (#2883) * fix: latest broadcast file is not always "run-latest" * fix: use timestamp when fetching new receipts * fix: silent exit if broadcast directory doesn't exist --- packages/solidity-devops/js/forgeScriptRun.js | 6 ++++- .../solidity-devops/js/utils/deployments.js | 25 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/solidity-devops/js/forgeScriptRun.js b/packages/solidity-devops/js/forgeScriptRun.js index 0f259d2457..4f61c9393c 100755 --- a/packages/solidity-devops/js/forgeScriptRun.js +++ b/packages/solidity-devops/js/forgeScriptRun.js @@ -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) ) diff --git a/packages/solidity-devops/js/utils/deployments.js b/packages/solidity-devops/js/utils/deployments.js index 3b3b285a82..6fe3366ecc 100644 --- a/packages/solidity-devops/js/utils/deployments.js +++ b/packages/solidity-devops/js/utils/deployments.js @@ -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) => { From 1ef950afa3f8888a475024049a694af2e64d808e Mon Sep 17 00:00:00 2001 From: ChiTimesChi Date: Wed, 17 Jul 2024 18:39:19 +0000 Subject: [PATCH 8/8] Publish - FastBridge@0.2.12 - @synapsecns/solidity-devops@0.4.4 --- packages/contracts-rfq/CHANGELOG.md | 8 ++++++++ packages/contracts-rfq/package.json | 4 ++-- packages/solidity-devops/CHANGELOG.md | 11 +++++++++++ packages/solidity-devops/package.json | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/contracts-rfq/CHANGELOG.md b/packages/contracts-rfq/CHANGELOG.md index 8fef9ca2d6..3ac0488c9b 100644 --- a/packages/contracts-rfq/CHANGELOG.md +++ b/packages/contracts-rfq/CHANGELOG.md @@ -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/FastBridge@0.2.11...FastBridge@0.2.12) (2024-07-17) + +**Note:** Version bump only for package FastBridge + + + + + ## [0.2.11](https://github.com/synapsecns/sanguine/compare/FastBridge@0.2.10...FastBridge@0.2.11) (2024-07-16) **Note:** Version bump only for package FastBridge diff --git a/packages/contracts-rfq/package.json b/packages/contracts-rfq/package.json index f4149a6bec..73ffd0dcb6 100644 --- a/packages/contracts-rfq/package.json +++ b/packages/contracts-rfq/package.json @@ -1,7 +1,7 @@ { "name": "FastBridge", "license": "UNLICENSED", - "version": "0.2.11", + "version": "0.2.12", "description": "FastBridge contracts.", "private": true, "files": [ @@ -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" diff --git a/packages/solidity-devops/CHANGELOG.md b/packages/solidity-devops/CHANGELOG.md index 53b36ad1fd..38e5edb4bf 100644 --- a/packages/solidity-devops/CHANGELOG.md +++ b/packages/solidity-devops/CHANGELOG.md @@ -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/solidity-devops@0.4.3...@synapsecns/solidity-devops@0.4.4) (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/solidity-devops@0.4.2...@synapsecns/solidity-devops@0.4.3) (2024-07-03) **Note:** Version bump only for package @synapsecns/solidity-devops diff --git a/packages/solidity-devops/package.json b/packages/solidity-devops/package.json index 17a0f91e23..713845fae2 100644 --- a/packages/solidity-devops/package.json +++ b/packages/solidity-devops/package.json @@ -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": {