gpt4 book ai didi

rust - `paint_evm::Event` 未针对 `Event` 实现

转载 作者:行者123 更新时间:2023-11-29 08:17:24 25 4
gpt4 key购买 nike

遵循 adding a module to your runtime ,我正在尝试实现 Parity Substrate Dothereum Runtimepaint-evm 特征。

根据我之前的工作:How to implement the EVM Trait for a Substrate Runtime?

我为 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 = ();
}

但是,Event 并未实现 paint_evm::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 模块在这里期望什么。这可以用什么来代替呢?

最佳答案

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

您需要添加这一行给您construct_runtime!定义:

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

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

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

添加此行后,您将克服此处显示的错误,并找到与配置的其他部分相关的任何真实错误。

关于rust - `paint_evm::Event` 未针对 `Event` 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58972350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com