So it's often seen in Precompile implementations as a trait bound :

impl<T: LinearCostPrecompile> Precompile for T {

and the trait itself :

pub trait LinearCostPrecompile {
    const BASE: u64;
    const WORD: u64;

    fn execute(
        input: &[u8],
        cost: u64,
    ) -> core::result::Result<(ExitSucceed, Vec<u8>), PrecompileFailure>;

Can someone explain the why and what of this trait?

  • Putting this as a comment because I'm not that sure about the answer but I think the idea of that trait is to tell that a precompile has a simple (linear) way to calculate its final cost (inside the EVM). Aug 3, 2023 at 12:12


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.