Skip to content

Commit

Permalink
refactor: remove unused contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcontracts committed Oct 1, 2021
1 parent 39eb838 commit bf09011
Show file tree
Hide file tree
Showing 109 changed files with 145 additions and 14,916 deletions.
115 changes: 0 additions & 115 deletions integration-tests/test/native-eth-ovm-calls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,120 +323,5 @@ describe('Native ETH value integration tests', () => {
expect(delegatedSuccess).to.be.true
expect(delegatedReturndata).to.deep.eq(BigNumber.from(value))
})

describe('Intrinsic gas for ovmCALL types', async () => {
let CALL_WITH_VALUE_INTRINSIC_GAS
let ValueGasMeasurer: Contract
before(async () => {
// Grab public variable from the EM
const OVM_ExecutionManager = new Contract(
await env.addressManager.getAddress('OVM_ExecutionManager'),
getContractInterface('OVM_ExecutionManager'),
env.l1Wallet.provider
)
const CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM =
await OVM_ExecutionManager.CALL_WITH_VALUE_INTRINSIC_GAS()
CALL_WITH_VALUE_INTRINSIC_GAS =
CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM.toNumber()

const Factory__ValueGasMeasurer = await ethers.getContractFactory(
'ValueGasMeasurer',
wallet
)
ValueGasMeasurer = await Factory__ValueGasMeasurer.deploy()
await ValueGasMeasurer.deployTransaction.wait()
})

it('a call with value to an empty account consumes <= the intrinsic gas including a buffer', async () => {
const value = 1
const gasLimit = 1_000_000
const minimalSendGas =
await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall(
ethers.constants.AddressZero,
value,
gasLimit,
{
gasLimit: 2_000_000,
}
)

const buffer = 1.2
expect(minimalSendGas * buffer).to.be.lte(CALL_WITH_VALUE_INTRINSIC_GAS)
})

it('a call with value to an reverting account consumes <= the intrinsic gas including a buffer', async () => {
// [magic deploy prefix] . [MSTORE] (will throw exception from no stack args)
const AutoRevertInitcode = '0x600D380380600D6000396000f3' + '52'
const Factory__AutoRevert = new ContractFactory(
new Interface([]),
AutoRevertInitcode,
wallet
)
const AutoRevert: Contract = await Factory__AutoRevert.deploy()
await AutoRevert.deployTransaction.wait()

const value = 1
const gasLimit = 1_000_000
// A revert, causing the ETH to be sent back, should consume the minimal possible gas for a nonzero ETH send
const minimalSendGas =
await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall(
AutoRevert.address,
value,
gasLimit,
{
gasLimit: 2_000_000,
}
)

const buffer = 1.2
expect(minimalSendGas * buffer).to.be.lte(CALL_WITH_VALUE_INTRINSIC_GAS)
})

it('a value call passing less than the intrinsic gas should appear to revert', async () => {
const Factory__PayableConstant: ContractFactory =
await ethers.getContractFactory('PayableConstant', wallet)
const PayableConstant: Contract =
await Factory__PayableConstant.deploy()
await PayableConstant.deployTransaction.wait()

const sendAmount = 15
const [success, returndata] =
await ValueCalls0.callStatic.sendWithDataAndGas(
PayableConstant.address,
sendAmount,
PayableConstant.interface.encodeFunctionData('returnValue'),
CALL_WITH_VALUE_INTRINSIC_GAS - 1,
{
gasLimit: 2_000_000,
}
)

expect(success).to.eq(false)
expect(returndata).to.eq('0x')
})

it('a value call which runs out of gas does not out-of-gas the parent', async () => {
const Factory__TestOOG: ContractFactory =
await ethers.getContractFactory('TestOOG', wallet)
const TestOOG: Contract = await Factory__TestOOG.deploy()
await TestOOG.deployTransaction.wait()

const sendAmount = 15
// Implicitly test that this call is not rejected
const [success, returndata] =
await ValueCalls0.callStatic.sendWithDataAndGas(
TestOOG.address,
sendAmount,
TestOOG.interface.encodeFunctionData('runOutOfGas'),
CALL_WITH_VALUE_INTRINSIC_GAS * 2,
{
gasLimit: 2_000_000,
}
)

expect(success).to.eq(false)
expect(returndata).to.eq('0x')
})
})
})
})
26 changes: 0 additions & 26 deletions l2geth/core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,20 +314,6 @@ func ApplyOvmStateToState(statedb *state.StateDB, stateDump *dump.OvmDump, l1XDo
l1BridgeValue := common.BytesToHash(l1StandardBridgeAddress.Bytes())
statedb.SetState(OVM_L2StandardBridge.Address, l1BridgeSlot, l1BridgeValue)
}
ExecutionManager, ok := stateDump.Accounts["OVM_ExecutionManager"]
if ok {
if chainID == nil {
chainID = new(big.Int)
}
log.Info("Setting ovmCHAINID in ExecutionManager", "chain-id", chainID.Uint64())
chainIdSlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000007")
chainIdValue := common.BytesToHash(chainID.Bytes())
statedb.SetState(ExecutionManager.Address, chainIdSlot, chainIdValue)
log.Info("Setting maxTransactionGasLimit in ExecutionManager", "gas-limit", gasLimit)
maxTxGasLimitSlot := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000004")
maxTxGasLimitValue := common.BytesToHash(new(big.Int).SetUint64(gasLimit).Bytes())
statedb.SetState(ExecutionManager.Address, maxTxGasLimitSlot, maxTxGasLimitValue)
}
OVM_SequencerFeeVault, ok := stateDump.Accounts["OVM_SequencerFeeVault"]
if ok {
log.Info("Setting l1FeeWallet in OVM_SequencerFeeVault", "wallet", l1FeeWalletAddress.Hex())
Expand Down Expand Up @@ -514,18 +500,6 @@ func DeveloperGenesisBlock(period uint64, faucet, l1XDomainMessengerAddress comm
if !ok {
panic("Lib_AddressManager not in state dump")
}
_, ok = stateDump.Accounts["OVM_StateManager"]
if !ok {
panic("OVM_StateManager not in state dump")
}
_, ok = stateDump.Accounts["OVM_ExecutionManager"]
if !ok {
panic("OVM_ExecutionManager not in state dump")
}
_, ok = stateDump.Accounts["OVM_SequencerEntrypoint"]
if !ok {
panic("OVM_SequencerEntrypoint not in state dump")
}
}
config.StateDump = &stateDump

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ describe('BatchSubmitter', () => {
'OVM_Sequencer',
await sequencer.getAddress()
)
await AddressManager.setAddress(
'OVM_DecompressionPrecompileAddress',
predeploys.OVM_SequencerEntrypoint
)

Mock__OVM_ExecutionManager = await smockit(
await getContractFactory('OVM_ExecutionManager')
Expand Down
12 changes: 0 additions & 12 deletions packages/contracts/bin/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ const parseEnv = () => {
'number'
),
ctcMaxTransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'),
emMinTransactionGasLimit: ensure('MIN_TRANSACTION_GAS_LIMIT', 'number'),
emMaxtransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'),
emMaxGasPerQueuePerEpoch: ensure('MAX_GAS_PER_QUEUE_PER_EPOCH', 'number'),
emSecondsPerEpoch: ensure('ECONDS_PER_EPOCH', 'number'),
emOvmChainId: ensure('CHAIN_ID', 'number'),
sccFraudProofWindow: ensure('FRAUD_PROOF_WINDOW_SECONDS', 'number'),
sccSequencerPublishWindow: ensure(
'SEQUENCER_PUBLISH_WINDOW_SECONDS',
Expand All @@ -56,16 +51,10 @@ const main = async () => {
l1BlockTimeSeconds: config.l1BlockTimeSeconds,
ctcForceInclusionPeriodSeconds: config.ctcForceInclusionPeriodSeconds,
ctcMaxTransactionGasLimit: config.ctcMaxTransactionGasLimit,
emMinTransactionGasLimit: config.emMinTransactionGasLimit,
emMaxtransactionGasLimit: config.emMaxtransactionGasLimit,
emMaxGasPerQueuePerEpoch: config.emMaxGasPerQueuePerEpoch,
emSecondsPerEpoch: config.emSecondsPerEpoch,
emOvmChainId: config.emOvmChainId,
sccFraudProofWindow: config.sccFraudProofWindow,
sccSequencerPublishWindow: config.sccFraudProofWindow,
ovmSequencerAddress: sequencer.address,
ovmProposerAddress: sequencer.address,
ovmRelayerAddress: sequencer.address,
ovmAddressManagerOwner: deployer.address,
noCompile: process.env.NO_COMPILE ? true : false,
})
Expand All @@ -75,7 +64,6 @@ const main = async () => {
// get the hardhat-deploy stuff merged. Woot.
const nicknames = {
Lib_AddressManager: 'AddressManager',
mockOVM_BondManager: 'OVM_BondManager',
}

const contracts: any = dirtree(
Expand Down
65 changes: 0 additions & 65 deletions packages/contracts/bin/gen_safety_checker_constants.py

This file was deleted.

4 changes: 0 additions & 4 deletions packages/contracts/bin/take-dump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as path from 'path'
import * as mkdirp from 'mkdirp'

const env = process.env
const CHAIN_ID = env.CHAIN_ID || '420'
const GAS_PRICE_ORACLE_OWNER =
env.GAS_PRICE_ORACLE_OWNER || '0x' + 'FF'.repeat(20)

Expand All @@ -17,9 +16,6 @@ import { RollupDeployConfig } from '../src/contract-deployment'
mkdirp.sync(outdir)

const config = {
ovmGlobalContext: {
ovmCHAINID: parseInt(CHAIN_ID, 10),
},
gasPriceOracleConfig: {
owner: GAS_PRICE_ORACLE_OWNER,
initialGasPrice: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { ReentrancyGuardUpgradeable } from
* from L2 onto L1. In the event that a message sent from L1 to L2 is rejected for exceeding the L2
* epoch gas limit, it can be resubmitted via this contract's replay function.
*
* Compiler used: solc
* Runtime target: EVM
*/
contract OVM_L1CrossDomainMessenger is
Expand Down Expand Up @@ -209,13 +208,12 @@ contract OVM_L1CrossDomainMessenger is
nonce
);

address l2CrossDomainMessenger = resolve("OVM_L2CrossDomainMessenger");
_sendXDomainMessage(
ovmCanonicalTransactionChain,
l2CrossDomainMessenger,
xDomainCalldata,
_gasLimit
);

emit SentMessage(xDomainCalldata);
}

Expand Down Expand Up @@ -312,12 +310,11 @@ contract OVM_L1CrossDomainMessenger is
Lib_OVMCodec.QueueElement memory element =
iOVM_CanonicalTransactionChain(canonicalTransactionChain).getQueueElement(_queueIndex);

address l2CrossDomainMessenger = resolve("OVM_L2CrossDomainMessenger");
// Compute the transactionHash
bytes32 transactionHash = keccak256(
abi.encode(
address(this),
l2CrossDomainMessenger,
Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER,
_gasLimit,
_message
)
Expand All @@ -337,7 +334,6 @@ contract OVM_L1CrossDomainMessenger is

_sendXDomainMessage(
canonicalTransactionChain,
l2CrossDomainMessenger,
xDomainCalldata,
_gasLimit
);
Expand Down Expand Up @@ -419,7 +415,7 @@ contract OVM_L1CrossDomainMessenger is
keccak256(
abi.encodePacked(
_xDomainCalldata,
resolve("OVM_L2CrossDomainMessenger")
Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER
)
),
uint256(0)
Expand Down Expand Up @@ -455,20 +451,18 @@ contract OVM_L1CrossDomainMessenger is
/**
* Sends a cross domain message.
* @param _canonicalTransactionChain Address of the OVM_CanonicalTransactionChain instance.
* @param _l2CrossDomainMessenger Address of the OVM_L2CrossDomainMessenger instance.
* @param _message Message to send.
* @param _gasLimit OVM gas limit for the message.
*/
function _sendXDomainMessage(
address _canonicalTransactionChain,
address _l2CrossDomainMessenger,
bytes memory _message,
uint256 _gasLimit
)
internal
{
iOVM_CanonicalTransactionChain(_canonicalTransactionChain).enqueue(
_l2CrossDomainMessenger,
Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER,
_gasLimit,
_message
);
Expand Down

0 comments on commit bf09011

Please sign in to comment.