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 1 commit into
base: master
Choose a base branch
from
Open
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
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
33 changes: 33 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")]
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
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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use std::{ops::Deref, sync::Arc};
use std::sync::Arc;


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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())

.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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|(_hash, extrinsic)| extrinsic.deref().clone())
.map(|(_hash, extrinsic)| extrinsic.as_ref().clone())

.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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ops::Deref,

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())

.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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())

.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;

Comment on lines +19 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use std::ops::Deref;

// 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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())

.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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use std::{ops::Deref, sync::Arc};
use std::sync::Arc;


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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())

.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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|(_hash, extrinsic)| extrinsic.deref().clone())
.map(|(_hash, extrinsic)| extrinsic.as_ref().clone())

.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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use std::{marker::PhantomData, ops::Deref, sync::Arc};
use std::{marker::PhantomData, sync::Arc};


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()];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let xts = vec![xt.data().deref().clone()];
let xts = vec![xt.data().as_ref().clone()];


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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use std::{marker::PhantomData, ops::Deref, sync::Arc};
use std::{marker::PhantomData, sync::Arc};


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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|in_pool_tx| in_pool_tx.data().deref().clone())
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())

.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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|(_, extrinsic)| extrinsic.deref().clone())
.map(|(_, extrinsic)| extrinsic.as_ref().clone())

.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);
Comment on lines 126 to +127
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this, you can remove all these and update LINE 131:

-		key.extend(blake2_128_extend(tmp));
+ 		key.extend(blake2_128_extend(&index.to_big_endian()));


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
10 changes: 7 additions & 3 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ where
len: usize,
) -> Option<Result<(), TransactionValidityError>> {
if let Call::transact { transaction } = self {
if let Err(e) = CheckWeight::<T>::do_pre_dispatch(dispatch_info, len) {
if let Err(e) =
CheckWeight::<T>::do_validate(dispatch_info, len).and_then(|(_, next_len)| {
CheckWeight::<T>::do_prepare(dispatch_info, len, next_len)
}) {
return Some(Err(e));
}

Expand Down Expand Up @@ -629,8 +632,9 @@ impl<T: Config> Pallet<T> {
let data = info.value;
let data_len = data.len();
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.min(T::ExtraDataLength::get() as usize),
);
Expand Down
2 changes: 1 addition & 1 deletion frame/evm-chain-id/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
Loading
Loading