Skip to content

Commit

Permalink
Merge branch 'fix/new-rfq' of https://github.com/synapsecns/sanguine
Browse files Browse the repository at this point in the history
…into fix/new-rfq
  • Loading branch information
aureliusbtc committed Dec 13, 2023
2 parents 3333d91 + d6d00ad commit 5d65c9b
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 28 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,23 @@ jobs:
run: |
forge doc
cp vercel.package.json docs/package.json
- name: Setup upterm session
uses: lhotari/action-upterm@v1
env:
VERCEL_PROJECT_ID: ${{ steps.project_id.outputs.VERCEL_PROJECT_ID}}
- name: Deploy (Prod)
if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }}
working-directory: "packages/${{matrix.package}}/docs"
run: |
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod
env:
VERCEL_PROJECT_ID: ${{ steps.project_id.outputs.VERCEL_PROJECT_ID}}
- name: Deploy
working-directory: "packages/${{matrix.package}}/docs"
run: |
pwd
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
echo "1"
vercel build --token=${{ secrets.VERCEL_TOKEN }}
echo "2"
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
echo "3"
env:
VERCEL_PROJECT_ID: ${{ steps.project_id.outputs.VERCEL_PROJECT_ID}}

Expand Down Expand Up @@ -211,14 +208,14 @@ jobs:
version: nightly

- name: Run Foundry Tests
working-directory: "/packages/${{matrix.package}}"
working-directory: "./packages/${{matrix.package}}"
run: forge coverage -vvv --report lcov --report summary >> $GITHUB_STEP_SUMMARY

- name: Send Coverage (Codecov)
uses: Wandalen/[email protected]
with:
action: codecov/codecov-action@v3
current_path: "/packages/${{matrix.package}}"
current_path: "./packages/${{matrix.package}}"
with: |
token: ${{ secrets.CODECOV }}
fail_ci_if_error: true # optional (default = false)
Expand Down
1 change: 1 addition & 0 deletions packages/contracts-rfq/vercel.package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
"build": "curl -Lo mdbook.tar.gz https://github.com/rust-lang/mdBook/releases/download/v0.4.32/mdbook-v0.4.32-x86_64-unknown-linux-musl.tar.gz; tar -xvzf mdbook.tar.gz; ./mdbook build --dest-dir build"
}
}

10 changes: 5 additions & 5 deletions services/rfq/contracts/fastbridge/fastbridge.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion services/rfq/contracts/fastbridge/generate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package fastbridge

//go:generate go run github.com/synapsecns/sanguine/tools/abigen generate --sol ../../../../packages/contracts-rfq/flattened/FastBridge.sol --pkg fastbridge --sol-version 0.8.20 --filename fastbridge
//go:generate go run github.com/synapsecns/sanguine/tools/abigen generate --sol ../../../../packages/contracts-rfq/flattened/FastBridge.sol --pkg fastbridge --sol-version 0.8.20 --filename fastbridge --evm-version istanbul
2 changes: 2 additions & 0 deletions services/rfq/relayer/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package relayer contains the rfq relayer
package relayer
4 changes: 4 additions & 0 deletions services/rfq/relayer/inventory/balance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package inventory

type balanceManager struct {
}
2 changes: 2 additions & 0 deletions services/rfq/relayer/inventory/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package inventory contains the inventory manager
package inventory
20 changes: 20 additions & 0 deletions services/rfq/relayer/inventory/manager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package inventory

import (
"context"
"github.com/ethereum/go-ethereum/common"
)

type InventoryManager interface{}

type inventoryManagerImpl struct {
tokens map[int][]common.Address
}

// NewInventoryManager creates a list of tokens we should use.
func NewInventoryManager(ctx context.Context, tokens map[int][]common.Address) {

}

// Ultimately this should produce a list of all balances and remove the
// quoted amounts from the database
2 changes: 1 addition & 1 deletion services/rfq/testutil/contracttype.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (c contractTypeImpl) ContractName() string {
func (c contractTypeImpl) ContractInfo() *compiler.Contract {
switch c {
case FastBridgeType:
return fastbridge.Contracts["solidity/"]
return fastbridge.Contracts["solidity/FastBridge.sol:FastBridge"]
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion services/rfq/testutil/deployers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewDeployManager(t *testing.T) *DeployManager {
t.Helper()

// TODO: add contracts here
parentManager := manager.NewDeployerManager(t)
parentManager := manager.NewDeployerManager(t, NewFastBridgeDeployer)
return &DeployManager{parentManager}
}

Expand Down
12 changes: 10 additions & 2 deletions services/rfq/testutil/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package testutil
package testutil_test

import (
"github.com/stretchr/testify/suite"
"github.com/synapsecns/sanguine/core/testsuite"
"github.com/synapsecns/sanguine/ethergo/manager"
"github.com/synapsecns/sanguine/services/rfq/testutil"
"testing"
)

Expand All @@ -20,5 +22,11 @@ func NewTestUtilSuite(tb testing.TB) *TestUtilSuite {
}

func TestTestUtilSuite(t *testing.T) {
suite.Run(t)
suite.Run(t, NewTestUtilSuite(t))
}

func (s *TestUtilSuite) TestDependencies() {
manager.AssertDependenciesCorrect(s.GetTestContext(), s.T(), func() manager.IDeployManager {
return testutil.NewDeployManager(s.T())
})
}
18 changes: 17 additions & 1 deletion tools/abigen/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/ethereum/go-ethereum/common"
"github.com/synapsecns/sanguine/core"
"github.com/synapsecns/sanguine/tools/abigen/internal"
"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -37,6 +38,20 @@ var optimizerRunsFlags = &cli.IntFlag{
Value: 10000,
}

var evmVersionFlags = &cli.StringFlag{
Name: "evm-version",
Usage: "evm version to target",
}

// strToPt converts a string to a pointer
// crucially, will return nil if stirng is empty
func strToPt(str string) *string {
if str == "" {
return nil
}
return core.PtrTo(str)
}

// GenerateCommand generates abi using flags.
var GenerateCommand = &cli.Command{
Name: "generate",
Expand All @@ -47,10 +62,11 @@ var GenerateCommand = &cli.Command{
filenameFlag,
solVersionFlag,
optimizerRunsFlags,
evmVersionFlags,
},
Action: func(context *cli.Context) error {
//nolint: wrapcheck
return internal.BuildTemplates(context.String(solVersionFlag.Name), context.String(solFlag.Name), context.String(pkgFlag.Name), context.String(filenameFlag.Name), context.Int(optimizerRunsFlags.Name))
return internal.BuildTemplates(context.String(solVersionFlag.Name), context.String(solFlag.Name), context.String(pkgFlag.Name), context.String(filenameFlag.Name), context.Int(optimizerRunsFlags.Name), strToPt(context.String(evmVersionFlags.Name)))
},
}

Expand Down
4 changes: 2 additions & 2 deletions tools/abigen/internal/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func CreateRunFile(version string) (runFile *os.File, err error) {
}

// CompileSolidity exports compileSolidity for testingw.
func CompileSolidity(version string, filePath string, optimizeRuns int) (map[string]*compiler.Contract, error) {
return compileSolidity(version, filePath, optimizeRuns)
func CompileSolidity(version string, filePath string, optimizeRuns int, evmVersion *string) (map[string]*compiler.Contract, error) {
return compileSolidity(version, filePath, optimizeRuns, evmVersion)
}

// FilePathsAreEqual exports filePathsAreEqual for testing.
Expand Down
13 changes: 9 additions & 4 deletions tools/abigen/internal/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ func GenerateABIFromEtherscan(ctx context.Context, chainID uint32, url string, c
optimizerRuns = contract.Runs
}

return BuildTemplates(solVersion, solFile.Name(), pkgName, fileName, optimizerRuns)
return BuildTemplates(solVersion, solFile.Name(), pkgName, fileName, optimizerRuns, nil)
}

// BuildTemplates builds the templates. version is the solidity version to use and sol is the solidity file to use.
func BuildTemplates(version, file, pkg, filename string, optimizerRuns int) error {
func BuildTemplates(version, file, pkg, filename string, optimizerRuns int, evmVersion *string) error {
// TODO ast
contracts, err := compileSolidity(version, file, optimizerRuns)
contracts, err := compileSolidity(version, file, optimizerRuns, evmVersion)
if err != nil {
return err
}
Expand Down Expand Up @@ -123,7 +123,7 @@ func BuildTemplates(version, file, pkg, filename string, optimizerRuns int) erro

// compileSolidity uses docker to compile solidity.
// nolint: cyclop
func compileSolidity(version string, filePath string, optimizeRuns int) (map[string]*compiler.Contract, error) {
func compileSolidity(version string, filePath string, optimizeRuns int, evmVersion *string) (map[string]*compiler.Contract, error) {
runFile, err := createRunFile(version)
if err != nil {
return nil, err
Expand Down Expand Up @@ -183,6 +183,11 @@ func compileSolidity(version string, filePath string, optimizeRuns int) (map[str
// compile the solidity
var stderr, stdout bytes.Buffer
args := []string{"--combined-json", "bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes", "--optimize", "--optimize-runs", strconv.Itoa(optimizeRuns), "--allow-paths", "., ./, ../"}

if evmVersion != nil {
args = append(args, fmt.Sprintf("--evm-version=%s", *evmVersion))
}

//nolint: gosec
cmd := exec.Command(runFile.Name(), append(args, "--", fmt.Sprintf("/solidity/%s", filepath.Base(solFile.Name())))...)
cmd.Stderr = &stderr
Expand Down
28 changes: 26 additions & 2 deletions tools/abigen/internal/generate_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package internal_test

import (
"encoding/json"
"errors"
"github.com/synapsecns/sanguine/core"
"github.com/synapsecns/sanguine/ethergo/debug"
"os"
"os/exec"
"path/filepath"
Expand All @@ -24,8 +27,8 @@ func TestCreateRunFile(t *testing.T) {
}
}

func (a *AbiSuite) TestCompileSolidity() {
vals, err := internal.CompileSolidity("0.8.4", a.exampleFilePath, 1)
func (a *AbiSuite) TestCompileSolidityImplicitEVM() {
vals, err := internal.CompileSolidity("0.8.4", a.exampleFilePath, 1, nil)
Nil(a.T(), err)

Len(a.T(), vals, 1)
Expand All @@ -35,6 +38,27 @@ func (a *AbiSuite) TestCompileSolidity() {
}
}

func (a *AbiSuite) TestCompileSolidityExplicitEVM() {
// default would be shnghai
const testEvmVersion = "istanbul"
vals, err := internal.CompileSolidity("0.8.20", a.exampleFilePath, 1, core.PtrTo(testEvmVersion))
Nil(a.T(), err)

Len(a.T(), vals, 1)
for _, value := range vals {
Equal(a.T(), value.Info.CompilerVersion, "0.8.20")
Equal(a.T(), value.Info.LanguageVersion, "0.8.20")

var metadata debug.ContractMetadata
err = json.Unmarshal([]byte(value.Info.Metadata), &metadata)
a.Require().NoError(err)

if metadata.Settings.EvmVersion != testEvmVersion {
a.T().Errorf("expected %s to be %s", metadata.Language, testEvmVersion)
}
}
}

func TestFilePathsAreEqual(t *testing.T) {
tests := []struct {
file1 string
Expand Down

0 comments on commit 5d65c9b

Please sign in to comment.