Skip to content

Commit

Permalink
Merge branch 'master' into account-abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Oct 9, 2024
2 parents 1217f3e + 6325009 commit 95e19c5
Show file tree
Hide file tree
Showing 77 changed files with 1,138 additions and 1,732 deletions.
8 changes: 8 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ module.exports = {
fgrep: '[skip-on-coverage]',
invert: true,
},
// Work around stack too deep for coverage
configureYulOptimizer: true,
solcOptimizerDetails: {
yul: true,
yulDetails: {
optimizerSteps: '',
},
},
};
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Breaking changes

- `ERC1967Utils`: Removed duplicate declaration of the `Upgraded`, `AdminChanged` and `BeaconUpgraded` events. These events are still available through the `IERC1967` interface located under the `contracts/interfaces/` directory. Minimum pragma version is now 0.8.21.
- `Governor`, `GovernorCountingSimple`: The `_countVotes` virtual function now returns an `uint256` with the total votes casted. This change allows for more flexibility for partial and fractional voting. Upgrading users may get a compilation error that can be fixed by adding a return statement to the `_countVotes` function.
- `Governor`, `GovernorCountingSimple`: The `_countVote` virtual function now returns an `uint256` with the total votes casted. This change allows for more flexibility for partial and fractional voting. Upgrading users may get a compilation error that can be fixed by adding a return statement to the `_countVote` function.

### Custom error changes

Expand Down
Binary file added audits/2024-10-v5.1.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions audits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

| Date | Version | Commit | Auditor | Scope | Links |
| ------------ | ------- | --------- | ------------ | -------------------- | ----------------------------------------------------------- |
| October 2024 | v5.1.0 | TBD | OpenZeppelin | v5.1 Changes | [🔗](./2024-10-v5.1.pdf) |
| October 2023 | v5.0.0 | `b5a3e69` | OpenZeppelin | v5.0 Changes | [🔗](./2023-10-v5.0.pdf) |
| May 2023 | v4.9.0 | `91df66c` | OpenZeppelin | v4.9 Changes | [🔗](./2023-05-v4.9.pdf) |
| October 2022 | v4.8.0 | `14f98db` | OpenZeppelin | ERC4626, Checkpoints | [🔗](./2022-10-ERC4626.pdf) [🔗](./2022-10-Checkpoints.pdf) |
Expand Down
2 changes: 2 additions & 0 deletions contracts/access/Ownable2Step.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ abstract contract Ownable2Step is Ownable {
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
Expand Down
4 changes: 2 additions & 2 deletions contracts/finance/VestingWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ contract VestingWallet is Context, Ownable {
uint64 private immutable _duration;

/**
* @dev Sets the sender as the initial owner, the beneficiary as the pending owner, the start timestamp and the
* vesting duration of the vesting wallet.
* @dev Sets the beneficiary (owner), the start timestamp and the vesting duration (in seconds) of the vesting
* wallet.
*/
constructor(address beneficiary, uint64 startTimestamp, uint64 durationSeconds) payable Ownable(beneficiary) {
_start = startTimestamp;
Expand Down
6 changes: 4 additions & 2 deletions contracts/finance/VestingWalletCliff.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {VestingWallet} from "./VestingWallet.sol";

/**
* @dev Extension of {VestingWallet} that adds a cliff to the vesting schedule.
*
* _Available since v5.1._
*/
abstract contract VestingWalletCliff is VestingWallet {
using SafeCast for *;
Expand All @@ -17,8 +19,8 @@ abstract contract VestingWalletCliff is VestingWallet {
error InvalidCliffDuration(uint64 cliffSeconds, uint64 durationSeconds);

/**
* @dev Sets the sender as the initial owner, the beneficiary as the pending owner, the start timestamp, the
* vesting duration and the duration of the cliff of the vesting wallet.
* @dev Set the duration of the cliff, in seconds. The cliff starts vesting schedule (see {VestingWallet}'s
* constructor) and ends `cliffSeconds` later.
*/
constructor(uint64 cliffSeconds) {
if (cliffSeconds > duration()) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72

// Extract what would be the `#proposer=0x` marker beginning the suffix
bytes12 marker;
assembly {
assembly ("memory-safe") {
// - Start of the string contents in memory = description + 32
// - First character of the marker = len - 52
// - Length of "#proposer=0x0000000000000000000000000000000000000000" = 52
Expand Down Expand Up @@ -802,7 +802,7 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72
* @dev Try to parse a character from a string as a hex value. Returns `(true, value)` if the char is in
* `[0-9a-fA-F]` and `(false, 0)` otherwise. Value is guaranteed to be in the range `0 <= value < 16`
*/
function _tryHexToUint(bytes1 char) private pure returns (bool, uint8) {
function _tryHexToUint(bytes1 char) private pure returns (bool isHex, uint8 value) {
uint8 c = uint8(char);
unchecked {
// Case 0-9
Expand Down
3 changes: 3 additions & 0 deletions contracts/governance/IGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {IERC6372} from "../interfaces/IERC6372.sol";

/**
* @dev Interface of the {Governor} core.
*
* NOTE: Event parameters lack the `indexed` keyword for compatibility with GovernorBravo events.
* Making event parameters `indexed` affects how events are decoded, potentially breaking existing indexers.
*/
interface IGovernor is IERC165, IERC6372 {
enum ProposalState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {Math} from "../../utils/math/Math.sol";
* * Voting privately from a shielded pool using zero knowledge proofs.
*
* Based on ScopeLift's GovernorCountingFractional[https://github.com/ScopeLift/flexible-voting/blob/e5de2efd1368387b840931f19f3c184c85842761/src/GovernorCountingFractional.sol]
*
* _Available since v5.1._
*/
abstract contract GovernorCountingFractional is Governor {
using Math for *;
Expand All @@ -43,7 +45,7 @@ abstract contract GovernorCountingFractional is Governor {
/**
* @dev Mapping from proposal ID to vote tallies for that proposal.
*/
mapping(uint256 => ProposalVote) private _proposalVotes;
mapping(uint256 proposalId => ProposalVote) private _proposalVotes;

/**
* @dev A fractional vote params uses more votes than are available for that user.
Expand Down Expand Up @@ -145,7 +147,7 @@ abstract contract GovernorCountingFractional is Governor {
uint256 againstVotes = 0;
uint256 forVotes = 0;
uint256 abstainVotes = 0;
uint256 usedWeight;
uint256 usedWeight = 0;

// For clarity of event indexing, fractional voting must be clearly advertised in the "support" field.
//
Expand Down
22 changes: 16 additions & 6 deletions contracts/governance/extensions/GovernorStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ abstract contract GovernorStorage is Governor {
*/
function proposalDetails(
uint256 proposalId
) public view virtual returns (address[] memory, uint256[] memory, bytes[] memory, bytes32) {
)
public
view
virtual
returns (address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
{
// here, using memory is more efficient than storage
ProposalDetails memory details = _proposalDetails[proposalId];
if (details.descriptionHash == 0) {
Expand All @@ -102,14 +107,19 @@ abstract contract GovernorStorage is Governor {
*/
function proposalDetailsAt(
uint256 index
) public view virtual returns (uint256, address[] memory, uint256[] memory, bytes[] memory, bytes32) {
uint256 proposalId = _proposalIds[index];
(
)
public
view
virtual
returns (
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) = proposalDetails(proposalId);
return (proposalId, targets, values, calldatas, descriptionHash);
)
{
proposalId = _proposalIds[index];
(targets, values, calldatas, descriptionHash) = proposalDetails(proposalId);
}
}
2 changes: 1 addition & 1 deletion contracts/governance/utils/Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 {
Checkpoints.Trace208 storage store,
function(uint208, uint208) view returns (uint208) op,
uint208 delta
) private returns (uint208, uint208) {
) private returns (uint208 oldValue, uint208 newValue) {
return store.push(clock(), op(store.latest(), delta));
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IERC1363Receiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IERC1363Receiver {
* (i.e. 0x88a7ca5c, or its own function selector).
*
* @param operator The address which called `transferAndCall` or `transferFromAndCall` function.
* @param from The address which are tokens transferred from.
* @param from The address which the tokens are transferred from.
* @param value The amount of tokens transferred.
* @param data Additional data with no specified format.
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` if transfer is allowed unless throwing.
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IERC1363Spender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pragma solidity ^0.8.20;

/**
* @title ERC1363Spender
* @title IERC1363Spender
* @dev Interface for any contract that wants to support `approveAndCall`
* from ERC-1363 token contracts.
*/
Expand Down
4 changes: 2 additions & 2 deletions contracts/metatx/ERC2771Forwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ contract ERC2771Forwarder is EIP712, Nonces {
*/
function _recoverForwardRequestSigner(
ForwardRequestData calldata request
) internal view virtual returns (bool, address) {
) internal view virtual returns (bool isValid, address signer) {
(address recovered, ECDSA.RecoverError err, ) = _hashTypedDataV4(
keccak256(
abi.encode(
Expand Down Expand Up @@ -286,7 +286,7 @@ contract ERC2771Forwarder is EIP712, Nonces {

uint256 gasLeft;

assembly {
assembly ("memory-safe") {
success := call(reqGas, to, value, add(data, 0x20), mload(data), 0, 0)
gasLeft := gas()
}
Expand Down
52 changes: 1 addition & 51 deletions contracts/mocks/StorageSlotMock.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// This file was procedurally generated from scripts/generate/templates/StorageSlotMock.js.

pragma solidity ^0.8.24;
pragma solidity ^0.8.20;

import {Multicall} from "../utils/Multicall.sol";
import {StorageSlot} from "../utils/StorageSlot.sol";
Expand Down Expand Up @@ -84,54 +84,4 @@ contract StorageSlotMock is Multicall {
function getBytesStorage(uint256 key) public view returns (bytes memory) {
return bytesMap[key].getBytesSlot().value;
}

event AddressValue(bytes32 slot, address value);

function tloadAddress(bytes32 slot) public {
emit AddressValue(slot, slot.asAddress().tload());
}

function tstore(bytes32 slot, address value) public {
slot.asAddress().tstore(value);
}

event BooleanValue(bytes32 slot, bool value);

function tloadBoolean(bytes32 slot) public {
emit BooleanValue(slot, slot.asBoolean().tload());
}

function tstore(bytes32 slot, bool value) public {
slot.asBoolean().tstore(value);
}

event Bytes32Value(bytes32 slot, bytes32 value);

function tloadBytes32(bytes32 slot) public {
emit Bytes32Value(slot, slot.asBytes32().tload());
}

function tstore(bytes32 slot, bytes32 value) public {
slot.asBytes32().tstore(value);
}

event Uint256Value(bytes32 slot, uint256 value);

function tloadUint256(bytes32 slot) public {
emit Uint256Value(slot, slot.asUint256().tload());
}

function tstore(bytes32 slot, uint256 value) public {
slot.asUint256().tstore(value);
}

event Int256Value(bytes32 slot, int256 value);

function tloadInt256(bytes32 slot) public {
emit Int256Value(slot, slot.asInt256().tload());
}

function tstore(bytes32 slot, int256 value) public {
slot.asInt256().tstore(value);
}
}
61 changes: 61 additions & 0 deletions contracts/mocks/TransientSlotMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: MIT
// This file was procedurally generated from scripts/generate/templates/TransientSlotMock.js.

pragma solidity ^0.8.24;

import {Multicall} from "../utils/Multicall.sol";
import {TransientSlot} from "../utils/TransientSlot.sol";

contract TransientSlotMock is Multicall {
using TransientSlot for *;

event AddressValue(bytes32 slot, address value);

function tloadAddress(bytes32 slot) public {
emit AddressValue(slot, slot.asAddress().tload());
}

function tstore(bytes32 slot, address value) public {
slot.asAddress().tstore(value);
}

event BooleanValue(bytes32 slot, bool value);

function tloadBoolean(bytes32 slot) public {
emit BooleanValue(slot, slot.asBoolean().tload());
}

function tstore(bytes32 slot, bool value) public {
slot.asBoolean().tstore(value);
}

event Bytes32Value(bytes32 slot, bytes32 value);

function tloadBytes32(bytes32 slot) public {
emit Bytes32Value(slot, slot.asBytes32().tload());
}

function tstore(bytes32 slot, bytes32 value) public {
slot.asBytes32().tstore(value);
}

event Uint256Value(bytes32 slot, uint256 value);

function tloadUint256(bytes32 slot) public {
emit Uint256Value(slot, slot.asUint256().tload());
}

function tstore(bytes32 slot, uint256 value) public {
slot.asUint256().tstore(value);
}

event Int256Value(bytes32 slot, int256 value);

function tloadInt256(bytes32 slot) public {
emit Int256Value(slot, slot.asInt256().tload());
}

function tstore(bytes32 slot, int256 value) public {
slot.asInt256().tstore(value);
}
}
7 changes: 1 addition & 6 deletions contracts/proxy/transparent/TransparentUpgradeableProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ import {ProxyAdmin} from "./ProxyAdmin.sol";
* include them in the ABI so this interface must be used to interact with it.
*/
interface ITransparentUpgradeableProxy is IERC1967 {
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* See {UUPSUpgradeable-upgradeToAndCall}
*/
/// @dev See {UUPSUpgradeable-upgradeToAndCall}
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable;
}

Expand Down
6 changes: 4 additions & 2 deletions contracts/token/ERC1155/utils/ERC1155Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import {IERC1155Errors} from "../../../interfaces/draft-IERC6093.sol";
* @dev Library that provide common ERC-1155 utility functions.
*
* See https://eips.ethereum.org/EIPS/eip-1155[ERC-1155].
*
* _Available since v5.1._
*/
library ERC1155Utils {
/**
* @dev Performs an acceptance check for the provided `operator` by calling {IERC1155-onERC1155Received}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address is doesn't contain code (i.e. an EOA).
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
* the transfer.
*/
Expand Down Expand Up @@ -50,7 +52,7 @@ library ERC1155Utils {
* @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-onERC1155BatchReceived}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address is doesn't contain code (i.e. an EOA).
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
* the transfer.
*/
Expand Down
2 changes: 2 additions & 0 deletions contracts/token/ERC20/extensions/ERC1363.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {ERC1363Utils} from "../utils/ERC1363Utils.sol";
* @dev Extension of {ERC20} tokens that adds support for code execution after transfers and approvals
* on recipient contracts. Calls after transfers are enabled through the {ERC1363-transferAndCall} and
* {ERC1363-transferFromAndCall} methods while calls after approvals can be made with {ERC1363-approveAndCall}
*
* _Available since v5.1._
*/
abstract contract ERC1363 is ERC20, ERC165, IERC1363 {
/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/extensions/ERC4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
/**
* @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.
*/
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool ok, uint8 assetDecimals) {
(bool success, bytes memory encodedDecimals) = address(asset_).staticcall(
abi.encodeCall(IERC20Metadata.decimals, ())
);
Expand Down
Loading

0 comments on commit 95e19c5

Please sign in to comment.