Skip to content

Commit

Permalink
Merge 8113d0b into 599006b
Browse files Browse the repository at this point in the history
  • Loading branch information
Defi-Moses authored Sep 25, 2024
2 parents 599006b + 8113d0b commit 24036a9
Show file tree
Hide file tree
Showing 185 changed files with 13,654 additions and 5,970 deletions.
70 changes: 43 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,29 @@ 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

- name: Send Coverage (Codecov)
if: ${{ matrix.package != 'solidity-devops' }}
Expand All @@ -236,39 +233,59 @@ 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' }}

# TODO: consider defining a package-specific script for this
- name: Run tests and generate gas report
working-directory: './packages/${{matrix.package}}'
run: forge snapshot >> $GITHUB_STEP_SUMMARY
# Excluding tests with reverts to get accurate average gas cost estimates
run: forge test --nmt "(fail|revert)" --gas-report > "../../gas-report-${{ matrix.package }}.ansi"
env:
# make fuzzing semi-deterministic to avoid noisy gas cost estimation
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}

- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3.18
# TODO: define some options?
with:
report: 'gas-report-${{ matrix.package }}.ansi'
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 +295,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
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
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"useWorkspaces": true,
"packages": [
"packages/*",
"packages/rfq-indexer/*",
"docs/*"
],
"version": "independent"
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"workspaces": {
"packages": [
"packages/*",
"packages/rfq-indexer/*",
"docs/*"
],
"nohoist": [
Expand Down Expand Up @@ -73,7 +74,8 @@
"ts-mocha": "^10.0.0",
"typedoc": "^0.23.24",
"typedoc-plugin-markdown": "^3.14.0",
"typescript": "^5.0.4"
"typescript": "^5.0.4",
"wagmi": "^2.12.12"
},
"dependencies": {
"@changesets/cli": "2.22.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/contracts-core/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"solidity.formatter": "forge",
"solidity.monoRepoSupport": false
}
19 changes: 19 additions & 0 deletions packages/contracts-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.0.33](https://github.com/synapsecns/sanguine/compare/@synapsecns/contracts-core@1.0.32...@synapsecns/contracts-core@1.0.33) (2024-09-24)


### Bug Fixes

* **contracts-rfq:** CI workflows [SLT-245] ([#3178](https://github.com/synapsecns/sanguine/issues/3178)) ([74b620e](https://github.com/synapsecns/sanguine/commit/74b620e4c928be8d0dbb422708376d167db7848d))





## [1.0.32](https://github.com/synapsecns/sanguine/compare/@synapsecns/contracts-core@1.0.31...@synapsecns/contracts-core@1.0.32) (2024-09-23)

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





## [1.0.31](https://github.com/synapsecns/sanguine/compare/@synapsecns/contracts-core@1.0.30...@synapsecns/contracts-core@1.0.31) (2024-04-03)

**Note:** Version bump only for package @synapsecns/contracts-core
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/contracts-core",
"version": "1.0.31",
"version": "1.0.33",
"description": "",
"scripts": {
"build": "yarn build:contracts && yarn build:typescript && yarn build:go",
Expand Down Expand Up @@ -28,7 +28,7 @@
"@typechain/ethers-v5": "10.0.0",
"hardhat": "2.22.2",
"rimraf": "3.0.2",
"solhint": "3.3.8",
"solhint": "5.0.3",
"typechain": "8.0.0",
"typescript": "4.7.3"
},
Expand Down
Loading

0 comments on commit 24036a9

Please sign in to comment.