Skip to content

Commit

Permalink
feat: unique-polkadot-v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigoriy Simonov committed Aug 7, 2024
1 parent 7369282 commit a8e4a5c
Show file tree
Hide file tree
Showing 18 changed files with 1,121 additions and 1,821 deletions.
2,068 changes: 685 additions & 1,383 deletions Cargo.lock

Large diffs are not rendered by default.

141 changes: 71 additions & 70 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ repository = "https://github.com/paritytech/frontier/"
[workspace.dependencies]
async-trait = "0.1"
bn = { package = "substrate-bn", version = "0.6", default-features = false }
clap = { version = "4.4.3", features = ["derive", "deprecated"] }
clap = { version = "4.5", features = ["derive", "deprecated"] }
derive_more = "0.99"
environmental = { version = "1.1.4", default-features = false }
ethereum = { version = "0.14.0", default-features = false }
Expand All @@ -57,7 +57,7 @@ hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
hex-literal = "0.4.1"
impl-serde = { version = "0.4.0", default-features = false }
impl-trait-for-tuples = "0.2.1"
jsonrpsee = "0.16.3"
jsonrpsee = "0.20.3"
kvdb-rocksdb = "0.19.0"
libsecp256k1 = { version = "0.7.1", default-features = false }
log = { version = "0.4.20", default-features = false }
Expand All @@ -75,77 +75,77 @@ thiserror = "1.0"
tokio = "1.32.0"

# Substrate Client
sc-basic-authorship = "0.33.0"
sc-block-builder = "0.32.0"
sc-chain-spec = "26.0.0"
sc-cli = { version = "0.35.0", default-features = false }
sc-client-api = "27.0.0"
sc-client-db = { version = "0.34.0", default-features = false }
sc-consensus = "0.32.0"
sc-consensus-aura = "0.33.0"
sc-consensus-grandpa = "0.18.0"
sc-consensus-manual-seal = "0.34.0"
sc-executor = "0.31.0"
sc-keystore = "24.0.0"
sc-network = "0.33.0"
sc-network-common = "0.32.0"
sc-network-sync = "0.32.0"
sc-offchain = "28.0.0"
sc-rpc = "28.0.0"
sc-rpc-api = "0.32.0"
sc-service = { version = "0.34.0", default-features = false }
sc-telemetry = "14.0.0"
sc-transaction-pool = "27.0.0"
sc-transaction-pool-api = "27.0.0"
sc-utils = "13.0.0"
sc-basic-authorship = "0.35.0"
sc-block-builder = "0.34.0"
sc-chain-spec = "28.0.0"
sc-cli = { version = "0.37.0", default-features = false }
sc-client-api = "29.0.0"
sc-client-db = { version = "0.36.0", default-features = false }
sc-consensus = "0.34.0"
sc-consensus-aura = "0.35.0"
sc-consensus-grandpa = "0.20.0"
sc-consensus-manual-seal = "0.36.0"
sc-executor = "0.33.0"
sc-keystore = "26.0.0"
sc-network = "0.35.0"
sc-network-common = "0.34.0"
sc-network-sync = "0.34.0"
sc-offchain = "30.0.0"
sc-rpc = "30.0.0"
sc-rpc-api = "0.34.0"
sc-service = { version = "0.36.0", default-features = false }
sc-telemetry = "16.0.0"
sc-transaction-pool = "29.0.0"
sc-transaction-pool-api = "29.0.0"
sc-utils = "15.0.0"
# Substrate Primitive
sp-api = { version = "25.0.0", default-features = false }
sp-block-builder = { version = "25.0.0", default-features = false }
sp-blockchain = "27.0.0"
sp-consensus = "0.31.0"
sp-consensus-aura = { version = "0.31.0", default-features = false }
sp-consensus-grandpa = { version = "12.0.0", default-features = false }
sp-core = { version = "27.0.0", default-features = false }
sp-core-hashing = { version = "14.0.0", default-features = false }
sp-core-hashing-proc-macro = { version = "14.0.0", default-features = false }
sp-database = "9.0.0"
sp-externalities = "0.24.0"
sp-inherents = { version = "25.0.0", default-features = false }
sp-io = { version = "29.0.0", default-features = false }
sp-keyring = "30.0.0"
sp-offchain = { version = "25.0.0", default-features = false }
sp-runtime = { version = "30.0.1", default-features = false }
sp-runtime-interface = { version = "23.0.0", default-features = false }
sp-session = { version = "26.0.0", default-features = false }
sp-state-machine = { version = "0.34.0", default-features = false }
sp-std = { version = "13.0.0", default-features = false }
sp-storage = { version = "18.0.0", default-features = false }
sp-timestamp = { version = "25.0.0", default-features = false }
sp-transaction-pool = { version = "25.0.0", default-features = false }
sp-version = { version = "28.0.0", default-features = false }
sp-api = { version = "27.0.1", default-features = false }
sp-block-builder = { version = "27.0.0", default-features = false }
sp-blockchain = "29.0.0"
sp-consensus = "0.33.0"
sp-consensus-aura = { version = "0.33.0", default-features = false }
sp-consensus-grandpa = { version = "14.0.0", default-features = false }
sp-core = { version = "29.0.0", default-features = false }
sp-core-hashing = { version = "16.0.0", default-features = false }
sp-core-hashing-proc-macro = { version = "16.0.0", default-features = false }
sp-database = "10.0.0"
sp-externalities = "0.26.0"
sp-inherents = { version = "27.0.0", default-features = false }
sp-io = { version = "31.0.0", default-features = false }
sp-keyring = "32.0.0"
sp-offchain = { version = "27.0.0", default-features = false }
sp-runtime = { version = "32.0.0", default-features = false }
sp-runtime-interface = { version = "25.0.0", default-features = false }
sp-session = { version = "28.0.0", default-features = false }
sp-state-machine = { version = "0.36.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
sp-storage = { version = "20.0.0", default-features = false }
sp-timestamp = { version = "27.0.0", default-features = false }
sp-transaction-pool = { version = "27.0.0", default-features = false }
sp-version = { version = "30.0.0", default-features = false }
# Substrate FRAME
frame-benchmarking = { version = "27.0.0", default-features = false }
frame-executive = { version = "27.0.0", default-features = false }
frame-support = { version = "27.0.0", default-features = false }
frame-system = { version = "27.0.0", default-features = false }
frame-system-benchmarking = { version = "27.0.0", default-features = false }
frame-system-rpc-runtime-api = { version = "25.0.0", default-features = false }
pallet-aura = { version = "26.0.0", default-features = false }
pallet-balances = { version = "27.0.0", default-features = false }
pallet-grandpa = { version = "27.0.0", default-features = false }
pallet-sudo = { version = "27.0.0", default-features = false }
pallet-timestamp = { version = "26.0.0", default-features = false }
pallet-transaction-payment = { version = "27.0.0", default-features = false }
pallet-transaction-payment-rpc = "29.0.0"
pallet-transaction-payment-rpc-runtime-api = { version = "27.0.0", default-features = false }
pallet-utility = { version = "27.0.0", default-features = false }
frame-benchmarking = { version = "29.0.0", default-features = false }
frame-executive = { version = "29.0.0", default-features = false }
frame-support = { version = "29.0.2", default-features = false }
frame-system = { version = "29.0.0", default-features = false }
frame-system-benchmarking = { version = "29.0.0", default-features = false }
frame-system-rpc-runtime-api = { version = "27.0.0", default-features = false }
pallet-aura = { version = "28.0.0", default-features = false }
pallet-balances = { version = "29.0.2", default-features = false }
pallet-grandpa = { version = "29.0.0", default-features = false }
pallet-sudo = { version = "29.0.0", default-features = false }
pallet-timestamp = { version = "28.0.0", default-features = false }
pallet-transaction-payment = { version = "29.0.2", default-features = false }
pallet-transaction-payment-rpc = "31.0.0"
pallet-transaction-payment-rpc-runtime-api = { version = "29.0.0", default-features = false }
pallet-utility = { version = "29.0.0", default-features = false }
# Substrate Utility
frame-benchmarking-cli = "31.0.0"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.16.0" }
substrate-build-script-utils = "10.0.0"
substrate-frame-rpc-system = "27.0.0"
frame-benchmarking-cli = "33.0.0"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.17.0" }
substrate-build-script-utils = "11.0.0"
substrate-frame-rpc-system = "29.0.0"
#substrate-test-runtime-client = "0.1.0"
substrate-wasm-builder = "16.0.0"
substrate-wasm-builder = "18.0.1"

# Frontier Client
fc-api = { version = "1.0.0-dev", path = "client/api" }
Expand Down Expand Up @@ -251,11 +251,12 @@ pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.
pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
pallet-utility = { version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
substrate-prometheus-endpoint = { version = "0.10.0-dev", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
substrate-prometheus-endpoint = { version = "0.16.0" }
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
#substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
sp-externalities = { version = "0.24.0" }

[profile.release]
# Substrate runtime requires unwinding.
Expand Down
4 changes: 4 additions & 0 deletions client/rpc-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ targets = ["x86_64-unknown-linux-gnu"]
ethereum = { workspace = true, features = ["with-codec", "with-serde"] }
ethereum-types = { workspace = true }
jsonrpsee = { workspace = true, features = ["server", "macros"] }
rlp = { workspace = true }
rustc-hex = "2.1.0"
serde = { workspace = true }
serde_json = { workspace = true }

# Substrate
sp-core-hashing = { workspace = true, features = ["default"] }

[features]
txpool = []
4 changes: 2 additions & 2 deletions client/rpc-core/src/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use serde::{ser::Error, Serialize, Serializer};
use crate::types::{Bytes, Transaction};

/// Block Transactions
#[derive(Debug)]
#[derive(Clone, Debug)]
pub enum BlockTransactions {
/// Only hashes
Hashes(Vec<H256>),
Expand All @@ -45,7 +45,7 @@ impl Serialize for BlockTransactions {
}

/// Block representation
#[derive(Debug, Serialize)]
#[derive(Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Block {
/// Header of the block
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-core/src/types/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use ethereum_types::U256;
use serde::Serialize;

/// `eth_feeHistory` response
#[derive(Debug, Serialize)]
#[derive(Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FeeHistory {
/// Lowest number block of the returned range.
Expand Down
52 changes: 36 additions & 16 deletions client/rpc-core/src/types/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl FilteredParams {
}

/// Build an address-based BloomFilter.
pub fn adresses_bloom_filter(address: &Option<FilterAddress>) -> BloomFilter<'_> {
pub fn address_bloom_filter(address: &Option<FilterAddress>) -> BloomFilter<'_> {
if let Some(address) = address {
return address.into();
}
Expand Down Expand Up @@ -301,7 +301,7 @@ impl FilteredParams {
}

/// Replace None values - aka wildcards - for the log input value in that position.
pub fn replace(&self, log: &Log, topic: FlatTopic) -> Option<Vec<H256>> {
pub fn replace(&self, topics: &[H256], topic: FlatTopic) -> Option<Vec<H256>> {
let mut out: Vec<H256> = Vec::new();
match topic {
VariadicValue::Single(Some(value)) => {
Expand All @@ -312,7 +312,7 @@ impl FilteredParams {
if let Some(v) = v {
out.push(v);
} else {
out.push(log.topics[k]);
out.push(topics[k]);
}
}
}
Expand All @@ -324,6 +324,26 @@ impl FilteredParams {
Some(out)
}

pub fn is_not_filtered(
&self,
block_number: U256,
block_hash: H256,
address: &H160,
topics: &[H256],
) -> bool {
if self.filter.is_some() {
let block_number = block_number.as_u64();
if !self.filter_block_range(block_number)
|| !self.filter_block_hash(block_hash)
|| !self.filter_address(address)
|| !self.filter_topics(topics)
{
return false;
}
}
true
}

pub fn filter_block_range(&self, block_number: u64) -> bool {
let mut out = true;
let filter = self.filter.clone().unwrap();
Expand Down Expand Up @@ -357,16 +377,16 @@ impl FilteredParams {
true
}

pub fn filter_address(&self, log: &Log) -> bool {
pub fn filter_address(&self, address: &H160) -> bool {
if let Some(input_address) = &self.filter.clone().unwrap().address {
match input_address {
VariadicValue::Single(x) => {
if log.address != *x {
if address != x {
return false;
}
}
VariadicValue::Multiple(x) => {
if !x.contains(&log.address) {
if !x.contains(address) {
return false;
}
}
Expand All @@ -378,13 +398,13 @@ impl FilteredParams {
true
}

pub fn filter_topics(&self, log: &Log) -> bool {
pub fn filter_topics(&self, topics: &[H256]) -> bool {
let mut out: bool = true;
for topic in self.flat_topics.clone() {
match topic {
VariadicValue::Single(single) => {
if let Some(single) = single {
if !log.topics.starts_with(&[single]) {
if !topics.starts_with(&[single]) {
out = false;
}
}
Expand All @@ -401,15 +421,15 @@ impl FilteredParams {
new_multi.pop();
}
// We can discard right away any logs with lesser topics than the filter.
if new_multi.len() > log.topics.len() {
if new_multi.len() > topics.len() {
out = false;
break;
}
let replaced: Option<Vec<H256>> =
self.replace(log, VariadicValue::Multiple(new_multi));
self.replace(topics, VariadicValue::Multiple(new_multi));
if let Some(replaced) = replaced {
out = false;
if log.topics.starts_with(&replaced[..]) {
if topics.starts_with(&replaced[..]) {
out = true;
break;
}
Expand All @@ -425,7 +445,7 @@ impl FilteredParams {
}

/// Results of the filter_changes RPC.
#[derive(Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum FilterChanges {
/// New logs.
Logs(Vec<Log>),
Expand Down Expand Up @@ -497,7 +517,7 @@ mod tests {
address: Some(VariadicValue::Single(test_address)),
topics: None,
};
let address_bloom = FilteredParams::adresses_bloom_filter(&filter.address);
let address_bloom = FilteredParams::address_bloom_filter(&filter.address);
assert!(FilteredParams::address_in_bloom(
block_bloom(),
&address_bloom
Expand All @@ -514,7 +534,7 @@ mod tests {
address: Some(VariadicValue::Single(test_address)),
topics: None,
};
let address_bloom = FilteredParams::adresses_bloom_filter(&filter.address);
let address_bloom = FilteredParams::address_bloom_filter(&filter.address);
assert!(!FilteredParams::address_in_bloom(
block_bloom(),
&address_bloom
Expand Down Expand Up @@ -635,7 +655,7 @@ mod tests {
} else {
None
};
let address_bloom = FilteredParams::adresses_bloom_filter(&filter.address);
let address_bloom = FilteredParams::address_bloom_filter(&filter.address);
let topics_bloom = FilteredParams::topics_bloom_filter(&topics_input);
let matches = FilteredParams::address_in_bloom(block_bloom(), &address_bloom)
&& FilteredParams::topics_in_bloom(block_bloom(), &topics_bloom);
Expand Down Expand Up @@ -669,7 +689,7 @@ mod tests {
} else {
None
};
let address_bloom = FilteredParams::adresses_bloom_filter(&filter.address);
let address_bloom = FilteredParams::address_bloom_filter(&filter.address);
let topics_bloom = FilteredParams::topics_bloom_filter(&topics_input);
let matches = FilteredParams::address_in_bloom(block_bloom(), &address_bloom)
&& FilteredParams::topics_in_bloom(block_bloom(), &topics_bloom);
Expand Down
Loading

0 comments on commit a8e4a5c

Please sign in to comment.