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

CCIP-3711 modify README for foundry and remove HH references #15101

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
63 changes: 54 additions & 9 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,76 @@ $ npm install @chainlink/contracts --save
@chainlink/contracts
├── src # Solidity contracts
│ └── v0.8
└── abi # ABI json output
└── v0.8
│── abi # ABI json output
│ └── v0.8
└── gas-snapshots # gas metered results of available non-fuzz tests
Copy link
Contributor

Choose a reason for hiding this comment

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

This readme will be the NPM readme and the gas snapshot isn't included in the NPM release

```

### Usage

The solidity smart contracts themselves can be imported via the `src` directory of `@chainlink/contracts`:

```solidity
import '@chainlink/contracts/src/v0.8/AutomationCompatibleInterface.sol';
import '@chainlink/contracts/src/v0.8/ChainSpecificUtil.sol';
```

## Local Development
## Foundry

Chainlink supports Foundry testing for Solidity for its available products. Any new products or tests should only use Foundry
in the future.

### Installation

Please see the [official docs](https://book.getfoundry.sh/getting-started/installation) for the latest installation guide

The foundry version used by the project may be different than your locally installed version, which
can result in different test results, so a series of alias commands with `GNUMakefile` is offered to help ensure the correct version is available. Please ensure your system supports makefiles before running them.

Note: Contracts in `dev/` directories are under active development and are likely unaudited. Please refrain from using these in production applications.
Depending on your foundry-profile, you may need to install external dependencies from libraries such as Openzeppelin.
This can be done efficiently with `pnpm` as well

```bash
# Clone Chainlink repository
$ git clone https://github.com/smartcontractkit/chainlink.git
# Continuing via pnpm
$ cd contracts/
$ pnpm
$ pnpm test
$ cd chainlink/contracts/
# Download and install the correct foundry version.
$ make foundry
# Download external dependencies
$ pnpm i
# Compile and run all tests using the default profile.
$ forge test
```


### CI

The Foundry CI will build, run tests and check the gas usage of all test functions against the version controlled `.gas-snapshot` file.
This snapshot should always be up-to-date and can be generated by running `make snapshot`. This will create a snapshot file in the current working dir, please make sure that you are in the root `chainlink/contracts` directory.

We do not track the gas results of fuzz-tests as to not introduce too much variability in the snapshot file between executions. Using `forge snapshot` is therefore not encouraged, as it will record the gas metered results of these-fuzz tests, which may not reproducible exactly by the CI. If you wish to view the results of these fuzz tests, we recommend using normal `forge test` instead.

```bash
$ make snapshot # Run the test files without fuzz tests and record results.
$ forge test # Run all tests, including fuzz.
```

### Configuration

Foundry config lives in `foundry.toml` in the root, the docs can be found [here](https://book.getfoundry.sh/config/).
The remapping of libraries, both from Foundry and NPM packages, is done in `remapping.txt`.

### Profiles

Different Chainlink projects are organized by folder and unique [Foundry Profiles](https://book.getfoundry.sh/reference/config/overview?highlight=profiles#profiles).
Setting a profile can be used to restrict the compiler to specific files, reducing compilation time significantly. We
recommend configuring this by setting your `FOUNDRY_PROFILE` environment variable to the profile which best fits your need.

```bash
$ export FOUNDRY_PROFILE=ccip # Set the profile to only apply only to CCIP specific contracts.
```

The complete list of profiles and their associated tests can be found in the `foundry.toml` file.

## Contributing

Please try to adhere to [Solidity Style Guide](https://github.com/smartcontractkit/chainlink/blob/develop/contracts/STYLE.md).
Expand Down
27 changes: 0 additions & 27 deletions contracts/foundry.md

This file was deleted.

Loading