style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -50,8 +50,9 @@ impl BizinikiwiCli for Cli {
|
||||
fn load_spec(&self, id: &str) -> Result<Box<dyn pezsc_service::ChainSpec>, String> {
|
||||
Ok(match id {
|
||||
"dev" | "" => Box::new(chain_spec::development_chain_spec()?),
|
||||
path =>
|
||||
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
|
||||
path => {
|
||||
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?)
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
use pezkuwi_subxt::OnlineClient;
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezpallet_revive_eth_rpc::subxt_client::{
|
||||
self, revive::calls::types::InstantiateWithCode, SrcChainConfig,
|
||||
};
|
||||
use pezsp_weights::Weight;
|
||||
use pezkuwi_subxt::OnlineClient;
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
use pezpallet_revive_eth_rpc::subxt_client::{self, system::calls::types::Remark, SrcChainConfig};
|
||||
use pezkuwi_subxt::OnlineClient;
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezpallet_revive_eth_rpc::subxt_client::{self, system::calls::types::Remark, SrcChainConfig};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
@@ -185,9 +185,10 @@ impl From<ClientError> for ErrorObjectOwned {
|
||||
match err {
|
||||
ClientError::SubxtError(pezkuwi_subxt::Error::OtherRpcClientError(
|
||||
pezkuwi_subxt::ext::pezkuwi_subxt_rpcs::Error::User(err),
|
||||
)) |
|
||||
ClientError::RpcError(pezkuwi_subxt::ext::pezkuwi_subxt_rpcs::Error::User(err)) =>
|
||||
ErrorObjectOwned::owned::<Vec<u8>>(err.code, err.message, None),
|
||||
))
|
||||
| ClientError::RpcError(pezkuwi_subxt::ext::pezkuwi_subxt_rpcs::Error::User(err)) => {
|
||||
ErrorObjectOwned::owned::<Vec<u8>>(err.code, err.message, None)
|
||||
},
|
||||
ClientError::TransactError(EthTransactError::Data(data)) => {
|
||||
let msg = match decode_revert_reason(&data) {
|
||||
Some(reason) => format!("execution reverted: {reason}"),
|
||||
@@ -197,10 +198,12 @@ impl From<ClientError> for ErrorObjectOwned {
|
||||
let data = format!("0x{}", hex::encode(data));
|
||||
ErrorObjectOwned::owned::<String>(REVERT_CODE, msg, Some(data))
|
||||
},
|
||||
ClientError::TransactError(EthTransactError::Message(msg)) =>
|
||||
ErrorObjectOwned::owned::<String>(CALL_EXECUTION_FAILED_CODE, msg, None),
|
||||
_ =>
|
||||
ErrorObjectOwned::owned::<String>(CALL_EXECUTION_FAILED_CODE, err.to_string(), None),
|
||||
ClientError::TransactError(EthTransactError::Message(msg)) => {
|
||||
ErrorObjectOwned::owned::<String>(CALL_EXECUTION_FAILED_CODE, msg, None)
|
||||
},
|
||||
_ => {
|
||||
ErrorObjectOwned::owned::<String>(CALL_EXECUTION_FAILED_CODE, err.to_string(), None)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,9 @@ impl RuntimeApi {
|
||||
block: BlockNumberOrTagOrHash,
|
||||
) -> Result<EthTransactInfo<Balance>, ClientError> {
|
||||
let timestamp_override = match block {
|
||||
BlockNumberOrTagOrHash::BlockTag(BlockTag::Pending) =>
|
||||
Some(Timestamp::current().as_millis()),
|
||||
BlockNumberOrTagOrHash::BlockTag(BlockTag::Pending) => {
|
||||
Some(Timestamp::current().as_millis())
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,10 @@ use pezsp_core::H256;
|
||||
|
||||
/// A wrapper around the Bizinikiwi Storage API.
|
||||
#[derive(Clone)]
|
||||
pub struct StorageApi(StorageClientAt<SrcChainConfig, OnlineClient<SrcChainConfig>>, #[expect(dead_code)] H256);
|
||||
pub struct StorageApi(
|
||||
StorageClientAt<SrcChainConfig, OnlineClient<SrcChainConfig>>,
|
||||
#[expect(dead_code)] H256,
|
||||
);
|
||||
|
||||
impl StorageApi {
|
||||
/// Create a new instance of the StorageApi.
|
||||
|
||||
@@ -225,8 +225,9 @@ impl<B: BlockInfoProvider> ReceiptProvider<B> {
|
||||
/// Check if the block is before the earliest block.
|
||||
pub fn is_before_earliest_block(&self, at: &BlockNumberOrTag) -> bool {
|
||||
match at {
|
||||
BlockNumberOrTag::U256(block_number) =>
|
||||
self.receipt_extractor.is_before_earliest_block(block_number.as_u32()),
|
||||
BlockNumberOrTag::U256(block_number) => {
|
||||
self.receipt_extractor.is_before_earliest_block(block_number.as_u32())
|
||||
},
|
||||
BlockNumberOrTag::BlockTag(_) => false,
|
||||
}
|
||||
}
|
||||
@@ -617,15 +618,17 @@ mod tests {
|
||||
|
||||
async fn count(pool: &SqlitePool, table: &str, block_hash: Option<H256>) -> usize {
|
||||
let count: i64 = match block_hash {
|
||||
None =>
|
||||
None => {
|
||||
sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {table}"))
|
||||
.fetch_one(pool)
|
||||
.await,
|
||||
Some(hash) =>
|
||||
.await
|
||||
},
|
||||
Some(hash) => {
|
||||
sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {table} WHERE block_hash = ?"))
|
||||
.bind(hash.as_ref())
|
||||
.fetch_one(pool)
|
||||
.await,
|
||||
.await
|
||||
},
|
||||
}
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -209,8 +209,8 @@ async fn submit_bizinikiwi_transactions(
|
||||
log::trace!(target: LOG_TARGET, "Bizinikiwi tx {i} submitted");
|
||||
while let Some(status) = progress.next().await {
|
||||
match status {
|
||||
Ok(TxStatus::InFinalizedBlock(block)) |
|
||||
Ok(TxStatus::InBestBlock(block)) => {
|
||||
Ok(TxStatus::InFinalizedBlock(block))
|
||||
| Ok(TxStatus::InBestBlock(block)) => {
|
||||
log::trace!(target: LOG_TARGET,
|
||||
"Bizinikiwi tx {i} included in block {:?}",
|
||||
block.block_hash()
|
||||
@@ -250,8 +250,9 @@ async fn verify_transactions_in_single_block(
|
||||
|
||||
let block_tx_hashes = match &block.transactions {
|
||||
HashesOrTransactionInfos::Hashes(hashes) => hashes.clone(),
|
||||
HashesOrTransactionInfos::TransactionInfos(infos) =>
|
||||
infos.iter().map(|info| info.hash).collect(),
|
||||
HashesOrTransactionInfos::TransactionInfos(infos) => {
|
||||
infos.iter().map(|info| info.hash).collect()
|
||||
},
|
||||
};
|
||||
|
||||
if let Some(missing_hash) =
|
||||
@@ -780,7 +781,11 @@ async fn test_runtime_pallets_address_upload_code(client: Arc<WsClient>) -> anyh
|
||||
let code_hash = H256(pezsp_io::hashing::keccak_256(&bytecode));
|
||||
let query = subxt_client::storage().revive().pristine_code();
|
||||
let block_hash: pezsp_core::H256 = get_bizinikiwi_block_hash(receipt.block_number).await?;
|
||||
let stored_code: Vec<u8> = node_client.storage().at(block_hash).fetch(&query, (code_hash,)).await
|
||||
let stored_code: Vec<u8> = node_client
|
||||
.storage()
|
||||
.at(block_hash)
|
||||
.fetch(&query, (code_hash,))
|
||||
.await
|
||||
.expect("Code with hash should exist in storage")
|
||||
.decode()?;
|
||||
assert_eq!(stored_code, bytecode, "Stored code should match the uploaded bytecode");
|
||||
|
||||
@@ -165,8 +165,8 @@ where
|
||||
}
|
||||
|
||||
fn is_mapped(account_id: &T::AccountId) -> bool {
|
||||
is_eth_derived(account_id) ||
|
||||
<OriginalAccount<T>>::contains_key(Self::to_address(account_id))
|
||||
is_eth_derived(account_id)
|
||||
|| <OriginalAccount<T>>::contains_key(Self::to_address(account_id))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -264,10 +264,11 @@ mod benchmarks {
|
||||
T::Currency::balance_on_hold(&HoldReason::AddressMapping.into(), &caller);
|
||||
assert_eq!(
|
||||
T::Currency::balance(&caller),
|
||||
caller_funding::<T>() -
|
||||
value - deposit -
|
||||
code_deposit - mapping_deposit -
|
||||
Pezpallet::<T>::min_balance(),
|
||||
caller_funding::<T>()
|
||||
- value - deposit
|
||||
- code_deposit
|
||||
- mapping_deposit
|
||||
- Pezpallet::<T>::min_balance(),
|
||||
);
|
||||
// contract has the full value
|
||||
assert_eq!(T::Currency::balance(&account_id), value + Pezpallet::<T>::min_balance());
|
||||
@@ -368,10 +369,11 @@ mod benchmarks {
|
||||
// value was removed from the caller
|
||||
assert_eq!(
|
||||
T::Currency::total_balance(&caller),
|
||||
caller_funding::<T>() -
|
||||
value - deposit -
|
||||
code_deposit - mapping_deposit -
|
||||
Pezpallet::<T>::min_balance(),
|
||||
caller_funding::<T>()
|
||||
- value - deposit
|
||||
- code_deposit
|
||||
- mapping_deposit
|
||||
- Pezpallet::<T>::min_balance(),
|
||||
);
|
||||
// contract has the full value
|
||||
assert_eq!(T::Currency::balance(&account_id), value + Pezpallet::<T>::min_balance());
|
||||
@@ -411,10 +413,11 @@ mod benchmarks {
|
||||
// value and value transferred via call should be removed from the caller
|
||||
assert_eq!(
|
||||
T::Currency::balance(&instance.caller),
|
||||
caller_funding::<T>() -
|
||||
value - deposit -
|
||||
code_deposit - mapping_deposit -
|
||||
Pezpallet::<T>::min_balance()
|
||||
caller_funding::<T>()
|
||||
- value - deposit
|
||||
- code_deposit
|
||||
- mapping_deposit
|
||||
- Pezpallet::<T>::min_balance()
|
||||
);
|
||||
// contract should have received the value
|
||||
assert_eq!(T::Currency::balance(&instance.account_id), before + value);
|
||||
|
||||
@@ -443,8 +443,9 @@ impl VmBinaryModule {
|
||||
// return execution right away without breaking up basic block
|
||||
// SENTINEL is a hard coded syscall that terminates execution
|
||||
0 => writeln!(text, "ecalli {}", crate::SENTINEL).unwrap(),
|
||||
i if i % (limits::code::BASIC_BLOCK_SIZE - 1) == 0 =>
|
||||
text.push_str("fallthrough\n"),
|
||||
i if i % (limits::code::BASIC_BLOCK_SIZE - 1) == 0 => {
|
||||
text.push_str("fallthrough\n")
|
||||
},
|
||||
_ => text.push_str("a0 = a1 + a2\n"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +62,9 @@ impl TransactionSigned {
|
||||
Transaction2930Signed(tx) => Transaction2930Unsigned(tx.transaction_2930_unsigned),
|
||||
Transaction1559Signed(tx) => Transaction1559Unsigned(tx.transaction_1559_unsigned),
|
||||
Transaction4844Signed(tx) => Transaction4844Unsigned(tx.transaction_4844_unsigned),
|
||||
TransactionLegacySigned(tx) =>
|
||||
TransactionLegacyUnsigned(tx.transaction_legacy_unsigned),
|
||||
TransactionLegacySigned(tx) => {
|
||||
TransactionLegacyUnsigned(tx.transaction_legacy_unsigned)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,11 +200,13 @@ impl<'a> serde::Deserialize<'a> for BlockNumberOrTagOrHash {
|
||||
BlockNumberOrTagOrHash::BlockNumber(val.into())
|
||||
},
|
||||
|
||||
BlockNumberOrTagOrHashWithAlias::NestedBlockNumber { block_number: val } =>
|
||||
BlockNumberOrTagOrHash::BlockNumber(val),
|
||||
BlockNumberOrTagOrHashWithAlias::BlockHash(val) |
|
||||
BlockNumberOrTagOrHashWithAlias::NestedBlockHash { block_hash: val } =>
|
||||
BlockNumberOrTagOrHash::BlockHash(val),
|
||||
BlockNumberOrTagOrHashWithAlias::NestedBlockNumber { block_number: val } => {
|
||||
BlockNumberOrTagOrHash::BlockNumber(val)
|
||||
},
|
||||
BlockNumberOrTagOrHashWithAlias::BlockHash(val)
|
||||
| BlockNumberOrTagOrHashWithAlias::NestedBlockHash { block_hash: val } => {
|
||||
BlockNumberOrTagOrHash::BlockHash(val)
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -544,8 +546,9 @@ impl HashesOrTransactionInfos {
|
||||
pub fn contains_tx(&self, hash: H256) -> bool {
|
||||
match self {
|
||||
HashesOrTransactionInfos::Hashes(hashes) => hashes.iter().any(|h256| *h256 == hash),
|
||||
HashesOrTransactionInfos::TransactionInfos(transaction_infos) =>
|
||||
transaction_infos.iter().any(|ti| ti.hash == hash),
|
||||
HashesOrTransactionInfos::TransactionInfos(transaction_infos) => {
|
||||
transaction_infos.iter().any(|ti| ti.hash == hash)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,16 +40,21 @@ impl TransactionUnsigned {
|
||||
/// Extract the unsigned transaction from a signed transaction.
|
||||
pub fn from_signed(tx: TransactionSigned) -> Self {
|
||||
match tx {
|
||||
TransactionSigned::TransactionLegacySigned(signed) =>
|
||||
Self::TransactionLegacyUnsigned(signed.transaction_legacy_unsigned),
|
||||
TransactionSigned::Transaction7702Signed(signed) =>
|
||||
Self::Transaction7702Unsigned(signed.transaction_7702_unsigned),
|
||||
TransactionSigned::Transaction4844Signed(signed) =>
|
||||
Self::Transaction4844Unsigned(signed.transaction_4844_unsigned),
|
||||
TransactionSigned::Transaction1559Signed(signed) =>
|
||||
Self::Transaction1559Unsigned(signed.transaction_1559_unsigned),
|
||||
TransactionSigned::Transaction2930Signed(signed) =>
|
||||
Self::Transaction2930Unsigned(signed.transaction_2930_unsigned),
|
||||
TransactionSigned::TransactionLegacySigned(signed) => {
|
||||
Self::TransactionLegacyUnsigned(signed.transaction_legacy_unsigned)
|
||||
},
|
||||
TransactionSigned::Transaction7702Signed(signed) => {
|
||||
Self::Transaction7702Unsigned(signed.transaction_7702_unsigned)
|
||||
},
|
||||
TransactionSigned::Transaction4844Signed(signed) => {
|
||||
Self::Transaction4844Unsigned(signed.transaction_4844_unsigned)
|
||||
},
|
||||
TransactionSigned::Transaction1559Signed(signed) => {
|
||||
Self::Transaction1559Unsigned(signed.transaction_1559_unsigned)
|
||||
},
|
||||
TransactionSigned::Transaction2930Signed(signed) => {
|
||||
Self::Transaction2930Unsigned(signed.transaction_2930_unsigned)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +65,7 @@ impl TransactionUnsigned {
|
||||
let recovery_id = signature[64];
|
||||
|
||||
match self {
|
||||
TransactionUnsigned::Transaction7702Unsigned(transaction_7702_unsigned) =>
|
||||
TransactionUnsigned::Transaction7702Unsigned(transaction_7702_unsigned) => {
|
||||
Transaction7702Signed {
|
||||
transaction_7702_unsigned,
|
||||
r,
|
||||
@@ -68,8 +73,9 @@ impl TransactionUnsigned {
|
||||
v: None,
|
||||
y_parity: U256::from(recovery_id),
|
||||
}
|
||||
.into(),
|
||||
TransactionUnsigned::Transaction2930Unsigned(transaction_2930_unsigned) =>
|
||||
.into()
|
||||
},
|
||||
TransactionUnsigned::Transaction2930Unsigned(transaction_2930_unsigned) => {
|
||||
Transaction2930Signed {
|
||||
transaction_2930_unsigned,
|
||||
r,
|
||||
@@ -77,8 +83,9 @@ impl TransactionUnsigned {
|
||||
v: None,
|
||||
y_parity: U256::from(recovery_id),
|
||||
}
|
||||
.into(),
|
||||
TransactionUnsigned::Transaction1559Unsigned(transaction_1559_unsigned) =>
|
||||
.into()
|
||||
},
|
||||
TransactionUnsigned::Transaction1559Unsigned(transaction_1559_unsigned) => {
|
||||
Transaction1559Signed {
|
||||
transaction_1559_unsigned,
|
||||
r,
|
||||
@@ -86,16 +93,18 @@ impl TransactionUnsigned {
|
||||
v: None,
|
||||
y_parity: U256::from(recovery_id),
|
||||
}
|
||||
.into(),
|
||||
.into()
|
||||
},
|
||||
|
||||
TransactionUnsigned::Transaction4844Unsigned(transaction_4844_unsigned) =>
|
||||
TransactionUnsigned::Transaction4844Unsigned(transaction_4844_unsigned) => {
|
||||
Transaction4844Signed {
|
||||
transaction_4844_unsigned,
|
||||
r,
|
||||
s,
|
||||
y_parity: U256::from(recovery_id),
|
||||
}
|
||||
.into(),
|
||||
.into()
|
||||
},
|
||||
|
||||
TransactionUnsigned::TransactionLegacyUnsigned(transaction_legacy_unsigned) => {
|
||||
let v = transaction_legacy_unsigned
|
||||
|
||||
@@ -321,10 +321,10 @@ mod test {
|
||||
|
||||
// Each mask in these vectors holds a u16.
|
||||
let masks_len = (hb.state_masks.len() + hb.tree_masks.len() + hb.hash_masks.len()) * 2;
|
||||
let _size = hb.key.len() +
|
||||
hb.value.as_slice().len() +
|
||||
hb.stack.len() * 33 +
|
||||
masks_len + hb.rlp_buf.len();
|
||||
let _size = hb.key.len()
|
||||
+ hb.value.as_slice().len()
|
||||
+ hb.stack.len() * 33
|
||||
+ masks_len + hb.rlp_buf.len();
|
||||
}
|
||||
|
||||
hb.root().0.into()
|
||||
|
||||
@@ -300,15 +300,16 @@ impl IncrementalHashBuilder {
|
||||
#[cfg(test)]
|
||||
fn calculate_current_size(&self) -> usize {
|
||||
// Each mask in these vectors holds a u16.
|
||||
let masks_len = (self.hash_builder.state_masks.len() +
|
||||
self.hash_builder.tree_masks.len() +
|
||||
self.hash_builder.hash_masks.len()) *
|
||||
2;
|
||||
let masks_len = (self.hash_builder.state_masks.len()
|
||||
+ self.hash_builder.tree_masks.len()
|
||||
+ self.hash_builder.hash_masks.len())
|
||||
* 2;
|
||||
|
||||
self.hash_builder.key.len() +
|
||||
self.hash_builder.value.as_slice().len() +
|
||||
self.hash_builder.stack.len() * 33 +
|
||||
masks_len + self.hash_builder.rlp_buf.len()
|
||||
self.hash_builder.key.len()
|
||||
+ self.hash_builder.value.as_slice().len()
|
||||
+ self.hash_builder.stack.len() * 33
|
||||
+ masks_len
|
||||
+ self.hash_builder.rlp_buf.len()
|
||||
}
|
||||
|
||||
/// Update accounting metrics after processing data.
|
||||
@@ -415,14 +416,15 @@ impl IncrementalHashBuilderIR {
|
||||
// Vector metadata overhead (capacity info, etc.)
|
||||
let vec_overhead = 8 * core::mem::size_of::<usize>(); // 8 Vec structures
|
||||
|
||||
fixed_size +
|
||||
key_size + builder_value_size +
|
||||
stack_size +
|
||||
state_masks_size +
|
||||
tree_masks_size +
|
||||
hash_masks_size +
|
||||
rlp_buf_size +
|
||||
vec_overhead
|
||||
fixed_size
|
||||
+ key_size
|
||||
+ builder_value_size
|
||||
+ stack_size
|
||||
+ state_masks_size
|
||||
+ tree_masks_size
|
||||
+ hash_masks_size
|
||||
+ rlp_buf_size
|
||||
+ vec_overhead
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,9 +84,9 @@ impl AccumulateReceipt {
|
||||
// Account for the size of the list header.
|
||||
let topics_list_header_length = topics_len + rlp::length_of_length(topics_len);
|
||||
// Compute the total payload length of the log.
|
||||
let payload_length = rlp::Encodable::length(&contract.0) +
|
||||
rlp::Encodable::length(&data) +
|
||||
topics_list_header_length;
|
||||
let payload_length = rlp::Encodable::length(&contract.0)
|
||||
+ rlp::Encodable::length(&data)
|
||||
+ topics_list_header_length;
|
||||
|
||||
let header = rlp::Header { list: true, payload_length };
|
||||
header.encode(&mut self.encoding);
|
||||
@@ -112,10 +112,10 @@ impl AccumulateReceipt {
|
||||
|
||||
let header = rlp::Header {
|
||||
list: true,
|
||||
payload_length: rlp::Encodable::length(&status) +
|
||||
rlp::Encodable::length(&gas) +
|
||||
rlp::Encodable::length(&bloom.bloom) +
|
||||
list_header_length,
|
||||
payload_length: rlp::Encodable::length(&status)
|
||||
+ rlp::Encodable::length(&gas)
|
||||
+ rlp::Encodable::length(&bloom.bloom)
|
||||
+ list_header_length,
|
||||
};
|
||||
|
||||
let mut encoded = transaction_type;
|
||||
|
||||
@@ -158,8 +158,9 @@ pub fn with_ethereum_context<T: Config>(
|
||||
with_transaction(|| -> TransactionOutcome<Result<_, DispatchError>> {
|
||||
let EthereumCallResult { receipt_gas_info, result } = call();
|
||||
match result {
|
||||
Ok(post_info) =>
|
||||
TransactionOutcome::Commit(Ok((None, receipt_gas_info, post_info))),
|
||||
Ok(post_info) => {
|
||||
TransactionOutcome::Commit(Ok((None, receipt_gas_info, post_info)))
|
||||
},
|
||||
Err(err) => TransactionOutcome::Rollback(Ok((
|
||||
Some(err.error),
|
||||
receipt_gas_info,
|
||||
|
||||
@@ -285,9 +285,9 @@ pub trait EthExtra {
|
||||
|
||||
// Check transaction type and reject unsupported transaction types
|
||||
match &tx {
|
||||
crate::evm::api::TransactionSigned::Transaction1559Signed(_) |
|
||||
crate::evm::api::TransactionSigned::Transaction2930Signed(_) |
|
||||
crate::evm::api::TransactionSigned::TransactionLegacySigned(_) => {
|
||||
crate::evm::api::TransactionSigned::Transaction1559Signed(_)
|
||||
| crate::evm::api::TransactionSigned::Transaction2930Signed(_)
|
||||
| crate::evm::api::TransactionSigned::TransactionLegacySigned(_) => {
|
||||
// Supported transaction types, continue processing
|
||||
},
|
||||
crate::evm::api::TransactionSigned::Transaction7702Signed(_) => {
|
||||
@@ -542,11 +542,11 @@ mod test {
|
||||
transaction_encoded,
|
||||
effective_gas_price,
|
||||
encoded_len,
|
||||
}) if dest == tx.to.unwrap() &&
|
||||
value == tx.value.unwrap_or_default().as_u64().into() &&
|
||||
data == tx.input.to_vec() &&
|
||||
transaction_encoded == signed_transaction.signed_payload() &&
|
||||
effective_gas_price == expected_effective_gas_price =>
|
||||
}) if dest == tx.to.unwrap()
|
||||
&& value == tx.value.unwrap_or_default().as_u64().into()
|
||||
&& data == tx.input.to_vec()
|
||||
&& transaction_encoded == signed_transaction.signed_payload()
|
||||
&& effective_gas_price == expected_effective_gas_price =>
|
||||
{
|
||||
assert_eq!(encoded_len, expected_encoded_len);
|
||||
assert!(
|
||||
@@ -581,11 +581,11 @@ mod test {
|
||||
transaction_encoded,
|
||||
effective_gas_price,
|
||||
encoded_len,
|
||||
}) if value == expected_value &&
|
||||
code == expected_code &&
|
||||
data == expected_data &&
|
||||
transaction_encoded == signed_transaction.signed_payload() &&
|
||||
effective_gas_price == expected_effective_gas_price =>
|
||||
}) if value == expected_value
|
||||
&& code == expected_code
|
||||
&& data == expected_data
|
||||
&& transaction_encoded == signed_transaction.signed_payload()
|
||||
&& effective_gas_price == expected_effective_gas_price =>
|
||||
{
|
||||
assert_eq!(encoded_len, expected_encoded_len);
|
||||
assert!(
|
||||
|
||||
@@ -200,8 +200,9 @@ impl<Gas: Default + core::fmt::Debug, GasMapper: Fn(Weight) -> Gas> Tracing
|
||||
trace.gas_used = (self.gas_mapper)(gas_used);
|
||||
|
||||
trace.error = match error {
|
||||
DispatchError::Module(pezsp_runtime::ModuleError { message, .. }) =>
|
||||
Some(message.unwrap_or_default().to_string()),
|
||||
DispatchError::Module(pezsp_runtime::ModuleError { message, .. }) => {
|
||||
Some(message.unwrap_or_default().to_string())
|
||||
},
|
||||
_ => Some(format!("{:?}", error)),
|
||||
};
|
||||
|
||||
|
||||
@@ -77,10 +77,10 @@ where
|
||||
let include_code = !self.config.disable_code;
|
||||
|
||||
let is_empty = |info: &PrestateTraceInfo| {
|
||||
!info.storage.values().any(|v| v.is_some()) &&
|
||||
info.balance.is_none() &&
|
||||
info.nonce.is_none() &&
|
||||
info.code.is_none()
|
||||
!info.storage.values().any(|v| v.is_some())
|
||||
&& info.balance.is_none()
|
||||
&& info.nonce.is_none()
|
||||
&& info.code.is_none()
|
||||
};
|
||||
|
||||
if self.config.diff_mode {
|
||||
|
||||
@@ -1005,12 +1005,13 @@ where
|
||||
// is a delegate call or not
|
||||
let mut contract = match (cached_info, &precompile) {
|
||||
(Some(info), _) => CachedContract::Cached(info),
|
||||
(None, None) =>
|
||||
(None, None) => {
|
||||
if let Some(info) = AccountInfo::<T>::load_contract(&address) {
|
||||
CachedContract::Cached(info)
|
||||
} else {
|
||||
return Ok(None);
|
||||
},
|
||||
}
|
||||
},
|
||||
(None, Some(precompile)) if precompile.has_contract_info() => {
|
||||
log::trace!(target: LOG_TARGET, "found precompile for address {address:?}");
|
||||
if let Some(info) = AccountInfo::<T>::load_contract(&address) {
|
||||
@@ -1287,9 +1288,9 @@ where
|
||||
// - Only when not delegate calling we are executing in the context of the pre-compile.
|
||||
// Pre-compiles itself cannot delegate call.
|
||||
if let Some(precompile) = executable.as_precompile() {
|
||||
if precompile.has_contract_info() &&
|
||||
frame.delegate.is_none() &&
|
||||
!<System<T>>::account_exists(account_id)
|
||||
if precompile.has_contract_info()
|
||||
&& frame.delegate.is_none()
|
||||
&& !<System<T>>::account_exists(account_id)
|
||||
{
|
||||
// prefix matching pre-compiles cannot have a contract info
|
||||
// hence we only mint once per pre-compile
|
||||
@@ -1305,10 +1306,12 @@ where
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut output = match executable {
|
||||
ExecutableOrPrecompile::Executable(executable) =>
|
||||
executable.execute(self, entry_point, input_data),
|
||||
ExecutableOrPrecompile::Precompile { instance, .. } =>
|
||||
instance.call(input_data, self),
|
||||
ExecutableOrPrecompile::Executable(executable) => {
|
||||
executable.execute(self, entry_point, input_data)
|
||||
},
|
||||
ExecutableOrPrecompile::Precompile { instance, .. } => {
|
||||
instance.call(input_data, self)
|
||||
},
|
||||
}
|
||||
.and_then(|output| {
|
||||
if u32::try_from(output.data.len())
|
||||
@@ -1337,8 +1340,8 @@ where
|
||||
// Only keep return data for tracing and for dry runs.
|
||||
// When a dry-run simulates contract deployment, keep the execution result's
|
||||
// data.
|
||||
let data = if crate::tracing::if_tracing(|_| {}).is_none() &&
|
||||
self.exec_config.is_dry_run.is_none()
|
||||
let data = if crate::tracing::if_tracing(|_| {}).is_none()
|
||||
&& self.exec_config.is_dry_run.is_none()
|
||||
{
|
||||
core::mem::replace(&mut output.data, Default::default())
|
||||
} else {
|
||||
@@ -1389,8 +1392,9 @@ where
|
||||
do_transaction()
|
||||
};
|
||||
match &output {
|
||||
Ok(result) if !result.did_revert() =>
|
||||
TransactionOutcome::Commit(Ok((true, output))),
|
||||
Ok(result) if !result.did_revert() => {
|
||||
TransactionOutcome::Commit(Ok((true, output)))
|
||||
},
|
||||
_ => TransactionOutcome::Rollback(Ok((false, output))),
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1628,7 +1628,7 @@ impl<T: Config> Pezpallet<T> {
|
||||
storage_deposit_limit.saturating_reduce(upload_deposit);
|
||||
(executable, upload_deposit)
|
||||
},
|
||||
Code::Upload(code) =>
|
||||
Code::Upload(code) => {
|
||||
if T::AllowEVMBytecode::get() {
|
||||
ensure!(data.is_empty(), <Error<T>>::EvmConstructorNonEmptyData);
|
||||
let origin = T::UploadOrigin::ensure_origin(origin)?;
|
||||
@@ -1636,7 +1636,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
(executable, Default::default())
|
||||
} else {
|
||||
return Err(<Error<T>>::CodeRejected.into());
|
||||
},
|
||||
}
|
||||
},
|
||||
Code::Existing(code_hash) => {
|
||||
let executable = ContractBlob::from_storage(code_hash, &mut gas_meter)?;
|
||||
ensure!(executable.code_info().is_pvm(), <Error<T>>::EvmConstructedFromHash);
|
||||
@@ -2044,8 +2045,9 @@ impl<T: Config> Pezpallet<T> {
|
||||
Self::evm_gas_from_weight as fn(Weight) -> U256,
|
||||
)
|
||||
.into(),
|
||||
TracerType::PrestateTracer(config) =>
|
||||
PrestateTracer::new(config.unwrap_or_default()).into(),
|
||||
TracerType::PrestateTracer(config) => {
|
||||
PrestateTracer::new(config.unwrap_or_default()).into()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2420,8 +2422,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
if exec::is_precompile::<T, ContractBlob<T>>(&address) ||
|
||||
<AccountInfo<T>>::is_contract(&address)
|
||||
if exec::is_precompile::<T, ContractBlob<T>>(&address)
|
||||
|| <AccountInfo<T>>::is_contract(&address)
|
||||
{
|
||||
log::debug!(
|
||||
target: crate::LOG_TARGET,
|
||||
|
||||
@@ -312,8 +312,9 @@ impl<E> Instance<E> {
|
||||
let result = (self.function)(&self.address, input, env);
|
||||
match result {
|
||||
Ok(data) => Ok(ExecReturnValue { flags: ReturnFlags::empty(), data }),
|
||||
Err(Error::Revert(msg)) =>
|
||||
Ok(ExecReturnValue { flags: ReturnFlags::REVERT, data: msg.abi_encode() }),
|
||||
Err(Error::Revert(msg)) => {
|
||||
Ok(ExecReturnValue { flags: ReturnFlags::REVERT, data: msg.abi_encode() })
|
||||
},
|
||||
Err(Error::Panic(kind)) => Ok(ExecReturnValue {
|
||||
flags: ReturnFlags::REVERT,
|
||||
data: Panic::from(kind).abi_encode(),
|
||||
|
||||
@@ -56,7 +56,9 @@ impl<T: Config> BuiltinPrecompile for Storage<T> {
|
||||
match input {
|
||||
IStorageCalls::clearStorage(_) | IStorageCalls::takeStorage(_)
|
||||
if env.is_read_only() =>
|
||||
Err(Error::Error(crate::Error::<Self::T>::StateChangeDenied.into())),
|
||||
{
|
||||
Err(Error::Error(crate::Error::<Self::T>::StateChangeDenied.into()))
|
||||
},
|
||||
|
||||
IStorageCalls::clearStorage(IStorage::clearStorageCall { flags, key, isFixedKey }) => {
|
||||
let transient = is_transient(*flags)
|
||||
|
||||
@@ -44,8 +44,9 @@ impl<T: Config> BuiltinPrecompile for System<T> {
|
||||
) -> Result<Vec<u8>, Error> {
|
||||
use ISystem::ISystemCalls;
|
||||
match input {
|
||||
ISystemCalls::terminate(_) if env.is_read_only() =>
|
||||
Err(crate::Error::<T>::StateChangeDenied.into()),
|
||||
ISystemCalls::terminate(_) if env.is_read_only() => {
|
||||
Err(crate::Error::<T>::StateChangeDenied.into())
|
||||
},
|
||||
ISystemCalls::hashBlake256(ISystem::hashBlake256Call { input }) => {
|
||||
env.gas_meter_mut().charge(RuntimeCosts::HashBlake256(input.len() as u32))?;
|
||||
let output = pezsp_io::hashing::blake2_256(input.as_bytes_ref());
|
||||
|
||||
@@ -282,18 +282,20 @@ where
|
||||
match (self, rhs) {
|
||||
(Charge(lhs), Charge(rhs)) => Charge(lhs.saturating_add(*rhs)),
|
||||
(Refund(lhs), Refund(rhs)) => Refund(lhs.saturating_add(*rhs)),
|
||||
(Charge(lhs), Refund(rhs)) =>
|
||||
(Charge(lhs), Refund(rhs)) => {
|
||||
if lhs >= rhs {
|
||||
Charge(lhs.saturating_sub(*rhs))
|
||||
} else {
|
||||
Refund(rhs.saturating_sub(*lhs))
|
||||
},
|
||||
(Refund(lhs), Charge(rhs)) =>
|
||||
}
|
||||
},
|
||||
(Refund(lhs), Charge(rhs)) => {
|
||||
if lhs > rhs {
|
||||
Refund(lhs.saturating_sub(*rhs))
|
||||
} else {
|
||||
Charge(rhs.saturating_sub(*lhs))
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,18 +305,20 @@ where
|
||||
match (self, rhs) {
|
||||
(Charge(lhs), Refund(rhs)) => Charge(lhs.saturating_add(*rhs)),
|
||||
(Refund(lhs), Charge(rhs)) => Refund(lhs.saturating_add(*rhs)),
|
||||
(Charge(lhs), Charge(rhs)) =>
|
||||
(Charge(lhs), Charge(rhs)) => {
|
||||
if lhs >= rhs {
|
||||
Charge(lhs.saturating_sub(*rhs))
|
||||
} else {
|
||||
Refund(rhs.saturating_sub(*lhs))
|
||||
},
|
||||
(Refund(lhs), Refund(rhs)) =>
|
||||
}
|
||||
},
|
||||
(Refund(lhs), Refund(rhs)) => {
|
||||
if lhs > rhs {
|
||||
Refund(lhs.saturating_sub(*rhs))
|
||||
} else {
|
||||
Charge(rhs.saturating_sub(*lhs))
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,8 +133,9 @@ impl<T: Config> From<H160> for AccountIdOrAddress<T> {
|
||||
impl<T: Config> AccountIdOrAddress<T> {
|
||||
pub fn address(&self) -> H160 {
|
||||
match self {
|
||||
AccountIdOrAddress::AccountId(id) =>
|
||||
<T::AddressMapper as AddressMapper<T>>::to_address(id),
|
||||
AccountIdOrAddress::AccountId(id) => {
|
||||
<T::AddressMapper as AddressMapper<T>>::to_address(id)
|
||||
},
|
||||
AccountIdOrAddress::Address(address) => *address,
|
||||
}
|
||||
}
|
||||
@@ -334,12 +335,13 @@ impl<T: Config> ContractInfo<T> {
|
||||
let mut diff = meter::Diff::default();
|
||||
let key_len = key.len() as u32;
|
||||
match (old_len, new_value.as_ref().map(|v| v.len() as u32)) {
|
||||
(Some(old_len), Some(new_len)) =>
|
||||
(Some(old_len), Some(new_len)) => {
|
||||
if new_len > old_len {
|
||||
diff.bytes_added = new_len - old_len;
|
||||
} else {
|
||||
diff.bytes_removed = old_len - new_len;
|
||||
},
|
||||
}
|
||||
},
|
||||
(None, Some(new_len)) => {
|
||||
diff.bytes_added = new_len.saturating_add(key_len);
|
||||
diff.items_added = 1;
|
||||
@@ -402,8 +404,8 @@ impl<T: Config> ContractInfo<T> {
|
||||
/// of those keys can be deleted from the deletion queue given the supplied weight limit.
|
||||
pub fn deletion_budget(meter: &WeightMeter) -> (Weight, u32) {
|
||||
let base_weight = T::WeightInfo::on_process_deletion_queue_batch();
|
||||
let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1) -
|
||||
T::WeightInfo::on_initialize_per_trie_key(0);
|
||||
let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1)
|
||||
- T::WeightInfo::on_initialize_per_trie_key(0);
|
||||
|
||||
// `weight_per_key` being zero makes no sense and would constitute a failure to
|
||||
// benchmark properly. We opt for not removing any keys at all in this case.
|
||||
|
||||
@@ -162,16 +162,20 @@ impl Diff {
|
||||
info.storage_items =
|
||||
info.storage_items.saturating_add(items_added).saturating_sub(items_removed);
|
||||
match &bytes_deposit {
|
||||
Deposit::Charge(amount) =>
|
||||
info.storage_byte_deposit = info.storage_byte_deposit.saturating_add(*amount),
|
||||
Deposit::Refund(amount) =>
|
||||
info.storage_byte_deposit = info.storage_byte_deposit.saturating_sub(*amount),
|
||||
Deposit::Charge(amount) => {
|
||||
info.storage_byte_deposit = info.storage_byte_deposit.saturating_add(*amount)
|
||||
},
|
||||
Deposit::Refund(amount) => {
|
||||
info.storage_byte_deposit = info.storage_byte_deposit.saturating_sub(*amount)
|
||||
},
|
||||
}
|
||||
match &items_deposit {
|
||||
Deposit::Charge(amount) =>
|
||||
info.storage_item_deposit = info.storage_item_deposit.saturating_add(*amount),
|
||||
Deposit::Refund(amount) =>
|
||||
info.storage_item_deposit = info.storage_item_deposit.saturating_sub(*amount),
|
||||
Deposit::Charge(amount) => {
|
||||
info.storage_item_deposit = info.storage_item_deposit.saturating_add(*amount)
|
||||
},
|
||||
Deposit::Refund(amount) => {
|
||||
info.storage_item_deposit = info.storage_item_deposit.saturating_sub(*amount)
|
||||
},
|
||||
}
|
||||
|
||||
bytes_deposit.saturating_add(&items_deposit)
|
||||
@@ -368,8 +372,8 @@ where
|
||||
) => {
|
||||
*last_amount = last_amount.saturating_add(ch_amount);
|
||||
},
|
||||
(ContractState::Alive { amount }, ContractState::Terminated) |
|
||||
(ContractState::Terminated, ContractState::Alive { amount }) => {
|
||||
(ContractState::Alive { amount }, ContractState::Terminated)
|
||||
| (ContractState::Terminated, ContractState::Alive { amount }) => {
|
||||
// undo all deposits made by a terminated contract
|
||||
self.total_deposit = self.total_deposit.saturating_sub(amount);
|
||||
last.state = ContractState::Terminated;
|
||||
|
||||
@@ -177,8 +177,8 @@ pub mod test_utils {
|
||||
let code_info_len = CodeInfo::<Test>::max_encoded_len() as u64;
|
||||
// Calculate deposit to be reserved.
|
||||
// We add 2 storage items: one for code, other for code_info
|
||||
DepositPerByte::get().saturating_mul(code_len as u64 + code_info_len) +
|
||||
DepositPerItem::get().saturating_mul(2)
|
||||
DepositPerByte::get().saturating_mul(code_len as u64 + code_info_len)
|
||||
+ DepositPerItem::get().saturating_mul(2)
|
||||
}
|
||||
pub fn ensure_stored(code_hash: pezsp_core::H256) -> usize {
|
||||
// Assert that code_info is stored
|
||||
@@ -421,8 +421,8 @@ impl SetWeightLimit for RuntimeCall {
|
||||
fn set_weight_limit(&mut self, weight_limit: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Contracts(
|
||||
Call::eth_call { gas_limit, .. } |
|
||||
Call::eth_instantiate_with_code { gas_limit, .. },
|
||||
Call::eth_call { gas_limit, .. }
|
||||
| Call::eth_instantiate_with_code { gas_limit, .. },
|
||||
) => {
|
||||
let old = *gas_limit;
|
||||
*gas_limit = weight_limit;
|
||||
|
||||
@@ -83,12 +83,15 @@ impl<T: Config> Precompile for NoInfo<T> {
|
||||
|
||||
match input {
|
||||
INoInfoCalls::identity(INoInfo::identityCall { number }) => Ok(number.abi_encode()),
|
||||
INoInfoCalls::reverts(INoInfo::revertsCall { error }) =>
|
||||
Err(Error::Revert(error.as_str().into())),
|
||||
INoInfoCalls::panics(INoInfo::panicsCall {}) =>
|
||||
Err(Error::Panic(PanicKind::Assert.into())),
|
||||
INoInfoCalls::errors(INoInfo::errorsCall {}) =>
|
||||
Err(Error::Error(DispatchError::Other("precompile failed").into())),
|
||||
INoInfoCalls::reverts(INoInfo::revertsCall { error }) => {
|
||||
Err(Error::Revert(error.as_str().into()))
|
||||
},
|
||||
INoInfoCalls::panics(INoInfo::panicsCall {}) => {
|
||||
Err(Error::Panic(PanicKind::Assert.into()))
|
||||
},
|
||||
INoInfoCalls::errors(INoInfo::errorsCall {}) => {
|
||||
Err(Error::Error(DispatchError::Other("precompile failed").into()))
|
||||
},
|
||||
INoInfoCalls::consumeMaxGas(INoInfo::consumeMaxGasCall {}) => {
|
||||
env.gas_meter_mut().charge(MaxGasToken)?;
|
||||
Ok(Vec::new())
|
||||
@@ -103,8 +106,9 @@ impl<T: Config> Precompile for NoInfo<T> {
|
||||
let call = <T as Config>::RuntimeCall::decode(&mut &call[..]).unwrap();
|
||||
match call.dispatch(frame_origin) {
|
||||
Ok(_) => Ok(Vec::new()),
|
||||
Err(e) =>
|
||||
Err(Error::Error(ExecError { error: e.error, origin: ErrorOrigin::Caller })),
|
||||
Err(e) => {
|
||||
Err(Error::Error(ExecError { error: e.error, origin: ErrorOrigin::Caller }))
|
||||
},
|
||||
}
|
||||
},
|
||||
INoInfoCalls::passData(INoInfo::passDataCall { inputLen }) => {
|
||||
@@ -119,8 +123,9 @@ impl<T: Config> Precompile for NoInfo<T> {
|
||||
)?;
|
||||
Ok(Vec::new())
|
||||
},
|
||||
INoInfoCalls::returnData(INoInfo::returnDataCall { returnLen }) =>
|
||||
Ok(vec![42; *returnLen as usize]),
|
||||
INoInfoCalls::returnData(INoInfo::returnDataCall { returnLen }) => {
|
||||
Ok(vec![42; *returnLen as usize])
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2946,8 +2946,8 @@ fn native_dependency_deposit_works() {
|
||||
.build_and_unwrap_result();
|
||||
|
||||
// Check updated storage_deposit due to code size changes
|
||||
let deposit_diff = lockup_deposit_percent.mul_ceil(upload_deposit) -
|
||||
lockup_deposit_percent.mul_ceil(get_code_deposit(&dummy_code_hash));
|
||||
let deposit_diff = lockup_deposit_percent.mul_ceil(upload_deposit)
|
||||
- lockup_deposit_percent.mul_ceil(get_code_deposit(&dummy_code_hash));
|
||||
let new_base_deposit = contract_base_deposit(&addr);
|
||||
assert_ne!(deposit_diff, 0);
|
||||
assert_eq!(base_deposit - new_base_deposit, deposit_diff);
|
||||
|
||||
@@ -62,8 +62,8 @@ impl<T: Config> Token<T> for EVMGas {
|
||||
impl<T: Config> ContractBlob<T> {
|
||||
/// Create a new contract from EVM init code.
|
||||
pub fn from_evm_init_code(code: Vec<u8>, owner: AccountIdOf<T>) -> Result<Self, DispatchError> {
|
||||
if code.len() > revm::primitives::eip3860::MAX_INITCODE_SIZE &&
|
||||
!DebugSettings::is_unlimited_contract_size_allowed::<T>()
|
||||
if code.len() > revm::primitives::eip3860::MAX_INITCODE_SIZE
|
||||
&& !DebugSettings::is_unlimited_contract_size_allowed::<T>()
|
||||
{
|
||||
return Err(<Error<T>>::BlobTooLarge.into());
|
||||
}
|
||||
@@ -98,8 +98,8 @@ impl<T: Config> ContractBlob<T> {
|
||||
code: Vec<u8>,
|
||||
owner: AccountIdOf<T>,
|
||||
) -> Result<Self, DispatchError> {
|
||||
if code.len() > revm::primitives::eip170::MAX_CODE_SIZE &&
|
||||
!DebugSettings::is_unlimited_contract_size_allowed::<T>()
|
||||
if code.len() > revm::primitives::eip170::MAX_CODE_SIZE
|
||||
&& !DebugSettings::is_unlimited_contract_size_allowed::<T>()
|
||||
{
|
||||
return Err(<Error<T>>::BlobTooLarge.into());
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ pub fn i256_div(mut first: U256, mut second: U256) -> U256 {
|
||||
|
||||
// Two's complement only if the signs are different
|
||||
// Note: This condition has better codegen than an exhaustive match, as of #582
|
||||
if (first_sign == Sign::Minus && second_sign != Sign::Minus) ||
|
||||
(second_sign == Sign::Minus && first_sign != Sign::Minus)
|
||||
if (first_sign == Sign::Minus && second_sign != Sign::Minus)
|
||||
|| (second_sign == Sign::Minus && first_sign != Sign::Minus)
|
||||
{
|
||||
two_compl(d)
|
||||
} else {
|
||||
|
||||
@@ -55,8 +55,8 @@ pub fn create<const IS_CREATE2: bool, E: Ext>(
|
||||
let mut code = Vec::new();
|
||||
if len != 0 {
|
||||
// EIP-3860: Limit initcode
|
||||
if len > revm::primitives::eip3860::MAX_INITCODE_SIZE &&
|
||||
!DebugSettings::is_unlimited_contract_size_allowed::<E::T>()
|
||||
if len > revm::primitives::eip3860::MAX_INITCODE_SIZE
|
||||
&& !DebugSettings::is_unlimited_contract_size_allowed::<E::T>()
|
||||
{
|
||||
return ControlFlow::Break(Error::<E::T>::BlobTooLarge.into());
|
||||
}
|
||||
@@ -209,8 +209,9 @@ fn run_call<'a, E: Ext>(
|
||||
true,
|
||||
scheme.is_static_call(),
|
||||
),
|
||||
CallScheme::DelegateCall =>
|
||||
interpreter.ext.delegate_call(gas_limit, U256::MAX, callee, input),
|
||||
CallScheme::DelegateCall => {
|
||||
interpreter.ext.delegate_call(gas_limit, U256::MAX, callee, input)
|
||||
},
|
||||
CallScheme::CallCode => {
|
||||
unreachable!()
|
||||
},
|
||||
|
||||
@@ -641,8 +641,9 @@ impl<'a, E: Ext, M: ?Sized + Memory<E::T>> Runtime<'a, E, M> {
|
||||
let callee = memory.read_h160(callee_ptr)?;
|
||||
let precompile = <AllPrecompiles<E::T>>::get::<E>(&callee.as_fixed_bytes());
|
||||
match &precompile {
|
||||
Some(precompile) if precompile.has_contract_info() =>
|
||||
self.charge_gas(RuntimeCosts::PrecompileWithInfoBase)?,
|
||||
Some(precompile) if precompile.has_contract_info() => {
|
||||
self.charge_gas(RuntimeCosts::PrecompileWithInfoBase)?
|
||||
},
|
||||
Some(_) => self.charge_gas(RuntimeCosts::PrecompileBase)?,
|
||||
None => self.charge_gas(call_type.cost())?,
|
||||
};
|
||||
|
||||
@@ -137,8 +137,9 @@ impl<'a, E: Ext, M: PolkaVmInstance<E::T>> Runtime<'a, E, M> {
|
||||
log::error!(target: LOG_TARGET, "polkavm execution error: {error}");
|
||||
Some(Err(Error::<E::T>::ExecutionFailed.into()))
|
||||
},
|
||||
Ok(Finished) =>
|
||||
Some(Ok(ExecReturnValue { flags: ReturnFlags::empty(), data: Vec::new() })),
|
||||
Ok(Finished) => {
|
||||
Some(Ok(ExecReturnValue { flags: ReturnFlags::empty(), data: Vec::new() }))
|
||||
},
|
||||
Ok(Trap) => Some(Err(Error::<E::T>::ContractTrapped.into())),
|
||||
Ok(Segfault(_)) => Some(Err(Error::<E::T>::ExecutionFailed.into())),
|
||||
Ok(NotEnoughGas) => Some(Err(Error::<E::T>::OutOfGas.into())),
|
||||
@@ -163,11 +164,12 @@ impl<'a, E: Ext, M: PolkaVmInstance<E::T>> Runtime<'a, E, M> {
|
||||
instance.write_output(return_value);
|
||||
None
|
||||
},
|
||||
Err(TrapReason::Return(ReturnData { flags, data })) =>
|
||||
Err(TrapReason::Return(ReturnData { flags, data })) => {
|
||||
match ReturnFlags::from_bits(flags) {
|
||||
None => Some(Err(Error::<E::T>::InvalidCallFlags.into())),
|
||||
Some(flags) => Some(Ok(ExecReturnValue { flags, data })),
|
||||
},
|
||||
}
|
||||
},
|
||||
Err(TrapReason::Termination) => Some(Ok(Default::default())),
|
||||
Err(TrapReason::SupervisorError(error)) => Some(Err(error.into())),
|
||||
}
|
||||
|
||||
@@ -309,18 +309,20 @@ impl<T: Config> Token<T> for RuntimeCosts {
|
||||
cost_args!(seal_call, 1, dust_transfer.into(), 0)
|
||||
},
|
||||
CallInputCloned(len) => cost_args!(seal_call, 0, 0, len),
|
||||
Instantiate { input_data_len, balance_transfer, dust_transfer } =>
|
||||
Instantiate { input_data_len, balance_transfer, dust_transfer } => {
|
||||
T::WeightInfo::seal_instantiate(
|
||||
balance_transfer.into(),
|
||||
dust_transfer.into(),
|
||||
input_data_len,
|
||||
),
|
||||
Create { init_code_len, balance_transfer, dust_transfer } =>
|
||||
)
|
||||
},
|
||||
Create { init_code_len, balance_transfer, dust_transfer } => {
|
||||
T::WeightInfo::evm_instantiate(
|
||||
balance_transfer.into(),
|
||||
dust_transfer.into(),
|
||||
init_code_len,
|
||||
),
|
||||
)
|
||||
},
|
||||
HashSha256(len) => T::WeightInfo::sha2_256(len),
|
||||
Ripemd160(len) => T::WeightInfo::ripemd_160(len),
|
||||
HashKeccak256(len) => T::WeightInfo::seal_hash_keccak_256(len),
|
||||
@@ -330,8 +332,9 @@ impl<T: Config> Token<T> for RuntimeCosts {
|
||||
P256Verify => T::WeightInfo::p256_verify(),
|
||||
Sr25519Verify(len) => T::WeightInfo::seal_sr25519_verify(len),
|
||||
Precompile(weight) => weight,
|
||||
SetCodeHash { old_code_removed } =>
|
||||
T::WeightInfo::seal_set_code_hash(old_code_removed.into()),
|
||||
SetCodeHash { old_code_removed } => {
|
||||
T::WeightInfo::seal_set_code_hash(old_code_removed.into())
|
||||
},
|
||||
EcdsaToEthAddress => T::WeightInfo::seal_ecdsa_to_eth_address(),
|
||||
GetImmutableData(len) => T::WeightInfo::seal_get_immutable_data(len),
|
||||
SetImmutableData(len) => T::WeightInfo::seal_set_immutable_data(len),
|
||||
|
||||
Reference in New Issue
Block a user