Commit 59ae29f4 authored by Victor Shih's avatar Victor Shih Committed by GitHub

fix: Clear Compiler Warnings (#322)

* fix Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.

* fix: shadows another variable error

* fix: Warning: Visibility for constructor is ignored.

* fix: unused local variable warning

* fix: Warning: Function state mutability can be restricted to pure

* Warning: Return value of low-level calls not used.

* fix: Warning: Unnamed return variable can remain unassigned.

* fix: final Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it abstract is sufficient

* implement comments

* fix: change return to address(0) to silence compiler
parent 8e9ea053
...@@ -41,7 +41,7 @@ abstract contract Abs_BaseCrossDomainMessenger is iAbs_BaseCrossDomainMessenger, ...@@ -41,7 +41,7 @@ abstract contract Abs_BaseCrossDomainMessenger is iAbs_BaseCrossDomainMessenger,
* Public Functions * * Public Functions *
********************/ ********************/
constructor() Lib_ReentrancyGuard() internal {} constructor() Lib_ReentrancyGuard() {}
function xDomainMessageSender() public override view returns (address) { function xDomainMessageSender() public override view returns (address) {
require(xDomainMsgSender != DEFAULT_XDOMAIN_SENDER, "xDomainMessageSender is not set"); require(xDomainMsgSender != DEFAULT_XDOMAIN_SENDER, "xDomainMessageSender is not set");
...@@ -111,12 +111,12 @@ abstract contract Abs_BaseCrossDomainMessenger is iAbs_BaseCrossDomainMessenger, ...@@ -111,12 +111,12 @@ abstract contract Abs_BaseCrossDomainMessenger is iAbs_BaseCrossDomainMessenger,
/** /**
* Sends a cross domain message. * Sends a cross domain message.
* @param _message Message to send. * param // Message to send.
* @param _gasLimit Gas limit for the provided message. * param // Gas limit for the provided message.
*/ */
function _sendXDomainMessage( function _sendXDomainMessage(
bytes memory _message, bytes memory, // _message,
uint256 _gasLimit uint256 // _gasLimit
) )
virtual virtual
internal internal
......
...@@ -122,11 +122,11 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, Abs_BaseCros ...@@ -122,11 +122,11 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, Abs_BaseCros
/** /**
* Sends a cross domain message. * Sends a cross domain message.
* @param _message Message to send. * @param _message Message to send.
* @param _gasLimit Gas limit for the provided message. * param _gasLimit Gas limit for the provided message.
*/ */
function _sendXDomainMessage( function _sendXDomainMessage(
bytes memory _message, bytes memory _message,
uint256 _gasLimit uint256 // _gasLimit
) )
override override
internal internal
......
...@@ -59,12 +59,12 @@ abstract contract Abs_L1TokenGateway is iOVM_L1TokenGateway, OVM_CrossDomainEnab ...@@ -59,12 +59,12 @@ abstract contract Abs_L1TokenGateway is iOVM_L1TokenGateway, OVM_CrossDomainEnab
* @dev Core logic to be performed when a withdrawal is finalized on L1. * @dev Core logic to be performed when a withdrawal is finalized on L1.
* In most cases, this will simply send locked funds to the withdrawer. * In most cases, this will simply send locked funds to the withdrawer.
* *
* @param _to Address being withdrawn to. * param _to Address being withdrawn to.
* @param _amount Amount being withdrawn. * param _amount Amount being withdrawn.
*/ */
function _handleFinalizeWithdrawal( function _handleFinalizeWithdrawal(
address _to, address, // _to,
uint256 _amount uint256 // _amount
) )
internal internal
virtual virtual
...@@ -76,14 +76,14 @@ abstract contract Abs_L1TokenGateway is iOVM_L1TokenGateway, OVM_CrossDomainEnab ...@@ -76,14 +76,14 @@ abstract contract Abs_L1TokenGateway is iOVM_L1TokenGateway, OVM_CrossDomainEnab
* @dev Core logic to be performed when a deposit is initiated on L1. * @dev Core logic to be performed when a deposit is initiated on L1.
* In most cases, this will simply send locked funds to the withdrawer. * In most cases, this will simply send locked funds to the withdrawer.
* *
* @param _from Address being deposited from on L1. * param _from Address being deposited from on L1.
* @param _to Address being deposited into on L2. * param _to Address being deposited into on L2.
* @param _amount Amount being deposited. * param _amount Amount being deposited.
*/ */
function _handleInitiateDeposit( function _handleInitiateDeposit(
address _from, address, // _from,
address _to, address, // _to,
uint256 _amount uint256 // _amount
) )
internal internal
virtual virtual
......
...@@ -88,13 +88,13 @@ abstract contract Abs_L2DepositedToken is iOVM_L2DepositedToken, OVM_CrossDomain ...@@ -88,13 +88,13 @@ abstract contract Abs_L2DepositedToken is iOVM_L2DepositedToken, OVM_CrossDomain
* @dev Core logic to be performed when a withdrawal from L2 is initialized. * @dev Core logic to be performed when a withdrawal from L2 is initialized.
* In most cases, this will simply burn the withdrawn L2 funds. * In most cases, this will simply burn the withdrawn L2 funds.
* *
* @param _to Address being withdrawn to * param _to Address being withdrawn to
* @param _amount Amount being withdrawn * param _amount Amount being withdrawn
*/ */
function _handleInitiateWithdrawal( function _handleInitiateWithdrawal(
address _to, address, // _to,
uint _amount uint // _amount
) )
internal internal
virtual virtual
...@@ -106,12 +106,12 @@ abstract contract Abs_L2DepositedToken is iOVM_L2DepositedToken, OVM_CrossDomain ...@@ -106,12 +106,12 @@ abstract contract Abs_L2DepositedToken is iOVM_L2DepositedToken, OVM_CrossDomain
* @dev Core logic to be performed when a deposit from L2 is finalized on L2. * @dev Core logic to be performed when a deposit from L2 is finalized on L2.
* In most cases, this will simply _mint() to credit L2 funds to the recipient. * In most cases, this will simply _mint() to credit L2 funds to the recipient.
* *
* @param _to Address being deposited to on L2 * param _to Address being deposited to on L2
* @param _amount Amount which was deposited on L1 * param _amount Amount which was deposited on L1
*/ */
function _handleFinalizeDeposit( function _handleFinalizeDeposit(
address _to, address, // _to
uint _amount uint // _amount
) )
internal internal
virtual virtual
......
...@@ -61,12 +61,12 @@ contract OVM_L1ERC20Gateway is Abs_L1TokenGateway { ...@@ -61,12 +61,12 @@ contract OVM_L1ERC20Gateway is Abs_L1TokenGateway {
* transfers the funds to itself for future withdrawals * transfers the funds to itself for future withdrawals
* *
* @param _from L1 address ETH is being deposited from * @param _from L1 address ETH is being deposited from
* @param _to L2 address that the ETH is being deposited to * param _to L2 address that the ETH is being deposited to
* @param _amount Amount of ERC20 to send * @param _amount Amount of ERC20 to send
*/ */
function _handleInitiateDeposit( function _handleInitiateDeposit(
address _from, address _from,
address _to, address, // _to,
uint256 _amount uint256 _amount
) )
internal internal
......
...@@ -45,7 +45,7 @@ contract OVM_L2DepositedERC20 is Abs_L2DepositedToken, UniswapV2ERC20 { ...@@ -45,7 +45,7 @@ contract OVM_L2DepositedERC20 is Abs_L2DepositedToken, UniswapV2ERC20 {
// When a withdrawal is initiated, we burn the withdrawer's funds to prevent subsequent L2 usage. // When a withdrawal is initiated, we burn the withdrawer's funds to prevent subsequent L2 usage.
function _handleInitiateWithdrawal( function _handleInitiateWithdrawal(
address _to, address, // _to,
uint _amount uint _amount
) )
internal internal
......
...@@ -334,13 +334,14 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -334,13 +334,14 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
/** /**
* Appends a given number of queued transactions as a single batch. * Appends a given number of queued transactions as a single batch.
* @param _numQueuedTransactions Number of transactions to append. * param _numQueuedTransactions Number of transactions to append.
*/ */
function appendQueueBatch( function appendQueueBatch(
uint256 _numQueuedTransactions uint256 // _numQueuedTransactions
) )
override override
public public
pure
{ {
// TEMPORARY: Disable `appendQueueBatch` for minnet // TEMPORARY: Disable `appendQueueBatch` for minnet
revert("appendQueueBatch is currently disabled."); revert("appendQueueBatch is currently disabled.");
...@@ -469,7 +470,6 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -469,7 +470,6 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
curContext, curContext,
nextContext, nextContext,
nextQueueIndex, nextQueueIndex,
queueLength,
queueRef queueRef
); );
...@@ -1007,14 +1007,12 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -1007,14 +1007,12 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
* @param _prevContext The previously validated batch context. * @param _prevContext The previously validated batch context.
* @param _nextContext The batch context to validate with this call. * @param _nextContext The batch context to validate with this call.
* @param _nextQueueIndex Index of the next queue element to process for the _nextContext's subsequentQueueElements. * @param _nextQueueIndex Index of the next queue element to process for the _nextContext's subsequentQueueElements.
* @param _queueLength The length of the queue at the start of the batchAppend call.
* @param _queueRef The storage container for the queue. * @param _queueRef The storage container for the queue.
*/ */
function _validateNextBatchContext( function _validateNextBatchContext(
BatchContext memory _prevContext, BatchContext memory _prevContext,
BatchContext memory _nextContext, BatchContext memory _nextContext,
uint40 _nextQueueIndex, uint40 _nextQueueIndex,
uint40 _queueLength,
iOVM_ChainStorageContainer _queueRef iOVM_ChainStorageContainer _queueRef
) )
internal internal
......
...@@ -187,8 +187,9 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -187,8 +187,9 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
return; return;
} }
// Check gas right before the call to get total gas consumed by OVM transaction. // TEMPORARY: Gas metering is disabled for minnet.
uint256 gasProvided = gasleft(); // // Check gas right before the call to get total gas consumed by OVM transaction.
// uint256 gasProvided = gasleft();
// Run the transaction, make sure to meter the gas usage. // Run the transaction, make sure to meter the gas usage.
ovmCALL( ovmCALL(
...@@ -196,10 +197,10 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -196,10 +197,10 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
_transaction.entrypoint, _transaction.entrypoint,
_transaction.data _transaction.data
); );
uint256 gasUsed = gasProvided - gasleft();
// TEMPORARY: Gas metering is disabled for minnet. // TEMPORARY: Gas metering is disabled for minnet.
// // Update the cumulative gas based on the amount of gas used. // // Update the cumulative gas based on the amount of gas used.
// uint256 gasUsed = gasProvided - gasleft();
// _updateCumulativeGas(gasUsed, _transaction.l1QueueOrigin); // _updateCumulativeGas(gasUsed, _transaction.l1QueueOrigin);
// Wipe the execution context. // Wipe the execution context.
...@@ -632,8 +633,6 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -632,8 +633,6 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
// DELEGATECALL does not change anything about the message context. // DELEGATECALL does not change anything about the message context.
MessageContext memory nextMessageContext = messageContext; MessageContext memory nextMessageContext = messageContext;
bool isStaticEntrypoint = false;
return _callContract( return _callContract(
nextMessageContext, nextMessageContext,
_gasLimit, _gasLimit,
...@@ -1625,12 +1624,12 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -1625,12 +1624,12 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
/** /**
* Validates the gas limit for a given transaction. * Validates the gas limit for a given transaction.
* @param _gasLimit Gas limit provided by the transaction. * @param _gasLimit Gas limit provided by the transaction.
* @param _queueOrigin Queue from which the transaction originated. * param _queueOrigin Queue from which the transaction originated.
* @return _valid Whether or not the gas limit is valid. * @return _valid Whether or not the gas limit is valid.
*/ */
function _isValidGasLimit( function _isValidGasLimit(
uint256 _gasLimit, uint256 _gasLimit,
Lib_OVMCodec.QueueOrigin _queueOrigin Lib_OVMCodec.QueueOrigin // _queueOrigin
) )
view view
internal internal
......
...@@ -22,7 +22,7 @@ contract UniswapV2ERC20 is IUniswapV2ERC20 { ...@@ -22,7 +22,7 @@ contract UniswapV2ERC20 is IUniswapV2ERC20 {
constructor( constructor(
string memory _name, string memory _name,
string memory _symbol string memory _symbol
) public { ) {
name = _name; name = _name;
symbol = _symbol; symbol = _symbol;
......
...@@ -349,9 +349,6 @@ library Lib_RingBuffer { ...@@ -349,9 +349,6 @@ library Lib_RingBuffer {
RingBufferContext memory _ctx RingBufferContext memory _ctx
) )
internal internal
returns (
bytes32
)
{ {
bytes32 contextA; bytes32 contextA;
bytes32 contextB; bytes32 contextB;
......
...@@ -23,18 +23,18 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -23,18 +23,18 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
* Executes a signed transaction. * Executes a signed transaction.
* @param _transaction Signed EOA transaction. * @param _transaction Signed EOA transaction.
* @param _signatureType Hashing scheme used for the transaction (e.g., ETH signed message). * @param _signatureType Hashing scheme used for the transaction (e.g., ETH signed message).
* @param _v Signature `v` parameter. * param _v Signature `v` parameter.
* @param _r Signature `r` parameter. * param _r Signature `r` parameter.
* @param _s Signature `s` parameter. * param _s Signature `s` parameter.
* @return _success Whether or not the call returned (rather than reverted). * @return _success Whether or not the call returned (rather than reverted).
* @return _returndata Data returned by the call. * @return _returndata Data returned by the call.
*/ */
function execute( function execute(
bytes memory _transaction, bytes memory _transaction,
Lib_OVMCodec.EOASignatureType _signatureType, Lib_OVMCodec.EOASignatureType _signatureType,
uint8 _v, uint8, // _v,
bytes32 _r, bytes32, // _r,
bytes32 _s bytes32 // _s
) )
override override
public public
......
...@@ -40,7 +40,8 @@ contract mockOVM_GenericCrossDomainMessenger { ...@@ -40,7 +40,8 @@ contract mockOVM_GenericCrossDomainMessenger {
public public
{ {
xDomainMessageSender = _sender; xDomainMessageSender = _sender;
_target.call{gas: _gasLimit}(_message); (bool success, ) = _target.call{gas: _gasLimit}(_message);
require(success, "Cross-domain message call reverted. Did you set your gas limit high enough?");
xDomainMessageSender = address(0); xDomainMessageSender = address(0);
} }
} }
...@@ -73,8 +73,8 @@ contract mockOVM_BondManager is iOVM_BondManager, Lib_AddressResolver { ...@@ -73,8 +73,8 @@ contract mockOVM_BondManager is iOVM_BondManager, Lib_AddressResolver {
} }
function getGasSpent( function getGasSpent(
bytes32 _preStateRoot, bytes32, // _preStateRoot,
address _who address // _who
) )
override override
public public
......
...@@ -7,7 +7,6 @@ contract Helper_ModifiableStorage { ...@@ -7,7 +7,6 @@ contract Helper_ModifiableStorage {
constructor( constructor(
address _target address _target
) )
public
{ {
target[address(this)] = _target; target[address(this)] = _target;
} }
......
...@@ -48,5 +48,6 @@ contract Helper_PrecompileCaller is Helper_SimpleProxy { ...@@ -48,5 +48,6 @@ contract Helper_PrecompileCaller is Helper_SimpleProxy {
) )
{ {
callPrecompile(_precompile, _data); callPrecompile(_precompile, _data);
return address(0); // unused: silence compiler
} }
} }
...@@ -6,7 +6,6 @@ contract Helper_SimpleProxy { ...@@ -6,7 +6,6 @@ contract Helper_SimpleProxy {
address internal target; address internal target;
constructor() constructor()
public
{ {
owner = msg.sender; owner = msg.sender;
} }
......
...@@ -24,15 +24,15 @@ contract Helper_TestRunner { ...@@ -24,15 +24,15 @@ contract Helper_TestRunner {
{ {
bytes32 namehash = keccak256(abi.encodePacked(_step.functionName)); bytes32 namehash = keccak256(abi.encodePacked(_step.functionName));
if (namehash == keccak256("evmRETURN")) { if (namehash == keccak256("evmRETURN")) {
bytes memory returndata = _step.functionData; bytes memory functionData = _step.functionData;
assembly { assembly {
return(add(returndata, 0x20), mload(returndata)) return(add(functionData, 0x20), mload(functionData))
} }
} }
if (namehash == keccak256("evmREVERT")) { if (namehash == keccak256("evmREVERT")) {
bytes memory returndata = _step.functionData; bytes memory functionData = _step.functionData;
assembly { assembly {
revert(add(returndata, 0x20), mload(returndata)) revert(add(functionData, 0x20), mload(functionData))
} }
} }
if (namehash == keccak256("evmINVALID")) { if (namehash == keccak256("evmINVALID")) {
...@@ -175,6 +175,7 @@ contract Helper_TestRunner { ...@@ -175,6 +175,7 @@ contract Helper_TestRunner {
function _failStep() function _failStep()
internal internal
pure
{ {
revert("Test step failed."); revert("Test step failed.");
} }
...@@ -185,7 +186,6 @@ contract Helper_TestRunner_CREATE is Helper_TestRunner { ...@@ -185,7 +186,6 @@ contract Helper_TestRunner_CREATE is Helper_TestRunner {
bytes memory _bytecode, bytes memory _bytecode,
TestStep[] memory _steps TestStep[] memory _steps
) )
public
{ {
if (_steps.length > 0) { if (_steps.length > 0) {
runMultipleTestSteps(_steps); runMultipleTestSteps(_steps);
......
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