Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
26f508cc
Unverified
Commit
26f508cc
authored
Jan 08, 2025
by
Michael Amadi
Committed by
GitHub
Jan 08, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transition snapshots script to common framework (#13398)
parent
b62e7740
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
161 additions
and
225 deletions
+161
-225
types.go
op-chain-ops/solc/types.go
+24
-3
main.go
...tracts-bedrock/scripts/autogen/generate-snapshots/main.go
+87
-198
util.go
packages/contracts-bedrock/scripts/checks/common/util.go
+22
-4
main.go
packages/contracts-bedrock/scripts/checks/test-names/main.go
+2
-2
main_test.go
.../contracts-bedrock/scripts/checks/test-names/main_test.go
+26
-18
No files found.
op-chain-ops/solc/types.go
View file @
26f508cc
package
solc
import
(
"encoding/json"
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi"
)
type
AbiType
struct
{
Parsed
abi
.
ABI
Raw
interface
{}
}
func
(
a
*
AbiType
)
UnmarshalJSON
(
data
[]
byte
)
error
{
if
err
:=
json
.
Unmarshal
(
data
,
&
a
.
Raw
);
err
!=
nil
{
return
err
}
return
json
.
Unmarshal
(
data
,
&
a
.
Parsed
)
}
type
CompilerInput
struct
{
Language
string
`json:"language"`
Sources
map
[
string
]
map
[
string
]
string
`json:"sources"`
...
...
@@ -39,7 +52,7 @@ type CompilerOutputContracts map[string]CompilerOutputContract
// CompilerOutputContract represents the solc compiler output for a contract.
// Ignoring some fields such as devdoc and userdoc.
type
CompilerOutputContract
struct
{
Abi
abi
.
ABI
`json:"abi"`
Abi
AbiType
`json:"abi"`
Evm
CompilerOutputEvm
`json:"evm"`
Metadata
string
`json:"metadata"`
StorageLayout
StorageLayout
`json:"storageLayout"`
...
...
@@ -72,6 +85,14 @@ func (s *StorageLayout) GetStorageLayoutType(name string) (StorageLayoutType, er
return
StorageLayoutType
{},
fmt
.
Errorf
(
"%s not found"
,
name
)
}
type
AbiSpecStorageLayoutEntry
struct
{
Bytes
uint
`json:"bytes,string"`
Label
string
`json:"label"`
Offset
uint
`json:"offset"`
Slot
uint
`json:"slot,string"`
Type
string
`json:"type"`
}
type
StorageLayoutEntry
struct
{
AstId
uint
`json:"astId"`
Contract
string
`json:"contract"`
...
...
@@ -241,7 +262,7 @@ type Expression struct {
}
type
ForgeArtifact
struct
{
Abi
abi
.
ABI
`json:"abi"`
Abi
AbiType
`json:"abi"`
Bytecode
CompilerOutputBytecode
`json:"bytecode"`
DeployedBytecode
CompilerOutputBytecode
`json:"deployedBytecode"`
MethodIdentifiers
map
[
string
]
string
`json:"methodIdentifiers"`
...
...
@@ -266,7 +287,7 @@ type ForgeCompilerInfo struct {
}
type
ForgeMetadataOutput
struct
{
Abi
abi
.
ABI
`json:"abi"`
Abi
AbiType
`json:"abi"`
DevDoc
ForgeDocObject
`json:"devdoc"`
UserDoc
ForgeDocObject
`json:"userdoc"`
}
...
...
packages/contracts-bedrock/scripts/autogen/generate-snapshots/main.go
View file @
26f508cc
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/scripts/checks/common/util.go
View file @
26f508cc
package
common
import
(
"bytes"
"encoding/json"
"fmt"
"os"
"path/filepath"
"runtime"
"sync"
"sync/atomic"
...
...
@@ -100,8 +100,7 @@ func FindFiles(includes, excludes []string) (map[string]string, error) {
return
nil
,
fmt
.
Errorf
(
"glob pattern error: %w"
,
err
)
}
for
_
,
match
:=
range
matches
{
name
:=
filepath
.
Base
(
match
)
included
[
name
]
=
match
included
[
match
]
=
match
}
}
...
...
@@ -112,7 +111,7 @@ func FindFiles(includes, excludes []string) (map[string]string, error) {
return
nil
,
fmt
.
Errorf
(
"glob pattern error: %w"
,
err
)
}
for
_
,
match
:=
range
matches
{
excluded
[
filepath
.
Base
(
match
)
]
=
struct
{}{}
excluded
[
match
]
=
struct
{}{}
}
}
...
...
@@ -137,3 +136,22 @@ func ReadForgeArtifact(path string) (*solc.ForgeArtifact, error) {
return
&
artifact
,
nil
}
func
WriteJSON
(
data
interface
{},
path
string
)
error
{
var
out
bytes
.
Buffer
enc
:=
json
.
NewEncoder
(
&
out
)
enc
.
SetEscapeHTML
(
false
)
enc
.
SetIndent
(
""
,
" "
)
err
:=
enc
.
Encode
(
data
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to encode data: %w"
,
err
)
}
jsonData
:=
out
.
Bytes
()
if
len
(
jsonData
)
>
0
&&
jsonData
[
len
(
jsonData
)
-
1
]
==
'\n'
{
// strip newline
jsonData
=
jsonData
[
:
len
(
jsonData
)
-
1
]
}
if
err
:=
os
.
WriteFile
(
path
,
jsonData
,
0644
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to write file: %w"
,
err
)
}
return
nil
}
packages/contracts-bedrock/scripts/checks/test-names/main.go
View file @
26f508cc
...
...
@@ -41,7 +41,7 @@ func processFile(path string) (*common.Void, []error) {
func
extractTestNames
(
artifact
*
solc
.
ForgeArtifact
)
[]
string
{
isTest
:=
false
for
_
,
entry
:=
range
artifact
.
Abi
.
Methods
{
for
_
,
entry
:=
range
artifact
.
Abi
.
Parsed
.
Methods
{
if
entry
.
Name
==
"IS_TEST"
{
isTest
=
true
break
...
...
@@ -52,7 +52,7 @@ func extractTestNames(artifact *solc.ForgeArtifact) []string {
}
names
:=
[]
string
{}
for
_
,
entry
:=
range
artifact
.
Abi
.
Methods
{
for
_
,
entry
:=
range
artifact
.
Abi
.
Parsed
.
Methods
{
if
!
strings
.
HasPrefix
(
entry
.
Name
,
"test"
)
{
continue
}
...
...
packages/contracts-bedrock/scripts/checks/test-names/main_test.go
View file @
26f508cc
...
...
@@ -218,13 +218,15 @@ func TestExtractTestNames(t *testing.T) {
{
name
:
"valid test contract"
,
artifact
:
&
solc
.
ForgeArtifact
{
Abi
:
abi
.
ABI
{
Methods
:
map
[
string
]
abi
.
Method
{
"IS_TEST"
:
{
Name
:
"IS_TEST"
},
"test_something_succeeds"
:
{
Name
:
"test_something_succeeds"
},
"test_other_fails"
:
{
Name
:
"test_other_fails"
},
"not_a_test"
:
{
Name
:
"not_a_test"
},
"testFuzz_something_works"
:
{
Name
:
"testFuzz_something_works"
},
Abi
:
solc
.
AbiType
{
Parsed
:
abi
.
ABI
{
Methods
:
map
[
string
]
abi
.
Method
{
"IS_TEST"
:
{
Name
:
"IS_TEST"
},
"test_something_succeeds"
:
{
Name
:
"test_something_succeeds"
},
"test_other_fails"
:
{
Name
:
"test_other_fails"
},
"not_a_test"
:
{
Name
:
"not_a_test"
},
"testFuzz_something_works"
:
{
Name
:
"testFuzz_something_works"
},
},
},
},
},
...
...
@@ -237,10 +239,12 @@ func TestExtractTestNames(t *testing.T) {
{
name
:
"non-test contract"
,
artifact
:
&
solc
.
ForgeArtifact
{
Abi
:
abi
.
ABI
{
Methods
:
map
[
string
]
abi
.
Method
{
"test_something_succeeds"
:
{
Name
:
"test_something_succeeds"
},
"not_a_test"
:
{
Name
:
"not_a_test"
},
Abi
:
solc
.
AbiType
{
Parsed
:
abi
.
ABI
{
Methods
:
map
[
string
]
abi
.
Method
{
"test_something_succeeds"
:
{
Name
:
"test_something_succeeds"
},
"not_a_test"
:
{
Name
:
"not_a_test"
},
},
},
},
},
...
...
@@ -249,8 +253,10 @@ func TestExtractTestNames(t *testing.T) {
{
name
:
"empty contract"
,
artifact
:
&
solc
.
ForgeArtifact
{
Abi
:
abi
.
ABI
{
Methods
:
map
[
string
]
abi
.
Method
{},
Abi
:
solc
.
AbiType
{
Parsed
:
abi
.
ABI
{
Methods
:
map
[
string
]
abi
.
Method
{},
},
},
},
want
:
nil
,
...
...
@@ -258,11 +264,13 @@ func TestExtractTestNames(t *testing.T) {
{
name
:
"test contract with no test methods"
,
artifact
:
&
solc
.
ForgeArtifact
{
Abi
:
abi
.
ABI
{
Methods
:
map
[
string
]
abi
.
Method
{
"IS_TEST"
:
{
Name
:
"IS_TEST"
},
"not_a_test"
:
{
Name
:
"not_a_test"
},
"another_method"
:
{
Name
:
"another_method"
},
Abi
:
solc
.
AbiType
{
Parsed
:
abi
.
ABI
{
Methods
:
map
[
string
]
abi
.
Method
{
"IS_TEST"
:
{
Name
:
"IS_TEST"
},
"not_a_test"
:
{
Name
:
"not_a_test"
},
"another_method"
:
{
Name
:
"another_method"
},
},
},
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment