mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 09:47:56 +00:00
contracts: Remove state rent (#9669)
* Remove storage rent * Add storage migration * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Add migration for deletetion queue * Fix compilation * Increase gas supplied to out_of_gas to be sure that it won't deplete too early * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
committed by
GitHub
parent
13f3e25ebb
commit
522e77e243
@@ -22,9 +22,7 @@ use std::sync::Arc;
|
||||
use codec::Codec;
|
||||
use jsonrpc_core::{Error, ErrorCode, Result};
|
||||
use jsonrpc_derive::rpc;
|
||||
use pallet_contracts_primitives::{
|
||||
Code, ContractExecResult, ContractInstantiateResult, RentProjection,
|
||||
};
|
||||
use pallet_contracts_primitives::{Code, ContractExecResult, ContractInstantiateResult};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
@@ -40,7 +38,6 @@ pub use pallet_contracts_rpc_runtime_api::ContractsApi as ContractsRuntimeApi;
|
||||
|
||||
const RUNTIME_ERROR: i64 = 1;
|
||||
const CONTRACT_DOESNT_EXIST: i64 = 2;
|
||||
const CONTRACT_IS_A_TOMBSTONE: i64 = 3;
|
||||
|
||||
pub type Weight = u64;
|
||||
|
||||
@@ -69,11 +66,6 @@ impl From<ContractAccessError> for Error {
|
||||
message: "The specified contract doesn't exist.".into(),
|
||||
data: None,
|
||||
},
|
||||
IsTombstone => Error {
|
||||
code: ErrorCode::ServerError(CONTRACT_IS_A_TOMBSTONE),
|
||||
message: "The contract is a tombstone and doesn't have any storage.".into(),
|
||||
data: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +122,7 @@ pub trait ContractsApi<BlockHash, BlockNumber, AccountId, Balance, Hash> {
|
||||
&self,
|
||||
instantiate_request: InstantiateRequest<AccountId, Hash>,
|
||||
at: Option<BlockHash>,
|
||||
) -> Result<ContractInstantiateResult<AccountId, BlockNumber>>;
|
||||
) -> Result<ContractInstantiateResult<AccountId>>;
|
||||
|
||||
/// Returns the value under a specified storage `key` in a contract given by `address` param,
|
||||
/// or `None` if it is not set.
|
||||
@@ -141,19 +133,6 @@ pub trait ContractsApi<BlockHash, BlockNumber, AccountId, Balance, Hash> {
|
||||
key: H256,
|
||||
at: Option<BlockHash>,
|
||||
) -> Result<Option<Bytes>>;
|
||||
|
||||
/// Returns the projected time a given contract will be able to sustain paying its rent.
|
||||
///
|
||||
/// The returned projection is relevant for the given block, i.e. it is as if the contract was
|
||||
/// accessed at the beginning of that block.
|
||||
///
|
||||
/// Returns `None` if the contract is exempted from rent.
|
||||
#[rpc(name = "contracts_rentProjection")]
|
||||
fn rent_projection(
|
||||
&self,
|
||||
address: AccountId,
|
||||
at: Option<BlockHash>,
|
||||
) -> Result<Option<BlockNumber>>;
|
||||
}
|
||||
|
||||
/// An implementation of contract specific RPC methods.
|
||||
@@ -217,8 +196,7 @@ where
|
||||
&self,
|
||||
instantiate_request: InstantiateRequest<AccountId, Hash>,
|
||||
at: Option<<Block as BlockT>::Hash>,
|
||||
) -> Result<ContractInstantiateResult<AccountId, <<Block as BlockT>::Header as HeaderT>::Number>>
|
||||
{
|
||||
) -> Result<ContractInstantiateResult<AccountId>> {
|
||||
let api = self.client.runtime_api();
|
||||
let at = BlockId::hash(at.unwrap_or_else(||
|
||||
// If the block hash is not supplied assume the best block.
|
||||
@@ -257,27 +235,6 @@ where
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn rent_projection(
|
||||
&self,
|
||||
address: AccountId,
|
||||
at: Option<<Block as BlockT>::Hash>,
|
||||
) -> Result<Option<<<Block as BlockT>::Header as HeaderT>::Number>> {
|
||||
let api = self.client.runtime_api();
|
||||
let at = BlockId::hash(at.unwrap_or_else(||
|
||||
// If the block hash is not supplied assume the best block.
|
||||
self.client.info().best_hash));
|
||||
|
||||
let result = api
|
||||
.rent_projection(&at, address)
|
||||
.map_err(runtime_error_into_rpc_err)?
|
||||
.map_err(ContractAccessError)?;
|
||||
|
||||
Ok(match result {
|
||||
RentProjection::NoEviction => None,
|
||||
RentProjection::EvictionAt(block_num) => Some(block_num),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts a runtime trap into an RPC error.
|
||||
@@ -404,8 +361,7 @@ mod tests {
|
||||
#[test]
|
||||
fn instantiate_result_should_serialize_deserialize_properly() {
|
||||
fn test(expected: &str) {
|
||||
let res: ContractInstantiateResult<String, u64> =
|
||||
serde_json::from_str(expected).unwrap();
|
||||
let res: ContractInstantiateResult<String> = serde_json::from_str(expected).unwrap();
|
||||
let actual = serde_json::to_string(&res).unwrap();
|
||||
assert_eq!(actual, trim(expected).as_str());
|
||||
}
|
||||
@@ -420,8 +376,7 @@ mod tests {
|
||||
"flags": 5,
|
||||
"data": "0x1234"
|
||||
},
|
||||
"accountId": "5CiPP",
|
||||
"rentProjection": null
|
||||
"accountId": "5CiPP"
|
||||
}
|
||||
}
|
||||
}"#,
|
||||
|
||||
Reference in New Issue
Block a user