Skip to content

Commit 5676216

Browse files
0xbillwl0r1s
authored andcommitted
Upgrade polkadot-sdk to stable2412 (polkadot-evm#1595)
* Upgrade the version of `polkadot-sdk` to `stable2412` * fix: `Invalid params`: missing field `accessList` * chore: `Deref` is not necessarily required * chore: remove unnecessary code that uses the `U256` type. * remove non-essential trait bounds from `fp-self-contained` these changes are based on the [suggestions](conr2d@df360d6) from @conr2d. * chore: using full-qualified name of an enumeration for matching arms is a best practice.
1 parent c98373b commit 5676216

File tree

59 files changed

+4913
-2251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4913
-2251
lines changed

Cargo.lock

Lines changed: 4479 additions & 1922 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 79 additions & 75 deletions
Large diffs are not rendered by default.

client/api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
1414
async-trait = { workspace = true }
15-
scale-codec = { package = "parity-scale-codec", workspace = true }
15+
scale-codec = { workspace = true }
1616
# Substrate
1717
sp-core = { workspace = true, features = ["default"] }
1818
sp-runtime = { workspace = true, features = ["default"] }

client/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fp-storage = { workspace = true, features = ["default"] }
2727

2828
[dev-dependencies]
2929
futures = { workspace = true }
30-
scale-codec = { package = "parity-scale-codec", workspace = true }
30+
scale-codec = { workspace = true }
3131
tempfile = "3.3.0"
3232
# Substrate
3333
sc-block-builder = { workspace = true }

client/db/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
1414
async-trait = { workspace = true }
15-
ethereum = { workspace = true, features = ["with-codec"], optional = true }
15+
ethereum = { workspace = true, features = ["with-scale"], optional = true }
1616
futures = { workspace = true, optional = true }
1717
kvdb-rocksdb = { workspace = true, optional = true }
1818
log = { workspace = true }
1919
parity-db = { workspace = true }
2020
parking_lot = { workspace = true }
21-
scale-codec = { package = "parity-scale-codec", workspace = true }
21+
scale-codec = { workspace = true }
2222
smallvec = { version = "1.13", optional = true }
2323
sqlx = { workspace = true, features = ["runtime-tokio-native-tls", "sqlite"], optional = true }
2424
tokio = { workspace = true, features = ["macros", "sync"], optional = true }

client/mapping-sync/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fp-rpc = { workspace = true, features = ["default"] }
3333
[dev-dependencies]
3434
ethereum = { workspace = true }
3535
ethereum-types = { workspace = true }
36-
scale-codec = { package = "parity-scale-codec", workspace = true }
36+
scale-codec = { workspace = true }
3737
sqlx = { workspace = true, features = ["runtime-tokio-native-tls", "sqlite"] }
3838
tempfile = "3.14.0"
3939
tokio = { workspace = true, features = ["sync"] }

client/rpc-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = { workspace = true }
1111
targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
14-
ethereum = { workspace = true, features = ["with-codec", "with-serde"] }
14+
ethereum = { workspace = true, features = ["with-scale", "with-serde"] }
1515
ethereum-types = { workspace = true }
1616
jsonrpsee = { workspace = true, features = ["server", "macros"] }
1717
rlp = { workspace = true }

client/rpc-core/src/types/transaction.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ impl BuildFrom for Transaction {
108108
access_list: None,
109109
y_parity: None,
110110
v: Some(U256::from(t.signature.v())),
111-
r: U256::from(t.signature.r().as_bytes()),
112-
s: U256::from(t.signature.s().as_bytes()),
111+
r: U256::from_big_endian(t.signature.r().as_bytes()),
112+
s: U256::from_big_endian(t.signature.s().as_bytes()),
113113
},
114114
EthereumTransaction::EIP2930(t) => Self {
115115
transaction_type: U256::from(1),
@@ -134,8 +134,8 @@ impl BuildFrom for Transaction {
134134
access_list: Some(t.access_list.clone()),
135135
y_parity: Some(U256::from(t.odd_y_parity as u8)),
136136
v: Some(U256::from(t.odd_y_parity as u8)),
137-
r: U256::from(t.r.as_bytes()),
138-
s: U256::from(t.s.as_bytes()),
137+
r: U256::from_big_endian(t.r.as_bytes()),
138+
s: U256::from_big_endian(t.s.as_bytes()),
139139
},
140140
EthereumTransaction::EIP1559(t) => Self {
141141
transaction_type: U256::from(2),
@@ -161,8 +161,8 @@ impl BuildFrom for Transaction {
161161
access_list: Some(t.access_list.clone()),
162162
y_parity: Some(U256::from(t.odd_y_parity as u8)),
163163
v: Some(U256::from(t.odd_y_parity as u8)),
164-
r: U256::from(t.r.as_bytes()),
165-
s: U256::from(t.s.as_bytes()),
164+
r: U256::from_big_endian(t.r.as_bytes()),
165+
s: U256::from_big_endian(t.s.as_bytes()),
166166
},
167167
}
168168
}

client/rpc-core/src/types/transaction_request.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub struct TransactionRequest {
5353
pub data: Data,
5454

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

66+
/// Fix broken unit-test due to the `serde(rename_all = "camelCase")` attribute of type [ethereum::AccessListItem] has been deleted.
67+
/// Refer to this [commit](https://github.com/rust-ethereum/ethereum/commit/b160820620aa9fd30050d5fcb306be4e12d58c8c#diff-2a6a2a5c32456901be5ffa0e2d0354f2d48d96a89e486270ae62808c34b6e96f)
68+
mod access_list_item_camelcase {
69+
use ethereum::AccessListItem;
70+
use ethereum_types::{Address, H256};
71+
use serde::{Deserialize, Deserializer};
72+
73+
#[derive(Deserialize)]
74+
struct AccessListItemDef {
75+
address: Address,
76+
#[serde(rename = "storageKeys")]
77+
storage_keys: Vec<H256>,
78+
}
79+
80+
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Vec<AccessListItem>>, D::Error>
81+
where
82+
D: Deserializer<'de>,
83+
{
84+
let access_item_defs_opt: Option<Vec<AccessListItemDef>> =
85+
Option::deserialize(deserializer)?;
86+
Ok(access_item_defs_opt.map(|access_item_defs| {
87+
access_item_defs
88+
.into_iter()
89+
.map(|access_item_def| AccessListItem {
90+
address: access_item_def.address,
91+
storage_keys: access_item_def.storage_keys,
92+
})
93+
.collect()
94+
}))
95+
}
96+
}
97+
6598
impl TransactionRequest {
6699
// We accept "data" and "input" for backwards-compatibility reasons.
67100
// "input" is the newer name and should be preferred by clients.
@@ -235,6 +268,31 @@ mod tests {
235268
);
236269
}
237270

271+
#[test]
272+
fn test_deserialize_missing_field_access_list() {
273+
let data = json!({
274+
"from": "0x60be2d1d3665660d22ff9624b7be0551ee1ac91b",
275+
"to": "0x13fe2d1d3665660d22ff9624b7be0551ee1ac91b",
276+
"gasPrice": "0x10",
277+
"maxFeePerGas": "0x20",
278+
"maxPriorityFeePerGas": "0x30",
279+
"gas": "0x40",
280+
"value": "0x50",
281+
"input": "0x123abc",
282+
"nonce": "0x60",
283+
"type": "0x70"
284+
});
285+
286+
let args = serde_json::from_value::<TransactionRequest>(data).unwrap();
287+
assert_eq!(
288+
args.data,
289+
Data {
290+
input: Some(Bytes::from(vec![0x12, 0x3a, 0xbc])),
291+
data: None,
292+
}
293+
);
294+
}
295+
238296
#[test]
239297
fn test_deserialize_with_only_data() {
240298
let data = json!({

client/rpc-v2/types/src/transaction/signature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct TransactionSignature {
3232
///
3333
/// - For legacy transactions, this is the recovery id.
3434
/// - For typed transactions (EIP-2930, EIP-1559, EIP-4844), this is set to the parity
35-
/// (0 for even, 1 for odd) of the y-value of the secp256k1 signature.
35+
/// (0 for even, 1 for odd) of the y-value of the secp256k1 signature.
3636
///
3737
/// # Note
3838
///

client/rpc/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = { workspace = true }
1111
targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
14-
ethereum = { workspace = true, features = ["with-codec"] }
14+
ethereum = { workspace = true, features = ["with-scale"] }
1515
ethereum-types = { workspace = true }
1616
evm = { workspace = true }
1717
futures = { workspace = true }
@@ -22,7 +22,7 @@ log = { workspace = true }
2222
prometheus = { version = "0.13.4", default-features = false }
2323
rand = "0.8"
2424
rlp = { workspace = true }
25-
scale-codec = { package = "parity-scale-codec", workspace = true }
25+
scale-codec = { workspace = true }
2626
schnellru = "0.2.4"
2727
serde = { workspace = true }
2828
thiserror = { workspace = true }

client/rpc/src/eth/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ where
147147
graph
148148
.validated_pool()
149149
.ready()
150-
.map(|in_pool_tx| in_pool_tx.data().clone())
150+
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
151151
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
152152
);
153153

@@ -157,7 +157,7 @@ where
157157
.validated_pool()
158158
.futures()
159159
.iter()
160-
.map(|(_hash, extrinsic)| extrinsic.clone())
160+
.map(|(_hash, extrinsic)| extrinsic.as_ref().clone())
161161
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
162162
);
163163

client/rpc/src/eth/execute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,8 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> RpcResult
978978
// A minimum size of error function selector (4) + offset (32) + string length (32)
979979
// should contain a utf-8 encoded revert reason.
980980
if data.len() > MESSAGE_START {
981-
let message_len =
982-
U256::from(&data[LEN_START..MESSAGE_START]).saturated_into::<usize>();
981+
let message_len = U256::from_big_endian(&data[LEN_START..MESSAGE_START])
982+
.saturated_into::<usize>();
983983
let message_end = MESSAGE_START.saturating_add(message_len);
984984

985985
if data.len() >= message_end {

client/rpc/src/eth/filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ where
111111
.graph
112112
.validated_pool()
113113
.ready()
114-
.map(|in_pool_tx| in_pool_tx.data().clone())
114+
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
115115
.collect();
116116
// Use the runtime to match the (here) opaque extrinsics against ethereum transactions.
117117
let api = self.client.runtime_api();
@@ -225,7 +225,7 @@ where
225225
.graph
226226
.validated_pool()
227227
.ready()
228-
.map(|in_pool_tx| in_pool_tx.data().clone())
228+
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
229229
.collect();
230230
// Use the runtime to match the (here) opaque extrinsics against ethereum transactions.
231231
let api = self.client.runtime_api();

client/rpc/src/eth/pending.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ where
125125
.graph
126126
.validated_pool()
127127
.ready()
128-
.map(|in_pool_tx| in_pool_tx.data().clone())
128+
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
129129
.collect::<Vec<<B as BlockT>::Extrinsic>>();
130130
log::debug!(target: LOG_TARGET, "Pending runtime API: extrinsic len = {}", extrinsics.len());
131131
// Apply the extrinsics from the ready queue to the pending block's state.

client/rpc/src/eth/transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ where
8181
graph
8282
.validated_pool()
8383
.ready()
84-
.map(|in_pool_tx| in_pool_tx.data().clone())
84+
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
8585
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
8686
);
8787

@@ -91,7 +91,7 @@ where
9191
.validated_pool()
9292
.futures()
9393
.iter()
94-
.map(|(_hash, extrinsic)| extrinsic.clone())
94+
.map(|(_hash, extrinsic)| extrinsic.as_ref().clone())
9595
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
9696
);
9797

client/rpc/src/eth_pubsub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ where
165165
return future::ready(None);
166166
};
167167

168-
let xts = vec![xt.data().clone()];
168+
let xts = vec![xt.data().as_ref().clone()];
169169

170170
let txs: Option<Vec<EthereumTransaction>> = if api_version > 1 {
171171
api.extrinsic_filter(best_block, xts).ok()

client/rpc/src/txpool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ where
109109
.graph
110110
.validated_pool()
111111
.ready()
112-
.map(|in_pool_tx| in_pool_tx.data().clone())
112+
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
113113
.collect();
114114

115115
// Collect extrinsics in the future validated pool.
@@ -118,7 +118,7 @@ where
118118
.validated_pool()
119119
.futures()
120120
.iter()
121-
.map(|(_, extrinsic)| extrinsic.clone())
121+
.map(|(_, extrinsic)| extrinsic.as_ref().clone())
122122
.collect();
123123

124124
// Use the runtime to match the (here) opaque extrinsics against ethereum transactions.

client/storage/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ repository = { workspace = true }
1111
targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
14-
ethereum = { workspace = true, features = ["with-codec"] }
14+
ethereum = { workspace = true, features = ["with-scale"] }
1515
ethereum-types = { workspace = true }
16-
scale-codec = { package = "parity-scale-codec", workspace = true }
16+
scale-codec = { workspace = true }
1717

1818
# Substrate
1919
sc-client-api = { workspace = true }

client/storage/src/overrides/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,9 @@ where
123123
}
124124

125125
pub fn account_storage(&self, at: B::Hash, address: Address, index: U256) -> Option<H256> {
126-
let tmp: &mut [u8; 32] = &mut [0; 32];
127-
index.to_big_endian(tmp);
128-
129126
let mut key: Vec<u8> = storage_prefix_build(PALLET_EVM, EVM_ACCOUNT_STORAGES);
130127
key.extend(blake2_128_extend(address.as_bytes()));
131-
key.extend(blake2_128_extend(tmp));
128+
key.extend(blake2_128_extend(&index.to_big_endian()));
132129

133130
self.query::<H256>(at, &StorageKey(key))
134131
}

frame/base-fee/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = { workspace = true }
1111
targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
14-
scale-codec = { package = "parity-scale-codec", workspace = true }
14+
scale-codec = { workspace = true }
1515
scale-info = { workspace = true }
1616
# Substrate
1717
frame-support = { workspace = true }

frame/dynamic-fee/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = { workspace = true }
1111
targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
14-
scale-codec = { package = "parity-scale-codec", workspace = true }
14+
scale-codec = { workspace = true }
1515
scale-info = { workspace = true }
1616
# Substrate
1717
frame-support = { workspace = true }

frame/ethereum/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ repository = { workspace = true }
1111
targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
14-
ethereum = { workspace = true, features = ["with-codec"] }
14+
ethereum = { workspace = true, features = ["with-scale"] }
1515
ethereum-types = { workspace = true }
1616
evm = { workspace = true, features = ["with-codec"] }
17-
scale-codec = { package = "parity-scale-codec", workspace = true }
17+
scale-codec = { workspace = true }
1818
scale-info = { workspace = true }
1919
# Substrate
2020
frame-support = { workspace = true }

frame/ethereum/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ where
137137
len: usize,
138138
) -> Option<Result<(), TransactionValidityError>> {
139139
if let Call::transact { transaction } = self {
140-
if let Err(e) = CheckWeight::<T>::do_pre_dispatch(dispatch_info, len) {
140+
if let Err(e) =
141+
CheckWeight::<T>::do_validate(dispatch_info, len).and_then(|(_, next_len)| {
142+
CheckWeight::<T>::do_prepare(dispatch_info, len, next_len)
143+
}) {
141144
return Some(Err(e));
142145
}
143146

@@ -629,8 +632,9 @@ impl<T: Config> Pallet<T> {
629632
let data = info.value;
630633
let data_len = data.len();
631634
if data_len > MESSAGE_START {
632-
let message_len = U256::from(&data[LEN_START..MESSAGE_START])
633-
.saturated_into::<usize>();
635+
let message_len =
636+
U256::from_big_endian(&data[LEN_START..MESSAGE_START])
637+
.saturated_into::<usize>();
634638
let message_end = MESSAGE_START.saturating_add(
635639
message_len.min(T::ExtraDataLength::get() as usize),
636640
);

frame/evm-chain-id/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = { workspace = true }
1111
targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
14-
scale-codec = { package = "parity-scale-codec", workspace = true }
14+
scale-codec = { workspace = true }
1515
scale-info = { workspace = true }
1616
# Substrate
1717
frame-support = { workspace = true }

frame/evm/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ hash-db = { workspace = true }
1818
hex-literal = { workspace = true }
1919
impl-trait-for-tuples = "0.2.3"
2020
log = { workspace = true }
21-
scale-codec = { package = "parity-scale-codec", workspace = true }
21+
scale-codec = { workspace = true }
2222
scale-info = { workspace = true }
2323
# Substrate
2424
frame-benchmarking = { workspace = true, optional = true }
@@ -43,7 +43,7 @@ default = ["std"]
4343
std = [
4444
"environmental?/std",
4545
"evm/std",
46-
"evm/with-serde",
46+
"evm/serde",
4747
"hex/std",
4848
"log/std",
4949
"scale-codec/std",

0 commit comments

Comments
 (0)