Skip to content

Commit

Permalink
upgrade transmission code to 0.8.19 (#12612)
Browse files Browse the repository at this point in the history
* upgrade transmission code to 0.8.19

* changeset
  • Loading branch information
RensR authored Mar 27, 2024
1 parent 76b72ee commit d44abe3
Show file tree
Hide file tree
Showing 26 changed files with 91 additions and 71 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-monkeys-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

upgraded transmission to 0.8.19
2 changes: 1 addition & 1 deletion .github/workflows/solidity-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- '.github/workflows/solidity-foundry.yml'
- 'contracts/foundry.toml'
- 'contracts/gas-snapshots/*.gas-snapshot'
- '.gitmodules'
- 'contracts/foundry-lib'
- '.gitmodules'
tests:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/solidity-hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
filters: |
src:
- 'contracts/src/!(v0.8/(llo-feeds|keystone|ccip)/**)/**/*'
- 'contracts/src/!(v0.8/(llo-feeds|keystone|ccip|functions|transmission)/**)/**/*'
- 'contracts/test/**/*'
- 'contracts/package.json'
- 'contracts/pnpm-lock.yaml'
Expand Down
5 changes: 5 additions & 0 deletions contracts/.changeset/afraid-years-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chainlink/contracts": patch
---

upgraded transmission to 0.8.19
2 changes: 1 addition & 1 deletion contracts/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ALL_FOUNDRY_PRODUCTS contains a list of all products that have a foundry
# profile defined and use the Foundry snapshots.
ALL_FOUNDRY_PRODUCTS = l2ep llo-feeds functions keystone shared
ALL_FOUNDRY_PRODUCTS = l2ep llo-feeds functions keystone shared transmission

# To make a snapshot for a specific product, either set the `FOUNDRY_PROFILE` env var
# or call the target with `FOUNDRY_PROFILE=product`
Expand Down
6 changes: 6 additions & 0 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ solc_version = '0.8.19'
src = 'src/v0.8/operatorforwarder'
test = 'src/v0.8/operatorforwarder/test'

[profile.transmission]
optimizer_runs = 1_000_000
solc_version = '0.8.19'
src = 'src/v0.8/transmission'
test = 'src/v0.8/transmission/test'

[profile.shared]
optimizer_runs = 1_000_000
src = 'src/v0.8/shared'
Expand Down
4 changes: 4 additions & 0 deletions contracts/gas-snapshots/transmission.gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EIP_712_1014_4337:testEIP712EIP4337AndCreateSmartContractAccount() (gas: 910039)
EIP_712_1014_4337:testEIP712EIP4337AndCreateSmartContractAccountWithPaymaster() (gas: 2286631)
EIP_712_1014_4337:testEIP712EIP4337AndCreateSmartContractAccountWithPaymasterForVRFRequest() (gas: 2876825)
EIP_712_1014_4337:testEIP712EIP4337WithExistingSmartContractAccount() (gas: 878457)
4 changes: 0 additions & 4 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ let config = {
version: '0.8.6',
settings: COMPILER_SETTINGS,
},
{
version: '0.8.15',
settings: COMPILER_SETTINGS,
},
{
version: '0.8.16',
settings: COMPILER_SETTINGS,
Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/native_solc_compile_all_transmission
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ echo " ┌───────────────────────
echo " │ Compiling Transmission contracts... │"
echo " └──────────────────────────────────────────────┘"

SOLC_VERSION="0.8.15"
SOLC_VERSION="0.8.19"
OPTIMIZE_RUNS=1000000

SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/transmission/dev/ERC-4337/Paymaster.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
pragma solidity ^0.8.19;

import {IPaymaster} from "../../../vendor/entrypoint/interfaces/IPaymaster.sol";
import {SCALibrary} from "./SCALibrary.sol";
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/v0.8/transmission/dev/ERC-4337/SCA.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: MIT
/// TODO: decide on a compiler version. Must not be dynamic, and must be > 0.8.12.
pragma solidity 0.8.15;
pragma solidity 0.8.19;

import {IAccount} from "../../../vendor/entrypoint/interfaces/IAccount.sol";
import {SCALibrary} from "./SCALibrary.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
pragma solidity ^0.8.19;

library SCALibrary {
// keccak256("EIP712Domain(uint256 chainId, address verifyingContract)");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
pragma solidity ^0.8.19;

contract SmartContractAccountFactory {
event ContractCreated(address scaAddress);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
pragma solidity ^0.8.19;

/// @dev Ownerless greeter contract.
contract Greeter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
pragma solidity ^0.8.19;

import {SCA} from "../ERC-4337/SCA.sol";
import {SmartContractAccountFactory} from "../ERC-4337/SmartContractAccountFactory.sol";
Expand Down
17 changes: 17 additions & 0 deletions contracts/src/v0.8/transmission/test/BaseTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pragma solidity ^0.8.0;

import {Test} from "forge-std/Test.sol";

contract BaseTest is Test {
bool private s_baseTestInitialized;
address internal constant OWNER = 0x00007e64E1fB0C487F25dd6D3601ff6aF8d32e4e;

function setUp() public virtual {
// BaseTest.setUp is often called multiple times from tests' setUp due to inheritance.
if (s_baseTestInitialized) return;
s_baseTestInitialized = true;

// Set msg.sender to OWNER until changePrank or stopPrank is called
vm.startPrank(OWNER);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
pragma solidity ^0.8.15;

import "../BaseTest.t.sol";
import "../../../../src/v0.8/transmission/dev/ERC-4337/SmartContractAccountFactory.sol";
import "../../../../src/v0.8/transmission/dev/testhelpers/SmartContractAccountHelper.sol";
import "../../../../src/v0.8/transmission/dev/ERC-4337/SCA.sol";
import "../../../../src/v0.8/transmission/dev/testhelpers/Greeter.sol";
import "../../../../src/v0.8/transmission/dev/ERC-4337/Paymaster.sol";
import "../../../../src/v0.8/vendor/entrypoint/interfaces/UserOperation.sol";
import "../../../../src/v0.8/vendor/entrypoint/core/EntryPoint.sol";
import "../../../../src/v0.8/vendor/entrypoint/interfaces/IEntryPoint.sol";
import "../../../../src/v0.8/transmission/dev/ERC-4337/SCALibrary.sol";
import "../../../../src/v0.8/mocks/MockLinkToken.sol";
import "../../../../src/v0.8/shared/interfaces/LinkTokenInterface.sol";
import "../../../../src/v0.8/vrf/mocks/VRFCoordinatorMock.sol";
import "../../../../src/v0.8/tests/MockV3Aggregator.sol";
import "../../../../src/v0.8/vrf/testhelpers/VRFConsumer.sol";
pragma solidity 0.8.19;

import "../../shared/interfaces/LinkTokenInterface.sol";

import "./BaseTest.t.sol";
import "../dev/ERC-4337/SmartContractAccountFactory.sol";
import "../dev/testhelpers/SmartContractAccountHelper.sol";
import "../dev/ERC-4337/SCA.sol";
import "../dev/testhelpers/Greeter.sol";
import "../dev/ERC-4337/Paymaster.sol";
import "../../transmission/dev/ERC-4337/SCALibrary.sol";
import "../../mocks/MockLinkToken.sol";
import "../../tests/MockV3Aggregator.sol";
import "../../vrf/mocks/VRFCoordinatorMock.sol";
import "../../vrf/testhelpers/VRFConsumer.sol";

import "../../vendor/entrypoint/interfaces/UserOperation.sol";
import "../../vendor/entrypoint/core/EntryPoint.sol";
import "../../vendor/entrypoint/interfaces/IEntryPoint.sol";

/*--------------------------------------------------------------------------------------------------------------------+
| EIP 712 + 1014 + 4337 |
Expand All @@ -27,7 +29,7 @@ import "../../../../src/v0.8/vrf/testhelpers/VRFConsumer.sol";
| |
| The below tests illustrate end-user flows for interacting with this meta-transaction system. For users with |
| existing Smart Contract Accounts (SCAs), they simply sign off on the operation, after which the executor |
| invokes the EntryPoint that authorizes the operation on the end-user's SCA, and then exectute the transaction |
| invokes the EntryPoint that authorizes the operation on the end-user's SCA, and then execute the transaction |
| as the SCA. For users without existing SCAs, EIP-1014 ensures that the address of an SCA can be known in advance, |
| so users can sign-off on transactions that will be executed by a not-yet-deployed SCA. The EntryPoint contract |
| takes advantage of this functionality and allows for the SCA to be created in the same user operation that invokes |
Expand All @@ -40,12 +42,6 @@ import "../../../../src/v0.8/vrf/testhelpers/VRFConsumer.sol";
| |
-+---------------------------------------------------------------------------------------------------------------------*/

/*----------------------------+
| TESTS |
| ________________ |
| |
+----------------------------*/

contract EIP_712_1014_4337 is BaseTest {
event RandomnessRequest(address indexed sender, bytes32 indexed keyHash, uint256 indexed seed, uint256 fee);

Expand All @@ -69,7 +65,7 @@ contract EIP_712_1014_4337 is BaseTest {
// Impersonate a LINK whale.
changePrank(LINK_WHALE);

// Create simople greeter contract.
// Create simple greeter contract.
greeter = new Greeter();
assertEq("", greeter.getGreeting());

Expand Down Expand Up @@ -178,7 +174,7 @@ contract EIP_712_1014_4337 is BaseTest {
encodedGreetingCall
);

// Construct the user opeartion.
// Construct the user operation.
UserOperation memory op = UserOperation({
sender: toDeployAddress,
nonce: 0,
Expand Down Expand Up @@ -322,7 +318,7 @@ contract EIP_712_1014_4337 is BaseTest {
topupAmount: 10 ether
});

// Construct the user opeartion.
// Construct the user operation.
UserOperation memory op = UserOperation({
sender: toDeployAddress,
nonce: 0,
Expand All @@ -344,7 +340,7 @@ contract EIP_712_1014_4337 is BaseTest {
// Deposit funds for the transaction.
entryPoint.depositTo{value: 10 ether}(address(paymaster));

// Assert correct log is emmitted for the end-contract vrf request.
// Assert correct log is emitted for the end-contract vrf request.
vm.expectEmit(true, true, true, true);
emit RandomnessRequest(
address(vrfConsumer),
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading

0 comments on commit d44abe3

Please sign in to comment.