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
ebae25b4
Unverified
Commit
ebae25b4
authored
May 31, 2023
by
OptimismBot
Committed by
GitHub
May 31, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5848 from ethereum-optimism/feat/op-wheel-set-code
op-wheel: add cheat code command
parents
6b44bcbc
36974c15
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
cheat.go
op-wheel/cheat/cheat.go
+8
-0
commands.go
op-wheel/commands.go
+21
-0
No files found.
op-wheel/cheat/cheat.go
View file @
ebae25b4
...
...
@@ -14,6 +14,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/beacon"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
...
...
@@ -379,6 +380,13 @@ func SetBalance(addr common.Address, amount *big.Int) HeadFn {
}
}
func
SetCode
(
addr
common
.
Address
,
code
hexutil
.
Bytes
)
HeadFn
{
return
func
(
headState
*
state
.
StateDB
)
error
{
headState
.
SetCode
(
addr
,
code
)
return
nil
}
}
func
SetNonce
(
addr
common
.
Address
,
nonce
uint64
)
HeadFn
{
return
func
(
headState
*
state
.
StateDB
)
error
{
headState
.
SetNonce
(
addr
,
nonce
)
...
...
op-wheel/commands.go
View file @
ebae25b4
...
...
@@ -12,6 +12,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/rpc"
...
...
@@ -179,6 +180,10 @@ func addrFlag(name string, usage string) cli.GenericFlag {
return
textFlag
[
*
common
.
Address
](
name
,
usage
,
new
(
common
.
Address
))
}
func
bytesFlag
(
name
string
,
usage
string
)
cli
.
GenericFlag
{
return
textFlag
[
*
hexutil
.
Bytes
](
name
,
usage
,
new
(
hexutil
.
Bytes
))
}
func
hashFlag
(
name
string
,
usage
string
)
cli
.
GenericFlag
{
return
textFlag
[
*
common
.
Hash
](
name
,
usage
,
new
(
common
.
Hash
))
}
...
...
@@ -191,6 +196,10 @@ func addrFlagValue(name string, ctx *cli.Context) common.Address {
return
*
ctx
.
Generic
(
name
)
.
(
*
TextFlag
[
*
common
.
Address
])
.
Value
}
func
bytesFlagValue
(
name
string
,
ctx
*
cli
.
Context
)
hexutil
.
Bytes
{
return
*
ctx
.
Generic
(
name
)
.
(
*
TextFlag
[
*
hexutil
.
Bytes
])
.
Value
}
func
hashFlagValue
(
name
string
,
ctx
*
cli
.
Context
)
common
.
Hash
{
return
*
ctx
.
Generic
(
name
)
.
(
*
TextFlag
[
*
common
.
Hash
])
.
Value
}
...
...
@@ -271,6 +280,17 @@ var (
return
ch
.
RunAndClose
(
cheat
.
SetBalance
(
addrFlagValue
(
"address"
,
ctx
),
bigFlagValue
(
"balance"
,
ctx
)))
}),
}
CheatSetCodeCmd
=
cli
.
Command
{
Name
:
"code"
,
Flags
:
[]
cli
.
Flag
{
DataDirFlag
,
addrFlag
(
"address"
,
"Address to change code of"
),
bytesFlag
(
"code"
,
"New code of the account"
),
},
Action
:
CheatAction
(
false
,
func
(
ctx
*
cli
.
Context
,
ch
*
cheat
.
Cheater
)
error
{
return
ch
.
RunAndClose
(
cheat
.
SetCode
(
addrFlagValue
(
"address"
,
ctx
),
bytesFlagValue
(
"code"
,
ctx
)))
}),
}
CheatSetNonceCmd
=
cli
.
Command
{
Name
:
"nonce"
,
Flags
:
[]
cli
.
Flag
{
...
...
@@ -440,6 +460,7 @@ var CheatCmd = cli.Command{
Subcommands
:
[]
cli
.
Command
{
CheatStorageCmd
,
CheatSetBalanceCmd
,
CheatSetCodeCmd
,
CheatSetNonceCmd
,
CheatOvmOwnersCmd
,
CheatPrintHeadBlock
,
...
...
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