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

[Naga] Dev Env #653

Draft
wants to merge 65 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2160d07
feat: update endpoint version
Ansonhkg Sep 25, 2024
fd762f7
feat: always use default anvil private keys on `custom` network for t…
Ansonhkg Sep 27, 2024
87a932f
Merge branch 'master' into feature/lit-3748-naga
Ansonhkg Sep 27, 2024
c7e4806
feat: update commit hash to use `NAGA_COMMIT_HASH`
Ansonhkg Sep 30, 2024
905f450
fix: use `NAGA_COMMIT_HASH`
Ansonhkg Sep 30, 2024
9692291
feat: duplicate a job for Naga instead
Ansonhkg Sep 30, 2024
2e2ab69
fix: wrong commit hash
Ansonhkg Sep 30, 2024
f78260f
Merge branch 'staging/v7' into feature/lit-3748-naga
Ansonhkg Oct 1, 2024
7b0b43d
ref: update naga hash
Oct 1, 2024
88df20e
Merge branch 'staging/v7' into feature/lit-3748-naga
Ansonhkg Oct 2, 2024
b5f79cd
Merge branch 'staging/v7' into feature/lit-3748-naga
Ansonhkg Oct 3, 2024
70b86d0
feat: update `NAGA_COMMIT_HASH` to `d33fa3317a4b0c3aecfe6bf1ec8faa9e3…
Ansonhkg Oct 4, 2024
ecae0e5
feat: update COMMIT HASH for CI
Ansonhkg Oct 7, 2024
d4dfd95
fix(ci): remove `datil-integration-tests` job
Ansonhkg Oct 7, 2024
d667c88
Merge branch 'staging/v7' into feature/lit-3748-naga
Ansonhkg Oct 8, 2024
4f4842f
fix(package.json): add `preinstall` script for the `wasm` package
Ansonhkg Oct 8, 2024
7b84caa
chore: update package to `8.x`
Ansonhkg Oct 8, 2024
7fefe64
Merge branch 'staging/v7' into feature/lit-3748-naga
Ansonhkg Oct 8, 2024
1adf2d0
fix(ci): remove `preinstall` cus it's failing CI
Ansonhkg Oct 8, 2024
8bbb0bf
Merge branch 'staging/v7' into feature/lit-3748-naga
Ansonhkg Oct 10, 2024
bc99122
doc(bls-encrypt): better comment on G2/G1 points usage
Ansonhkg Oct 10, 2024
5f4b017
feat(bls): remove case 218 as we don't use it
Ansonhkg Oct 10, 2024
ac26418
feat: add package.json
Ansonhkg Nov 19, 2024
48ee1e8
feat: add tinnytest package.json
Ansonhkg Nov 19, 2024
24263e2
feat: tinny pkg works
Ansonhkg Nov 20, 2024
def59fc
Merge branch 'master' into feature/lit-3748-naga
Ansonhkg Dec 16, 2024
4c3f652
Merge branch 'master' into feature/lit-3748-naga
Ansonhkg Dec 16, 2024
c168b02
chore: update commit hash
Ansonhkg Dec 16, 2024
29e92be
Merge branch 'feature/lit-3748-naga' of https://github.com/LIT-Protoc…
Ansonhkg Dec 16, 2024
e4fab93
wip: test ci
Ansonhkg Dec 16, 2024
f781d9e
feat(interfaces): add nodeSet interface to interfaces that uses the E…
Ansonhkg Dec 19, 2024
2b88caf
feat: add `nodeSet` to the requests
Ansonhkg Dec 19, 2024
5fa589c
fmt
Ansonhkg Dec 19, 2024
96994c4
feat: add support for `EcdsaK256Sha256`
Ansonhkg Dec 19, 2024
2019031
feat: add price feed contract call
Ansonhkg Dec 19, 2024
fca727f
feat: add support for `EcdsaK256Sha256`
Ansonhkg Dec 19, 2024
fcc5f44
fix: it passes the `testUseEoaSessionSigsToPkpSign` test! but it's a …
Ansonhkg Dec 19, 2024
6b66532
chore: update comment for wasm error
Ansonhkg Dec 19, 2024
4766389
fix: hacky sigType map
Ansonhkg Dec 19, 2024
4ef2b8e
fmt
Ansonhkg Dec 19, 2024
345cd29
chore: update local networkContext generated by the local nodes
Ansonhkg Dec 19, 2024
432ac93
feat(priceFeed):
Ansonhkg Dec 20, 2024
d97f177
remove: deprecated code. Use `getConnectionInfo` instead
Ansonhkg Dec 20, 2024
b532c39
fmt
Ansonhkg Dec 20, 2024
741761a
feat(constant): add PRODUCT_IDS constant for price feed products
Ansonhkg Dec 20, 2024
8a0307c
Merge branch 'master' into feat/tinny-standalone
Ansonhkg Dec 30, 2024
1f33367
chore: remove built files in local-tests directory
Ansonhkg Dec 30, 2024
5148f01
chore: cleanup tinny build scripts
Ansonhkg Dec 30, 2024
35d54f6
feat: add Ci to test & verify tinny build
Ansonhkg Dec 30, 2024
da2da73
fix: remove tinny build ci and override
Ansonhkg Dec 30, 2024
5efd926
feat: duplicate the private keys if the length is only 1 cus it's gon…
Ansonhkg Dec 30, 2024
d40943e
fmt
Ansonhkg Dec 30, 2024
b976a41
feat: remove `BOOTSTRAP_URLS` as it's deprecated
Ansonhkg Dec 30, 2024
4fdeddd
feat: export utils & add custom networkContext in TinnyEnv constructor
Ansonhkg Dec 30, 2024
5a61adc
feat: include accs for tinny utils
Ansonhkg Dec 30, 2024
5515e15
chore: remove ci tests
Ansonhkg Dec 30, 2024
ac2b87f
Merge branch 'feat/tinny-standalone' into feature/lit-3748-naga
Ansonhkg Dec 30, 2024
0453483
fmt
Ansonhkg Dec 30, 2024
7cae5d8
feat: add back the CLI version of tinny to fix CI
Ansonhkg Dec 30, 2024
7490d3f
fix: ci
Ansonhkg Dec 31, 2024
fbe39cc
chore: optimise build script
Ansonhkg Dec 31, 2024
bc2ba11
Merge branch 'feat/tinny-standalone' into feature/lit-3748-naga
Ansonhkg Dec 31, 2024
0f0a9d2
chore: update to use `rc-naga-2025-01-06`
Ansonhkg Jan 6, 2025
7218f66
fix: tinny build
Ansonhkg Jan 8, 2025
27d1bdf
feat: add checks on `getPriceFeedInfo` function and type
Ansonhkg Jan 8, 2025
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
61 changes: 12 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,50 +39,43 @@ jobs:
run: yarn build:dev
- name: Run Unit tests
run: yarn tools --test --unit
integration-tests:
naga-integration-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
NAGA_COMMIT_HASH: a5afaa47ecf6d9de090c50648a44e535df091857
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Find latest datil commit hash for last successful "rust/lit-node-build-commit-hash" workflow in the Lit Assets repo
uses: LIT-Protocol/last-successful-build-action@372ea3325a894558ee74d970217ca421ea562fba
id: last-successful-build
with:
token: "${{ secrets.GH_PAT_FOR_SHIVA }}"
branch: "datil"
workflow: "rust/lit-node-build-commit-hash"
repo: LIT-Protocol/lit-assets
# this outputs to dollarSign{{ steps.last-successful-build.outputs.lastSuccessfulBuildSha }}
- name: Checkout Lit Assets
- name: Checkout Lit Actions
uses: actions/checkout@v4
id: checkout
with:
with:
fetch-depth: 0
repository: LIT-Protocol/lit-assets
ref: ${{ steps.last-successful-build.outputs.lastSuccessfulBuildSha }}
ref: ${{env.NAGA_COMMIT_HASH}}
token: ${{secrets.GH_PAT_FOR_SHIVA}}
path: ${{ github.workspace }}/lit-assets/
submodules: false
sparse-checkout: |
blockchain
rust/lit-node
blockchain
rust/lit-node
- name: Check LA dir
run: ls -la ${{github.workspace}}/lit-assets
- name: Install LA Blockchain Dependencies
run: npm i
working-directory: ${{github.workspace}}/lit-assets/blockchain/contracts
- name: Docker login
id: login
run: docker login ghcr.io/ -u ${{ github.actor }} --password ${{secrets.GH_PAT_FOR_SHIVA}}
run: docker login ghcr.io/ -u ${{secrets.GH_USER}} --password ${{secrets.GH_PAT_FOR_SHIVA}}
- name: Pull Shiva Container
id: shiva-pull
run: docker pull ghcr.io/lit-protocol/shiva:latest
run: docker pull ghcr.io/lit-protocol/shiva:latest
- name: Run Shiva Container
id: shiva-runner
run: docker run -d -m 32g -p 8000:8000 -p 8545:8545 -p 7470:7470 -p 7471:7471 -p 7472:7472 -p 7473:7473 -p 7474:7474 -p 7475:7475 -v ${{github.workspace}}/lit-assets:/data -e GH_PAT=${{secrets.GH_PAT_FOR_SHIVA}} -e HASH=${{ steps.last-successful-build.outputs.lastSuccessfulBuildSha }} -e IPFS_API_KEY=${{secrets.IPFS_API_KEY}} --name shiva ghcr.io/lit-protocol/shiva:latest
run: docker run -d -m 32g -p 8000:8000 -p 8545:8545 -p 7470:7470 -p 7471:7471 -p 7472:7472 -p 7473:7473 -p 7474:7474 -p 7475:7475 -v ${{github.workspace}}/lit-assets:/data -e GH_PAT=${{secrets.GH_PAT_FOR_SHIVA}} -e HASH=$NAGA_COMMIT_HASH -e IPFS_API_KEY=${{secrets.IPFS_API_KEY}} --name shiva ghcr.io/lit-protocol/shiva:latest
- name: Set up Node.js
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -113,34 +106,4 @@ jobs:
run: docker stop shiva && docker rm shiva
- name: Post Pull Shiva Image
if: steps.shiva-pull.outputs.exit_code == 0
run: docker rmi ghcr.io/lit-protocol/shiva
ping-lit-configuration-guides:
runs-on: ubuntu-latest
# needs: [unit-tests, integration-tests] # Make sure this job runs after others complete
steps:
- name: Get PR labels
id: pr-labels
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
with:
script: |
const labels = context.payload.pull_request.labels
.map(label => label.name)
.filter(name => name.startsWith('tag:'))
.map(name => name.split(':')[1]);
if (labels.length > 0) {
core.setOutput('tag', labels[0]);
} else {
core.setOutput('skip', 'true');
}
- name: Trigger dependencies bot in lit-configuration-guides
if: steps.pr-labels.outputs.skip != 'true'
run: |
TAG="${{ steps.pr-labels.outputs.tag }}"
curl -X POST \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ secrets.GH_PAT_LIT_CONFIGURATION_GUIDES_REPO }}" \
https://api.github.com/repos/LIT-Protocol/lit-configuration-guides/dispatches \
-d "{\"event_type\":\"dependency_update\", \"client_payload\": {\"labels\": [\"$TAG\"]}}"
env:
GH_PAT_LIT_CONFIGURATION_GUIDES_REPO: ${{ secrets.GH_PAT_LIT_CONFIGURATION_GUIDES_REPO }}
run: docker rmi ghcr.io/lit-protocol/shiva
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/out-tsc
**/dist
**/out-tsc
local-tests/**/*.js

# dependencies
node_modules
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": true,
"useWorkspaces": true,
"version": "7.0.3"
"version": "8.0.0-alpha.0"
}
98 changes: 50 additions & 48 deletions local-tests/build.mjs
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
import * as esbuild from 'esbuild';
import { nodeExternalsPlugin } from 'esbuild-node-externals';
import fs from 'fs';
import { fileURLToPath } from 'url';

const TEST_DIR = 'local-tests';
const ALLOW_LIST = [
'ethers',
'@lit-protocol/accs-schemas',
'@lit-protocol/contracts',
'crypto',
'secp256k1',
'cross-fetch',
];

const getPath = (relativePath) =>
fileURLToPath(new URL(relativePath, import.meta.url));

/**
* Builds the project using esbuild.
* @returns {Promise<void>} A promise that resolves when the build is complete.
* Common esbuild configuration options.
* @param {string} entry - Entry file path.
* @param {string} outfile - Output file path.
* @param {string} [globalName] - Optional global name for the bundle.
* @returns {esbuild.BuildOptions} Esbuild configuration object.
*/
const createBuildConfig = (entry, outfile, globalName) => ({
entryPoints: [getPath(entry)],
outfile: getPath(outfile),
bundle: true,
plugins: [
nodeExternalsPlugin({
allowList: ALLOW_LIST,
}),
],
platform: 'node',
target: 'esnext',
format: 'esm',
inject: [getPath('./shim.mjs')],
mainFields: ['module', 'main'],
...(globalName ? { globalName } : {}),
});

/**
* Builds the CLI-enabled version of Tinny.
*/
export const build = async () => {
await esbuild.build({
entryPoints: [`${TEST_DIR}/test.ts`],
outfile: `./${TEST_DIR}/build/test.mjs`,
bundle: true,
plugins: [
nodeExternalsPlugin({
allowList: [
'ethers',
'@lit-protocol/accs-schemas',
'@lit-protocol/contracts',
'crypto',
'secp256k1',
],
}),
],
platform: 'node',
target: 'esnext',
format: 'esm',
inject: [`./${TEST_DIR}/shim.mjs`],
mainFields: ['module', 'main'],
});
await esbuild.build(createBuildConfig('./test.ts', './build/test.mjs'));
};

/**
* Inserts a polyfill at the beginning of a file.
* The polyfill ensures that the global `fetch` function is available.
* @returns {void}
* Bundles Tinny as a standalone package.
*/
export const postBuildPolyfill = () => {
try {
const file = fs.readFileSync(`./${TEST_DIR}/build/test.mjs`, 'utf8');
const content = `import fetch from 'node-fetch';
try {
if (!globalThis.fetch) {
globalThis.fetch = fetch;
}
} catch (error) {
console.error('❌ Error in polyfill', error);
}
`;
const newFile = content + file;
fs.writeFileSync(`./${TEST_DIR}/build/test.mjs`, newFile);
} catch (e) {
throw new Error(`Error in postBuildPolyfill: ${e}`);
}
export const bundle = async () => {
await esbuild.build(
createBuildConfig('./index.ts', './index.js', 'tinnySdk')
);
};

// Go!
(async () => {
const start = Date.now();
await build();
postBuildPolyfill();
console.log(`[build.mjs] 🚀 Build time: ${Date.now() - start}ms`);
try {
await build();
await bundle();
console.log(`[build.mjs] 🚀 Build time: ${Date.now() - start}ms`);
} catch (error) {
console.error(`[build.mjs] ❌ Build failed:`, error);
}
})();
33 changes: 33 additions & 0 deletions local-tests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { TinnyEnvironment } from './setup/tinny-environment';
import { runInBand, runTestsParallel } from './setup/tinny-operations';
import * as tinnyTests from './tests';
import { getEoaSessionSigs } from './setup/session-sigs/get-eoa-session-sigs';
import { getLitActionSessionSigs } from './setup/session-sigs/get-lit-action-session-sigs';
import { getPkpSessionSigs } from './setup/session-sigs/get-pkp-session-sigs';
import { AccessControlConditions } from './setup/accs/accs';

export {
TinnyEnvironment,
runInBand,
runTestsParallel,
tinnyTests,
getEoaSessionSigs,
getLitActionSessionSigs,
getPkpSessionSigs,
AccessControlConditions,
};

// Usage
// const devEnv = new TinnyEnvironment();

// await devEnv.init();

// const testConfig = {
// tests: {
// testEthAuthSigToEncryptDecryptString,
// },
// devEnv,
// }

// const res = await runTestsParallel(testConfig);
// console.log("res:", res);
97 changes: 97 additions & 0 deletions local-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"name": "@lit-protocol/tinny",
"version": "0.0.5",
"description": "A package to run the test script for Lit Protocol with custom commands",
"type": "module",
"main": "./index.js",
"typings": "./index.ts",
"license": "MIT",
"author": "Anson (https://github.com/ansonhkg)",
"publishConfig": {
"access": "public",
"directory": "./"
},
"dependencies": {
"@cosmjs/amino": "0.30.1",
"@cosmjs/crypto": "0.30.1",
"@cosmjs/encoding": "0.30.1",
"@cosmjs/proto-signing": "0.30.1",
"@cosmjs/stargate": "0.30.1",
"@cypress/code-coverage": "^3.10.0",
"@cypress/react": "^6.2.0",
"@cypress/webpack-dev-server": "^2.3.0",
"@lit-protocol/accs-schemas": "0.0.7",
"@metamask/eth-sig-util": "5.0.2",
"@mysten/sui.js": "^0.37.1",
"@playwright/test": "^1.25.2",
"@simplewebauthn/browser": "^7.2.0",
"@simplewebauthn/typescript-types": "^7.0.0",
"@spruceid/siwe-parser": "2.0.0",
"@synthetixio/js": "^2.41.0",
"@testing-library/cypress": "^8.0.3",
"@testing-library/react": "^13.4.0",
"@types/testing-library__cypress": "^5.0.9",
"@walletconnect/core": "2.9.2",
"@walletconnect/ethereum-provider": "2.9.2",
"@walletconnect/jsonrpc-utils": "1.0.8",
"@walletconnect/modal": "2.6.1",
"@walletconnect/types": "2.9.2",
"@walletconnect/utils": "2.9.2",
"@walletconnect/web3wallet": "1.8.8",
"@websaam/nx-esbuild": "^0.0.1",
"ajv": "^8.12.0",
"axios": "^0.27.2",
"base64url": "^3.0.1",
"bitcoinjs-lib": "^6.1.0",
"blockstore-core": "^3.0.0",
"browserify-zlib": "^0.2.0",
"bs58": "^5.0.0",
"bytes32": "^0.0.3",
"cbor-web": "^9.0.1",
"commander": "^9.4.0",
"concurrently": "^7.4.0",
"core-js": "^3.6.5",
"cross-fetch": "3.1.4",
"crypto-browserify": "^3.12.0",
"cypress-wait-until": "^1.7.2",
"cypress-watch-and-reload": "^1.10.3",
"date-and-time": "^2.4.1",
"dotenv": "^16.0.2",
"dotenv-parse-variables": "^2.0.0",
"download": "^8.0.0",
"ethers": "^5.7.1",
"etherscan-api": "^10.2.0",
"find-config": "^1.0.0",
"g": "^2.0.1",
"https-browserify": "^1.0.0",
"jose": "^4.14.4",
"jszip": "^3.10.1",
"micromodal": "^0.4.10",
"multiformats": "^9.7.1",
"nanoid": "3.3.4",
"next": "13.3.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"regenerator-runtime": "0.13.7",
"secp256k1": "^5.0.0",
"serve": "^14.0.1",
"siwe": "^2.0.5",
"siwe-recap": "0.0.2-alpha.0",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"synthetix-js": "^2.74.1",
"tslib": "^2.3.0",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1",
"uint8arrays": "^4.0.3",
"@openagenda/verror": "^3.1.4",
"ipfs-unixfs-importer": "12.0.1",
"@solana/web3.js": "^1.95.3",
"bech32": "^2.0.0",
"pako": "^2.1.0",
"@lit-protocol/misc": "^7.0.0",
"@lit-protocol/lit-node-client": "^7.0.0",
"@lit-protocol/lit-auth-client": "^7.0.0",
"@lit-protocol/contracts": "^0.0.71"
}
}
Loading