Commit ad4a4ff2 authored by Mark Tyneway's avatar Mark Tyneway

op-wheel: add cheat code command

Allows it to set into the state arbitrary code at an arbitrary account.
This will make it very easy to patch contracts that contain immutables.
Then we can patch the contracts to have different immutables without
needing to update the proxies and worry about that.

We can also cheat the impl of the multisig to be a call forwarder so
that we do not need to cheat so many storage slots and forget about
particular slots.
parent ce94c644
...@@ -379,6 +379,13 @@ func SetBalance(addr common.Address, amount *big.Int) HeadFn { ...@@ -379,6 +379,13 @@ func SetBalance(addr common.Address, amount *big.Int) HeadFn {
} }
} }
func SetCode(addr common.Address, code string) HeadFn {
return func(headState *state.StateDB) error {
headState.SetCode(addr, common.FromHex(code))
return nil
}
}
func SetNonce(addr common.Address, nonce uint64) HeadFn { func SetNonce(addr common.Address, nonce uint64) HeadFn {
return func(headState *state.StateDB) error { return func(headState *state.StateDB) error {
headState.SetNonce(addr, nonce) headState.SetNonce(addr, nonce)
......
...@@ -271,6 +271,17 @@ var ( ...@@ -271,6 +271,17 @@ var (
return ch.RunAndClose(cheat.SetBalance(addrFlagValue("address", ctx), bigFlagValue("balance", ctx))) 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"),
cli.StringFlag{Name: "code", Usage: "New code of the account"},
},
Action: CheatAction(false, func(ctx *cli.Context, ch *cheat.Cheater) error {
return ch.RunAndClose(cheat.SetCode(addrFlagValue("address", ctx), ctx.String("code")))
}),
}
CheatSetNonceCmd = cli.Command{ CheatSetNonceCmd = cli.Command{
Name: "nonce", Name: "nonce",
Flags: []cli.Flag{ Flags: []cli.Flag{
...@@ -440,6 +451,7 @@ var CheatCmd = cli.Command{ ...@@ -440,6 +451,7 @@ var CheatCmd = cli.Command{
Subcommands: []cli.Command{ Subcommands: []cli.Command{
CheatStorageCmd, CheatStorageCmd,
CheatSetBalanceCmd, CheatSetBalanceCmd,
CheatSetCodeCmd,
CheatSetNonceCmd, CheatSetNonceCmd,
CheatOvmOwnersCmd, CheatOvmOwnersCmd,
CheatPrintHeadBlock, CheatPrintHeadBlock,
......
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