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

feat: deploy l1 contracts npm pkg #2754

Merged
merged 5 commits into from
Oct 11, 2023
Merged
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
22 changes: 22 additions & 0 deletions yarn-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,25 @@ To add a new package, make sure to add it to the `build_manifest.json`, to the `
- `tsconfig.json`

You may also need to modify the [Dockerfile](yarn-project/yarn-project-base/Dockerfile) to copy your new `package.json` into the container to get CI to pass.

## Deploying npm packages
`deploy-npm` script handles the releases of npm packages within yarn-project. But the initial release is a manual process:

1. Ensure relevant folders are copied in by docker in `yarn-project/yarn-project-base/Dockerfile` and `yarn-project/Dockerfile`
2. SSH into the CI
3. Run the following:
```sh
cd project
./build-system/scripts/setup_env "$(git rev-parse HEAD)" "" "" ""
source /tmp/.bash_env*
BUILD_SYSTEM_DEBUG=1
COMMIT_TAG=<RELEASE_TAG_NUMBER_YOU_WANT e.g. aztec-packages-v0.8.8>
```
4. Follow the [`deploy-npm` script](./deploy_npm.sh).
- Best to run the `deploy_package()` method line by line by manually setting `REPOSITORY` var.
- Extract `VERSION` as the script shows (in the eg it should be 0.8.8)
- Skip the version existing checks like `if [ "$VERSION" == "$PUBLISHED_VERSION" ]` and `if [ "$VERSION" != "$HIGHER_VERSION" ]`. Since this is our first time deploying the package, `PUBLISHED_VERSION` and `HIGHER_VERSION` will be empty and hence these checks would fail. These checks are necessary in the CI for continual releases.
- Locally update the package version in package.json using `jq` as shown in the script
- Do a dry-run
- If dry run succeeds, publish the package!
5. Create a PR by adding your package into the `deploy-npm` script so next release onwards, CI can cut releases for your package.
11 changes: 9 additions & 2 deletions yarn-project/deploy_npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ extract_repo yarn-project /usr/src project
cd project/src/yarn-project

echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
# also copy npcrc into the l1-contracts directory
cp .npmrc ../l1-contracts

function deploy_package() {
REPOSITORY=$1
cd $REPOSITORY

VERSION=$(extract_tag_version $REPOSITORY true)
VERSION=$(extract_tag_version $REPOSITORY false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this one changed? Should it not error if failing anymore?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The idea is to be able to take in this without a tag and see the entire process dry run. Open to thoughts here but this was changed by me then back by @spalladino . This reverts to my intended change allowing dry runs

Copy link
Contributor

Choose a reason for hiding this comment

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

So it should be false? @ludamad (remember I'm peanut-brain, so I just need a simple yes/no here 🥜).

Copy link
Contributor Author

@rahul-kothari rahul-kothari Oct 10, 2023

Choose a reason for hiding this comment

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

yeap - without it, you can't do dry runs

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh good to know, I wasn't aware that that was the intention. Makes sense then!

echo "Deploying $REPOSITORY $VERSION"

# If the commit tag itself has a dist-tag (e.g. v2.1.0-testnet.123), extract the dist-tag.
Expand Down Expand Up @@ -55,7 +57,11 @@ function deploy_package() {
fi

# Back to root
cd ..
if [ "$REPOSITORY" == "../l1-contracts" ]; then
cd ../yarn-project
else
cd ..
fi
}

deploy_package foundation
Expand All @@ -77,3 +83,4 @@ deploy_package world-state
deploy_package sequencer-client
deploy_package aztec-node
deploy_package aztec-sandbox
deploy_package ../l1-contracts
3 changes: 2 additions & 1 deletion yarn-project/yarn-project-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ COPY --from=circuits /usr/src/circuits/cpp/build-wasm/bin /usr/src/circuits/cpp/
# Copy ignition download script.
COPY --from=circuits /usr/src/barretenberg/cpp/srs_db/download_ignition.sh /usr/src/barretenberg/cpp/srs_db/download_ignition.sh

# Copy L1 contracts.
COPY --from=contracts /usr/src/l1-contracts /usr/src/l1-contracts
# Generate L1 contract TypeScript artifacts.
COPY --from=contracts /usr/src/l1-contracts/out /usr/src/l1-contracts/out
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this one? Were they redundant with the generate-artifacts.sh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No now that we are copying the entire l1-contracts, out directory gets copied with it. So this line is not needed anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, I forgot to think.

RUN cd l1-artifacts && ./scripts/generate-artifacts.sh