Commit 0d429564 authored by Mark Tyneway's avatar Mark Tyneway

l2geth: config enable arbitrary contract deployment

Add a new config option `ROLLUP_ENABLE_ARBITRARY_CONTRACT_DEPLOYMENT`.
This config option must be set with an env var, there is no flag to
set it with.

If it is not set, the functionality is unchanged. If it is set, then it
will override the function `isDeployerAllowed(address)` on the
`OVM_DeployerWhitelist`
parent 0a7f99d0
---
'@eth-optimism/l2geth': patch
---
Add ROLLUP_ENABLE_ARBITRARY_CONTRACT_DEPLOYMENT_FLAG
......@@ -135,6 +135,24 @@ func run(evm *EVM, contract *Contract, input []byte, readOnly bool) ([]byte, err
}
return callStateManager(input, evm, contract)
}
// Only in the case where EnableArbitraryContractDeployment is
// set, allows codepath to be skipped when it is not set
if EnableArbitraryContractDeployment != nil {
// When the address manager is called
if contract.Address() == WhitelistAddress {
// If the first four bytes match `isDeployerAllowed(address)`
if bytes.Equal(input[0:4], isDeployerAllowedSig) {
// Already checked to make sure this value is not nil
switch *EnableArbitraryContractDeployment {
case EnableArbitraryContractDeploymentTrue:
return AbiBytesTrue, nil
case EnableArbitraryContractDeploymentFalse:
return AbiBytesFalse, nil
}
}
}
}
}
if contract.CodeAddr != nil {
......
package vm
import (
"fmt"
"os"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
// AbiBytesTrue represents the ABI encoding of "true" as a byte slice
var AbiBytesTrue = common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000001")
var (
// AbiBytesTrue represents the ABI encoding of "true" as a byte slice
AbiBytesTrue = common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000001")
// AbiBytesFalse represents the ABI encoding of "false" as a byte slice
var AbiBytesFalse = common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000")
// AbiBytesFalse represents the ABI encoding of "false" as a byte slice
AbiBytesFalse = common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000")
// UsingOVM is used to enable or disable functionality necessary for the OVM.
var UsingOVM bool
// UsingOVM is used to enable or disable functionality necessary for the OVM.
UsingOVM bool
// EnableArbitraryContractDeployment is used to override the
// deployer whitelist
EnableArbitraryContractDeployment *bool
// These are aliases to the pointer EnableArbitraryContractDeployment
EnableArbitraryContractDeploymentTrue bool = true
EnableArbitraryContractDeploymentFalse bool = false
WhitelistAddress = common.HexToAddress("0x4200000000000000000000000000000000000002")
isDeployerAllowedSig = crypto.Keccak256([]byte("isDeployerAllowed(address)"))[:4]
)
func init() {
UsingOVM = os.Getenv("USING_OVM") == "true"
value := os.Getenv("ROLLUP_ENABLE_ARBITRARY_CONTRACT_DEPLOYMENT")
if value != "" {
switch value {
case "true":
EnableArbitraryContractDeployment = &EnableArbitraryContractDeploymentTrue
case "false":
EnableArbitraryContractDeployment = &EnableArbitraryContractDeploymentFalse
default:
panic(fmt.Sprintf("Unknown ROLLUP_ENABLE_ARBITRARY_CONTRACT_DEPLOYMENT value: %s", value))
}
}
}
......@@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
......@@ -142,6 +143,10 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
cfg.MinL2GasLimit = value
}
if vm.EnableArbitraryContractDeployment != nil {
log.Info("Setting arbitrary contract deployment", "value", *vm.EnableArbitraryContractDeployment)
}
service := SyncService{
ctx: ctx,
cancel: cancel,
......
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