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

Add minimal viable Anchor #602

Merged
merged 29 commits into from
Sep 17, 2024
Merged

Add minimal viable Anchor #602

merged 29 commits into from
Sep 17, 2024

Conversation

chrismaree
Copy link
Member

@chrismaree chrismaree commented Sep 10, 2024

This PR re-works this repo to work alongside Solana Anchor. To achieve this, it adds a number of dependencies and re-works a lot of the repo layout, such as moving where some tests are located (hence the large file diff). In broad strokes this PR does:

  • Updates the repo to work with node 20. to achieve this two deprecated & redundant packages were removed arb-bridge-eth and arb-bridge-peripherals. both of these are not supported by Arbitrum anymore. We only used these packages to fetch the interfaces in some tests when creating a fake. to supplement this, the ArbutrumMocks.sol was updated to store the same interface (see here).
  • Added required MVP anchor files, including Anchor.toml, Cargo.lock, Cargo.toml, Programs/x, test/svm/x. sample program has the simplest posible SVM contract and test to show the tooling working.
  • Moved existing EVM tests from /test/x to /test/evm/hardhat & /test/evm/foundry to better separate test directories and not mix and match the way things were before. This required editing all ts files within the test directory, hence the large change in the PR (done with an automated tool).
  • Updates the GitHub work flow. This change was pretty extensive. I did the following:
    • Updated to node 20. Added the setup and build for Anchor + solana local key gen + rust compilation steps.
    • Removed the Solhint job and rather placed this within the Lint job. Solhint is just a lint flow. now, we have a Lint job that does: a) lint-js, b) lint-solidity, c) lint-rust.
    • Re-work the Test job to now have: a) test evm-hardhat, b test svm. The test evm-forge is left as a separate job (under the title Forge) to keep the speed of CI up.

Signed-off-by: chrismaree <[email protected]>
Copy link

socket-security bot commented Sep 10, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@babel/[email protected] None 0 248 kB nicolo-ribaudo
npm/@coral-xyz/[email protected] None 0 37.1 kB acheroncrypto
npm/@coral-xyz/[email protected] environment, filesystem, network 0 1.8 MB acheroncrypto
npm/@coral-xyz/[email protected] None 0 22.2 kB acheroncrypto
npm/@noble/[email protected] None 0 1.6 MB paulmillr
npm/@noble/[email protected] None 0 837 kB paulmillr
npm/@solana/[email protected] None 0 197 kB steveluscher
npm/@solana/[email protected] network 0 10.9 MB lorisleiva
npm/@swc/[email protected] None 0 231 kB kdy1, kwonoj
npm/@types/[email protected] None 0 5.91 kB types
npm/@types/[email protected] None 0 6.67 kB types
npm/@types/[email protected] None 0 21.2 kB types
npm/[email protected] network 0 43.7 kB fengmk2
npm/[email protected] None 0 55.7 kB no2chem
npm/[email protected] None 0 99 kB fanatid
npm/[email protected] None 0 34.6 kB volovyk-s
npm/[email protected] None 0 213 kB pabigot
npm/[email protected] None 0 11.7 kB sindresorhus
npm/[email protected] network 0 75.1 kB lquixada
npm/[email protected] None 0 9.42 kB sindresorhus
npm/[email protected] None 0 11.2 kB sindresorhus
npm/[email protected] None 0 10.5 kB blakeembrey
npm/[email protected] None 0 7.76 kB digitaldesignlabs
npm/[email protected] None 0 38 kB lpinca
npm/[email protected] None 0 14 kB indexzero
npm/[email protected] None 0 125 kB nickyout
npm/[email protected] None 0 3.66 kB dead_horse
npm/[email protected] None 0 3.89 kB heineiuo
npm/[email protected] None 0 162 kB tedeh
npm/[email protected] None 0 36.8 kB creationix
npm/[email protected] None 0 0 B
npm/[email protected] None 0 17.7 kB blakeembrey
npm/[email protected] environment, eval, filesystem 0 3.91 MB juergba
npm/[email protected] None 0 6.72 kB styfle
npm/[email protected] None 0 25.1 kB blakeembrey
npm/[email protected] network 0 162 kB node-fetch-bot
npm/[email protected] None 0 1.64 MB vitaly
npm/[email protected] None 0 27.9 kB benjamn
npm/[email protected] None 0 332 kB mkozjak
npm/[email protected] None 0 10.4 kB blakeembrey
npm/[email protected] None 0 182 kB artmllr
npm/[email protected] None 0 79.4 kB arv
npm/[email protected] None 0 12.5 kB dominictarr
npm/[email protected] None 0 144 kB binarymuse
npm/[email protected] None 0 86.2 kB typescript-bot
npm/[email protected] None 0 116 kB ctavan
npm/[email protected] environment, network 0 147 kB lpinca

🚮 Removed packages: npm/@babel/[email protected], npm/@sqltools/[email protected], npm/@types/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

@chrismaree chrismaree marked this pull request as draft September 10, 2024 10:52
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
@@ -29,3 +29,27 @@ contract ArbitrumMockErc20GatewayRouter {
return address(this);
}
}

contract Inbox {
Copy link
Member Author

@chrismaree chrismaree Sep 10, 2024

Choose a reason for hiding this comment

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

interfaces added to replace the need for arb-bridge-eth and arb-bridge-peripherals

utils/utils.ts Outdated Show resolved Hide resolved
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
@@ -66,8 +71,8 @@
"@types/node": "^12.0.0",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"arb-bridge-eth": "^0.7.4",
Copy link
Member Author

Choose a reason for hiding this comment

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

packages removed to get node 20 support.

@chrismaree chrismaree changed the title Add minimal viable svm Add minimal viable Anchor Sep 11, 2024
@chrismaree chrismaree marked this pull request as ready for review September 11, 2024 09:38
@@ -19,20 +19,25 @@
"main": "dist/index.js",
"scripts": {
Copy link
Member Author

Choose a reason for hiding this comment

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

note some of the extra split up scripts that I added so we can have seperate parts executed from CI job. We might want to further split up the build command.

Signed-off-by: chrismaree <[email protected]>
cache: "yarn"
node-version: "${{ matrix.node }}"
cache: yarn
- name: Setup Anchor & Build
Copy link
Member

Choose a reason for hiding this comment

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

Aside: is github CI smart enough to only run certain tasks if certain files are changed? For example, we should only run anchor tasks if solana files are touched right?

Copy link
Member Author

Choose a reason for hiding this comment

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

not easily. right now it will do all parts of the work flow on each run. we can improve this later. it's not too slow by comparison to how it was before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Conditional runs are pretty hard, but I think there are easier ways to make it less imapctful.

Two things on this if it becomes a pain point:

  • We can use a docker image with rust tools and/or solana tools preinstalled.
  • We can run this setup in parallel while we're doing EVM build, tests, etc, which I suspect will take longer.

Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

LGTM just a few small questions around ci.

I also ran the install and svm-test locally. All worked great.

cache: "yarn"
node-version: "${{ matrix.node }}"
cache: yarn
- name: Setup Anchor & Build
Copy link
Contributor

Choose a reason for hiding this comment

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

Conditional runs are pretty hard, but I think there are easier ways to make it less imapctful.

Two things on this if it becomes a pain point:

  • We can use a docker image with rust tools and/or solana tools preinstalled.
  • We can run this setup in parallel while we're doing EVM build, tests, etc, which I suspect will take longer.

run: solana-keygen new --no-bip39-passphrase
shell: bash
- name: Make Anchor.toml compatible with runner
run: "sed -i 's:/user/:/runner/:' Anchor.toml"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the string user in the Anchor.toml?

Copy link
Member Author

Choose a reason for hiding this comment

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

I might actually be able to delete this. it was trying to get anchor to detect the solana-keygen new command from above. the util can in some environments place the key in a location anchor cant find it, hence this command. but it looks like we don't need that after all and the tests run without it.

@@ -24,6 +24,13 @@ jobs:
uses: manovotny/[email protected]

# Setup .npmrc file to publish to npm
- name: Setup Anchor & Build
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move the comment above down to above npm?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, sorry. I messed that up. have fixed it.

with:
anchor-version: 0.30.1
solana-cli-version: 1.18.21
node-version: 20.17.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this break if the node version varies (i.e. 20 resolves to 20.17.1)?

Can we just specify 20 here or does it have to be specific?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it will work just fine? the version specified above in the config has 20 set, with no sub versions. I'll try changing this here and see if the workflow still runs.

Copy link
Member Author

Choose a reason for hiding this comment

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

test worked just fine with the node version simply being "20"

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect

@@ -468,6 +468,9 @@ const config: HardhatUserConfig = {
outDir: "./typechain",
target: "ethers-v5",
},
paths: {
tests: "./test/evm/hardhat",
Copy link
Contributor

Choose a reason for hiding this comment

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

You've double checked that this still runs all the tests, right? Just want to double check that a change like this doesn't accidentally disable all the evm tests because of a minor typo or config issue causes it to point at an empty dir.

Copy link
Member Author

Choose a reason for hiding this comment

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

2024-09-15 at 19 19 08@2x

Copy link
Member Author

Choose a reason for hiding this comment

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

2024-09-15 at 19 19 43@2x

Copy link
Contributor

Choose a reason for hiding this comment

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

Amazing

Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

LGTM!

@chrismaree chrismaree merged commit 5c779a9 into master Sep 17, 2024
9 checks passed
@chrismaree chrismaree deleted the chrismaree/add-anchor-minimum branch September 17, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants