-
Notifications
You must be signed in to change notification settings - Fork 293
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: Test against Sepolia #8176
Changes from 15 commits
8583ea8
b05d744
6f47089
2c7c374
b05356b
27c5aeb
f8fd356
31f2218
be262db
fadf2e4
c22f2e1
fa918e7
f48e4dc
0f36e36
4f77326
811641d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Run public testnet test | ||
on: | ||
schedule: | ||
- cron: '00 08 * * 1-5' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
GIT_COMMIT: ${{ github.sha }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
|
||
# Uncomment the following to run against Sepolia | ||
# SEQ_PUBLISHER_PRIVATE_KEY: ${{ secrets.SEPOLIA_SEQ_PRIVATE_KEY }} | ||
# PROVER_PUBLISHER_PRIVATE_KEY: ${{ secrets.SEPOLIA_PROVER_PRIVATE_KEY }} | ||
# ETHEREUM_HOST: 'https://sepolia.infura.io/v3/${{ secrets.SEPOLIA_API_KEY }}'; | ||
# L1_CHAIN_ID: '11155111' # Sepolia Chain ID | ||
|
||
jobs: | ||
setup: | ||
uses: ./.github/workflows/setup-runner.yml | ||
with: | ||
username: ${{ github.event.pull_request.user.login || github.actor }} | ||
runner_type: builder-x86 | ||
secrets: inherit | ||
|
||
build: | ||
needs: setup | ||
runs-on: ${{ github.event.pull_request.user.login || github.actor }}-x86 | ||
outputs: | ||
e2e_list: ${{ steps.e2e_list.outputs.list }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
#ref: "${{ env.GIT_COMMIT }}" | ||
ref: pw/new-test-2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the cron run if it is defined in a PR? If not, let's just change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, this was a oversight. |
||
|
||
- uses: ./.github/ci-setup-action | ||
with: | ||
concurrency_key: build-test-artifacts-${{ github.actor }} | ||
|
||
- name: "Build E2E Image" | ||
timeout-minutes: 40 | ||
run: | | ||
earthly-ci ./yarn-project+export-e2e-test-images | ||
|
||
- name: Create list of devnet end-to-end jobs | ||
id: e2e_list | ||
run: echo "list=$(earthly ls ./yarn-project/end-to-end | grep 'public_testnet' | sed 's/+//' | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT | ||
|
||
e2e: | ||
needs: build | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test: ${{ fromJson( needs.build.outputs.e2e_list )}} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: { ref: "${{ env.GIT_COMMIT }}" } | ||
- uses: ./.github/ci-setup-action | ||
- name: Setup and Test | ||
timeout-minutes: 40 | ||
uses: ./.github/ensure-tester-with-images | ||
with: | ||
# big machine since we're doing proving | ||
runner_type: "64core-tester-x86" | ||
builder_type: builder-x86 | ||
# these are copied to the tester and expected by the earthly command below | ||
# if they fail to copy, it will try to build them on the tester and fail | ||
builder_images_to_copy: aztecprotocol/end-to-end:${{ env.GIT_COMMIT }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# command to produce the images in case they don't exist | ||
builder_command: scripts/earthly-ci ./yarn-project+export-e2e-test-images | ||
run: | | ||
set -eux | ||
cd ./yarn-project/end-to-end/ | ||
export FORCE_COLOR=1 | ||
../../scripts/earthly-ci -P --no-output +${{ matrix.test }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { createAccounts } from '@aztec/accounts/testing'; | ||
import { type AztecNodeConfig } from '@aztec/aztec-node'; | ||
import { type AztecNode, type DebugLogger, Fr, type PXE } from '@aztec/aztec.js'; | ||
import { NULL_KEY } from '@aztec/ethereum'; | ||
import { EasyPrivateTokenContract } from '@aztec/noir-contracts.js'; | ||
import { type ProverNode, type ProverNodeConfig, getProverNodeConfigFromEnv } from '@aztec/prover-node'; | ||
|
||
import { foundry, sepolia } from 'viem/chains'; | ||
|
||
import { createAndSyncProverNode } from '../fixtures/snapshot_manager.js'; | ||
import { getPrivateKeyFromIndex, setup } from '../fixtures/utils.js'; | ||
|
||
// process.env.SEQ_PUBLISHER_PRIVATE_KEY = '<PRIVATE_KEY_WITH_SEPOLIA_ETH>'; | ||
// process.env.PROVER_PUBLISHER_PRIVATE_KEY = '<PRIVATE_KEY_WITH_SEPOLIA_ETH>'; | ||
// process.env.ETHEREUM_HOST= 'https://sepolia.infura.io/v3/<API_KEY>'; | ||
// process.env.L1_CHAIN_ID = '11155111'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this getting set for the nightly run? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently it's not as leaving everything defaulted causes the test to run against a local Anvil. Once I have seen it run successfully against Anvil I will put in another PR to set these values in the |
||
|
||
describe(`deploys and transfers a private only token`, () => { | ||
let secretKey1: Fr; | ||
let secretKey2: Fr; | ||
let proverConfig: ProverNodeConfig; | ||
let config: AztecNodeConfig; | ||
let aztecNode: AztecNode; | ||
let proverNode: ProverNode; | ||
|
||
let pxe: PXE; | ||
let logger: DebugLogger; | ||
let teardown: () => Promise<void>; | ||
|
||
beforeEach(async () => { | ||
const chainId = !process.env.L1_CHAIN_ID ? foundry.id : +process.env.L1_CHAIN_ID; | ||
const chain = chainId == sepolia.id ? sepolia : foundry; // Not the best way of doing this. | ||
({ logger, pxe, teardown, config, aztecNode } = await setup( | ||
0, | ||
{ skipProtocolContracts: true, stateLoad: undefined, salt: 1 }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh yeah. You make a good point. I was hoping to save on ETH by not re-deploying everytime but that's probably not desirable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had the same concern. |
||
{}, | ||
false, | ||
false, | ||
chain, | ||
)); | ||
proverConfig = getProverNodeConfigFromEnv(); | ||
const proverNodePrivateKey = getPrivateKeyFromIndex(2); | ||
proverConfig.publisherPrivateKey = | ||
proverConfig.publisherPrivateKey === NULL_KEY | ||
? `0x${proverNodePrivateKey?.toString('hex')}` | ||
: proverConfig.publisherPrivateKey; | ||
|
||
proverNode = await createAndSyncProverNode( | ||
config.l1Contracts.rollupAddress, | ||
proverConfig.publisherPrivateKey, | ||
config, | ||
aztecNode, | ||
); | ||
}, 600_000); | ||
|
||
afterEach(async () => { | ||
await proverNode.stop(); | ||
await teardown(); | ||
}); | ||
|
||
it('calls a private function', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've feel we've written variations of this test a dozen times already There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly. The difference here really is that this uses the |
||
const initialBalance = 100000000000n; | ||
const transferValue = 5n; | ||
secretKey1 = Fr.random(); | ||
secretKey2 = Fr.random(); | ||
|
||
logger.info(`Deploying accounts.`); | ||
|
||
const accounts = await createAccounts(pxe, 2, [secretKey1, secretKey2], { | ||
interval: 0.1, | ||
proven: true, | ||
provenTimeout: 600, | ||
}); | ||
|
||
logger.info(`Accounts deployed, deploying token.`); | ||
|
||
const [deployerWallet, recipientWallet] = accounts; | ||
|
||
const token = await EasyPrivateTokenContract.deploy( | ||
deployerWallet, | ||
initialBalance, | ||
deployerWallet.getAddress(), | ||
deployerWallet.getAddress(), | ||
) | ||
.send({ | ||
universalDeploy: true, | ||
skipPublicDeployment: true, | ||
skipClassRegistration: true, | ||
skipInitialization: false, | ||
skipPublicSimulation: true, | ||
}) | ||
.deployed({ | ||
proven: true, | ||
provenTimeout: 600, | ||
}); | ||
|
||
logger.info(`Performing transfer.`); | ||
|
||
await token.methods | ||
.transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress(), deployerWallet.getAddress()) | ||
.send() | ||
.wait({ proven: true, provenTimeout: 600 }); | ||
|
||
logger.info(`Transfer completed`); | ||
|
||
const balanceDeployer = await token.methods.get_balance(deployerWallet.getAddress()).simulate(); | ||
const balanceRecipient = await token.methods.get_balance(recipientWallet.getAddress()).simulate(); | ||
|
||
logger.info(`Deployer balance: ${balanceDeployer}, Recipient balance: ${balanceRecipient}`); | ||
|
||
expect(balanceDeployer).toBe(initialBalance - transferValue); | ||
expect(balanceRecipient).toBe(transferValue); | ||
}, 600_000); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we uncomment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not just yet. Once I have seen a successful Anvil run I will uncomment, and will have to load some ETH.