-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2302 from subspace/subspace-malicious-operator
Introduce the intentional malicious operator
- Loading branch information
Showing
27 changed files
with
1,761 additions
and
83 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
[package] | ||
name = "subspace-malicious-operator" | ||
version = "0.1.0" | ||
authors = ["Subspace Labs <https://subspace.network>"] | ||
description = "A Subspace Network Blockchain node." | ||
edition = "2021" | ||
license = "GPL-3.0-or-later" | ||
build = "build.rs" | ||
homepage = "https://subspace.network" | ||
repository = "https://github.com/subspace/subspace" | ||
include = [ | ||
"/src", | ||
"/build.rs", | ||
"/Cargo.toml", | ||
"/README.md" | ||
] | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] | ||
|
||
[dependencies] | ||
cross-domain-message-gossip = { version = "0.1.0", path = "../../domains/client/cross-domain-message-gossip" } | ||
domain-client-message-relayer = { version = "0.1.0", path = "../../domains/client/relayer" } | ||
domain-client-operator = { version = "0.1.0", path = "../../domains/client/domain-operator" } | ||
domain-eth-service = { version = "0.1.0", path = "../../domains/client/eth-service" } | ||
domain-service = { version = "0.1.0", path = "../../domains/service" } | ||
domain-runtime-primitives = { version = "0.1.0", path = "../../domains/primitives/runtime" } | ||
evm-domain-runtime = { version = "0.1.0", path = "../../domains/runtime/evm" } | ||
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
futures = "0.3.29" | ||
log = "0.4.20" | ||
mimalloc = "0.1.39" | ||
pallet-domains = { version = "0.1.0", default-features = false, path = "../pallet-domains" } | ||
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
parity-scale-codec = "3.6.5" | ||
pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5", default-features = false } | ||
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sc-consensus-subspace = { version = "0.1.0", path = "../sc-consensus-subspace" } | ||
sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5", default-features = false } | ||
sc-storage-monitor = { version = "0.1.0", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5", default-features = false } | ||
sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
serde_json = "1.0.106" | ||
sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sp-block-builder = { git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5", default-features = false, version = "4.0.0-dev" } | ||
sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" } | ||
sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sp-domains = { version = "0.1.0", path = "../sp-domains" } | ||
sp-domain-digests = { version = "0.1.0", path = "../../domains/primitives/digests" } | ||
sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sp-messenger = { version = "0.1.0", path = "../../domains/primitives/messenger" } | ||
sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sp-keystore = { version = "0.27.0", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
sp-keyring = { git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" } | ||
subspace-networking = { version = "0.1.0", path = "../subspace-networking" } | ||
subspace-proof-of-space = { version = "0.1.0", path = "../subspace-proof-of-space" } | ||
subspace-runtime = { version = "0.1.0", path = "../subspace-runtime" } | ||
subspace-runtime-primitives = { version = "0.1.0", path = "../subspace-runtime-primitives" } | ||
subspace-node = { version = "0.1.0", path = "../subspace-node" } | ||
subspace-service = { version = "0.1.0", path = "../subspace-service" } | ||
thiserror = "1.0.48" | ||
tokio = "1.34.0" | ||
rand = "0.8.5" | ||
tracing = "0.1.37" | ||
|
||
[build-dependencies] | ||
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" } | ||
|
||
[features] | ||
default = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# The intentional malicious operator node | ||
|
||
NOTE: ****this is only use for testing purpose**** | ||
|
||
The malicious operator node act as a regular [domain operator](../../domains/README.md) but it will intentionally and continuously produce malicious content to test if the network can handle it properly. | ||
|
||
### How it works | ||
|
||
Most parts of the malicious operator act exactly the same as the regular domain operator except its bundle producer. When it produce a bundle, the bundle will be tampered with malicious content with probability before submitting to the consensus chain. | ||
|
||
Currently, it supports produce: | ||
- Invalid bundle | ||
- Fraudulent ER | ||
|
||
When the operator submit malicious content to the consensus chain, the honest operator in the network will detect and submit fraud proof that target these content, and cause the malicious operator being slashed and baned from submitting bundle. | ||
|
||
The malicious operator node will detect the slashing and register a new operator as the malicious operator, moreover, it will enforce the epoch transition to accelerate the onboard of the new malicious operator, and contiune producing malicious content. | ||
|
||
### Build from source | ||
|
||
```bash | ||
cargo build -r subspace-malicious-operator | ||
``` | ||
|
||
### Run | ||
|
||
The malicious operator node take the same args as the regular domain operator, please refer to [Domain operator](../../domains/README.md). | ||
|
||
A few notable differences: | ||
- The malicious operator node will ignore the `--operator-id` arg if specified, instead it will register new operator internally and automatically and using their id to produce malicious content. | ||
- The malicious operator node requires the consensus chain sudo key pair to run in the network. | ||
- With `--chains local/dev`, Alice is the sudo account and its key pair is already exist in the node. | ||
- With `--chain devnet`, the sudo key pair need to insert into the keystore with `subspace-node key insert --suri "<Secret phrase>" --key-type sub_ --scheme sr25519 --keystore-path <PATH>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (C) 2023 Subspace Labs, Inc. | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; | ||
|
||
fn main() { | ||
generate_cargo_keys(); | ||
|
||
rerun_if_git_head_changed(); | ||
} |
Oops, something went wrong.