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

Upgrade polkadot-sdk to stable2412 #1595

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5,270 changes: 3,578 additions & 1,692 deletions Cargo.lock

Large diffs are not rendered by default.

152 changes: 76 additions & 76 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
# Substrate
sp-core = { workspace = true, features = ["default"] }
sp-runtime = { workspace = true, features = ["default"] }
Expand Down
2 changes: 1 addition & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fp-storage = { workspace = true, features = ["default"] }

[dev-dependencies]
futures = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
tempfile = "3.3.0"
# Substrate
sc-block-builder = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = { workspace = true }
ethereum = { workspace = true, features = ["with-codec"], optional = true }
ethereum = { workspace = true, features = ["with-scale"], optional = true }
futures = { workspace = true, optional = true }
kvdb-rocksdb = { workspace = true, optional = true }
log = { workspace = true }
parity-db = { workspace = true }
parking_lot = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
smallvec = { version = "1.13", optional = true }
sqlx = { workspace = true, features = ["runtime-tokio-native-tls", "sqlite"], optional = true }
tokio = { workspace = true, features = ["macros", "sync"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion client/mapping-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fp-rpc = { workspace = true, features = ["default"] }
[dev-dependencies]
ethereum = { workspace = true }
ethereum-types = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
sqlx = { workspace = true, features = ["runtime-tokio-native-tls", "sqlite"] }
tempfile = "3.14.0"
tokio = { workspace = true, features = ["sync"] }
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
ethereum = { workspace = true, features = ["with-codec", "with-serde"] }
ethereum = { workspace = true, features = ["with-scale", "with-serde"] }
ethereum-types = { workspace = true }
jsonrpsee = { workspace = true, features = ["server", "macros"] }
rlp = { workspace = true }
Expand Down
12 changes: 6 additions & 6 deletions client/rpc-core/src/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ impl BuildFrom for Transaction {
access_list: None,
y_parity: None,
v: Some(U256::from(t.signature.v())),
r: U256::from(t.signature.r().as_bytes()),
s: U256::from(t.signature.s().as_bytes()),
r: U256::from_big_endian(t.signature.r().as_bytes()),
s: U256::from_big_endian(t.signature.s().as_bytes()),
},
EthereumTransaction::EIP2930(t) => Self {
transaction_type: U256::from(1),
Expand All @@ -134,8 +134,8 @@ impl BuildFrom for Transaction {
access_list: Some(t.access_list.clone()),
y_parity: Some(U256::from(t.odd_y_parity as u8)),
v: Some(U256::from(t.odd_y_parity as u8)),
r: U256::from(t.r.as_bytes()),
s: U256::from(t.s.as_bytes()),
r: U256::from_big_endian(t.r.as_bytes()),
s: U256::from_big_endian(t.s.as_bytes()),
},
EthereumTransaction::EIP1559(t) => Self {
transaction_type: U256::from(2),
Expand All @@ -161,8 +161,8 @@ impl BuildFrom for Transaction {
access_list: Some(t.access_list.clone()),
y_parity: Some(U256::from(t.odd_y_parity as u8)),
v: Some(U256::from(t.odd_y_parity as u8)),
r: U256::from(t.r.as_bytes()),
s: U256::from(t.s.as_bytes()),
r: U256::from_big_endian(t.r.as_bytes()),
s: U256::from_big_endian(t.s.as_bytes()),
},
}
}
Expand Down
58 changes: 58 additions & 0 deletions client/rpc-core/src/types/transaction_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub struct TransactionRequest {
pub data: Data,

/// EIP-2930 access list
#[serde(with = "access_list_item_camelcase", default)]
pub access_list: Option<Vec<AccessListItem>>,
/// Chain ID that this transaction is valid on
pub chain_id: Option<U64>,
Expand All @@ -62,6 +63,38 @@ pub struct TransactionRequest {
pub transaction_type: Option<U256>,
}

/// Fix broken unit-test due to the `serde(rename_all = "camelCase")` attribute of type [ethereum::AccessListItem] has been deleted.
/// Refer to this [commit](https://github.com/rust-ethereum/ethereum/commit/b160820620aa9fd30050d5fcb306be4e12d58c8c#diff-2a6a2a5c32456901be5ffa0e2d0354f2d48d96a89e486270ae62808c34b6e96f)
mod access_list_item_camelcase {
use ethereum::AccessListItem;
use ethereum_types::{Address, H256};
use serde::{Deserialize, Deserializer};

#[derive(Deserialize)]
struct AccessListItemDef {
address: Address,
#[serde(rename = "storageKeys")]
storage_keys: Vec<H256>,
}

pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Vec<AccessListItem>>, D::Error>
where
D: Deserializer<'de>,
{
let access_item_defs_opt: Option<Vec<AccessListItemDef>> =
Option::deserialize(deserializer)?;
Ok(access_item_defs_opt.map(|access_item_defs| {
access_item_defs
.into_iter()
.map(|access_item_def| AccessListItem {
address: access_item_def.address,
storage_keys: access_item_def.storage_keys,
})
.collect()
}))
}
}

impl TransactionRequest {
// We accept "data" and "input" for backwards-compatibility reasons.
// "input" is the newer name and should be preferred by clients.
Expand Down Expand Up @@ -235,6 +268,31 @@ mod tests {
);
}

#[test]
fn test_deserialize_missing_field_access_list() {
let data = json!({
"from": "0x60be2d1d3665660d22ff9624b7be0551ee1ac91b",
"to": "0x13fe2d1d3665660d22ff9624b7be0551ee1ac91b",
"gasPrice": "0x10",
"maxFeePerGas": "0x20",
"maxPriorityFeePerGas": "0x30",
"gas": "0x40",
"value": "0x50",
"input": "0x123abc",
"nonce": "0x60",
"type": "0x70"
});

let args = serde_json::from_value::<TransactionRequest>(data).unwrap();
assert_eq!(
args.data,
Data {
input: Some(Bytes::from(vec![0x12, 0x3a, 0xbc])),
data: None,
}
);
}

#[test]
fn test_deserialize_with_only_data() {
let data = json!({
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-v2/types/src/transaction/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct TransactionSignature {
///
/// - For legacy transactions, this is the recovery id.
/// - For typed transactions (EIP-2930, EIP-1559, EIP-4844), this is set to the parity
/// (0 for even, 1 for odd) of the y-value of the secp256k1 signature.
/// (0 for even, 1 for odd) of the y-value of the secp256k1 signature.
///
/// # Note
///
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
ethereum = { workspace = true, features = ["with-codec"] }
ethereum = { workspace = true, features = ["with-scale"] }
ethereum-types = { workspace = true }
evm = { workspace = true }
futures = { workspace = true }
Expand All @@ -22,7 +22,7 @@ log = { workspace = true }
prometheus = { version = "0.13.4", default-features = false }
rand = "0.8"
rlp = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
schnellru = "0.2.4"
serde = { workspace = true, optional = true }
thiserror = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// 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 std::sync::Arc;
use std::{ops::Deref, sync::Arc};
0xbillw marked this conversation as resolved.
Show resolved Hide resolved

use ethereum_types::{H256, U256};
use jsonrpsee::core::RpcResult;
Expand Down Expand Up @@ -147,7 +147,7 @@ where
graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().clone())
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
);

Expand All @@ -157,7 +157,7 @@ where
.validated_pool()
.futures()
.iter()
.map(|(_hash, extrinsic)| extrinsic.clone())
.map(|(_hash, extrinsic)| extrinsic.deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
);

Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> RpcResult
// A minimum size of error function selector (4) + offset (32) + string length (32)
// should contain a utf-8 encoded revert reason.
if data.len() > MESSAGE_START {
let message_len =
U256::from(&data[LEN_START..MESSAGE_START]).saturated_into::<usize>();
let message_len = U256::from_big_endian(&data[LEN_START..MESSAGE_START])
.saturated_into::<usize>();
let message_end = MESSAGE_START.saturating_add(message_len);

if data.len() >= message_end {
Expand Down
5 changes: 3 additions & 2 deletions client/rpc/src/eth/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use std::{
collections::{BTreeMap, HashSet},
marker::PhantomData,
ops::Deref,
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
sync::Arc,
time::{Duration, Instant},
};
Expand Down Expand Up @@ -111,7 +112,7 @@ where
.graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().clone())
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect();
// Use the runtime to match the (here) opaque extrinsics against ethereum transactions.
let api = self.client.runtime_api();
Expand Down Expand Up @@ -225,7 +226,7 @@ where
.graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().clone())
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect();
// Use the runtime to match the (here) opaque extrinsics against ethereum transactions.
let api = self.client.runtime_api();
Expand Down
4 changes: 3 additions & 1 deletion client/rpc/src/eth/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// 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 std::ops::Deref;

0xbillw marked this conversation as resolved.
Show resolved Hide resolved
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
Expand Down Expand Up @@ -125,7 +127,7 @@ where
.graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().clone())
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect::<Vec<<B as BlockT>::Extrinsic>>();
log::debug!(target: LOG_TARGET, "Pending runtime API: extrinsic len = {}", extrinsics.len());
// Apply the extrinsics from the ready queue to the pending block's state.
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// 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 std::sync::Arc;
use std::{ops::Deref, sync::Arc};
0xbillw marked this conversation as resolved.
Show resolved Hide resolved

use ethereum::TransactionV2 as EthereumTransaction;
use ethereum_types::{H256, U256, U64};
Expand Down Expand Up @@ -81,7 +81,7 @@ where
graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().clone())
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
);

Expand All @@ -91,7 +91,7 @@ where
.validated_pool()
.futures()
.iter()
.map(|(_hash, extrinsic)| extrinsic.clone())
.map(|(_hash, extrinsic)| extrinsic.deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
);

Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// 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 std::{marker::PhantomData, sync::Arc};
use std::{marker::PhantomData, ops::Deref, sync::Arc};
0xbillw marked this conversation as resolved.
Show resolved Hide resolved

use ethereum::TransactionV2 as EthereumTransaction;
use futures::{future, FutureExt as _, StreamExt as _};
Expand Down Expand Up @@ -165,7 +165,7 @@ where
return future::ready(None);
};

let xts = vec![xt.data().clone()];
let xts = vec![xt.data().deref().clone()];
0xbillw marked this conversation as resolved.
Show resolved Hide resolved

let txs: Option<Vec<EthereumTransaction>> = if api_version > 1 {
api.extrinsic_filter(best_block, xts).ok()
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// 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 std::{marker::PhantomData, sync::Arc};
use std::{marker::PhantomData, ops::Deref, sync::Arc};
0xbillw marked this conversation as resolved.
Show resolved Hide resolved

use ethereum::TransactionV2 as EthereumTransaction;
use ethereum_types::{H160, H256, U256};
Expand Down Expand Up @@ -109,7 +109,7 @@ where
.graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().clone())
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect();

// Collect extrinsics in the future validated pool.
Expand All @@ -118,7 +118,7 @@ where
.validated_pool()
.futures()
.iter()
.map(|(_, extrinsic)| extrinsic.clone())
.map(|(_, extrinsic)| extrinsic.deref().clone())
0xbillw marked this conversation as resolved.
Show resolved Hide resolved
.collect();

// Use the runtime to match the (here) opaque extrinsics against ethereum transactions.
Expand Down
4 changes: 2 additions & 2 deletions client/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
ethereum = { workspace = true, features = ["with-codec"] }
ethereum = { workspace = true, features = ["with-scale"] }
ethereum-types = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }

# Substrate
sc-client-api = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion client/storage/src/overrides/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ where

pub fn account_storage(&self, at: B::Hash, address: Address, index: U256) -> Option<H256> {
let tmp: &mut [u8; 32] = &mut [0; 32];
index.to_big_endian(tmp);
index.write_as_big_endian(tmp);
0xbillw marked this conversation as resolved.
Show resolved Hide resolved

let mut key: Vec<u8> = storage_prefix_build(PALLET_EVM, EVM_ACCOUNT_STORAGES);
key.extend(blake2_128_extend(address.as_bytes()));
Expand Down
2 changes: 1 addition & 1 deletion frame/base-fee/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
scale-info = { workspace = true }
# Substrate
frame-support = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion frame/dynamic-fee/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
scale-info = { workspace = true }
# Substrate
frame-support = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions frame/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
ethereum = { workspace = true, features = ["with-codec"] }
ethereum = { workspace = true, features = ["with-scale"] }
ethereum-types = { workspace = true }
evm = { workspace = true, features = ["with-codec"] }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
scale-info = { workspace = true }
# Substrate
frame-support = { workspace = true }
Expand Down
Loading
Loading