Skip to content

Commit

Permalink
Merge branch 'master' into rust
Browse files Browse the repository at this point in the history
  • Loading branch information
sneurlax authored Oct 16, 2024
2 parents b556f50 + 9390400 commit 6260fed
Show file tree
Hide file tree
Showing 20 changed files with 1,235 additions and 628 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/full_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ jobs:
key: depends-${{ github.job }}-${{ matrix.coin }}-${{ hashFiles('*/contrib/depends/packages/*.mk') }}
- name: build
run: |
./build_single.sh ${{ matrix.coin }} aarch64-host-apple-darwin -j$(sysctl -n hw.logicalcpu)
./build_single.sh ${{ matrix.coin }} aarch64-host-apple-darwin -j$(sysctl -n hw.logicalcpu)
- name: rename artifacts
run: |
mkdir release/gh/
Expand Down Expand Up @@ -448,7 +448,7 @@ jobs:
key: depends-${{ github.job }}-${{ matrix.coin }}-${{ hashFiles('*/contrib/depends/packages/*.mk') }}
- name: build
run: |
./build_single.sh ${{ matrix.coin }} host-apple-ios -j$(sysctl -n hw.logicalcpu)
./build_single.sh ${{ matrix.coin }} host-apple-ios -j$(sysctl -n hw.logicalcpu)
- name: rename artifacts
run: |
mkdir release/gh/
Expand Down Expand Up @@ -586,6 +586,32 @@ jobs:
cd impls/monero.ts
deno run --unstable-ffi --allow-ffi checksum.ts
regression_check:
strategy:
matrix:
coin: [monero, wownero]
needs: [
lib_linux
]
runs-on: ubuntu-24.04
steps:
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- uses: actions/download-artifact@v4
with:
name: linux ${{ matrix.coin }}
path: release/${{ matrix.coin }}

- name: Run regression tests
run: COIN="${{ matrix.coin }}" deno test -A tests/

comment_pr:
name: comment on pr
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
release/
build/
tests/monero-cli
tests/libs
tests/wallets
17 changes: 12 additions & 5 deletions impls/monero.ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
This library does not ship with `monero_c` libraries.\
To use these bindings you have to bring your own `monero_c` libraries.\
There are at least two ways to do so:

- Ahead-of-time, during builds where you only ship necessary library for a given platform.\
See [monero-tui](https://github.com/Im-Beast/monero-tui/blob/main/.github/workflows/dev-build.yml) build workflow as an example of doing so.
See [monero-tui](https://github.com/Im-Beast/monero-tui/blob/main/.github/workflows/dev-build.yml) build workflow as
an example of doing so.
```ts
import { loadDylib, Wallet, WalletManager } from "https://raw.githubusercontent.com/MrCyjaneK/monero_c/master/impls/monero.ts/mod.ts";
import {
loadMoneroDylib,
Wallet,
WalletManager,
} from "https://raw.githubusercontent.com/MrCyjaneK/monero_c/master/impls/monero.ts/mod.ts";

// Try to load dylib from the default lib/* path
loadDylib();
// You can also use loadWowneroDylib for Wownero
loadMoneroDylib();

const wm = await WalletManager.new();
const wallet = await Wallet.create(wm, "./my_wallet", "password");
Expand All @@ -27,11 +34,11 @@ There are at least two ways to do so:
```ts
import { dlopen } from "jsr:@denosaurs/plug";
// It's recommened to put the monero.ts github link into your import_map to reduce the url clutter
import { loadDylib, symbols, Wallet, WalletManager } from "https://raw.githubusercontent.com/MrCyjaneK/monero_c/master/impls/monero.ts/mod.ts";
import { loadMoneroDylib, symbols, Wallet, WalletManager } from "https://raw.githubusercontent.com/MrCyjaneK/monero_c/master/impls/monero.ts/mod.ts";

// Load dylib loaded by plug
const lib = await dlopen(..., symbols);
loadDylib(lib);
loadMoneroDylib(lib);

const wm = await WalletManager.new();
const wallet = await Wallet.create(wm, "./my_wallet", "password");
Expand Down
12 changes: 6 additions & 6 deletions impls/monero.ts/checksum.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { moneroChecksum } from "./checksum_monero.ts";
import { readCString } from "./src/utils.ts";
import { dylib, loadDylib } from "./src/bindings.ts";
import { getSymbol, readCString } from "./src/utils.ts";
import { dylib, loadMoneroDylib } from "./src/bindings.ts";

loadDylib();
loadMoneroDylib();

export class ChecksumError extends Error {
readonly code: number;
Expand All @@ -21,7 +21,7 @@ export class ChecksumError extends Error {
* @returns {ChecksumError} which contains information about why checksum failed
*/
export async function validateChecksum(): Promise<ChecksumError | null> {
const cppHeaderHash = await readCString(await dylib.symbols.MONERO_checksum_wallet2_api_c_h(), false);
const cppHeaderHash = await readCString(await getSymbol("checksum_wallet2_api_c_h")!(), false);
const tsHeaderHash = moneroChecksum.wallet2_api_c_h_sha256;

const errors: string[] = [];
Expand All @@ -32,14 +32,14 @@ export async function validateChecksum(): Promise<ChecksumError | null> {
errorCode++;
}

const cppSourceHash = await readCString(await dylib.symbols.MONERO_checksum_wallet2_api_c_cpp(), false);
const cppSourceHash = await readCString(await getSymbol("checksum_wallet2_api_c_cpp")!(), false);
const tsSourceHash = moneroChecksum.wallet2_api_c_cpp_sha256;
if (cppSourceHash !== tsSourceHash) {
errors.push(`ERR: CPP source file check mismatch ${cppSourceHash} == ${tsSourceHash}`);
errorCode++;
}

const cppExportHash = await readCString(await dylib.symbols.MONERO_checksum_wallet2_api_c_exp(), false);
const cppExportHash = await readCString(await getSymbol("checksum_wallet2_api_c_exp")!(), false);
const tsExportHash = moneroChecksum.wallet2_api_c_exp_sha256;
if (cppExportHash !== tsExportHash) {
if (Deno.build.os !== "darwin") {
Expand Down
Loading

0 comments on commit 6260fed

Please sign in to comment.