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

Substrate governor update #371

Merged
merged 9 commits into from
Mar 21, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ store/
.DS_Store
.vscode/
.idea/
.env
4 changes: 3 additions & 1 deletion crates/event-watcher-traits/src/evm/bridge_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ where
.map_err(Into::into)
.map_err(backoff::Error::transient)
.await?;
let bridge_key = BridgeKey::new(my_chain_id);
let typed_chain_id =
salman01zp marked this conversation as resolved.
Show resolved Hide resolved
webb_proposals::TypedChainId::Evm(my_chain_id.as_u32());
let bridge_key = BridgeKey::new(typed_chain_id);
let key = SledQueueKey::from_bridge_key(bridge_key);
loop {
let result = match store.dequeue_item(key)? {
Expand Down
5 changes: 3 additions & 2 deletions crates/event-watcher-traits/src/substrate/bridge_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ where
let backoff = backoff::backoff::Constant::new(Duration::from_secs(1));

let task = || async {
let my_chain_id = webb_proposals::TypedChainId::Substrate(chain_id);
let bridge_key = BridgeKey::new(my_chain_id);
let typed_chain_id =
webb_proposals::TypedChainId::Substrate(chain_id);
let bridge_key = BridgeKey::new(typed_chain_id);
let key = SledQueueKey::from_bridge_key(bridge_key);
loop {
let result = match store.dequeue_item(key)? {
Expand Down
3 changes: 2 additions & 1 deletion crates/tx-queue/src/substrate/substrate_tx_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,14 @@ where
status = "Broadcast",
);
}
TransactionStatus::InBlock(_) => {
TransactionStatus::InBlock(data) => {
tracing::event!(
target: webb_relayer_utils::probe::TARGET,
tracing::Level::DEBUG,
kind = %webb_relayer_utils::probe::Kind::TxQueue,
ty = "SUBSTRATE",
chain_id = %chain_id,
block_hash = ?data.block_hash(),
status = "InBlock",
);
}
Expand Down
22 changes: 16 additions & 6 deletions event-watchers/dkg/src/public_key_changed_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use ethereum_types::U256;
use std::sync::Arc;
use tokio::sync::Mutex;
use webb::substrate::dkg_runtime::api::dkg;
Expand Down Expand Up @@ -75,11 +74,22 @@ impl EventHandler<PolkadotConfig> for DKGPublicKeyChangedHandler {
%block_number,
"DKG Public Key Changed",
);
let bridge_keys = self
.webb_config
.evm
.values()
.map(|c| BridgeKey::new(U256::from(c.chain_id)));
let mut bridge_keys = Vec::new();
// get evm bridges
for (_, config) in self.webb_config.evm.iter() {
let typed_chain_id =
webb_proposals::TypedChainId::Evm(config.chain_id);
let bridge_key = BridgeKey::new(typed_chain_id);
bridge_keys.push(bridge_key);
}
// get substrate bridges
for (_, config) in self.webb_config.substrate.iter() {
let typed_chain_id =
webb_proposals::TypedChainId::Substrate(config.chain_id);
let bridge_key = BridgeKey::new(typed_chain_id);
bridge_keys.push(bridge_key);
}

// now we just signal every signature bridge to transfer the ownership.
for bridge_key in bridge_keys {
tracing::debug!(
Expand Down
8 changes: 6 additions & 2 deletions event-watchers/substrate/src/signature_bridge_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,21 @@ where
signature = %hex::encode(&signature),
);

let mut message = nonce.to_be_bytes().to_vec();
message.extend_from_slice(&new_maintainer);

let set_maintainer_call = SetMaintainer {
message: BoundedVec(new_maintainer.clone()),
message: BoundedVec(message.clone()),
signature: BoundedVec(signature.clone()),
};

// webb dynamic payload
tracing::debug!("DKG Message Payload : {:?}", message);
let set_maintainer_tx = WebbDynamicTxPayload {
pallet_name: Cow::Borrowed("SignatureBridge"),
call_name: Cow::Borrowed("set_maintainer"),
fields: vec![
Value::from_bytes(new_maintainer),
Value::from_bytes(message),
Value::from_bytes(signature),
],
};
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly"
channel = "nightly-2023-03-12"
components = ["rustfmt", "clippy"]
targets = []
10 changes: 6 additions & 4 deletions tests/lib/localDkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ECPairAPI, TinySecp256k1Interface, ECPairFactory } from 'ecpair';
import isCI from 'is-ci';
import * as TinySecp256k1 from 'tiny-secp256k1';

import { LocalNodeOpts, SubstrateNodeBase } from '@webb-tools/test-utils';
import { LocalNodeOpts } from '@webb-tools/test-utils';
import {
EventsWatcher,
LinkedAnchor,
Expand All @@ -33,6 +33,7 @@ import {
ProposalSigningBackend,
} from './webbRelayer.js';
import { ConvertToKebabCase } from './tsHacks.js';
import { SubstrateNodeBase } from './substrateNodeBase.js';

type ExportedConfigOptions = {
suri: string;
Expand Down Expand Up @@ -101,6 +102,7 @@ export class LocalDkg extends SubstrateNodeBase<TypedEvent> {
} else {
startArgs.push(
'--tmp',
'--chain=local',
'--rpc-cors',
'all',
'--rpc-methods=unsafe',
Expand Down Expand Up @@ -143,7 +145,7 @@ export class LocalDkg extends SubstrateNodeBase<TypedEvent> {
// get chainId
public async getChainId(): Promise<number> {
const api = await super.api();
const chainId = (await api.consts.dkgProposals.chainIdentifier).toNumber();
const chainId = api.consts?.dkgProposals?.chainIdentifier?.toNumber();
return chainId;
}

Expand Down Expand Up @@ -194,8 +196,8 @@ export class LocalDkg extends SubstrateNodeBase<TypedEvent> {
'events-watcher': {
enabled: c.eventsWatcher.enabled,
'polling-interval': c.eventsWatcher.pollingInterval,
'print-progress-interval' : c.eventsWatcher.printProgressInterval,
'sync-blocks-from': c.eventsWatcher.syncBlocksFrom
'print-progress-interval': c.eventsWatcher.printProgressInterval,
'sync-blocks-from': c.eventsWatcher.syncBlocksFrom,
},
};
return convertedPallet;
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/localProtocolSubstrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ export class LocalProtocolSubstrate extends BaseLocalSubstrate {
'events-watcher': {
enabled: c.eventsWatcher.enabled,
'polling-interval': c.eventsWatcher.pollingInterval,
'print-progress-interval' : c.eventsWatcher.printProgressInterval,
'sync-blocks-from': c.eventsWatcher.syncBlocksFrom
'print-progress-interval': c.eventsWatcher.printProgressInterval,
'sync-blocks-from': c.eventsWatcher.syncBlocksFrom,
},
'proposal-signing-backend':
c.proposalSigningBackend?.type === 'Mocked'
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/localTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '@webb-tools/interfaces';
import { FungibleTokenWrapper, MintableToken } from '@webb-tools/tokens';
import { fetchComponentsFromFilePaths } from '@webb-tools/utils';
import { LocalEvmChain } from '@webb-tools/test-utils';

import path from 'path';
import child from 'child_process';
import {
Expand All @@ -41,6 +41,7 @@ import { ConvertToKebabCase } from './tsHacks';
import { CircomUtxo, Keypair, Utxo } from '@webb-tools/sdk-core';
import { hexToU8a, u8aToHex } from '@polkadot/util';
import { TokenConfig } from '@webb-tools/vbridge/lib/VBridge';
import { LocalEvmChain } from '@webb-tools/evm-test-utils';

export type GanacheAccounts = {
balance: string;
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/localTestnetOpenVBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { Utility, VBridge } from '@webb-tools/protocol-solidity';
import { DeployerConfig, GovernorConfig } from '@webb-tools/interfaces';
import { MintableToken } from '@webb-tools/tokens';
import { FungibleTokenWrapper } from '@webb-tools/tokens';
import { LocalEvmChain } from '@webb-tools/test-utils';
import child from 'child_process';
import {
ChainInfo,
Contract,
Expand All @@ -33,6 +31,7 @@ import {
WithdrawConfig,
} from './webbRelayer';
import { ConvertToKebabCase } from './tsHacks';
import { LocalEvmChain } from '@webb-tools/evm-test-utils';

export type GanacheAccounts = {
balance: string;
Expand Down
Loading