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

L1EP missing gauntlet commands for e2e tests #298

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions contracts/solidity/mocks/MockAggregator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract MockAggregator {
int256 public s_answer;

function setLatestAnswer(int256 answer) public {
s_answer = answer;
}

function latestAnswer() public view returns (int256) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@augustbleeds augustbleeds Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdrug are you waiting on review? I think this still needs to be changed. The line above has been changed

return s_answer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dependencies": {
"@chainlink/gauntlet-core": "0.3.1",
"@chainlink/evm-gauntlet": "0.1.0",
"@chainlink/evm-gauntlet-common": "0.3.1",
"@chainlink/starknet-gauntlet": "*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { EVMExecuteCommandConfig, makeEVMExecuteCommand } from '@chainlink/evm-gauntlet'
import { CATEGORIES } from '../../lib/categories'
import { L1AccessControllerContractLoader, CONTRACT_LIST } from '../../lib/contracts'

type UserInput = {}

type ContractInput = []

const makeUserInput = async (flags, args, env): Promise<UserInput> => ({})

const makeContractInput = async (input: UserInput): Promise<ContractInput> => {
return []
}

const commandConfig: EVMExecuteCommandConfig<UserInput, ContractInput> = {
contractId: CONTRACT_LIST.L1_ACCESS_CONTROLLER,
category: CATEGORIES.L1_ACCESS_CONTROLLER,
action: 'deploy',
ux: {
description: 'Deploy an AccessController',
examples: [`${CATEGORIES.L1_ACCESS_CONTROLLER}:deploy --network=<NETWORK>`],
},
makeUserInput,
makeContractInput,
validations: [],
loadContract: L1AccessControllerContractLoader,
}

export default makeEVMExecuteCommand(commandConfig)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Deploy from './deploy'

export default [Deploy]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { EVMExecuteCommandConfig, makeEVMExecuteCommand } from '@chainlink/evm-gauntlet'
import { CATEGORIES } from '../../lib/categories'
import { L1MockAggregatorLoader, CONTRACT_LIST } from '../../lib/contracts'

type UserInput = {}

type ContractInput = []

const makeUserInput = async (flags, args, env): Promise<UserInput> => ({})

const makeContractInput = async (input: UserInput): Promise<ContractInput> => {
return []
}

const commandConfig: EVMExecuteCommandConfig<UserInput, ContractInput> = {
contractId: CONTRACT_LIST.L1_MOCK_AGGREGATOR,
category: CATEGORIES.L1_MOCK_AGGREGATOR,
action: 'deploy',
ux: {
description: 'Deploy an MockAggregator',
examples: [`${CATEGORIES.L1_MOCK_AGGREGATOR}:deploy --network=<NETWORK>`],
},
makeUserInput,
makeContractInput,
validations: [],
loadContract: L1MockAggregatorLoader,
}

export default makeEVMExecuteCommand(commandConfig)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Deploy from './deploy'
import SetAnswer from './setAnswer'

export default [Deploy, SetAnswer]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { EVMExecuteCommandConfig, makeEVMExecuteCommand } from '@chainlink/evm-gauntlet'
import { CATEGORIES } from '../../lib/categories'
import { L1MockAggregatorLoader, CONTRACT_LIST } from '../../lib/contracts'

type UserInput = {
answer: number
}

type ContractInput = [number]

const makeUserInput = async (flags, args, env): Promise<UserInput> => {
if (flags.input) return flags.input as UserInput
return {
answer: flags.answer,
}
}

const makeContractInput = async (input: UserInput): Promise<ContractInput> => {
return [Number(input.answer)]
}

const commandConfig: EVMExecuteCommandConfig<UserInput, ContractInput> = {
contractId: CONTRACT_LIST.L1_MOCK_AGGREGATOR,
category: CATEGORIES.L1_MOCK_AGGREGATOR,
action: 'set_answer',
internalFunction: 'setLatestAnswer',
ux: {
description: 'Set the static LatestAnswer',
examples: [
`${CATEGORIES.L1_MOCK_AGGREGATOR}:set_answer --network=<NETWORK> --answer=<ANSWER> <AGGREGATOR_CONTRACT>`,
],
},
makeUserInput,
makeContractInput,
validations: [],
loadContract: L1MockAggregatorLoader,
}

export default makeEVMExecuteCommand(commandConfig)
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import {
executionCommands as UptimeFeedCommands,
inspectionCommands as UptimeInspectionCommands,
} from './sequencerUptimeFeed'
import StarknetValidatorCommands from './starknetValidator'
import StarknetValidatorCommands from './L1StarknetValidator'
import L1AccessController from './L1AccessController'
import L1GasPriceFeed from './L1GasPriceFeed'

export const L1Commands = [...StarknetValidatorCommands]
export const L1Commands = [...StarknetValidatorCommands, ...L1AccessController, ...L1GasPriceFeed]
export const L2Commands = [...UptimeFeedCommands]
export const L2InspectionCommands = [...UptimeInspectionCommands]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ import { CONTRACT_LIST } from './contracts'
export const CATEGORIES = {
SEQUENCER_UPTIME_FEED: CONTRACT_LIST.SEQUENCER_UPTIME_FEED,
STARKNET_VALIDATOR: CONTRACT_LIST.STARKNET_VALIDATOR,
L1_ACCESS_CONTROLLER: 'l1_access_controller',
L1_MOCK_AGGREGATOR: 'l1_mock_aggregator',
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import fs from 'fs'
import { ContractFactory } from 'ethers'
import { loadContract } from '@chainlink/starknet-gauntlet'
import * as accessControllerArtifact from '@chainlink/evm-gauntlet-common/artifacts/evm/SimpleWriteAccessController.json'

export enum CONTRACT_LIST {
SEQUENCER_UPTIME_FEED = 'SequencerUptimeFeed',
STARKNET_VALIDATOR = 'starknet_validator',
L1_ACCESS_CONTROLLER = 'AccessController',
L1_MOCK_AGGREGATOR = 'MockAggregator',
}

export const uptimeFeedContractLoader = () => {
Expand All @@ -20,3 +23,20 @@ export const starknetValidatorContractLoader = (): ContractFactory => {
)
return new ContractFactory(abi?.abi, abi?.bytecode)
}

export const L1AccessControllerContractLoader = () => {
return new ContractFactory(
accessControllerArtifact.compilerOutput?.abi,
accessControllerArtifact.compilerOutput?.evm?.bytecode,
)
}

export const L1MockAggregatorLoader = () => {
const abi = JSON.parse(
fs.readFileSync(
`${__dirname}/../../../../contracts/artifacts/solidity/mocks/MockAggregator.sol/MockAggregator.json`,
'utf-8',
),
)
return new ContractFactory(abi?.abi, abi?.bytecode)
}
52 changes: 51 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,25 @@
dependencies:
"@eth-optimism/contracts" "^0.5.21"

"@chainlink/[email protected]":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@chainlink/evm-gauntlet-common/-/evm-gauntlet-common-0.3.1.tgz#7a1d82a5300f1f1f70b92de37bc77d987ffa86b7"
integrity sha512-+aaIFvMEqoEeEOfUkgUW/Kn/ACuPB5ysNEvJLfZpzaP7x+h3oV1EbtQ+f3k/tkqnEHdsXX/KoeVS2nEZfe4CDA==
dependencies:
"@chainlink/evm-gauntlet" "*"
"@chainlink/gauntlet-contracts-link" "*"
"@chainlink/gauntlet-core" "0.6.0"
"@chainlink/zksync-gauntlet" "*"
ethers "^5.7.0"

"@chainlink/evm-gauntlet@*":
version "0.12.0"
resolved "https://registry.yarnpkg.com/@chainlink/evm-gauntlet/-/evm-gauntlet-0.12.0.tgz#639f1e308735807016eb5d4ef6c6e25d21255604"
integrity sha512-LAvomZD70AhSkz8sycNepchypke4UoD61lyjb+i6Wxpq+K7jiTfBNgHOpiLtOvlnVrJfgYEhoBGlfj3F7Xeq4Q==
dependencies:
"@chainlink/gauntlet-core" "0.6.0"
ethers "^5.6.9"

"@chainlink/[email protected]":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@chainlink/evm-gauntlet/-/evm-gauntlet-0.1.0.tgz#cf5cdbf66f1126b5b1d23fa8d494ab4598317674"
Expand Down Expand Up @@ -362,6 +381,13 @@
dependencies:
"@chainlink/gauntlet-core" "*"

"@chainlink/gauntlet-contracts-link@*":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@chainlink/gauntlet-contracts-link/-/gauntlet-contracts-link-0.1.3.tgz#3107c4773df8a378ac88e6e5b4c87fa80a4cf6ca"
integrity sha512-+OzDDljKBe2q2g66rOUYa+i1KL5ZUeRJb/mmK66eFyhw+sMStG/s4aXh2l2wvyBCqOxz+hmkfiyeIQsd8wHGTA==
dependencies:
"@chainlink/gauntlet-core" "*"

"@chainlink/[email protected]":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@chainlink/gauntlet-contracts-ocr2/-/gauntlet-contracts-ocr2-0.2.2.tgz#b2e6deab8c52abea588cad7c152bf8cc7a03ca28"
Expand Down Expand Up @@ -389,6 +415,25 @@
bn.js "^5.2.0"
protobufjs "^6.11.2"

"@chainlink/[email protected]":
version "0.6.0"
resolved "https://registry.yarnpkg.com/@chainlink/gauntlet-core/-/gauntlet-core-0.6.0.tgz#0a21802ea63ad0bd5948099d7c6f6e96b3868a5c"
integrity sha512-e2yLhvZUHiCT1N8sDJcqoKz6LwViQL55EMp8/eTb9PQktqBRhQDHdJK0dAlolFC+BiKVbka6THUAqyTXXxZxUQ==
dependencies:
"@ethersproject/keccak256" "^5.5.0"
axios "^0.24.0"
bn.js "^5.2.0"
protobufjs "^6.11.2"

"@chainlink/zksync-gauntlet@*":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@chainlink/zksync-gauntlet/-/zksync-gauntlet-0.3.1.tgz#c15d9c8648a0929ef0434a9ba9b1cf5d85d8ef55"
integrity sha512-qxD4gLIHjB/Zhy9tAAl8TqJ1hHeU4X5cD9eiMoBHRnViW2ylXLY5oTxcTjxQHbwYqd/6gBz3TRFVdeMu4w/Ctg==
dependencies:
"@chainlink/gauntlet-core" "0.6.0"
ethers "^5.7.1"
zksync-web3 "^0.14.0"

"@chainsafe/as-sha256@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@chainsafe/as-sha256/-/as-sha256-0.3.1.tgz#3639df0e1435cab03f4d9870cc3ac079e57a6fc9"
Expand Down Expand Up @@ -3575,7 +3620,7 @@ ethereumjs-util@^7.1.0:
ethereum-cryptography "^0.1.3"
rlp "^2.2.4"

ethers@^5.6.8, ethers@^5.6.9, ethers@^5.7.1:
ethers@^5.6.8, ethers@^5.6.9, ethers@^5.7.0, ethers@^5.7.1:
version "5.7.2"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.7.2.tgz#3a7deeabbb8c030d4126b24f84e525466145872e"
integrity sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==
Expand Down Expand Up @@ -7859,3 +7904,8 @@ yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zksync-web3@^0.14.0:
version "0.14.3"
resolved "https://registry.yarnpkg.com/zksync-web3/-/zksync-web3-0.14.3.tgz#64ac2a16d597464c3fc4ae07447a8007631c57c9"
integrity sha512-hT72th4AnqyLW1d5Jlv8N2B/qhEnl2NePK2A3org7tAa24niem/UAaHMkEvmWI3SF9waYUPtqAtjpf+yvQ9zvQ==