Skip to content

Commit

Permalink
Merge b40bc84 into 32deb4b
Browse files Browse the repository at this point in the history
  • Loading branch information
Defi-Moses authored Oct 3, 2024
2 parents 32deb4b + b40bc84 commit 266dc5f
Show file tree
Hide file tree
Showing 404 changed files with 14,073 additions and 6,880 deletions.
71 changes: 44 additions & 27 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ jobs:
env:
VERCEL_PROJECT_ID: ${{ steps.project_id.outputs.VERCEL_PROJECT_ID}}


cancel-outdated:
name: Cancel Outdated Jobs
runs-on: ubuntu-latest
Expand All @@ -130,6 +129,9 @@ jobs:
fail-fast: false
matrix:
package: ${{ fromJson(needs.changes.outputs.packages) }}
# Slither is irrelevant for solidity-devops, as it only contains devops scripts rather than deployed contracts
exclude:
- package: solidity-devops
permissions:
# always required
security-events: write
Expand All @@ -138,40 +140,34 @@ jobs:
contents: read
steps:
- name: Checkout repository
if: ${{ matrix.package != 'solidity-devops' }}
uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: 'recursive'

- name: Setup NodeJS
if: ${{ matrix.package != 'solidity-devops' }}
uses: ./.github/actions/setup-nodejs

- name: Install Foundry
if: ${{ matrix.package != 'solidity-devops' }}
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

# TODO: find a flag for this
- name: Delete Untested Files
if: ${{ matrix.package != 'solidity-devops' }}
working-directory: './packages/${{matrix.package}}'
run: |
rm -rf test/ || true
rm -rf script/ || true
- name: Build Contracts
if: ${{ matrix.package != 'solidity-devops' }}
# TODO: unforunately, as of now concurrency needs to be 1 since if multiple instances of forge try to install the same version
# of solc at the same time, we get "text file busy" errors. See https://github.com/synapsecns/sanguine/actions/runs/8457116792/job/23168392860?pr=2234
# for an example.
run: |
npx lerna exec npm run build:slither --concurrency=1
- name: Run Slither
if: ${{ matrix.package != 'solidity-devops' }}
uses: crytic/slither-action@v0.3.0
continue-on-error: true
id: slither
Expand All @@ -183,7 +179,7 @@ jobs:
solc-version: 0.8.17

- name: Upload SARIF file
if: ${{!github.event.repository.private && matrix.package != 'solidity-devops'}}
if: ${{!github.event.repository.private}}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ./results.sarif
Expand All @@ -199,28 +195,32 @@ jobs:
package: ${{ fromJson(needs.changes.outputs.packages) }}
steps:
- uses: actions/checkout@v4
if: ${{ matrix.package != 'solidity-devops' }}
with:
submodules: recursive

- name: Setup Node JS
if: ${{ matrix.package != 'solidity-devops' }}
uses: ./.github/actions/setup-nodejs

- name: Installing dependencies
if: ${{ matrix.package != 'solidity-devops' }}
run: yarn install --immutable

- name: Install Foundry
if: ${{ matrix.package != 'solidity-devops' }}
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Foundry Tests
working-directory: './packages/${{matrix.package}}'
run: forge test -vvv

# We skip only the coverage steps for solidity-devops before we establish a good coverage there
- name: Run Foundry Coverage
if: ${{ matrix.package != 'solidity-devops' }}
working-directory: './packages/${{matrix.package}}'
run: forge coverage -vvv --report lcov --report summary >> $GITHUB_STEP_SUMMARY
run: forge coverage --report lcov --report summary >> $GITHUB_STEP_SUMMARY
# Limit the number of fuzz runs to speed up the coverage
env:
FOUNDRY_FUZZ_RUNS: 10

- name: Send Coverage (Codecov)
if: ${{ matrix.package != 'solidity-devops' }}
Expand All @@ -236,39 +236,57 @@ jobs:
attempt_limit: 5
attempt_delay: 30000


snapshot:
gas-diff:
runs-on: ubuntu-latest
name: Foundry Gas Snapshot
name: Foundry Gas Diff
if: ${{ needs.changes.outputs.package_count > 0 }}
needs: changes
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.changes.outputs.packages) }}
# Gas diff is irrelevant for solidity-devops, as it only contains devops scripts rather than deployed contracts
exclude:
- package: solidity-devops
steps:
- uses: actions/checkout@v4
if: ${{ matrix.package != 'solidity-devops' }}
with:
submodules: recursive

- name: Setup Node JS
if: ${{ matrix.package != 'solidity-devops' }}
uses: ./.github/actions/setup-nodejs

- name: Installing dependencies
if: ${{ matrix.package != 'solidity-devops' }}
run: yarn install --immutable

- name: Install Foundry
if: ${{ matrix.package != 'solidity-devops' }}
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run snapshot
if: ${{ matrix.package != 'solidity-devops' }}

- name: Run tests and generate gas report
working-directory: './packages/${{matrix.package}}'
run: forge snapshot >> $GITHUB_STEP_SUMMARY
# 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"

- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3.18
with:
ignore: 'test/**/*'
report: 'gas-report-${{ matrix.package }}.ansi'
sortCriteria: avg
sortOrders: desc
summaryQuantile: 0.5
id: gas_diff

- name: Add gas diff to sticky comment
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
# delete the comment in case changes no longer impact gas costs
delete: ${{ !steps.gas_diff.outputs.markdown }}
message: ${{ steps.gas_diff.outputs.markdown }}

size-check:
name: Foundry Size Check
runs-on: ubuntu-latest
Expand All @@ -278,25 +296,24 @@ jobs:
fail-fast: false
matrix:
package: ${{ fromJson(needs.changes.outputs.packages) }}
# Size check is irrelevant for solidity-devops, as it only contains devops scripts rather than deployed contracts
exclude:
- package: solidity-devops
steps:
- uses: actions/checkout@v4
if: ${{ matrix.package != 'solidity-devops' }}
with:
submodules: recursive

- name: Setup Node JS
if: ${{ matrix.package != 'solidity-devops' }}
uses: ./.github/actions/setup-nodejs

- name: Install Foundry
if: ${{ matrix.package != 'solidity-devops' }}
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

# This will run https://book.getfoundry.sh/reference/forge/forge-build#build-options
- name: Run forge build --sizes
if: ${{ matrix.package != 'solidity-devops' }}
run: |
forge build --sizes
working-directory: './packages/${{matrix.package}}'
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"editor.fontLigatures": "'calt', 'liga', 'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss08', 'ss09'",
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
Expand All @@ -16,11 +19,8 @@
"eslint.format.enable": true,
"editorconfig.generateAuto": false,
"files.trimTrailingWhitespace": true,
"solidity.packageDefaultDependenciesContractsDirectory": "contracts",
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.compileUsingRemoteVersion": "v0.8.17+commit.8df45f5f",
"solidity.formatter": "prettier",
"solidity.defaultCompiler": "remote",
"solidity.formatter": "forge",
"solidity.monoRepoSupport": true,
"tailwindCSS.classAttributes": [
".*class.*",
".*Class.*",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ root
│ ├── <a href="./packages/coverage-aggregator">coverage-aggregator</a>: Javascript coverage aggregator based on <a href="https://www.npmjs.com/package/nyc">nyc</a>
│ ├── <a href="./packages/docs">docs</a>: Docasaurus documentation. Note: this is not yet in use, and docs are still maintained on gitbook
│ ├── <a href="./packages/explorer-ui">explorer-ui</a>: Explorer UI
│ ├── <a href="./packages/rfq-indexer">rfq-indexer</a>: RFQ indexer
│ ├── <a href="./packages/rest-api">rest-api</a>: Rest API
│ ├── <a href="./packages/sdk-router">sdk-router</a>: SDK router
│ ├── <a href="./packages/solidity-devops">solidity-devops</a>: provides a set of tools and scripts to help with the development of Solidity smart contracts
Expand Down
14 changes: 5 additions & 9 deletions contrib/opbot/botmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/synapsecns/sanguine/core/retry"
"github.com/synapsecns/sanguine/ethergo/chaindata"
"github.com/synapsecns/sanguine/ethergo/client"
"github.com/synapsecns/sanguine/ethergo/submitter"
rfqClient "github.com/synapsecns/sanguine/services/rfq/api/client"
"github.com/synapsecns/sanguine/services/rfq/contracts/fastbridge"
"github.com/synapsecns/sanguine/services/rfq/relayer/relapi"
Expand Down Expand Up @@ -347,17 +348,12 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition {
return
}

var txHash *relapi.TxHashByNonceResponse
var status submitter.SubmissionStatus
err = retry.WithBackoff(
ctx.Context(),
func(ctx context.Context) error {
txHash, err = relClient.GetTxHashByNonce(
ctx,
&relapi.GetTxByNonceRequest{
ChainID: rawRequest.OriginChainID,
Nonce: nonce,
})
if err != nil {
status, err = b.submitter.GetSubmissionStatus(ctx, big.NewInt(int64(rawRequest.OriginChainID)), nonce)
if err != nil || !status.HasTx() {
b.logger.Errorf(ctx, "error fetching quote request: %v", err)
return fmt.Errorf("error fetching quote request: %w", err)
}
Expand All @@ -373,7 +369,7 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition {
return
}

_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted: %s", toExplorerSlackLink(txHash.Hash)))
_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted: %s", toExplorerSlackLink(status.TxHash().String())))
if err != nil {
log.Println(err)
}
Expand Down
1 change: 1 addition & 0 deletions contrib/opbot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.54.0 // indirect
github.com/prometheus/procfs v0.15.0 // indirect
github.com/puzpuzpuz/xsync v1.5.2 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/richardwilkes/toolbox v1.74.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
Expand Down
11 changes: 6 additions & 5 deletions contrib/promexporter/exporters/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ func (e *exporter) collectMetrics(parentCtx context.Context) (err error) {
for _, pending := range e.cfg.DFKPending {
if err := e.stuckHeroCountStats(ctx, common.HexToAddress(pending.Owner), pending.ChainName); err != nil {
errs = append(errs, fmt.Errorf("could not get stuck hero count: %w", err))
span.AddEvent("could not get stuck hero count")
}
span.AddEvent("could not get stuck hero count")
}

for _, gasCheck := range e.cfg.SubmitterChecks {
for _, chainID := range gasCheck.ChainIDs {
if err := e.submitterStats(common.HexToAddress(gasCheck.Address), chainID, gasCheck.Name); err != nil {
errs = append(errs, fmt.Errorf("could setup metric: %w", err))
errs = append(errs, fmt.Errorf("could not get submitter stats: %w", err))
span.AddEvent("could not get submitter stats")
}
}
span.AddEvent("could get submitter stats")
}

for chainID := range e.cfg.BridgeChecks {
Expand All @@ -161,7 +161,8 @@ func (e *exporter) collectMetrics(parentCtx context.Context) (err error) {
return retry.WithBackoff(ctx, func(ctx context.Context) error {
err := e.vpriceStats(ctx, chainID, token)
if err != nil && !errors.Is(err, errPoolNotExist) {
errs = append(errs, fmt.Errorf("stuck hero stats: %w", err))
errs = append(errs, fmt.Errorf("could not get vprice %w", err))
span.AddEvent("could not get vprice stats")
}

return nil
Expand All @@ -172,7 +173,7 @@ func (e *exporter) collectMetrics(parentCtx context.Context) (err error) {

if len(errs) > 0 {
span.AddEvent("could not collect metrics")
return fmt.Errorf("could not collect metrics: %v", errs)
return fmt.Errorf("could not collect metrics: %w", combineErrors(errs))
}

return nil
Expand Down
8 changes: 8 additions & 0 deletions core/commandline/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package commandline
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/util/sets"
"os"
"os/signal"
"os/user"
Expand Down Expand Up @@ -90,11 +91,18 @@ func GenerateShellCommand(shellCommands []*cli.Command) *cli.Command {
// pruneShellCommands gets a list of commands including the shell command.
func pruneShellCommands(commands []*cli.Command) (prunedCommands []*cli.Command) {
// initialize shell commands
nameSet := sets.NewString()
for _, command := range commands {
if command.Name != shellCommandName {
prunedCommands = append(prunedCommands, command)
}
if !nameSet.Has(command.Name) {
fmt.Printf("Command %s already exists, skipping\n", command.Name)
}

nameSet.Insert(command.Name)
}

return prunedCommands
}

Expand Down
11 changes: 11 additions & 0 deletions docs/bridge/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.3.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.2.4...@synapsecns/bridge-docs@0.3.0) (2024-10-02)


### Features

* **rfq:** relay rate limiting ([#2933](https://github.com/synapsecns/sanguine/issues/2933)) [SLT-149] ([a240292](https://github.com/synapsecns/sanguine/commit/a2402928f7e56369ce39cc6f211c3e3b3dfd404e))





## [0.2.4](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.2.3...@synapsecns/bridge-docs@0.2.4) (2024-09-09)

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
19 changes: 19 additions & 0 deletions docs/bridge/docs/01-About/01-DAO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Synapse DAO
---

# Synapse DAO

Since launch of the Synapse Protocol, a number of governance initiatives have been put forward and voted on by the Synapse DAO.

## Governance Model

SYN holders with more than 100,000 SYN tokens can put forward proposals to be voted on by the DAO. SYN holders can vote using SYN on multiple chains, or delegate their votes to other token holders.

In order to be adopted by the DAO, a proposal must gather at least `50% + 1` of all votes and reach the minimum quorum of 5 million SYN tokens.

## Governance Components

* **[Forum](https://forum.synapseprotocol.com/)**: A Platform to post proposals for discussion before an official vote
* **[Snapshot](https://snapshot.org/#/synapseprotocol.eth)**: A decentralized governance platform for conducting official votes.
* **[Discord](https://discord.gg/synapseprotocol)**: Discussion channel for general Synapse matters
Loading

0 comments on commit 266dc5f

Please sign in to comment.