Skip to content

Commit fef22a3

Browse files
chore: remove revive dependencies from ink_e2e (#2657)
* feat: ink_revive crate * refactor: remove revive references from e2e crate * chore: format * chore: format in tests * docs: licenses in ink_revive files * refactor: move pallet_revive deps into ink_sandbox * refactor: rename ink_revive to ink_revive_types * docs: description and version in ink_revive_types * refactor: remove some unnecesary dependencies * Update changelog --------- Co-authored-by: davidsemakula <hello@davidsemakula.com>
1 parent 18ad7d7 commit fef22a3

File tree

22 files changed

+825
-44
lines changed

22 files changed

+825
-44
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Implements the API for the `pallet-revive` host function `to_account_id` - [#2578](https://github.com/use-ink/ink/pull/2578)
1111
- Add `#[ink::contract_ref]` attribute - [#2648](https://github.com/use-ink/ink/pull/2648)
12+
- Add `ink_revive_types` (and remove `pallet-revive` dependency from `ink_e2e`) - [#2657](https://github.com/use-ink/ink/pull/2657)
1213

1314
### Changed
1415
- Marks the `pallet-revive` host function `account_id` stable - [#2578](https://github.com/use-ink/ink/pull/2578)

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ members = [
1212
"crates/ink/ir",
1313
"crates/ink/macro",
1414
"crates/metadata",
15+
"crates/revive-types",
1516
"crates/prelude",
1617
"crates/primitives",
1718
"crates/storage",
@@ -104,6 +105,7 @@ xcm = { package = "staging-xcm", git = "https://github.com/use-ink/polkadot-sdk.
104105
polkavm-derive = { version = "0.26.0", default-features = false }
105106

106107
# Solidity dependencies
108+
alloy-core = { version = "1.1.0", default-features = false }
107109
alloy-sol-types = { version = "1.3.0", default-features = false }
108110
const_format = { version = "0.2.34", features = ["fmt"] }
109111
keccak-const = "0.2.0"
@@ -121,6 +123,7 @@ ink_macro = { version = "=6.0.0-alpha.4", path = "crates/ink/macro", default-fea
121123
ink_metadata = { version = "=6.0.0-alpha.4", path = "crates/metadata", default-features = false }
122124
ink_prelude = { version = "=6.0.0-alpha.4", path = "crates/prelude", default-features = false }
123125
ink_primitives = { version = "=6.0.0-alpha.4", path = "crates/primitives", default-features = false }
126+
ink_revive_types = { version = "=6.0.0-alpha.4", path = "crates/revive-types", default-features = false }
124127
ink_storage = { version = "=6.0.0-alpha.4", path = "crates/storage", default-features = false }
125128
ink_storage_traits = { version = "=6.0.0-alpha.4", path = "crates/storage/traits", default-features = false }
126129

crates/e2e/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ ink_e2e_macro = { workspace = true, default-features = true }
1919
ink = { workspace = true, default-features = true }
2020
ink_env = { workspace = true, default-features = true }
2121
ink_primitives = { workspace = true, default-features = true }
22+
ink_revive_types = { workspace = true, default-features = true }
2223
ink_sandbox = { version = "=6.0.0-alpha.4", path = "./sandbox", optional = true }
2324

2425
cargo_metadata = { workspace = true }
2526
contract-build = { workspace = true }
26-
pallet-revive = { workspace = true }
2727
funty = { workspace = true }
2828
impl-serde = { workspace = true }
2929
jsonrpsee = { workspace = true, features = ["ws-client"] }
@@ -61,7 +61,6 @@ default = [ "std" ]
6161
std = [
6262
"impl-serde/std",
6363
"ink_e2e_macro/std",
64-
"pallet-revive/std",
6564
"scale-info/std",
6665
"scale/std",
6766
"serde/std",
@@ -72,6 +71,7 @@ std = [
7271
"sp-runtime-interface/std",
7372
"sp-weights/std",
7473
"ink_e2e_macro/std",
74+
"ink_revive_types/std",
7575
"ink_sandbox?/std",
7676
"frame-support/std",
7777
]

crates/e2e/sandbox/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ sp-externalities = { workspace = true }
2323
sp-runtime = { workspace = true }
2424
sp-io = { workspace = true }
2525
ink_primitives = { workspace = true }
26+
ink_revive_types = { workspace = true }
2627

2728
paste = { workspace = true }
2829
scale-info = { workspace = true }
@@ -37,6 +38,7 @@ std = [
3738
"frame-system/std",
3839
"frame-metadata/std",
3940
"ink_primitives/std",
41+
"ink_revive_types/std",
4042
"pallet-balances/std",
4143
"pallet-revive/std",
4244
"pallet-timestamp/std",

crates/e2e/sandbox/src/lib.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ use frame_system::{
1717
},
1818
};
1919
use ink_primitives::U256;
20+
use ink_revive_types::evm::{
21+
CallLog,
22+
CallTrace,
23+
};
2024
pub use macros::{
2125
BlockBuilder,
2226
DefaultSandbox,
@@ -170,3 +174,64 @@ where
170174
let evm_value: U256 = value.into();
171175
native_to_eth_ratio.saturating_mul(evm_value)
172176
}
177+
178+
/// Convert a `pallet_revive::CallTrace` (sandbox) into an `ink_revive_types::CallTrace`
179+
/// (API).
180+
pub fn to_revive_trace(t: pallet_revive::evm::CallTrace) -> CallTrace {
181+
CallTrace {
182+
from: t.from,
183+
gas: t.gas,
184+
gas_used: t.gas_used,
185+
to: t.to,
186+
input: t.input.0,
187+
output: t.output.0,
188+
error: t.error,
189+
revert_reason: t.revert_reason,
190+
calls: t.calls.into_iter().map(to_revive_trace).collect(),
191+
logs: t
192+
.logs
193+
.into_iter()
194+
.map(|log| {
195+
CallLog {
196+
address: log.address,
197+
topics: log.topics,
198+
data: log.data.0,
199+
..Default::default()
200+
}
201+
})
202+
.collect(),
203+
value: t.value,
204+
call_type: to_revive_call_type(t.call_type),
205+
}
206+
}
207+
208+
/// Convert a `pallet_revive::CallType` into an `ink_revive_types::evm::CallType`.
209+
fn to_revive_call_type(
210+
ct: pallet_revive::evm::CallType,
211+
) -> ink_revive_types::evm::CallType {
212+
match ct {
213+
pallet_revive::evm::CallType::Call => ink_revive_types::evm::CallType::Call,
214+
pallet_revive::evm::CallType::StaticCall => {
215+
ink_revive_types::evm::CallType::StaticCall
216+
}
217+
pallet_revive::evm::CallType::DelegateCall => {
218+
ink_revive_types::evm::CallType::DelegateCall
219+
}
220+
pallet_revive::evm::CallType::Create => ink_revive_types::evm::CallType::Create,
221+
pallet_revive::evm::CallType::Create2 => ink_revive_types::evm::CallType::Create2,
222+
}
223+
}
224+
225+
/// Convert a `pallet_revive::StorageDeposit` into an `ink_revive_types::StorageDeposit`.
226+
pub fn to_revive_storage_deposit<B>(
227+
sd: pallet_revive::StorageDeposit<B>,
228+
) -> ink_revive_types::StorageDeposit<B> {
229+
match sd {
230+
pallet_revive::StorageDeposit::Charge(b) => {
231+
ink_revive_types::StorageDeposit::Charge(b)
232+
}
233+
pallet_revive::StorageDeposit::Refund(b) => {
234+
ink_revive_types::StorageDeposit::Refund(b)
235+
}
236+
}
237+
}

crates/e2e/src/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use ink_primitives::{
2121
H160,
2222
abi::AbiEncodeWith,
2323
};
24+
use ink_revive_types::evm::CallTrace;
2425
use jsonrpsee::core::async_trait;
25-
use pallet_revive::evm::CallTrace;
2626
use sp_weights::Weight;
2727
use subxt::dynamic::Value;
2828

crates/e2e/src/contract_results.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use ink_primitives::{
3636
H256,
3737
MessageResult,
3838
};
39-
use pallet_revive::{
39+
use ink_revive_types::{
4040
CodeUploadResult,
4141
ExecReturnValue,
4242
InstantiateReturnValue,

crates/e2e/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use pallet_revive::evm::CallTrace;
15+
use ink_revive_types::evm::CallTrace;
1616
use std::fmt;
1717

1818
/// An error occurred while interacting with the E2E backend.

crates/e2e/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ pub use contract_results::{
5353
UploadResult,
5454
};
5555
pub use ink_e2e_macro::test;
56+
pub use ink_revive_types::evm::CallTrace;
5657
pub use node_proc::{
5758
TestNodeProcess,
5859
TestNodeProcessBuilder,
5960
};
60-
pub use pallet_revive::evm::CallTrace;
6161
#[cfg(feature = "sandbox")]
6262
pub use sandbox_client::{
6363
Client as SandboxClient,

0 commit comments

Comments
 (0)