开发者问题收集

`paint_evm::Event` 没有为 `Event` 实现

2019-11-21
577

按照 向运行时添加模块 的步骤,我正在尝试为 Dothereum Runtime 实现 Dothereum Runtime 实现 Parity Substrate paint-evm 特性。

根据我之前的工作: 如何为 Substrate 运行时实现 EVM 特征?

我为 Dothereum 运行时实现了 EVM 特征:

// Implement the EVM Trait for the Dothereum Runtime.
impl evm::Trait for Runtime {
    type FeeCalculator = FixedGasPrice;
    type ConvertAccountId = TruncatedAccountId;
    type Currency = Balances;
    type Event = Event;
    type Precompiles = ();
}

但是, paint_evm::Event 特征未为 Event 实现:

error: failed to run custom build command for `dothereum-runtime v0.2.2 (/home/user/.opt/dothereum/runtime)`

Caused by:
  process didn't exit successfully: `/home/user/.opt/dothereum/target/debug/build/dothereum-runtime-54902422e823ba8e/build-script-build` (exit code: 1)
--- stdout
Executing build command: "rustup" "run" "nightly" "cargo" "build" "--target=wasm32-unknown-unknown" "--manifest-path=/home/user/.opt/dothereum/target/debug/wbuild/dothereum-runtime/Cargo.toml"

--- stderr
    Blocking waiting for file lock on package cache
   Compiling wasm-build-runner-impl v1.0.0 (/home/user/.opt/dothereum/target/debug/wbuild-runner/dothereum-runtime)
    Finished dev [unoptimized + debuginfo] target(s) in 1.62s
     Running `/home/user/.opt/dothereum/target/debug/wbuild-runner/dothereum-runtime/target/debug/wasm-build-runner-impl`
   Compiling dothereum-runtime v0.2.2 (/home/user/.opt/dothereum/runtime)
error[E0277]: the trait bound `Event: core::convert::From<paint_evm::Event>` is not satisfied
   --> /home/user/.opt/dothereum/runtime/src/lib.rs:255:2
    |
251 | impl evm::Trait for Runtime {
    | --------------------------- in this `impl` item
...
255 |     type Event = Event;
    |     ^^^^^^^^^^^^^^^^^^^ the trait `core::convert::From<paint_evm::Event>` is not implemented for `Event`
    |
    = help: the following implementations were found:
              <Event as core::convert::From<paint_balances::RawEvent<substrate_primitives::crypto::AccountId32, u128, paint_balances::DefaultInstance>>>
              <Event as core::convert::From<paint_grandpa::Event>>
              <Event as core::convert::From<paint_indices::RawEvent<substrate_primitives::crypto::AccountId32, u32>>>
              <Event as core::convert::From<paint_sudo::RawEvent<substrate_primitives::crypto::AccountId32>>>
              <Event as core::convert::From<paint_system::Event>>

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: could not compile `dothereum-runtime`.

To learn more, run the command again with --verbose.

paint_evm 模块在这里需要什么。如何替代?

2个回答

此处的错误具有误导性。真正的问题是您没有将 EVM 模块放入 construct_runtime! 宏中。

您需要将此行添加到 construct_runtime! 定义中:

EVM: evm::{Module, Call, Storage, Config, Event},

更详细地解释一下, construct_runtime! 宏将为每个 YOUR_MODULE 实现 core::convert::From<YOUR_MODULE::Event> 特征。由于您没有将模块包含在宏中,因此它不会生成特征实现,并且您会收到此处看到的错误。

这就是为什么您看到错误消息向您推荐所有其他已实现此特征的模块,仅仅是因为它们已包含在您的 construct_runtime! 中。

一旦您添加此行,您将解决此处显示的错误并找到与您配置的其他部分相关的任何 实际 错误。

Shawn Tabrizi
2019-11-22

如果你在这个文件结构中有一个托盘:

pallet-xyz
|-Cargo.toml
|-src
|--lib.rs
|--tight/mod.rs

在你的runtime/src/lib.rs中,你需要在“pallet_xyz”后添加“::tight”:

impl pallet_xyz::tight::Config for Runtime {
    type RuntimeEvent = RuntimeEvent;
}
construct_runtime!(
   ...
    PalletXyz: pallet_xyz::tight,
)
Russo
2023-03-13