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
91349655
Commit
91349655
authored
Jan 25, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Semgrep + README
parent
0d86b084
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
README.md
op-chain-ops/eof-crawler/README.md
+2
-0
eof_crawler.go
op-chain-ops/eof-crawler/eof_crawler.go
+8
-4
No files found.
op-chain-ops/eof-crawler/README.md
View file @
91349655
...
...
@@ -4,6 +4,8 @@ Simple CLI tool to scan all accounts in a geth LevelDB for contracts that begin
## Usage
1.
Pass the directory of the Geth DB into the tool
```
sh
go run eof_crawler.go <db_path>
```
2.
Once the indexing has completed, an array of all EOF-prefixed contracts will be written to
`eof_contracts.json`
.
op-chain-ops/eof-crawler/eof_crawler.go
View file @
91349655
...
...
@@ -3,7 +3,6 @@ package main
import
(
"bytes"
"encoding/json"
"io/ioutil"
"log"
"os"
"time"
...
...
@@ -69,7 +68,10 @@ func main() {
for
it
.
Next
()
{
// Decode the state account
var
data
types
.
StateAccount
rlp
.
DecodeBytes
(
it
.
Value
,
&
data
)
err
:=
rlp
.
DecodeBytes
(
it
.
Value
,
&
data
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to decode state account: %v"
,
err
)
}
// Check to see if the account has any code associated with it before performing
// more reads from the trie & db.
...
...
@@ -100,7 +102,6 @@ func main() {
code
,
err
:=
stateDB
.
ContractCode
(
crypto
.
Keccak256Hash
(
addrBytes
),
common
.
BytesToHash
(
data
.
CodeHash
))
if
err
!=
nil
{
log
.
Fatalf
(
"Could not load code for account %x: %v"
,
addr
,
err
)
continue
}
// Check if the contract's runtime bytecode starts with the EOF prefix.
...
...
@@ -125,7 +126,10 @@ func main() {
if
err
!=
nil
{
log
.
Fatalf
(
"Cannot marshal EOF contracts: %v"
,
err
)
}
err
=
ioutil
.
WriteFile
(
"eof_contracts.json"
,
file
,
0644
)
err
=
os
.
WriteFile
(
"eof_contracts.json"
,
file
,
0644
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to write EOF contracts array to file: %v"
,
err
)
}
log
.
Printf
(
"Wrote list of EOF contracts to `eof_contracts.json`"
)
}
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