Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-1325] Test out solidity artifact pipeline #14049

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2eedc1f
test without any soldity changes
Tofel Aug 6, 2024
08b0b1d
some changes present
Tofel Aug 6, 2024
a3cf665
trigger
Tofel Aug 6, 2024
de8a20c
test with shared
Tofel Aug 6, 2024
f9b063a
run only for shared
Tofel Aug 6, 2024
0b8f76d
remove shared change
Tofel Aug 6, 2024
92ad9d8
only test changes
Tofel Aug 6, 2024
6c70732
test changes and product
Tofel Aug 6, 2024
8037c87
test changes and product and shared
Tofel Aug 6, 2024
cc4c958
add a bunch of files here and there
Tofel Aug 6, 2024
cbf3d8b
exclude mocks
Tofel Aug 6, 2024
f001766
test with deleted file
Tofel Aug 6, 2024
4cece32
try with commit
Tofel Aug 6, 2024
99d5305
remove everything, but the deleted contract
Tofel Aug 6, 2024
002b316
add check if there are any not deleted modified contracts
Tofel Aug 6, 2024
5979ecb
add new file
Tofel Aug 6, 2024
0156d2c
run with invalid ref
Tofel Aug 6, 2024
71f0cd8
move changes to correct pipeline
Tofel Aug 6, 2024
fb8abed
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 6, 2024
a2859ad
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 6, 2024
77ca540
check if missing umls are noticed
Tofel Aug 6, 2024
675c929
check if missing umls and reports are noticed
Tofel Aug 6, 2024
1a14933
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 7, 2024
adfa5fb
test out again with no matches
Tofel Aug 7, 2024
110ac29
run for automation changes
Tofel Aug 7, 2024
6a3d7a0
run for automation with shared also modified
Tofel Aug 7, 2024
ef8bb5e
try with shared
Tofel Aug 7, 2024
e0040c0
do not print deleted files in the warning
Tofel Aug 7, 2024
a6db622
do not print deleted files in the warning
Tofel Aug 7, 2024
1aaeba9
try with another shared contract
Tofel Aug 7, 2024
a910e56
try with shared test
Tofel Aug 7, 2024
3f5572a
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 7, 2024
d65d1e7
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 7, 2024
d15a224
test with test files
Tofel Aug 7, 2024
8d3c928
try with fixed shared
Tofel Aug 7, 2024
f4cbd74
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 7, 2024
1338e3e
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 8, 2024
6236b7d
try with failing uml
Tofel Aug 8, 2024
aad9863
run for funcitons
Tofel Aug 8, 2024
09359d8
try with contract with no issues
Tofel Aug 8, 2024
5f8187d
test failure of foundry version extraction
Tofel Aug 8, 2024
9d4c398
move Foundry version detection to an action
Tofel Aug 8, 2024
6461716
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 8, 2024
16b9fa8
Merge branch 'tt_1325_solidity_pipelines_genhtml' into tt_1325_solidi…
Tofel Aug 8, 2024
829ae23
try with automation and tag
Tofel Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
391 changes: 333 additions & 58 deletions .github/workflows/solidity-hardhat.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ optimizer_runs = 3_600
evm_version = 'paris'

[profile.functions]
solc_version = '0.8.19'
solc_version = '0.8.26'
src = 'src/v0.8/functions/dev/v1_X'
test = 'src/v0.8/functions/tests/v1_X'
gas_price = 3_000_000_000 # 3 gwei
Expand Down
116 changes: 116 additions & 0 deletions contracts/src/v0.8/ChainlinkNew.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {CBORChainlink} from "./vendor/CBORChainlink.sol";
import {BufferChainlink} from "./vendor/BufferChainlink.sol";

/**
* @title Library for common Chainlink functions
* @dev Uses imported CBOR library for encoding to buffer
*/
library Chainlink {
// solhint-disable-next-line chainlink-solidity/all-caps-constant-storage-variables
uint256 internal constant defaultBufferSize = 256;

using CBORChainlink for BufferChainlink.buffer;

struct Request {
bytes32 id;
address callbackAddress;
bytes4 callbackFunctionId;
uint256 nonce;
BufferChainlink.buffer buf;
}

/**
* @notice Initializes a Chainlink request
* @dev Sets the ID, callback address, and callback function signature on the request
* @param self The uninitialized request
* @param jobId The Job Specification ID
* @param callbackAddr The callback address
* @param callbackFunc The callback function signature
* @return The initialized request
*/
function _initialize(
Request memory self,
bytes32 jobId,
address callbackAddr,
bytes4 callbackFunc
) internal pure returns (Chainlink.Request memory) {
BufferChainlink.init(self.buf, defaultBufferSize);
self.id = jobId;
self.callbackAddress = callbackAddr;
self.callbackFunctionId = callbackFunc;
return self;
}

/**
* @notice Sets the data for the buffer without encoding CBOR on-chain
* @dev CBOR can be closed with curly-brackets {} or they can be left off
* @param self The initialized request
* @param data The CBOR data
*/
function _setBuffer(Request memory self, bytes memory data) internal pure {
BufferChainlink.init(self.buf, data.length);
BufferChainlink.append(self.buf, data);
}

/**
* @notice Adds a string value to the request with a given key name
* @param self The initialized request
* @param key The name of the key
* @param value The string value to add
*/
function _add(Request memory self, string memory key, string memory value) internal pure {
self.buf.encodeString(key);
self.buf.encodeString(value);
}

/**
* @notice Adds a bytes value to the request with a given key name
* @param self The initialized request
* @param key The name of the key
* @param value The bytes value to add
*/
function _addBytes(Request memory self, string memory key, bytes memory value) internal pure {
self.buf.encodeString(key);
self.buf.encodeBytes(value);
}

/**
* @notice Adds a int256 value to the request with a given key name
* @param self The initialized request
* @param key The name of the key
* @param value The int256 value to add
*/
function _addInt(Request memory self, string memory key, int256 value) internal pure {
self.buf.encodeString(key);
self.buf.encodeInt(value);
}

/**
* @notice Adds a uint256 value to the request with a given key name
* @param self The initialized request
* @param key The name of the key
* @param value The uint256 value to add
*/
function _addUint(Request memory self, string memory key, uint256 value) internal pure {
self.buf.encodeString(key);
self.buf.encodeUInt(value);
}

/**
* @notice Adds an array of strings to the request with a given key name
* @param self The initialized request
* @param key The name of the key
* @param values The array of string values to add
*/
function _addStringArray(Request memory self, string memory key, string[] memory values) internal pure {
self.buf.encodeString(key);
self.buf.startArray();
for (uint256 i = 0; i < values.length; i++) {
self.buf.encodeString(values[i]);
}
self.buf.endSequence();
}
}
14 changes: 14 additions & 0 deletions contracts/src/v0.8/automation/BaseTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "forge-std/Test.sol";

contract BaseTest is Test {
address internal OWNER = 0x00007e64E1fB0C487F25dd6D3601ff6aF8d32e4e;
address internal constant STRANGER = address(999);

function setUp() public virtual {
vm.startPrank(OWNER);
deal(OWNER, 1e20);
}
}
51 changes: 51 additions & 0 deletions contracts/src/v0.8/automation/chains/ArbitrumModuleNew.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

import {ArbSys} from "../../vendor/@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol";
import {ArbGasInfo} from "../../vendor/@arbitrum/nitro-contracts/src/precompiles/ArbGasInfo.sol";
import {ChainModuleBase} from "./ChainModuleBase.sol";

contract ArbitrumModule is ChainModuleBase {
/// @dev ARB_SYS_ADDR is the address of the ArbSys precompile on Arbitrum.
/// @dev reference: https://github.com/OffchainLabs/nitro/blob/v2.0.14/contracts/src/precompiles/ArbSys.sol#L10
address private constant ARB_SYS_ADDR = 0x0000000000000000000000000000000000000064;
ArbSys private constant ARB_SYS = ArbSys(ARB_SYS_ADDR);

/// @dev ARB_GAS_ADDR is the address of the ArbGasInfo precompile on Arbitrum.
/// @dev reference: https://github.com/OffchainLabs/nitro/blob/v2.0.14/contracts/src/precompiles/ArbGasInfo.sol#L10
address private constant ARB_GAS_ADDR = 0x000000000000000000000000000000000000006C;
ArbGasInfo private constant ARB_GAS = ArbGasInfo(ARB_GAS_ADDR);

uint256 private constant FIXED_GAS_OVERHEAD = 5000;
uint256 private constant PER_CALLDATA_BYTE_GAS_OVERHEAD = 0;

function blockHash(uint256 n) external view override returns (bytes32) {
uint256 blockNum = ARB_SYS.arbBlockNumber();
if (n >= blockNum || blockNum - n > 256) {
return "";
}
return ARB_SYS.arbBlockHash(n);
}

function blockNumber() external view override returns (uint256) {
return ARB_SYS.arbBlockNumber();
}

function getCurrentL1Fee() external view override returns (uint256) {
return ARB_GAS.getCurrentTxL1GasFees();
}

function getMaxL1Fee(uint256 dataSize) external view override returns (uint256) {
(, uint256 perL1CalldataByte, , , , ) = ARB_GAS.getPricesInWei();
return perL1CalldataByte * dataSize;
}

function getGasOverhead()
external
view
override
returns (uint256 chainModuleFixedOverhead, uint256 chainModulePerByteOverhead)
{
return (FIXED_GAS_OVERHEAD, PER_CALLDATA_BYTE_GAS_OVERHEAD);
}
}
17 changes: 17 additions & 0 deletions contracts/src/v0.8/automation/mocks/ERC20Mock6DecimalsNew.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pragma solidity ^0.8.0;

import {ERC20Mock} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/mocks/ERC20Mock.sol";

// mock ERC20 with 6 decimals
contract ERC20Mock6Decimals is ERC20Mock {
constructor(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) payable ERC20Mock(name, symbol, initialAccount, initialBalance) {}

function decimals() public view virtual override returns (uint8) {
return 6;
}
}
74 changes: 74 additions & 0 deletions contracts/src/v0.8/automation/test/AutomationForwarderNew.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.16;

import {IAutomationForwarder} from "../interfaces/IAutomationForwarder.sol";
import {AutomationForwarder} from "../AutomationForwarder.sol";
import {AutomationForwarderLogic} from "../AutomationForwarderLogic.sol";
import "forge-std/Test.sol";

// in contracts directory, run
// forge test --match-path src/v0.8/automation/test/AutomationForwarder.t.sol

contract Target {
function handler() external pure {}

function handlerRevert() external pure {
revert("revert");
}
}

contract AutomationForwarderTestSetUp is Test {
address internal constant REGISTRY = 0x3e19ef5Aaa2606655f5A677A97E085cf3811067c;
address internal constant STRANGER = 0x618fae5d04963B2CEf533F247Eb2C46Bf1801D3b;

IAutomationForwarder internal forwarder;
address internal TARGET;

function setUp() public {
TARGET = address(new Target());
AutomationForwarderLogic logicContract = new AutomationForwarderLogic();
forwarder = IAutomationForwarder(address(new AutomationForwarder(TARGET, REGISTRY, address(logicContract))));
}
}

contract AutomationForwarderTest_constructor is AutomationForwarderTestSetUp {
function testInitialValues() external {
assertEq(address(forwarder.getRegistry()), REGISTRY);
assertEq(forwarder.getTarget(), TARGET);
}

function testTypeAndVersion() external {
assertEq(forwarder.typeAndVersion(), "AutomationForwarder 1.0.0");
}
}

contract AutomationForwarderTest_forward is AutomationForwarderTestSetUp {
function testOnlyCallableByTheRegistry() external {
vm.prank(REGISTRY);
forwarder.forward(100000, abi.encodeWithSelector(Target.handler.selector));
vm.prank(STRANGER);
vm.expectRevert();
forwarder.forward(100000, abi.encodeWithSelector(Target.handler.selector));
}

function testReturnsSuccessValueAndGasUsed() external {
vm.startPrank(REGISTRY);
(bool success, uint256 gasUsed) = forwarder.forward(100000, abi.encodeWithSelector(Target.handler.selector));
assertTrue(success);
assertGt(gasUsed, 0);
(success, gasUsed) = forwarder.forward(100000, abi.encodeWithSelector(Target.handlerRevert.selector));
assertFalse(success);
assertGt(gasUsed, 0);
}
}

contract AutomationForwarderTest_updateRegistry is AutomationForwarderTestSetUp {
function testOnlyCallableByTheActiveRegistry() external {
address newRegistry = address(1);
vm.startPrank(REGISTRY);
forwarder.updateRegistry(newRegistry);
assertEq(address(forwarder.getRegistry()), newRegistry);
vm.expectRevert();
forwarder.updateRegistry(REGISTRY);
}
}
17 changes: 0 additions & 17 deletions contracts/src/v0.8/automation/v2_3/AutomationUtils2_3.sol

This file was deleted.

Loading
Loading