Commit 63b4f0cd authored by Karl Floersch's avatar Karl Floersch

Merge branch 'feat/freeze' of github.com:ethereum-optimism/contracts-v2 into feat/pointer-queue

parents 726dd197 333d4cfc
# Optimism's Contracts (V2) # Optimism's Contracts (V2)
This package contains the various Ethereum smart contracts that make up the Layer 1 component of Optimism's Optimistic Rollup construction. This package contains the various Ethereum smart contracts that make up the Layer 1 component of Optimism's Optimistic Rollup construction.
## Building and Running
This package requires that `yarn` be installed on your machine! Once it is, run `yarn test` to build and run tests.
## Disclaimer ## Disclaimer
......
...@@ -729,7 +729,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -729,7 +729,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
) )
override override
public public
{ {
// Since this function is public, anyone can attempt to directly call it. We need to make // Since this function is public, anyone can attempt to directly call it. We need to make
// sure that the OVM_ExecutionManager itself is the only party that can actually try to // sure that the OVM_ExecutionManager itself is the only party that can actually try to
// call this function. // call this function.
...@@ -871,10 +871,16 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -871,10 +871,16 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
bytes memory _returndata bytes memory _returndata
) )
{ {
// EVM precompiles have the same address on L1 and L2 --> no trie lookup neededgit s.
address codeContractAddress =
uint(_contract) < 100
? _contract
: _getAccountEthAddress(_contract)
return _handleExternalInteraction( return _handleExternalInteraction(
_nextMessageContext, _nextMessageContext,
_gasLimit, _gasLimit,
_getAccountEthAddress(_contract), codeContractAddress,
_calldata, _calldata,
_isStaticEntrypoint _isStaticEntrypoint
); );
......
...@@ -17,12 +17,12 @@ import { OVM_BaseQueue } from "./OVM_BaseQueue.sol"; ...@@ -17,12 +17,12 @@ import { OVM_BaseQueue } from "./OVM_BaseQueue.sol";
*/ */
contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueue, Lib_AddressResolver { contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueue, Lib_AddressResolver {
/*************************************************
* Contract Variables: Transaction Restrinctions *
*************************************************/
/********************************* uint constant MAX_ROLLUP_TX_SIZE = 10000;
* Contract Variables: Constants * uint constant L2_GAS_DISCOUNT_DIVISOR = 10;
********************************/
uint constant public L2_GAS_DISCOUNT_DIVISOR = 10;
/******************************************* /*******************************************
* Contract Variables: Contract References * * Contract Variables: Contract References *
...@@ -66,10 +66,14 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu ...@@ -66,10 +66,14 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu
public public
{ {
require(_gasLimit >= 20000, "Gas limit too low."); require(_gasLimit >= 20000, "Gas limit too low.");
uint gasToBurn = _gasLimit / L2_GAS_DISCOUNT_DIVISOR; require(
_data.length <= MAX_ROLLUP_TX_SIZE,
"Transaction exceeds maximum rollup data size."
);
uint gasToConsume = _gasLimit/L2_GAS_DISCOUNT_DIVISOR;
uint startingGas = gasleft(); uint startingGas = gasleft();
uint i; uint i;
while(startingGas - gasleft() > gasToBurn) { while(startingGas - gasleft() > gasToConsume) {
i++; // TODO: Replace this dumb work with minting gas token. i++; // TODO: Replace this dumb work with minting gas token.
} }
...@@ -100,4 +104,21 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu ...@@ -100,4 +104,21 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu
_dequeue(); _dequeue();
} }
/***************************************
* External Functions: Gas Consumption *
***************************************/
/**
* Consumes all gas provided.
* Note: this is an external function, but is only called by self.
*/
function consumeAllGasProvided()
external
{
assembly {
invalid()
}
}
} }
...@@ -31,7 +31,7 @@ const makeQueueElements = (count: number): any => { ...@@ -31,7 +31,7 @@ const makeQueueElements = (count: number): any => {
return [...Array(count)].map((el, idx) => { return [...Array(count)].map((el, idx) => {
return { return {
target: NON_ZERO_ADDRESS, target: NON_ZERO_ADDRESS,
gasLimit: (idx + 1) * 20000, gasLimit: idx + 30_000,
data: DUMMY_BYTES32[0], data: DUMMY_BYTES32[0],
} }
}) })
......
...@@ -176,6 +176,7 @@ export const isTestStep_Context = ( ...@@ -176,6 +176,7 @@ export const isTestStep_Context = (
'ovmCALLER', 'ovmCALLER',
'ovmNUMBER', 'ovmNUMBER',
'ovmADDRESS', 'ovmADDRESS',
'ovmNUMBER',
'ovmL1TXORIGIN', 'ovmL1TXORIGIN',
'ovmTIMESTAMP', 'ovmTIMESTAMP',
'ovmGASLIMIT', 'ovmGASLIMIT',
......
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