Commit 16bc3e3a authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #1457 from ethereum-optimism/hotfix/enable-arbitrary-contract-deployment

l2geth: config enable arbitrary contract deployment
parents 769896d2 0d429564
---
'@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 ...@@ -135,6 +135,24 @@ func run(evm *EVM, contract *Contract, input []byte, readOnly bool) ([]byte, err
} }
return callStateManager(input, evm, contract) 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 { if contract.CodeAddr != nil {
......
package vm package vm
import ( import (
"fmt"
"os" "os"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
) )
// AbiBytesTrue represents the ABI encoding of "true" as a byte slice var (
var AbiBytesTrue = common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000001") // 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 // AbiBytesFalse represents the ABI encoding of "false" as a byte slice
var AbiBytesFalse = common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000") AbiBytesFalse = common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000")
// UsingOVM is used to enable or disable functionality necessary for the OVM. // UsingOVM is used to enable or disable functionality necessary for the OVM.
var UsingOVM bool 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() { func init() {
UsingOVM = os.Getenv("USING_OVM") == "true" 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 ( ...@@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state" "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/ethdb"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
...@@ -142,6 +143,10 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co ...@@ -142,6 +143,10 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
cfg.MinL2GasLimit = value cfg.MinL2GasLimit = value
} }
if vm.EnableArbitraryContractDeployment != nil {
log.Info("Setting arbitrary contract deployment", "value", *vm.EnableArbitraryContractDeployment)
}
service := SyncService{ service := SyncService{
ctx: ctx, ctx: ctx,
cancel: cancel, 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