Skip to content

Commit

Permalink
feat: multicore (anoma#549)
Browse files Browse the repository at this point in the history
* feat: multicore

* test(e2e): transfers

* chore: cleanup

* test(e2e): transfers

* feat: ff multicore support

* fix: multicore namada ff and e2e timeouts
  • Loading branch information
mateuszjasiuk authored Jan 12, 2024
1 parent d373c9f commit 5528a7f
Show file tree
Hide file tree
Showing 34 changed files with 496 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-wallet-at-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:

- name: Build WASM dependencies
working-directory: ./apps/extension
run: yarn wasm:build
run: yarn wasm:build:multicore

- name: Build the extension
working-directory: ./apps/extension
Expand Down
6 changes: 4 additions & 2 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
"test": "./scripts/build-node.sh && yarn jest",
"test:watch": "./scripts/build-node.sh && yarn jest --watchAll=true",
"test:ci": "jest",
"wasm:build": "./scripts/build.sh --release",
"wasm:build:dev": "./scripts/build.sh"
"wasm:build": "node ./scripts/build.js --release",
"wasm:build:multicore": "node ./scripts/build.js --release --multicore",
"wasm:build:dev": "node ./scripts/build.js",
"wasm:build:dev:multicore": "node ./scripts/build.js --multicore"
},
"dependencies": {
"@cosmjs/encoding": "^0.29.0",
Expand Down
20 changes: 20 additions & 0 deletions apps/extension/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { spawnSync } = require("child_process");

const args = process.argv.filter((arg) => arg.match(/--\w+/));
const strippedArgs = new Set(args.map((arg) => arg.replace("--", "")));

const isRelease = strippedArgs.has("release");
const isMulticore = strippedArgs.has("multicore");
const taskShared = `wasm:build${!isRelease ? ":dev" : ""}${
isMulticore ? ":multicore" : ""
}`;

const taskCrypto = `wasm:build${!isRelease ? ":dev" : ""}`;

spawnSync("yarn", ["workspace", "@namada/crypto", "run", taskCrypto], {
stdio: "inherit",
});

spawnSync("yarn", ["workspace", "@namada/shared", "run", taskShared], {
stdio: "inherit",
});
14 changes: 0 additions & 14 deletions apps/extension/scripts/build.sh

This file was deleted.

7 changes: 6 additions & 1 deletion apps/extension/src/Setup/ImportAccount/SeedPhraseImport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ export const SeedPhraseImport: React.FC<Props> = ({ onConfirm }) => {
/>
)}
</Stack>
<ActionButton disabled={isSubmitButtonDisabled}>Import</ActionButton>
<ActionButton
data-testid="setup-import-keys-import-button"
disabled={isSubmitButtonDisabled}
>
Import
</ActionButton>
</Stack>
</>
);
Expand Down
20 changes: 17 additions & 3 deletions apps/extension/src/Setup/ImportAccount/SeedPhraseSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,25 @@ export const SeedPhraseSetup = (props: SeedPhraseSetupProps): JSX.Element => {
<PageHeader title="Set up your imported keys" />
<form onSubmit={onSubmitForm}>
<Stack gap={5}>
<AccountAlias value={accountName} onChange={setAccountName} />
{passwordRequired && <Password onValidPassword={setPassword} />}
<AccountAlias
data-testid="setup-import-keys-alias-input"
value={accountName}
onChange={setAccountName}
/>
{passwordRequired && (
<Password
data-testid="setup-import-keys-pwd-input"
onValidPassword={setPassword}
/>
)}
</Stack>
<footer className="mt-14">
<ActionButton disabled={notVerified}>Next</ActionButton>
<ActionButton
data-testid="setup-import-keys-next-button"
disabled={notVerified}
>
Next
</ActionButton>
</footer>
</form>
</>
Expand Down
1 change: 1 addition & 0 deletions apps/extension/src/Setup/Start.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const Start: React.FC = () => {
</ActionButton>
<ActionButton
size="lg"
data-testid="setup-import-keys-button"
onClick={() => navigate(routes.accountImportSeed())}
>
Import existing keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fromBase64 } from "@cosmjs/encoding";
import { deserialize, serialize } from "@dao-xyz/borsh";
import { chains, defaultChainId } from "@namada/chains";
import { Sdk } from "@namada/shared";
import { init as initShared } from "@namada/shared/src/init";
import { initMulticore as initShared } from "@namada/shared/src/init";
import { TxMsgValue } from "@namada/types";
import {
INIT_MSG,
Expand Down
7 changes: 6 additions & 1 deletion apps/extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ if (NODE_ENV === "development") {

module.exports = {
mode: NODE_ENV,
target: "web",
target: "webworker",
devtool:
NODE_ENV === "development" && TARGET === "firefox"
? "eval-source-map"
Expand All @@ -155,6 +155,7 @@ module.exports = {
output: {
publicPath: "",
path: OUTPUT_PATH,
//TODO: this might lead to problems with caching
filename: "[name].namada.js",
},
module: {
Expand Down Expand Up @@ -214,4 +215,8 @@ module.exports = {
},
},
plugins,
stats: {
// We want to ignore wasm-bindgen-rayon circular dependency warning
warningsFilter: [/dependency between chunks.+wasm-bindgen-rayon/],
},
};
7 changes: 5 additions & 2 deletions apps/namada-interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
"e2e-test": "PLAYWRIGHT_BASE_URL=http://localhost:3000 yarn playwright test",
"e2e-test:headed": "PLAYWRIGHT_BASE_URL=http://localhost:3000 yarn playwright test --project=chromium --headed",
"eject": "npx react-scripts eject",
"wasm:build": "./scripts/build.sh --release",
"wasm:build:dev": "./scripts/build.sh",
"wasm:build": "node ./scripts/build.js --release",
"wasm:build:multicore": "node ./scripts/build.js --release --multicore",
"wasm:build:dev": "node ./scripts/build.js",
"wasm:build:dev:multicore": "node ./scripts/build.js --multicore",
"wasm:build:node": "./scripts/build-node.sh"
},
"browserslist": {
Expand Down Expand Up @@ -113,6 +115,7 @@
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript-plugin-styled-components": "^2.0.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1"
}
Expand Down
19 changes: 19 additions & 0 deletions apps/namada-interface/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { spawnSync } = require("child_process");

const args = process.argv.filter((arg) => arg.match(/--\w+/));
const strippedArgs = new Set(args.map((arg) => arg.replace("--", "")));

const isRelease = strippedArgs.has("release");
const isMulticore = strippedArgs.has("multicore");
const taskShared = `wasm:build${!isRelease ? ":dev" : ""}${
isMulticore ? ":multicore" : ""
}`;
const taskCrypto = `wasm:build${!isRelease ? ":dev" : ""}`;

spawnSync("yarn", ["workspace", "@namada/crypto", "run", taskCrypto], {
stdio: "inherit",
});

spawnSync("yarn", ["workspace", "@namada/shared", "run", taskShared], {
stdio: "inherit",
});
7 changes: 0 additions & 7 deletions apps/namada-interface/scripts/build.sh

This file was deleted.

12 changes: 11 additions & 1 deletion apps/namada-interface/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const webpack = require("webpack");
const { resolve, join } = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
Expand All @@ -7,7 +9,7 @@ const { getProcessEnv } = require("@namada/config/webpack.js");
// Load environment variables
require("dotenv").config({ path: resolve(__dirname, ".env") });

const { NODE_ENV } = process.env;
const { NODE_ENV, BUNDLE_ANALYZE } = process.env;

const createStyledComponentsTransformer =
require("typescript-plugin-styled-components").default;
Expand All @@ -27,7 +29,11 @@ const copyPatterns = [
},
];

const analyzePlugins =
BUNDLE_ANALYZE === "true" ? [new BundleAnalyzerPlugin()] : [];

const plugins = [
...analyzePlugins,
new CopyPlugin({
patterns: copyPatterns,
}),
Expand Down Expand Up @@ -160,4 +166,8 @@ module.exports = {
port: 3000,
historyApiFallback: true,
},
stats: {
// We want to ignore wasm-bindgen-rayon circular dependency warning
warningsFilter: [/dependency between chunks.+wasm-bindgen-rayon/],
},
};
4 changes: 2 additions & 2 deletions e2e/genesis/localnet/parameters.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ vp_whitelist = []
tx_whitelist = []
# Implicit VP WASM name
implicit_vp = "vp_implicit"
# Expected number of epochs per year (also sets the min duration of an epoch in seconds)
epochs_per_year = 31_536_000
# Epoch every 10 mins
epochs_per_year = 87_600
# The P gain factor in the Proof of Stake rewards controller
pos_gain_p = "0.1"
# The D gain factor in the Proof of Stake rewards controller
Expand Down
1 change: 1 addition & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"lint:ci": "yarn lint --max-warnings 0",
"setup": "./setup-frontend.sh",
"test": "jest --runInBand",
"test:logs": "NAMADA_LOG=true jest --runInBand",
"test:watch": "jest --watch --runInBand"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 5528a7f

Please sign in to comment.