Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/actions/run-polkadot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
ref: ${{ inputs.polkadot-version }}
path: polkadot-sdk
- name: Apply Polkadot patches
run: git apply ../substrate-tip-bot/polkadot.e2e.patch
run: git apply ../substrate-tip-bot/polkadot.e2e.patch --unidiff-zero
shell: bash
working-directory: polkadot-sdk
- name: Restore cached Polkadot build
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
branches:
- master

schedule:
# every week Monday 8:00 AM UTC
- cron: '0 8 * * 1'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -19,7 +23,7 @@ jobs:
- name: Start a local Polkadot node
uses: ./.github/actions/run-polkadot
with:
polkadot-version: polkadot-v1.15.0
polkadot-version: polkadot-v1.18.6
- name: Wait for the node
run: |
until curl -s '127.0.0.1:9902'; do sleep 3; done
Expand Down
4 changes: 2 additions & 2 deletions .papi/descriptors/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.0-autogenerated.13825733048180440900",
"version": "0.1.0-autogenerated.5767143997680986487",
"name": "@polkadot-api/descriptors",
"files": [
"dist"
Expand All @@ -19,6 +19,6 @@
"types": "./dist/index.d.ts",
"sideEffects": false,
"peerDependencies": {
"polkadot-api": "*"
"polkadot-api": ">=1.11.2"
}
}
Binary file modified .papi/metadata/kusama.scale
Binary file not shown.
Binary file modified .papi/metadata/polkadot.scale
Binary file not shown.
Binary file modified .papi/metadata/rococo.scale
Binary file not shown.
Binary file modified .papi/metadata/westend.scale
Binary file not shown.
16 changes: 12 additions & 4 deletions .papi/polkadot-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@
"polkadot": {
"wsUrl": "wss://rpc.polkadot.io",
"chain": "polkadot",
"metadata": ".papi/metadata/polkadot.scale"
"metadata": ".papi/metadata/polkadot.scale",
"genesis": "0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3",
"codeHash": "0x716bb701ec19452fa522cdaa83ef101d368ba2bcfd89fde9acb6f793a420a616"
},
"kusama": {
"wsUrl": "wss://kusama-rpc.polkadot.io",
"chain": "ksmcc3",
"metadata": ".papi/metadata/kusama.scale"
"metadata": ".papi/metadata/kusama.scale",
"genesis": "0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe",
"codeHash": "0xf45689276dfdcf05b6defd26da68e3283a96190d789f7a311ff31f64b455b421"
},
"westend": {
"wsUrl": "wss://westend-rpc.polkadot.io",
"chain": "westend2",
"metadata": ".papi/metadata/westend.scale"
"metadata": ".papi/metadata/westend.scale",
"genesis": "0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e",
"codeHash": "0xe042061a17fc950bbee15fdc7997fb04fd1a8e7b3af8c59655f19eaaa23cce28"
},
"rococo": {
"wsUrl": "wss://rococo-rpc.polkadot.io",
"chain": "rococo_v2_2",
"metadata": ".papi/metadata/rococo.scale"
"metadata": ".papi/metadata/rococo.scale",
"genesis": "0x6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e",
"codeHash": "0xf645d939be087a8a76ade94d3e28f51f0c4b70abfc0db8b302e2372590b9e31a"
}
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"@eng-automation/integrations": "^4.4.0",
"@eng-automation/js": "^2.2.0",
"@polkadot-api/descriptors": "portal:.papi/descriptors",
"@polkadot-labs/hdkd": "^0.0.6",
"@polkadot-labs/hdkd-helpers": "^0.0.6",
"@polkadot-labs/hdkd": "^0.0.17",
"@polkadot-labs/hdkd-helpers": "^0.0.17",
"concurrently": "^8.2.2",
"ethers": "^5.7.2",
"matrix-js-sdk": "^26.1.0",
"polkadot-api": "1.2.0",
"polkadot-api": "^1.13.1",
"probot": "^12.2.8",
"prom-client": "^14.2.0"
},
Expand Down
32 changes: 16 additions & 16 deletions polkadot.e2e.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/polkadot/runtime/rococo/src/governance/mod.rs b/polkadot/runtime/rococo/src/governance/mod.rs
index ef2adf60753..218c0a3c837 100644
index 4cd7739..08a43de 100644
--- a/polkadot/runtime/rococo/src/governance/mod.rs
+++ b/polkadot/runtime/rococo/src/governance/mod.rs
@@ -35,7 +35,7 @@ mod fellowship;
Expand All @@ -12,11 +12,11 @@ index ef2adf60753..218c0a3c837 100644

impl pallet_conviction_voting::Config for Runtime {
diff --git a/polkadot/runtime/rococo/src/governance/tracks.rs b/polkadot/runtime/rococo/src/governance/tracks.rs
index 3765569f183..ed226f4ef65 100644
index 62229ff..70601da 100644
--- a/polkadot/runtime/rococo/src/governance/tracks.rs
+++ b/polkadot/runtime/rococo/src/governance/tracks.rs
@@ -212,10 +212,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15
name: "small_tipper",
@@ -215,10 +215,10 @@ const TRACKS_DATA: [pallet_referenda::Track<u16, Balance, BlockNumber>; 15] = [
name: s("small_tipper"),
max_deciding: 200,
decision_deposit: 1 * 3 * CENTS,
- prepare_period: 1 * MINUTES,
Expand All @@ -30,8 +30,8 @@ index 3765569f183..ed226f4ef65 100644
min_approval: APP_SMALL_TIPPER,
min_support: SUP_SMALL_TIPPER,
},
@@ -226,10 +226,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15
name: "big_tipper",
@@ -229,10 +229,10 @@ const TRACKS_DATA: [pallet_referenda::Track<u16, Balance, BlockNumber>; 15] = [
name: s("big_tipper"),
max_deciding: 100,
decision_deposit: 10 * 3 * CENTS,
- prepare_period: 4 * MINUTES,
Expand All @@ -46,10 +46,10 @@ index 3765569f183..ed226f4ef65 100644
min_support: SUP_BIG_TIPPER,
},
diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs
index 7309eeead31..35d75fc49cd 100644
index 58593ff..1705eab 100644
--- a/polkadot/runtime/rococo/src/lib.rs
+++ b/polkadot/runtime/rococo/src/lib.rs
@@ -477,7 +477,7 @@ parameter_types! {
@@ -507,7 +507,7 @@ parameter_types! {
}

parameter_types! {
Expand All @@ -59,7 +59,7 @@ index 7309eeead31..35d75fc49cd 100644
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
diff --git a/polkadot/runtime/westend/src/governance/mod.rs b/polkadot/runtime/westend/src/governance/mod.rs
index d027f788d71..de6f36ecfce 100644
index 50d29bc..1e86f84 100644
--- a/polkadot/runtime/westend/src/governance/mod.rs
+++ b/polkadot/runtime/westend/src/governance/mod.rs
@@ -32,7 +32,7 @@ mod tracks;
Expand All @@ -72,11 +72,11 @@ index d027f788d71..de6f36ecfce 100644

impl pallet_conviction_voting::Config for Runtime {
diff --git a/polkadot/runtime/westend/src/governance/tracks.rs b/polkadot/runtime/westend/src/governance/tracks.rs
index 3765569f183..ed226f4ef65 100644
index 62229ff..70601da 100644
--- a/polkadot/runtime/westend/src/governance/tracks.rs
+++ b/polkadot/runtime/westend/src/governance/tracks.rs
@@ -212,10 +212,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15
name: "small_tipper",
@@ -215,10 +215,10 @@ const TRACKS_DATA: [pallet_referenda::Track<u16, Balance, BlockNumber>; 15] = [
name: s("small_tipper"),
max_deciding: 200,
decision_deposit: 1 * 3 * CENTS,
- prepare_period: 1 * MINUTES,
Expand All @@ -90,8 +90,8 @@ index 3765569f183..ed226f4ef65 100644
min_approval: APP_SMALL_TIPPER,
min_support: SUP_SMALL_TIPPER,
},
@@ -226,10 +226,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15
name: "big_tipper",
@@ -229,10 +229,10 @@ const TRACKS_DATA: [pallet_referenda::Track<u16, Balance, BlockNumber>; 15] = [
name: s("big_tipper"),
max_deciding: 100,
decision_deposit: 10 * 3 * CENTS,
- prepare_period: 4 * MINUTES,
Expand All @@ -106,10 +106,10 @@ index 3765569f183..ed226f4ef65 100644
min_support: SUP_BIG_TIPPER,
},
diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs
index 369fd308272..733ec32f581 100644
index 9c0db32..8b06e0b 100644
--- a/polkadot/runtime/westend/src/lib.rs
+++ b/polkadot/runtime/westend/src/lib.rs
@@ -666,7 +666,7 @@ impl pallet_fast_unstake::Config for Runtime {
@@ -898,7 +898,7 @@ impl pallet_fast_unstake::Config for Runtime {
}

parameter_types! {
Expand Down
4 changes: 4 additions & 0 deletions src/bot-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { envVar } from "@eng-automation/js";
import { sr25519CreateDerive } from "@polkadot-labs/hdkd";
import { entropyToMiniSecret, mnemonicToEntropy, parseSuri, ss58Address } from "@polkadot-labs/hdkd-helpers";
import { createClient } from "matrix-js-sdk";
import assert from "node:assert";
import * as process from "node:process";
import { PolkadotSigner } from "polkadot-api";
import { getPolkadotSigner } from "polkadot-api/signer";
Expand All @@ -20,6 +21,9 @@ type AsyncApplicationFunction = (
export const generateSigner = (accountSeed: string): PolkadotSigner => {
const suri = parseSuri(accountSeed);

assert(suri.phrase, "Invalid account seed");
assert(typeof suri.paths === "string", "Invalid account seed - paths should be a string");

const entropy = mnemonicToEntropy(suri.phrase);
const miniSecret = entropyToMiniSecret(entropy);
const hdkdKeyPair = sr25519CreateDerive(miniSecret)(suri.paths);
Expand Down
16 changes: 8 additions & 8 deletions src/chain-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ export const kusamaConstants: Constants = {

/**
* Source of the calculation:
* https://github.com/paritytech/polkadot/blob/e164da65873f11bf8c583e81f6d82c21b005cfe4/runtime/kusama/src/governance/origins.rs#L172
* https://github.com/paritytech/polkadot/blob/e164da65873f11bf8c583e81f6d82c21b005cfe4/runtime/kusama/constants/src/lib.rs#L29
* https://github.com/polkadot-fellows/runtimes/blob/30804db6b266ea79ad496a58208106038562e8fe/relay/kusama/src/governance/origins.rs#L185
* https://github.com/polkadot-fellows/runtimes/blob/30804db6b266ea79ad496a58208106038562e8fe/relay/kusama/constants/src/lib.rs#L31
*/
smallTipperMaximum: 8.33,

/**
* Source of the calculation:
* https://github.com/paritytech/polkadot/blob/e164da65873f11bf8c583e81f6d82c21b005cfe4/runtime/kusama/src/governance/origins.rs#L173
* https://github.com/paritytech/polkadot/blob/e164da65873f11bf8c583e81f6d82c21b005cfe4/runtime/kusama/constants/src/lib.rs#L31
* https://github.com/polkadot-fellows/runtimes/blob/30804db6b266ea79ad496a58208106038562e8fe/relay/kusama/src/governance/origins.rs#L186
* https://github.com/polkadot-fellows/runtimes/blob/30804db6b266ea79ad496a58208106038562e8fe/relay/kusama/constants/src/lib.rs#L33
*/
bigTipperMaximum: 33.33,

Expand All @@ -97,15 +97,15 @@ export const polkadotConstants: Constants = {

/**
* Source of the calculation:
* https://github.com/paritytech/polkadot/blob/e164da65873f11bf8c583e81f6d82c21b005cfe4/runtime/polkadot/src/governance/origins.rs#L143
* https://github.com/paritytech/polkadot/blob/e164da65873f11bf8c583e81f6d82c21b005cfe4/runtime/polkadot/constants/src/lib.rs#L31
* https://github.com/polkadot-fellows/runtimes/blob/30804db6b266ea79ad496a58208106038562e8fe/relay/polkadot/src/governance/origins.rs#L156
* https://github.com/polkadot-fellows/runtimes/blob/30804db6b266ea79ad496a58208106038562e8fe/relay/polkadot/constants/src/lib.rs#L33
*/
smallTipperMaximum: 250,

/**
* Source of the calculation:
* https://github.com/paritytech/polkadot/blob/e164da65873f11bf8c583e81f6d82c21b005cfe4/runtime/polkadot/src/governance/origins.rs#L144
* https://github.com/paritytech/polkadot/blob/e164da65873f11bf8c583e81f6d82c21b005cfe4/runtime/polkadot/constants/src/lib.rs#L32
* https://github.com/polkadot-fellows/runtimes/blob/30804db6b266ea79ad496a58208106038562e8fe/relay/polkadot/src/governance/origins.rs#L157
* https://github.com/polkadot-fellows/runtimes/blob/30804db6b266ea79ad496a58208106038562e8fe/relay/polkadot/constants/src/lib.rs#L34
*/
bigTipperMaximum: 1000,

Expand Down
38 changes: 9 additions & 29 deletions src/tip-opengov.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { until } from "@eng-automation/js";
import {
GovernanceOrigin,
PolkadotRuntimeOriginCaller,
PreimagesBounded,
TraitsScheduleDispatchTime,
WestendRuntimeGovernanceOriginsPalletCustomOriginsOrigin,
WestendRuntimeOriginCaller,
} from "@polkadot-api/descriptors";
import { PreimagesBounded, TraitsScheduleDispatchTime } from "@polkadot-api/descriptors";
import { ss58Address } from "@polkadot-labs/hdkd-helpers";
import { getDescriptor } from "#src/chain-config";
import { Binary, PolkadotClient, Transaction } from "polkadot-api";
import { Binary, Enum, PolkadotClient, Transaction } from "polkadot-api";
import { Probot } from "probot";

import { Polkassembly } from "./polkassembly/polkassembly";
Expand Down Expand Up @@ -42,27 +35,14 @@ export async function tipOpenGovReferendumExtrinsic(opts: { client: PolkadotClie

const enactMoment = TraitsScheduleDispatchTime.After(10);

let referendumExtrinsic: Transaction<object, "Referenda", "submit", unknown>;
const network: TipNetwork = tipRequest.contributor.account.network;
if (network === "westend" || network === "rococo") {
const api = client.getTypedApi(getDescriptor(network));
const proposalOrigin = WestendRuntimeOriginCaller.Origins(
track.track.trackName as WestendRuntimeGovernanceOriginsPalletCustomOriginsOrigin,
);
referendumExtrinsic = api.tx.Referenda.submit({
proposal,
proposal_origin: proposalOrigin,
enactment_moment: enactMoment,
});
} else {
const api = client.getTypedApi(getDescriptor(network));
const proposalOrigin = PolkadotRuntimeOriginCaller.Origins(track.track.trackName as GovernanceOrigin);
referendumExtrinsic = api.tx.Referenda.submit({
proposal,
proposal_origin: proposalOrigin,
enactment_moment: enactMoment,
});
}

const api = client.getTypedApi(getDescriptor(network));
const referendumExtrinsic = api.tx.Referenda.submit({
proposal,
proposal_origin: Enum("Origins", Enum(track.track.trackName.type)),
enactment_moment: enactMoment,
});

return {
success: true,
Expand Down
14 changes: 7 additions & 7 deletions src/tip.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import fs from "fs/promises";
import path from "path";
import { Binary, createClient, PolkadotClient, TypedApi } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws-provider/node";
import { filter, firstValueFrom } from "rxjs";
import { filter, firstValueFrom, Observable } from "rxjs";
import { Readable } from "stream";
import { GenericContainer, Network, StartedTestContainer, TestContainers, Wait } from "testcontainers";

Expand Down Expand Up @@ -316,13 +316,13 @@ describe("tip", () => {
expect(body.body).toContain("was successfully submitted for @contributor");
expect(body.body).toContain(`Referendum number: **${nextFreeReferendumId}**`);

// This returns undefined for a bit, so using subscription to wait for the data
const referendum = await firstValueFrom(
api.query.Referenda.ReferendumInfoFor.watchValue(nextFreeReferendumId).pipe(
filter((value) => value !== undefined),
const referendum = (await firstValueFrom(
(api.query.Referenda.ReferendumInfoFor.watchValue(nextFreeReferendumId) as Observable<{ type: string }>).pipe(
filter((v: unknown) => v !== undefined),
),
);
expect(referendum?.type).toEqual("Ongoing");
)) as { type: string };

expect(referendum.type).toEqual("Ongoing");
});

test(`huge tip in ${network}`, async () => {
Expand Down
10 changes: 7 additions & 3 deletions src/tip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ async function createApi(
// Set up the types
const api = client.getTypedApi(getDescriptor(network));

const version = await api.apis.Core.version();
bot.log(`You are connected to chain ${version.spec_name}#${version.spec_version}`);
try {
const version = await api.apis.Core.version();
bot.log(`You are connected to chain ${version.spec_name}#${version.spec_version}`);
} catch (e) {
console.error("Error getting core version", e);
}

return { client: client };
return { client };
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ export const formatTipSize = (tipRequest: TipRequest): string => {
* Currently - Engineering Automation / Opstooling.
* It is used to tag these usernames when there is a failure.
*/
export const teamMatrixHandles =
process.env.NODE_ENV === "development" ? [] : ["@przemek", "@mak", "@yuri", "@bullrich"]; // Don't interrupt other people when testing.
export const teamMatrixHandles = process.env.NODE_ENV === "development" ? [] : ["@mak", "@yuri"]; // Don't interrupt other people when testing.

export const byteSize = (extrinsic: Uint8Array): number => extrinsic.length * Uint8Array.BYTES_PER_ELEMENT;

Expand All @@ -170,7 +169,7 @@ export const encodeProposal = async (
const proposalTx = api.tx.Treasury.spend_local({ amount: track.value, beneficiary });

const encodedProposal = await proposalTx.getEncodedData();
const proposalByteSize = byteSize(encodedProposal.asBytes());
const proposalByteSize = byteSize(encodedProposal.asBytes() as Uint8Array);
if (proposalByteSize >= 128) {
return {
success: false,
Expand Down
Loading
Loading