Commit f7368e09 authored by clabby's avatar clabby

chore: fix

chore: fix

x
parent 45a7ab80
...@@ -717,32 +717,6 @@ jobs: ...@@ -717,32 +717,6 @@ jobs:
command: make fuzz command: make fuzz
working_directory: op-chain-ops working_directory: op-chain-ops
op-chain-ops-tests:
docker:
- image: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:latest
resource_class: xlarge
steps:
- checkout
- attach_workspace: { at: "." }
- restore_cache:
name: Restore PNPM Package Cache
keys:
- pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }}
- run:
name: prep results dir
command: mkdir -p /tmp/test-results
- run:
name: run tests
command: |
gotestsum --format=standard-verbose --junitfile=/tmp/test-results/op-chain-ops.xml \
-- -parallel=8 -coverpkg=github.com/ethereum-optimism/optimism/... -coverprofile=coverage.out ./...
working_directory: op-chain-ops
- run:
name: upload coverage
command: codecov --verbose --clean --flags bedrock-go-tests
- store_test_results:
path: /tmp/test-results
fuzz-cannon: fuzz-cannon:
docker: docker:
- image: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:latest - image: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:latest
...@@ -1257,10 +1231,6 @@ workflows: ...@@ -1257,10 +1231,6 @@ workflows:
- depcheck: - depcheck:
requires: requires:
- pnpm-monorepo - pnpm-monorepo
- op-chain-ops-tests:
name: op-chain-ops-tests
requires:
- pnpm-monorepo
- devnet: - devnet:
name: devnet (with deployed contracts) name: devnet (with deployed contracts)
deploy: true deploy: true
...@@ -1324,6 +1294,9 @@ workflows: ...@@ -1324,6 +1294,9 @@ workflows:
- go-test: - go-test:
name: op-bindings-tests name: op-bindings-tests
module: op-bindings module: op-bindings
- go-test:
name: op-chain-ops-tests
module: op-chain-ops
- go-test: - go-test:
name: op-node-tests name: op-node-tests
module: op-node module: op-node
...@@ -1362,6 +1335,7 @@ workflows: ...@@ -1362,6 +1335,7 @@ workflows:
- op-service-lint - op-service-lint
- op-batcher-tests - op-batcher-tests
- op-bindings-tests - op-bindings-tests
- op-chain-ops-tests
- op-node-tests - op-node-tests
- op-proposer-tests - op-proposer-tests
- op-challenger-tests - op-challenger-tests
......
...@@ -19,7 +19,6 @@ import ( ...@@ -19,7 +19,6 @@ import (
"github.com/ethereum/go-ethereum/eth/tracers/logger" "github.com/ethereum/go-ethereum/eth/tracers/logger"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/srcmap" "github.com/ethereum-optimism/optimism/op-chain-ops/srcmap"
) )
...@@ -38,19 +37,12 @@ func testContractsSetup(t require.TestingT) (*Contracts, *Addresses) { ...@@ -38,19 +37,12 @@ func testContractsSetup(t require.TestingT) (*Contracts, *Addresses) {
} }
func SourceMapTracer(t *testing.T, contracts *Contracts, addrs *Addresses) vm.EVMLogger { func SourceMapTracer(t *testing.T, contracts *Contracts, addrs *Addresses) vm.EVMLogger {
sources := bindings.Sources t.Fatal("TODO(clabby): The source map tracer is disabled until source IDs have been added to foundry artifacts.")
contractsDir := "../../packages/contracts-bedrock"
for i, source := range sources {
// Add relative path to contracts directory if the source is not
// already relativized.
if !strings.HasPrefix(source, "..") {
sources[i] = path.Join(contractsDir, source)
}
}
mipsSrcMap, err := contracts.MIPS.SourceMap(append([]string{path.Join(contractsDir, "src/cannon/MIPS.sol")}, sources...)) contractsDir := "../../packages/contracts-bedrock"
mipsSrcMap, err := contracts.MIPS.SourceMap([]string{path.Join(contractsDir, "src/cannon/MIPS.sol")})
require.NoError(t, err) require.NoError(t, err)
oracleSrcMap, err := contracts.Oracle.SourceMap(append([]string{path.Join(contractsDir, "src/cannon/PreimageOracle.sol")}, sources...)) oracleSrcMap, err := contracts.Oracle.SourceMap([]string{path.Join(contractsDir, "src/cannon/PreimageOracle.sol")})
require.NoError(t, err) require.NoError(t, err)
return srcmap.NewSourceMapTracer(map[common.Address]*srcmap.SourceMap{addrs.MIPS: mipsSrcMap, addrs.Oracle: oracleSrcMap}, os.Stdout) return srcmap.NewSourceMapTracer(map[common.Address]*srcmap.SourceMap{addrs.MIPS: mipsSrcMap, addrs.Oracle: oracleSrcMap}, os.Stdout)
......
...@@ -12,14 +12,13 @@ version: ...@@ -12,14 +12,13 @@ version:
compile: compile:
cd $(contracts-dir) && \ cd $(contracts-dir) && \
pnpm build --build-info pnpm build
bindings: compile bindings-build bindings: compile bindings-build
bindings-build: bindings-build:
go run ./gen/main.go \ go run ./gen/main.go \
-forge-artifacts $(contracts-dir)/forge-artifacts \ -forge-artifacts $(contracts-dir)/forge-artifacts \
-forge-build-info $(contracts-dir)/artifacts/build-info \
-out ./bindings \ -out ./bindings \
-contracts ./artifacts.json \ -contracts ./artifacts.json \
-source-maps MIPS,PreimageOracle \ -source-maps MIPS,PreimageOracle \
......
This diff is collapsed.
...@@ -15,12 +15,10 @@ import ( ...@@ -15,12 +15,10 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/ast" "github.com/ethereum-optimism/optimism/op-bindings/ast"
"github.com/ethereum-optimism/optimism/op-bindings/foundry" "github.com/ethereum-optimism/optimism/op-bindings/foundry"
"github.com/ethereum-optimism/optimism/op-bindings/hardhat"
) )
type flags struct { type flags struct {
ForgeArtifacts string ForgeArtifacts string
ForgeBuildInfo string
Contracts string Contracts string
SourceMaps string SourceMaps string
OutDir string OutDir string
...@@ -29,7 +27,6 @@ type flags struct { ...@@ -29,7 +27,6 @@ type flags struct {
} }
type data struct { type data struct {
SourceId uint
Name string Name string
StorageLayout string StorageLayout string
DeployedBin string DeployedBin string
...@@ -37,17 +34,9 @@ type data struct { ...@@ -37,17 +34,9 @@ type data struct {
DeployedSourceMap string DeployedSourceMap string
} }
type sourceIdData struct {
Package string
Sources []string
SourceToId map[string]uint
IdToSource map[uint]string
}
func main() { func main() {
var f flags var f flags
flag.StringVar(&f.ForgeArtifacts, "forge-artifacts", "", "Forge artifacts directory, to load sourcemaps from, if available") flag.StringVar(&f.ForgeArtifacts, "forge-artifacts", "", "Forge artifacts directory, to load sourcemaps from, if available")
flag.StringVar(&f.ForgeBuildInfo, "forge-build-info", "", "Forge build info directory, to load source IDs from, if available")
flag.StringVar(&f.OutDir, "out", "", "Output directory to put code in") flag.StringVar(&f.OutDir, "out", "", "Output directory to put code in")
flag.StringVar(&f.Contracts, "contracts", "artifacts.json", "Path to file containing list of contracts to generate bindings for") flag.StringVar(&f.Contracts, "contracts", "artifacts.json", "Path to file containing list of contracts to generate bindings for")
flag.StringVar(&f.SourceMaps, "source-maps", "", "Comma-separated list of contracts to generate source-maps for") flag.StringVar(&f.SourceMaps, "source-maps", "", "Comma-separated list of contracts to generate source-maps for")
...@@ -208,79 +197,6 @@ func main() { ...@@ -208,79 +197,6 @@ func main() {
outfile.Close() outfile.Close()
log.Printf("wrote file %s\n", outfile.Name()) log.Printf("wrote file %s\n", outfile.Name())
} }
mostRecentBuildInfo, err := getLargestInDir(f.ForgeBuildInfo)
if err != nil {
log.Fatalf("Error getting most recently modified build info file: %v", err)
}
buildInfoRaw, err := os.ReadFile(mostRecentBuildInfo)
if err != nil {
log.Fatalf("Error reading build info file: %v", err)
}
var buildInfo hardhat.BuildInfo
if err := json.Unmarshal(buildInfoRaw, &buildInfo); err != nil {
log.Fatalf("Error parsing build info file: %v", err)
}
sourceToId := make(map[string]uint)
idToSource := make(map[uint]string)
monorepoBase, err := filepath.Abs(f.MonorepoBase)
if err != nil {
log.Fatalf("Error getting absolute path of monorepo base: %v", err)
}
for k, v := range buildInfo.Output.Sources {
// Replace absolute monorepo base with relative path to monorepo root
k = strings.Replace(k, monorepoBase+"/", "../../", 1)
sourceToId[k] = v.Id
idToSource[v.Id] = k
}
fname := filepath.Join(f.OutDir, "source_ids.go")
outfile, err := os.OpenFile(
fname,
os.O_RDWR|os.O_CREATE|os.O_TRUNC,
0o600,
)
if err != nil {
log.Fatalf("error opening %s: %v\n", fname, err)
}
t = template.Must(template.New("source_ids").Parse(sourceIdTmpl))
d := sourceIdData{
Package: f.Package,
SourceToId: sourceToId,
IdToSource: idToSource,
}
if err := t.Execute(outfile, d); err != nil {
log.Fatalf("error writing template %s: %v", outfile.Name(), err)
}
outfile.Close()
log.Printf("wrote file %s\n", outfile.Name())
}
// getLargestInDir returns the path of the largest file in a directory.
func getLargestInDir(dirPath string) (string, error) {
var largestFile string
var largestSize int64
err := filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
// Check if the current path is a regular file and not a directory
if !info.IsDir() {
if info.Size() > largestSize {
largestFile = path
largestSize = info.Size()
}
}
return nil
})
return largestFile, err
} }
var tmpl = `// Code generated - DO NOT EDIT. var tmpl = `// Code generated - DO NOT EDIT.
...@@ -311,21 +227,3 @@ func init() { ...@@ -311,21 +227,3 @@ func init() {
deployedBytecodes["{{.Name}}"] = {{.Name}}DeployedBin deployedBytecodes["{{.Name}}"] = {{.Name}}DeployedBin
} }
` `
var sourceIdTmpl = `// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package {{.Package}}
var Sources = []string{
{{range $key, $value := .SourceToId}} "{{$key}}",
{{end}}}
var SourceToId = map[string]uint{
{{range $key, $value := .SourceToId}} "{{$key}}": {{$value}},
{{end}}}
var IdToSource = map[uint]string{
{{range $key, $value := .IdToSource}} {{$key}}: "{{$value}}",
{{end}}}
`
...@@ -12,15 +12,12 @@ import ( ...@@ -12,15 +12,12 @@ import (
) )
func TestSourcemap(t *testing.T) { func TestSourcemap(t *testing.T) {
t.Skip("TODO(clabby): This test is disabled until source IDs have been added to foundry artifacts.")
contractsDir := "../../packages/contracts-bedrock" contractsDir := "../../packages/contracts-bedrock"
sources := []string{path.Join(contractsDir, "src/cannon/MIPS.sol")} sources := []string{path.Join(contractsDir, "src/cannon/MIPS.sol")}
sources = append(sources, bindings.Sources...)
for i, source := range sources { for i, source := range sources {
// Add relative path to contracts directory if the source is not sources[i] = path.Join(contractsDir, source)
// already relativized.
if !strings.HasPrefix(source, "..") {
sources[i] = path.Join(contractsDir, source)
}
} }
deployedByteCode := hexutil.MustDecode(bindings.MIPSDeployedBin) deployedByteCode := hexutil.MustDecode(bindings.MIPSDeployedBin)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment