Skip to content

chore: update pallet-revive in e2e crate #2527

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
211 changes: 133 additions & 78 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ frame-system = { version = "40.1.0", default-features = false }
frame-support = { version = "40.1.0", default-features = false }
pallet-balances = { version = "41.1.0", default-features = false }
pallet-timestamp = { version = "39.0.0", default-features = false }
pallet-revive = { version = "0.5.0", default-features = false }
pallet-revive-mock-network = { version = "0.4.0", default-features = false }
pallet-revive = { version = "0.6.1", default-features = false }
pallet-revive-mock-network = { version = "0.5.0", default-features = false }
pallet-revive-uapi = { version = "0.4.0", default-features = false, features = ["unstable-hostfn"] }
sp-externalities = { version = "0.30.0", default-features = false }
sp-io = { version = "40.0.0", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-io = { version = "40.0.1", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-runtime-interface = { version = "29.0.1", default-features = false, features = ["disable_target_static_assertions"] }
sp-core = { version = "36.1.0", default-features = false }
sp-keyring = { version = "41.0.0", default-features = false }
sp-runtime = "41.1.0"
sp-weights = { version = "31.1.0", default-features = false }
xcm = { package = "staging-xcm", version = "16.1.0", default-features = false }
xcm = { version = "16.2.0", package = "staging-xcm", default-features = false }

# PolkaVM dependencies
polkavm-derive = { version = "0.22.0", default-features = false }
Expand Down
10 changes: 10 additions & 0 deletions crates/e2e/sandbox/src/api/revive_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ use ink_primitives::{
DepositLimit,
};
use pallet_revive::{
evm::{
Tracer,
TracerType,
},
Code,
CodeUploadResult,
};
Expand Down Expand Up @@ -133,6 +137,8 @@ pub trait ContractAPI {
gas_limit: Weight,
storage_deposit_limit: DepositLimit<BalanceOf<Self::T>>,
) -> ContractExecResultFor<Self::T>;

fn evm_tracer(&mut self, tracer_type: TracerType) -> Tracer;
}

impl<T> ContractAPI for T
Expand Down Expand Up @@ -240,6 +246,10 @@ where
)
})
}

fn evm_tracer(&mut self, tracer_type: TracerType) -> Tracer {
self.execute_with(|| pallet_revive::Pallet::<Self::T>::evm_tracer(tracer_type))
}
}

/// todo
Expand Down
33 changes: 18 additions & 15 deletions crates/e2e/src/sandbox_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ use jsonrpsee::core::async_trait;
use pallet_revive::{
evm::{
CallTrace,
TracerConfig,
CallTracerConfig,
Trace,
TracerType,
U256,
},
CodeUploadReturnValue,
Expand Down Expand Up @@ -264,12 +266,11 @@ where
// get the trace
let _ = self.sandbox.build_block();

let tracer_config = TracerConfig::CallTracer { with_logs: true };
let tracer_type = TracerType::CallTracer(Some(CallTracerConfig::default()));
let mut tracer = self.sandbox.evm_tracer(tracer_type);

let mut tracer =
tracer_config.build(pallet_revive::Pallet::<S::Runtime>::evm_gas_from_weight);
let mut code_hash: Option<H256> = None;
let result = pallet_revive::tracing::trace(&mut tracer, || {
let result = pallet_revive::tracing::trace(tracer.as_tracing(), || {
let code = self.contracts.load_code(contract_name);
code_hash = Some(H256(crate::client_utils::code_hash(&code[..])));
let data = constructor_exec_input(constructor.clone());
Expand All @@ -292,9 +293,10 @@ where
Ok(res) => res.addr,
};

let mut traces = tracer.collect_traces();
assert_eq!(traces.len(), 1);
let trace = traces.pop();
let trace = match tracer.collect_trace() {
Some(Trace::Call(call_trace)) => Some(call_trace),
_ => None,
};

Ok(BareInstantiationResult {
addr: addr_raw,
Expand Down Expand Up @@ -417,10 +419,10 @@ where
let exec_input = message.clone().params().exec_input().encode();

// todo
let tracer_config = TracerConfig::CallTracer { with_logs: true };
let mut tracer =
tracer_config.build(pallet_revive::Pallet::<S::Runtime>::evm_gas_from_weight);
let _result = pallet_revive::tracing::trace(&mut tracer, || {
let tracer_type = TracerType::CallTracer(Some(CallTracerConfig::default()));
let mut tracer = self.sandbox.evm_tracer(tracer_type);

let _result = pallet_revive::tracing::trace(tracer.as_tracing(), || {
self.sandbox
.call_contract(
addr,
Expand All @@ -433,9 +435,10 @@ where
.result
.map_err(|err| SandboxErr::new(format!("bare_call: {err:?}")))
})?;
let mut traces = tracer.collect_traces();
assert_eq!(traces.len(), 1);
let trace = traces.pop();
let trace = match tracer.collect_trace() {
Some(Trace::Call(call_trace)) => Some(call_trace),
_ => None,
};

Ok(((), trace))
}
Expand Down
18 changes: 13 additions & 5 deletions crates/e2e/src/xts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ use ink_primitives::{
use pallet_revive::{
evm::{
CallTrace,
TracerConfig,
CallTracerConfig,
Trace,
TracerType,
},
CodeUploadResult,
};
Expand Down Expand Up @@ -457,11 +459,11 @@ where
_ => panic!("pattern error"),
};

let tracer_config = TracerConfig::CallTracer { with_logs: true };
let tracer_type = TracerType::CallTracer(Some(CallTracerConfig::default()));
let func = "ReviveApi_trace_tx";

let params =
scale::Encode::encode(&((header, exts), tx_index.as_u32(), tracer_config));
scale::Encode::encode(&((header, exts), tx_index.as_u32(), tracer_type));

let bytes = self
.rpc
Expand All @@ -473,8 +475,14 @@ where
format!("{}", err).trim_start_matches("RPC error: ")
);
});
scale::Decode::decode(&mut bytes.as_ref())
.unwrap_or_else(|err| panic!("decoding `trace_tx` result failed: {err}"))

let trace: Option<Trace> = scale::Decode::decode(&mut bytes.as_ref())
.unwrap_or_else(|err| panic!("decoding `trace_tx` result failed: {err}"));
let call_trace = match trace {
Some(Trace::Call(trace)) => Some(trace),
_ => None,
};
call_trace
}

/// Return the hash of the *best* block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ publish = false
frame-support = { version = "40.1.0", default-features = false }
frame-system = { version = "40.1.0", default-features = false }
pallet-balances = { version = "41.1.0", default-features = false }
pallet-revive = { version = "0.5.0", default-features = false }
pallet-revive = { version = "0.6.1", default-features = false }
sp-runtime = { version = "41.1.0", default-features = false }
# todo
codec = { package = "parity-scale-codec", version = "3.7.4", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sha3 = { version = "0.10", default-features = false }
[dev-dependencies]
ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] }
ink_sandbox = { path = "../../../crates/e2e/sandbox" }
pallet-revive = { version = "0.5.0", default-features = false }
pallet-revive = { version = "0.6.1", default-features = false }
sha3 = { version = "0.10" }
other-contract-sol = { path = "other-contract-sol" }

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/solidity-abi/sol-encoding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ink = { path = "../../../crates/ink", default-features = false }
[dev-dependencies]
ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] }
ink_sandbox = { path = "../../../crates/e2e/sandbox" }
pallet-revive = { version = "0.5.0", default-features = false }
pallet-revive = { version = "0.6.1", default-features = false }
sha3 = { version = "0.10" }

[lib]
Expand Down
Loading