Skip to content

Commit

Permalink
Merge branch 'master' into fe/confirm-new-price
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboydiamonds authored Sep 9, 2024
2 parents c7b2981 + 4c491d4 commit 62d7735
Show file tree
Hide file tree
Showing 69 changed files with 1,976 additions and 807 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
cancel_others: 'true'

# changes allows us to only run a job on changed packages

changes:
name: Change Detection
runs-on: ubuntu-latest
Expand All @@ -37,6 +37,8 @@ jobs:
packages_nodeps: ${{ steps.filter_go.outputs.changed_modules }}
package_count_nodeps: ${{ steps.length.outputs.FILTER_LENGTH_NODEPS }}
solidity_changes: ${{ steps.filter_solidity.outputs.any_changed }}
golangci_changed: ${{ steps.golangci_changed.outputs.any_changed }}
all_packages: ${{ steps.filter_go.outputs.all_modules }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -55,11 +57,28 @@ jobs:
with:
files: |
**/*.sol
- name: Check For GolangCI Changes
id: golangci_changed
uses: tj-actions/changed-files@v26.1
with:
# note: without building a yaml tree of our workflow, we won't be able to tell if golangci version changed so any ci change triggers full lint.
files: |
.golangci.yml
.github/workflows/go.yml
- name: Run step if any of the listed files above change
if: steps.filter_solidity.outputs.any_changed == 'true'
run: |
echo "One or more files listed above has changed."
- name: Golangci changed
if: steps.golangci_changed.outputs.any_changed == 'true'
run: |
echo "Golangci has changed."
- id: length
run: |
export FILTER_LENGTH_DEPS=$(echo $FILTERED_PATHS_DEPS | jq '. | length')
Expand Down Expand Up @@ -298,18 +317,16 @@ jobs:
name: Lint
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.package_count_deps > 0 && (github.event_name != 'push' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) }}
if: ${{ (needs.changes.outputs.package_count_deps > 0 || needs.changes.outputs.golangci_changed == 'true') && (github.event_name != 'push' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) }}
strategy:
fail-fast: false
max-parallel: 8
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['package1', 'package2'] if both package folders contains changes
package: ${{ fromJSON(needs.changes.outputs.packages_nodeps) }}
package: ${{ needs.changes.outputs.golangci_changed == 'true' && fromJSON(needs.changes.outputs.all_packages) || fromJSON(needs.changes.outputs.packages_nodeps) }}
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version: 1.23.x

- uses: actions/checkout@v4
with:
Expand All @@ -324,15 +341,14 @@ jobs:
with:
working-directory: ${{matrix.package}}/
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.56.2
version: v1.60.3
# see: https://github.com/golangci/golangci-lint/issues/2654
args: --timeout=60m
env:
# GitHub token for annotations (optional)
GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT || secrets.GITHUB_TOKEN }}
GOMEMLIMIT: 6GiB
GOGC: -1

pr_metadata:
# this is needed to prevent us from hitting the github api rate limit
name: Get PR Metadata
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ issues:
linters:
- revive
- stylecheck
- dupl
# wrapping errors when exporting for testing is tedious
- path: export_test\.go
linters:
Expand Down
8 changes: 6 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"editor.fontLigatures": "'calt', 'liga', 'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss08', 'ss09'",
// "editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
Expand All @@ -21,5 +20,10 @@
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.compileUsingRemoteVersion": "v0.8.17+commit.8df45f5f",
"solidity.formatter": "prettier",
"solidity.defaultCompiler": "remote"
"solidity.defaultCompiler": "remote",
"tailwindCSS.classAttributes": [
".*class.*",
".*Class.*",
".*Properties.*",
]
}
57 changes: 55 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@

Contributions should roughly follow the [uber style guide](https://github.com/uber-go/guide/blob/master/style.md)

# Submitting a PR

When preparing to submit a pull request, there are a few key points to keep in mind to ensure a smooth review process and maintain the quality of our codebase.

First and foremost, we encourage you to use the default PR template provided in the repository. This template is designed to capture all the necessary information about your changes, making it easier for reviewers to understand the context and purpose of your work.

If your PR is related to a specific task in Notion, it's helpful to include the Notion ID in your PR title or description. For example, you might use a format like [SLT-143] at the beginning of your PR title. This allows us to easily track the relationship between tasks and code changes.

![Example](./assets/notion-example.png)

During the review process, you might notice comments about code coverage changes. While we generally aim to maintain or improve code coverage, don't be overly concerned if you see minor fluctuations. If the coverage changes aren't material to the core functionality you're modifying, it's usually fine to proceed.

You'll likely encounter suggestions from CodeRabbit, our automated code review tool. While CodeRabbit can provide valuable insights, remember that it's an AI tool and may not always understand the full context of your changes. Use its suggestions as a starting point for improvement, but don't feel obligated to implement every recommendation it makes. Your judgment as a developer is crucial in determining which suggestions are truly beneficial.

If your PR gets labeled with `needs-go-generate`, don't worry - this is an easy fix. Simply run `go generate ./...` in your terminal, commit the changes, and push. This will update any auto-generated code that might be out of sync.

Similarly, if you see a `needs-yarn-lock` label, it means your changes have affected the project's dependencies. To resolve this, navigate to the root directory of the project and run `yarn`. This will update the yarn.lock file, ensuring that all developers are working with the same dependency versions.

Remember, these guidelines are here to help streamline our development process and maintain consistency across the project. We appreciate your contributions and look forward to reviewing your PRs!



## Carefully Reviewing PRs

Before merging a pull request, it's crucial to carefully review the changes. Here are some key points to consider:

1. Code quality: Ensure the code follows our style guide and best practices.
2. Functionality: Verify that the changes work as intended and don't introduce new bugs.
3. Tests: Check that appropriate tests have been added or updated.
4. Documentation: Confirm that any necessary documentation updates have been made.
5. Performance: Consider the impact on performance, especially for critical paths.

Take your time during the review process. It's better to have a thorough review than to rush and potentially introduce issues.

## Using Squash and Merge

When it's time to merge a PR, we prefer using the "Squash and Merge" option instead of rebasing. This approach combines all commits from the feature branch into a single commit in the main branch, which helps keep our commit history clean and easier to navigate.

Here's how to use the "Squash and Merge" option:

1. Once the PR is approved and ready to merge, click on the "Squash and merge" button in the GitHub interface.
2. Review the commit message. It will be pre-filled with the PR title and description, but you can edit it if needed.
3. Click "Confirm squash and merge".

![Squash and Merge Example](./assets/merge-example.png)

By using "Squash and Merge", we maintain a linear and clean history in our main branch, making it easier to understand the progression of our project and to revert changes if necessary.




<!-- todo: more-->

## Adding a new JS/TS Package
Expand All @@ -16,11 +67,13 @@ If you need to make a new JS/TS package, here are the steps to follow:
- If the package is a library that you'd like to publish, simply set the `private` field in `package.json` to `false` and the `publishConfig` access to public.
- If the package is a UI, please see [here](./.github/workflows/ui-preview.md) for instructions on configuring vercel. Make sure to update the paths there as well.

# Go

## Linting

Linting for go is used using [golangci-lint](https://golangci-lint.run/) at the latest released version. Please upgrade or install using your package manager. and run `make lint` from your desired module.

# Adding a new Go Module
## Adding a new Go Module

If you need to make a new go module, here are the steps to follow:

Expand Down Expand Up @@ -286,6 +339,6 @@ func TestEventDBSuite(t *testing.T) {

```

## Github Actions
# Github Actions

If you want to do a shallow clone, use `fetch-depth: 2` rather than `fetch-depth: 1`. This allows [some actions](https://docs.codecov.com/docs/environment-specific-requirements) (though not all of them) to determine the correct sha.
12 changes: 8 additions & 4 deletions agents/testutil/simulated_backends_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,15 @@ func (a *SimulatedBackendsTestSuite) SetupBackends() {

var wg sync.WaitGroup
wg.Add(3)
var err error
go func() {
defer wg.Done()
if useAnvil {
anvilOptsOrigin := anvil.NewAnvilOptionBuilder()
anvilOptsOrigin.SetChainID(uint64(params.SepoliaChainConfig.ChainID.Int64()))
anvilOptsOrigin.SetBlockTime(1 * time.Second)
a.TestBackendOrigin = anvil.NewAnvilBackend(a.GetTestContext(), a.T(), anvilOptsOrigin)
a.TestBackendOrigin, err = anvil.NewAnvilBackend(a.GetTestContext(), a.T(), anvilOptsOrigin)
a.Nil(err)
a.TestSuite.DeferAfterTest(a.TestBackendOrigin.(*anvil.Backend).TearDown)
} else {
a.TestBackendOrigin = preset.GetSepolia().Geth(a.GetTestContext(), a.T())
Expand All @@ -431,7 +433,8 @@ func (a *SimulatedBackendsTestSuite) SetupBackends() {
anvilOptsDestination := anvil.NewAnvilOptionBuilder()
anvilOptsDestination.SetChainID(uint64(client.ChapelChainConfig.ChainID.Int64()))
anvilOptsDestination.SetBlockTime(1 * time.Second)
a.TestBackendDestination = anvil.NewAnvilBackend(a.GetTestContext(), a.T(), anvilOptsDestination)
a.TestBackendDestination, err = anvil.NewAnvilBackend(a.GetTestContext(), a.T(), anvilOptsDestination)
a.Nil(err)
a.TestSuite.DeferAfterTest(a.TestBackendDestination.(*anvil.Backend).TearDown)
} else {
a.TestBackendDestination = preset.GetBSCTestnet().Geth(a.GetTestContext(), a.T())
Expand All @@ -443,7 +446,8 @@ func (a *SimulatedBackendsTestSuite) SetupBackends() {
anvilOptsSummit := anvil.NewAnvilOptionBuilder()
anvilOptsSummit.SetChainID(uint64(10))
anvilOptsSummit.SetBlockTime(1 * time.Second)
a.TestBackendSummit = anvil.NewAnvilBackend(a.GetTestContext(), a.T(), anvilOptsSummit)
a.TestBackendSummit, err = anvil.NewAnvilBackend(a.GetTestContext(), a.T(), anvilOptsSummit)
a.Nil(err)
a.TestSuite.DeferAfterTest(a.TestBackendSummit.(*anvil.Backend).TearDown)
} else {
a.TestBackendSummit = preset.GetMaticMumbaiFakeSynDomain().Geth(a.GetTestContext(), a.T())
Expand Down Expand Up @@ -474,7 +478,7 @@ func (a *SimulatedBackendsTestSuite) SetupBackends() {

a.TestOmniRPC = omnirpcHelper.NewOmnirpcServer(a.GetTestContext(), a.T(), testBackends...)

err := a.TestDeployManager.LoadHarnessContractsOnChains(
err = a.TestDeployManager.LoadHarnessContractsOnChains(
a.GetTestContext(),
a.TestBackendSummit,
[]backends.SimulatedTestBackend{a.TestBackendOrigin, a.TestBackendDestination},
Expand Down
Binary file added assets/merge-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notion-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 66 additions & 41 deletions contrib/opbot/botmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/slack-go/slack"
"github.com/slack-io/slacker"
"github.com/synapsecns/sanguine/contrib/opbot/signoz"
"github.com/synapsecns/sanguine/core/retry"
"github.com/synapsecns/sanguine/ethergo/chaindata"
"github.com/synapsecns/sanguine/ethergo/client"
rfqClient "github.com/synapsecns/sanguine/services/rfq/api/client"
Expand Down Expand Up @@ -278,63 +279,87 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition {
return
}

var rawRequest *relapi.GetQuoteRequestResponse
var err error
var relClient relapi.RelayerClient
for _, relayer := range b.cfg.RelayerURLS {
relClient := relapi.NewRelayerClient(b.handler, relayer)

rawRequest, err := getQuoteRequest(ctx.Context(), relClient, tx)
if err != nil {
_, err := ctx.Response().Reply("error fetching quote request")
if err != nil {
log.Println(err)
}
return
relClient = relapi.NewRelayerClient(b.handler, relayer)
rawRequest, err = getQuoteRequest(ctx.Context(), relClient, tx)
if err == nil {
break
}

fastBridgeContract, err := b.makeFastBridge(ctx.Context(), rawRequest)
}
if err != nil {
_, err := ctx.Response().Reply("error fetching quote request")
if err != nil {
_, err := ctx.Response().Reply(err.Error())
if err != nil {
log.Println(err)
}
return
log.Println(err)
}
return
}

canRefund, err := b.screener.ScreenAddress(ctx.Context(), rawRequest.Sender)
fastBridgeContract, err := b.makeFastBridge(ctx.Context(), rawRequest)
if err != nil {
_, err := ctx.Response().Reply(err.Error())
if err != nil {
_, err := ctx.Response().Reply("error screening address")
if err != nil {
log.Println(err)
}
return
log.Println(err)
}
return
}

if !canRefund {
_, err := ctx.Response().Reply("address cannot be refunded")
if err != nil {
log.Println(err)
}
return
isScreened, err := b.screener.ScreenAddress(ctx.Context(), rawRequest.Sender)
if err != nil {
_, err := ctx.Response().Reply("error screening address")
if err != nil {
log.Println(err)
}

nonce, err := b.submitter.SubmitTransaction(ctx.Context(), big.NewInt(int64(rawRequest.OriginChainID)), func(transactor *bind.TransactOpts) (tx *types.Transaction, err error) {
tx, err = fastBridgeContract.Refund(transactor, common.Hex2Bytes(rawRequest.QuoteRequestRaw))
if err != nil {
return nil, fmt.Errorf("error submitting refund: %w", err)
}
return tx, nil
})
return
}
if isScreened {
_, err := ctx.Response().Reply("address cannot be refunded")
if err != nil {
log.Printf("error submitting refund: %v\n", err)
continue
log.Println(err)
}
return
}

// TODO: follow the lead of https://github.com/synapsecns/sanguine/pull/2845
_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted with nonce %d", nonce))
nonce, err := b.submitter.SubmitTransaction(ctx.Context(), big.NewInt(int64(rawRequest.OriginChainID)), func(transactor *bind.TransactOpts) (tx *types.Transaction, err error) {
tx, err = fastBridgeContract.Refund(transactor, common.Hex2Bytes(rawRequest.QuoteRequestRaw))
if err != nil {
log.Println(err)
return nil, fmt.Errorf("error submitting refund: %w", err)
}
return tx, nil
})
if err != nil {
log.Printf("error submitting refund: %v\n", err)
return
}

var txHash *relapi.TxHashByNonceResponse
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 {
return fmt.Errorf("error fetching quote request: %w", err)
}
return nil
},
retry.WithMaxAttempts(3),
retry.WithMaxAttemptTime(15*time.Second),
)
if err != nil {
_, err := ctx.Response().Reply(fmt.Sprintf("error fetching explorer link to refund, but nonce is %d", nonce))
log.Printf("error fetching quote request: %v\n", err)
return
}

_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted: %s", toExplorerSlackLink(txHash.Hash)))
if err != nil {
log.Println(err)
}
},
}
}
Expand Down
3 changes: 2 additions & 1 deletion contrib/opbot/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package config

import (
"errors"
"strings"

"github.com/synapsecns/sanguine/ethergo/signer/config"
submitterConfig "github.com/synapsecns/sanguine/ethergo/submitter/config"
"strings"
)

// Config represents the configuration of the application.
Expand Down
2 changes: 2 additions & 0 deletions core/metrics/rookout.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build go1.16 && !go1.23

package metrics

import (
Expand Down
Loading

0 comments on commit 62d7735

Please sign in to comment.