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

solana: Document IDL repo policy, tools, and CI checks #443

Open
johnsaigle opened this issue May 8, 2024 · 4 comments
Open

solana: Document IDL repo policy, tools, and CI checks #443

johnsaigle opened this issue May 8, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed solana Change to Solana programs tooling

Comments

@johnsaigle
Copy link
Collaborator

johnsaigle commented May 8, 2024

Issue

A PR I wrote is failing due to issues with the IDL generated by the new code and the code committed to the repo (I think)?
https://github.com/wormhole-foundation/example-native-token-transfers/actions/runs/8943060910/job/24566966899?pr=298

In general I'm sort of lost regarding what parts of the build happens where.

Desired solution

  • Add some quick, grok-able steps for patching Solana code quickly.
  • Identify which parts of the process are covered by the various build tools (Makefile, Docker, bash scripts, GitHub CI workflows) and how to reproduce remote commands locally

Details/Pain Points

It's not obvious how to resolve this issue:

  • Running the command git diff --exit-code idl locally didn't work
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
  • There is no obvious target in the Makefile either in the top-level directory or the solana/ directory

  • Running the scripts in solana/scripts fails:

./scripts/patch-idl
./scripts/patch-idl: line 5: $1: unbound variable

./scripts/run-ts-tests
Patched ../target/idl/example_native_token_transfers.json
yarn run v1.22.22
$ solana/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*.ts'
secp256k1 unavailable, reverting to browser version
(node:77102) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)


  example-native-token-transfers
    1) "before all" hook for "Can check version"


  0 passing (43ms)
  1 failing

  1) example-native-token-transfers
       "before all" hook for "Can check version":
     TypeError: fetch failed
      at node:internal/deps/undici/undici:12502:13
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at ClientBrowser.callServer (node_modules/@solana/web3.js/src/connection.ts:1625:17)
  • docker build . did not yield helpful results:
[+] Building 0.5s (3/3) FINISHED                                                                                                                                                                                                                             docker:desktop-linux
=> [internal] load build definition from Dockerfile                                                                                                                                                                                                                         0.0s
=> => transferring dockerfile: 2.09kB                                                                                                                                                                                                                                       0.0s
=> ERROR [internal] load metadata for docker.io/library/solana-contract:latest                                                                                                                                                                                              0.4s
=> [internal] load metadata for docker.io/backpackapp/build:v0.29.0@sha256:9aee169b2d8b89b4a4243419ae35c176773136e78d751b3e439eff692c9c1293                                                                                                                                 0.4s
------
> [internal] load metadata for docker.io/library/solana-contract:latest:
------
Dockerfile:37
--------------------
 35 |     COPY --from=solana-contract /opt/solana/deps/nft_bridge.so /opt/solana/deps/nft_bridge.so
 36 |     COPY --from=solana-contract /opt/solana/deps/cpi_poster.so /opt/solana/deps/cpi_poster.so
 37 | >>> COPY --from=solana-contract /opt/solana/deps/mpl_token_metadata.so /opt/solana/deps/mpl_token_metadata.so
 38 |     COPY --from=solana-contract /opt/solana/deps/wormhole_migration.so /opt/solana/deps/wormhole_migration.so
 39 |
--------------------
ERROR: failed to solve: solana-contract: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/ykv6p646wgr65ko57ypmxw5s7
@johnsaigle johnsaigle added documentation Improvements or additions to documentation help wanted Extra attention is needed tooling solana Change to Solana programs labels May 8, 2024
@barnjamin
Copy link
Contributor

barnjamin commented May 9, 2024

In this case, I think the issue is related to the IDL being slightly different and not checked in.

The test that is failing is https://github.com/wormhole-foundation/example-native-token-transfers/blob/main/.github/workflows/solana.yml#L137-L139

It should be possible to run the idl generation command in the make file and commit the updated IDL so that git diff doesn't complain

That said, we should definitely have some docs around the build process and tests for this

@johnsaigle
Copy link
Collaborator Author

Thanks for the comment. Agreed that CI check is the issue but I'm still not clear on how to solve it.

It should be possible to run the idl generation command in the make file

Which command? I tried build, _anchor-build, and make target/idl/example_native_token_transfers.json. After these I tried to check with git status and couldn't find any modified files to commit.

git diff doesn't complain

I'm probably missing something here, but I'm unable to reproduce the issue locally:

fatal: ambiguous argument 'idl': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

@barnjamin
Copy link
Contributor

I think it'd be make idl in the solana directory

after running that command, i get the following status:

ben@pluto:~/examples/example-native-token-transfers/solana$ git status
On branch solana/empty-transceiver-guard
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   idl/json/dummy_transfer_hook.json
        modified:   idl/json/example_native_token_transfers.json
        modified:   idl/ts/dummy_transfer_hook.ts
        modified:   idl/ts/example_native_token_transfers.ts

no changes added to commit (use "git add" and/or "git commit -a")

@johnsaigle
Copy link
Collaborator Author

We resolved this issue. Turns out my PR was not rebased on main so I was missing the make idl target.
Leaving this open because it's still probably worth documenting some of this stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed solana Change to Solana programs tooling
Projects
None yet
Development

No branches or pull requests

2 participants