Skip to content

Commit

Permalink
make evm call and estimateResources public (#1649)
Browse files Browse the repository at this point in the history
* make evm call and estimateResources public

* fix

* bump

* update bootnode

* fix test
  • Loading branch information
xlc authored Nov 28, 2021
1 parent 82d54ff commit a2e2e25
Show file tree
Hide file tree
Showing 59 changed files with 127 additions and 121 deletions.
100 changes: 50 additions & 50 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ecosystem-modules/compound-cash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ecosystem-compound-cash"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion ecosystem-modules/ren/renvm-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ecosystem-renvm-bridge"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion ecosystem-modules/starport/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ecosystem-starport"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion inspect/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "acala-inspect"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-asset-registry"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/auction-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-auction-manager"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/cdp-engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-cdp-engine"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/cdp-treasury/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-cdp-treasury"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/collator-selection/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'module-collator-selection'
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/currencies/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-currencies"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/dex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-dex"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/emergency-shutdown/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-emergency-shutdown"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm-accounts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-accounts"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-bridge"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm-utiltity/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-utiltity"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm-utiltity/macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-utiltity-macro"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "evm-rpc"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/evm/rpc/runtime_api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-evm-rpc-runtime-api"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
21 changes: 11 additions & 10 deletions modules/evm/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ fn decode_revert_message(data: &[u8]) -> Option<String> {

pub struct EVMApi<B, C, Balance> {
client: Arc<C>,
deny_unsafe: DenyUnsafe,
_deny_unsafe: DenyUnsafe,
_marker: PhantomData<(B, Balance)>,
}

impl<B, C, Balance> EVMApi<B, C, Balance> {
pub fn new(client: Arc<C>, deny_unsafe: DenyUnsafe) -> Self {
pub fn new(client: Arc<C>, _deny_unsafe: DenyUnsafe) -> Self {
Self {
client,
deny_unsafe,
_deny_unsafe,
_marker: Default::default(),
}
}
Expand All @@ -126,6 +126,11 @@ fn to_u128(val: NumberOrHex) -> std::result::Result<u128, ()> {
val.into_u256().try_into().map_err(|_| ())
}

// 20M. TODO: use value from runtime
const MAX_GAS_LIMIT: u64 = 20_000_000;
// 4M. TODO: use value from runtime
const MAX_STROAGE_LIMIT: u32 = 4 * 1024 * 1024;

impl<B, C, Balance> EVMApiT<<B as BlockT>::Hash> for EVMApi<B, C, Balance>
where
B: BlockT,
Expand All @@ -135,8 +140,6 @@ where
Balance: Codec + MaybeDisplay + MaybeFromStr + Default + Send + Sync + 'static + TryFrom<u128> + Into<U256>,
{
fn call(&self, request: CallRequest, at: Option<<B as BlockT>::Hash>) -> Result<Bytes> {
self.deny_unsafe.check_if_safe()?;

let hash = at.unwrap_or_else(|| self.client.info().best_hash);

let CallRequest {
Expand All @@ -148,8 +151,8 @@ where
data,
} = request;

let gas_limit = gas_limit.unwrap_or_else(u64::max_value); // TODO: set a limit
let storage_limit = storage_limit.unwrap_or_else(u32::max_value); // TODO: set a limit
let gas_limit = gas_limit.unwrap_or(MAX_GAS_LIMIT);
let storage_limit = storage_limit.unwrap_or(MAX_STROAGE_LIMIT);
let data = data.map(|d| d.0).unwrap_or_default();

let api = self.client.runtime_api();
Expand Down Expand Up @@ -205,8 +208,6 @@ where
unsigned_extrinsic: Bytes,
at: Option<<B as BlockT>::Hash>,
) -> Result<EstimateResourcesResponse> {
self.deny_unsafe.check_if_safe()?;

let hash = at.unwrap_or_else(|| self.client.info().best_hash);
let request = self
.client
Expand All @@ -216,7 +217,7 @@ where
.map_err(|err| internal_err(format!("execution fatal: {:?}", err)))?;

// Determine the highest possible gas limits
let max_gas_limit = u64::max_value(); // TODO: set a limit
let max_gas_limit = MAX_GAS_LIMIT;
let mut highest = U256::from(request.gas_limit.unwrap_or(max_gas_limit));

let request = CallRequest {
Expand Down
2 changes: 1 addition & 1 deletion modules/example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-example"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/homa-lite/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-homa-lite"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/homa-validator-list/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-homa-validator-list"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/homa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-homa"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/honzon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-honzon"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/idle-scheduler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-idle-scheduler"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/incentives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-incentives"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/loans/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-loans"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/nft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-nft"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/nominees-election/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-nominees-election"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/polkadot-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-polkadot-bridge"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/prices/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-prices"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/relaychain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-relaychain"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/session-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-session-manager"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/staking-pool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-staking-pool"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/staking-pool/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-staking-pool-rpc"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/staking-pool/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-staking-pool-rpc-runtime-api"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/support/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-support"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/transaction-pause/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-transaction-pause"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion modules/transaction-payment/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "module-transaction-payment"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "acala"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"
default-run = "acala"
Expand Down
2 changes: 1 addition & 1 deletion node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "acala-cli"
version = "2.0.2"
version = "2.0.3"
authors = ["Acala Developers"]
edition = "2018"

Expand Down
Loading

0 comments on commit a2e2e25

Please sign in to comment.