Skip to content

Commit

Permalink
Merge branch 'master' into GH-524
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshg6 authored Oct 7, 2024
2 parents 0e02fb9 + 91f3b8c commit 8a7f0ab
Show file tree
Hide file tree
Showing 21 changed files with 287 additions and 106 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ stage - MASQ Network and it's developers are not responsible for any activity, o
## Source
The MASQ project was forked from Substratum's Node project in order to carry on development after Substratum ceased
operations in October of 2019. In 2021, Substratum's Node repositories were removed from GitHub, so the fork link
with MASQ was broken, but all credit for the original idea, the original design, and the first two years of MASQ's
development belongs to Substratum.
with MASQ was broken, but all credit for the original idea and the original design belongs to Substratum (and properly attributed through GPLv3 license)

## Running the MASQ Node

Expand Down Expand Up @@ -452,6 +451,4 @@ recommend using a 64-bit version to build.

We do plan to release binaries that will run on 32-bit Windows, but they will likely be built on 64-bit Windows.

Copyright (c) 2019-2022, MASQ Network

Copyright (c) 2017-2019, Substratum LLC and/or its affiliates. All rights reserved.
Copyright (c) 2019-2024, MASQ Network
4 changes: 2 additions & 2 deletions automap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion automap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "automap"
version = "0.8.0"
version = "0.8.1"
authors = ["Dan Wiebe <[email protected]>", "MASQ"]
license = "GPL-3.0-only"
description = "Library full of code to make routers map ports through firewalls"
Expand Down
4 changes: 2 additions & 2 deletions dns_utility/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dns_utility/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dns_utility"
version = "0.8.0"
version = "0.8.1"
license = "GPL-3.0-only"
authors = ["Dan Wiebe <[email protected]>", "MASQ"]
copyright = "Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved."
Expand Down
2 changes: 1 addition & 1 deletion masq/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masq"
version = "0.8.0"
version = "0.8.1"
authors = ["Dan Wiebe <[email protected]>", "MASQ"]
license = "GPL-3.0-only"
description = "Reference implementation of user interface for MASQ Node"
Expand Down
2 changes: 1 addition & 1 deletion masq_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masq_lib"
version = "0.8.0"
version = "0.8.1"
authors = ["Dan Wiebe <[email protected]>", "MASQ"]
license = "GPL-3.0-only"
description = "Code common to Node and masq; also, temporarily, to dns_utility"
Expand Down
127 changes: 97 additions & 30 deletions masq_lib/src/blockchains/blockchain_records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

use crate::blockchains::chains::Chain;
use crate::constants::{
AMOY_TESTNET_CONTRACT_CREATION_BLOCK, DEV_CHAIN_FULL_IDENTIFIER,
ETH_MAINNET_CONTRACT_CREATION_BLOCK, ETH_MAINNET_FULL_IDENTIFIER, ETH_ROPSTEN_FULL_IDENTIFIER,
MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK, POLYGON_AMOY_FULL_IDENTIFIER,
POLYGON_MAINNET_CONTRACT_CREATION_BLOCK, POLYGON_MAINNET_FULL_IDENTIFIER,
ROPSTEN_TESTNET_CONTRACT_CREATION_BLOCK,
BASE_MAINNET_CONTRACT_CREATION_BLOCK, BASE_MAINNET_FULL_IDENTIFIER,
BASE_SEPOLIA_CONTRACT_CREATION_BLOCK, BASE_SEPOLIA_FULL_IDENTIFIER, DEV_CHAIN_FULL_IDENTIFIER,
ETH_MAINNET_CONTRACT_CREATION_BLOCK, ETH_MAINNET_FULL_IDENTIFIER,
ETH_ROPSTEN_CONTRACT_CREATION_BLOCK, ETH_ROPSTEN_FULL_IDENTIFIER,
MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK, POLYGON_AMOY_CONTRACT_CREATION_BLOCK,
POLYGON_AMOY_FULL_IDENTIFIER, POLYGON_MAINNET_CONTRACT_CREATION_BLOCK,
POLYGON_MAINNET_FULL_IDENTIFIER,
};
use ethereum_types::{Address, H160};

pub const CHAINS: [BlockchainRecord; 5] = [
pub const CHAINS: [BlockchainRecord; 7] = [
BlockchainRecord {
self_id: Chain::PolyMainnet,
num_chain_id: 137,
Expand All @@ -25,19 +27,33 @@ pub const CHAINS: [BlockchainRecord; 5] = [
contract: ETH_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: ETH_MAINNET_CONTRACT_CREATION_BLOCK,
},
BlockchainRecord {
self_id: Chain::BaseMainnet,
num_chain_id: 8453,
literal_identifier: BASE_MAINNET_FULL_IDENTIFIER,
contract: BASE_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: BASE_MAINNET_CONTRACT_CREATION_BLOCK,
},
BlockchainRecord {
self_id: Chain::BaseSepolia,
num_chain_id: 84532,
literal_identifier: BASE_SEPOLIA_FULL_IDENTIFIER,
contract: BASE_SEPOLIA_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: BASE_SEPOLIA_CONTRACT_CREATION_BLOCK,
},
BlockchainRecord {
self_id: Chain::PolyAmoy,
num_chain_id: 80002,
literal_identifier: POLYGON_AMOY_FULL_IDENTIFIER,
contract: AMOY_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: AMOY_TESTNET_CONTRACT_CREATION_BLOCK,
contract: POLYGON_AMOY_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: POLYGON_AMOY_CONTRACT_CREATION_BLOCK,
},
BlockchainRecord {
self_id: Chain::EthRopsten,
num_chain_id: 3,
literal_identifier: ETH_ROPSTEN_FULL_IDENTIFIER,
contract: ROPSTEN_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: ROPSTEN_TESTNET_CONTRACT_CREATION_BLOCK,
contract: ETH_ROPSTEN_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: ETH_ROPSTEN_CONTRACT_CREATION_BLOCK,
},
BlockchainRecord {
self_id: Chain::Dev,
Expand Down Expand Up @@ -68,17 +84,27 @@ const ETH_MAINNET_CONTRACT_ADDRESS: Address = H160([
]);

// $tMASQ (Amoy)
const AMOY_TESTNET_CONTRACT_ADDRESS: Address = H160([
const POLYGON_AMOY_TESTNET_CONTRACT_ADDRESS: Address = H160([
0xd9, 0x8c, 0x3e, 0xbd, 0x6b, 0x7f, 0x9b, 0x7c, 0xda, 0x24, 0x49, 0xec, 0xac, 0x00, 0xd1, 0xe5,
0xf4, 0x7a, 0x81, 0x93,
]);

// SHRD (Ropsten)
const ROPSTEN_TESTNET_CONTRACT_ADDRESS: Address = H160([
const ETH_ROPSTEN_TESTNET_CONTRACT_ADDRESS: Address = H160([
0x38, 0x4d, 0xec, 0x25, 0xe0, 0x3f, 0x94, 0x93, 0x17, 0x67, 0xce, 0x4c, 0x35, 0x56, 0x16, 0x84,
0x68, 0xba, 0x24, 0xc3,
]);

const BASE_MAINNET_CONTRACT_ADDRESS: Address = H160([
0x45, 0xD9, 0xC1, 0x01, 0xa3, 0x87, 0x0C, 0xa5, 0x02, 0x45, 0x82, 0xfd, 0x78, 0x8F, 0x4E, 0x1e,
0x8F, 0x79, 0x71, 0xc3,
]);

const BASE_SEPOLIA_TESTNET_CONTRACT_ADDRESS: Address = H160([
0x89, 0x8e, 0x1c, 0xe7, 0x20, 0x08, 0x4A, 0x90, 0x2b, 0xc3, 0x7d, 0xd8, 0x22, 0xed, 0x6d, 0x6a,
0x5f, 0x02, 0x7e, 0x10,
]);

const MULTINODE_TESTNET_CONTRACT_ADDRESS: Address = H160([
0x59, 0x88, 0x2e, 0x4a, 0x8f, 0x5d, 0x24, 0x64, 0x3d, 0x4d, 0xda, 0x42, 0x29, 0x22, 0xa8, 0x70,
0xf1, 0xb3, 0xe6, 0x64,
Expand All @@ -88,20 +114,20 @@ const MULTINODE_TESTNET_CONTRACT_ADDRESS: Address = H160([
mod tests {
use super::*;
use crate::blockchains::chains::chain_from_chain_identifier_opt;
use crate::constants::{
AMOY_TESTNET_CONTRACT_CREATION_BLOCK, POLYGON_MAINNET_CONTRACT_CREATION_BLOCK,
};
use crate::constants::BASE_MAINNET_CONTRACT_CREATION_BLOCK;
use std::collections::HashSet;
use std::iter::FromIterator;

#[test]
fn record_returns_correct_blockchain_record() {
let test_array = [
assert_returns_correct_record(Chain::EthMainnet, 1),
assert_returns_correct_record(Chain::Dev, 2),
assert_returns_correct_record(Chain::EthRopsten, 3),
assert_returns_correct_record(Chain::PolyMainnet, 137),
assert_returns_correct_record(Chain::PolyAmoy, 80002),
assert_returns_correct_record(Chain::BaseMainnet, 8453),
assert_returns_correct_record(Chain::BaseSepolia, 84532),
assert_returns_correct_record(Chain::Dev, 2),
];
assert_exhaustive(&test_array)
}
Expand All @@ -118,6 +144,8 @@ mod tests {
assert_from_str(Chain::PolyAmoy),
assert_from_str(Chain::EthMainnet),
assert_from_str(Chain::EthRopsten),
assert_from_str(Chain::BaseMainnet),
assert_from_str(Chain::BaseSepolia),
assert_from_str(Chain::Dev),
];
assert_exhaustive(&test_array)
Expand All @@ -137,18 +165,23 @@ mod tests {
#[test]
fn chains_are_ordered_by_their_significance_for_users() {
let test_array = [
assert_chain_significance(0, Chain::PolyMainnet),
assert_chain_significance(1, Chain::EthMainnet),
assert_chain_significance(2, Chain::PolyAmoy),
assert_chain_significance(3, Chain::EthRopsten),
assert_chain_significance(4, Chain::Dev),
Chain::PolyMainnet,
Chain::EthMainnet,
Chain::BaseMainnet,
Chain::BaseSepolia,
Chain::PolyAmoy,
Chain::EthRopsten,
Chain::Dev,
];
test_array
.iter()
.enumerate()
.for_each(assert_chain_significance);
assert_exhaustive(&test_array)
}

fn assert_chain_significance(idx: usize, chain: Chain) -> Chain {
assert_eq!(CHAINS[idx].self_id, chain, "Error at index {}", idx);
chain
fn assert_chain_significance((idx, chain): (usize, &Chain)) {
assert_eq!(CHAINS[idx].self_id, *chain, "Error at index {}", idx);
}

#[test]
Expand Down Expand Up @@ -177,8 +210,8 @@ mod tests {
num_chain_id: 3,
self_id: examined_chain,
literal_identifier: "eth-ropsten",
contract: ROPSTEN_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: ROPSTEN_TESTNET_CONTRACT_CREATION_BLOCK,
contract: ETH_ROPSTEN_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: ETH_ROPSTEN_CONTRACT_CREATION_BLOCK,
}
);
}
Expand Down Expand Up @@ -209,8 +242,40 @@ mod tests {
num_chain_id: 80002,
self_id: examined_chain,
literal_identifier: "polygon-amoy",
contract: AMOY_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: AMOY_TESTNET_CONTRACT_CREATION_BLOCK,
contract: POLYGON_AMOY_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: POLYGON_AMOY_CONTRACT_CREATION_BLOCK,
}
);
}

#[test]
fn base_mainnet_record_is_properly_declared() {
let examined_chain = Chain::BaseMainnet;
let chain_record = return_examined(examined_chain);
assert_eq!(
chain_record,
&BlockchainRecord {
num_chain_id: 8453,
self_id: examined_chain,
literal_identifier: "base-mainnet",
contract: BASE_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: BASE_MAINNET_CONTRACT_CREATION_BLOCK,
}
);
}

#[test]
fn base_sepolia_record_is_properly_declared() {
let examined_chain = Chain::BaseSepolia;
let chain_record = return_examined(examined_chain);
assert_eq!(
chain_record,
&BlockchainRecord {
num_chain_id: 84532,
self_id: examined_chain,
literal_identifier: "base-sepolia",
contract: BASE_SEPOLIA_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: BASE_SEPOLIA_CONTRACT_CREATION_BLOCK,
}
);
}
Expand All @@ -226,7 +291,7 @@ mod tests {
self_id: examined_chain,
literal_identifier: "dev",
contract: MULTINODE_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: 0,
contract_creation_block: MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK,
}
);
}
Expand All @@ -240,9 +305,11 @@ mod tests {
let test_array = [
assert_chain_from_chain_identifier_opt("eth-mainnet", Some(Chain::EthMainnet)),
assert_chain_from_chain_identifier_opt("eth-ropsten", Some(Chain::EthRopsten)),
assert_chain_from_chain_identifier_opt("dev", Some(Chain::Dev)),
assert_chain_from_chain_identifier_opt("polygon-mainnet", Some(Chain::PolyMainnet)),
assert_chain_from_chain_identifier_opt("polygon-amoy", Some(Chain::PolyAmoy)),
assert_chain_from_chain_identifier_opt("base-mainnet", Some(Chain::BaseMainnet)),
assert_chain_from_chain_identifier_opt("base-sepolia", Some(Chain::BaseSepolia)),
assert_chain_from_chain_identifier_opt("dev", Some(Chain::Dev)),
];
assert_exhaustive(&test_array)
}
Expand Down
13 changes: 10 additions & 3 deletions masq_lib/src/blockchains/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use crate::blockchains::blockchain_records::{BlockchainRecord, CHAINS};
use crate::constants::{
DEFAULT_CHAIN, DEV_CHAIN_FULL_IDENTIFIER, ETH_MAINNET_FULL_IDENTIFIER,
ETH_ROPSTEN_FULL_IDENTIFIER, POLYGON_AMOY_FULL_IDENTIFIER, POLYGON_MAINNET_FULL_IDENTIFIER,
BASE_MAINNET_FULL_IDENTIFIER, BASE_SEPOLIA_FULL_IDENTIFIER, DEFAULT_CHAIN,
DEV_CHAIN_FULL_IDENTIFIER, ETH_MAINNET_FULL_IDENTIFIER, ETH_ROPSTEN_FULL_IDENTIFIER,
POLYGON_AMOY_FULL_IDENTIFIER, POLYGON_MAINNET_FULL_IDENTIFIER,
};
use serde_derive::{Deserialize, Serialize};

Expand All @@ -13,6 +14,8 @@ pub enum Chain {
EthRopsten,
PolyMainnet,
PolyAmoy,
BaseMainnet,
BaseSepolia,
Dev,
}

Expand All @@ -28,6 +31,10 @@ impl From<&str> for Chain {
Chain::PolyMainnet
} else if str == ETH_MAINNET_FULL_IDENTIFIER {
Chain::EthMainnet
} else if str == BASE_MAINNET_FULL_IDENTIFIER {
Chain::BaseMainnet
} else if str == BASE_SEPOLIA_FULL_IDENTIFIER {
Chain::BaseSepolia
} else if str == POLYGON_AMOY_FULL_IDENTIFIER {
Chain::PolyAmoy
} else if str == ETH_ROPSTEN_FULL_IDENTIFIER {
Expand Down Expand Up @@ -56,7 +63,7 @@ impl Chain {
}

fn mainnets() -> &'static [Chain] {
&[Chain::PolyMainnet, Chain::EthMainnet]
&[Chain::PolyMainnet, Chain::BaseMainnet, Chain::EthMainnet]
}
}

Expand Down
Loading

0 comments on commit 8a7f0ab

Please sign in to comment.