Skip to content
Snippets Groups Projects
  1. Mar 06, 2025
  2. Mar 05, 2025
    • Oliver Tale-Yazdi's avatar
      pallet revive: rpc build script should not panic (#7786) · 9100d249
      Oliver Tale-Yazdi authored
      
      This can error when you use `cargo remote` and probably also with `cargo
      vendor`.
      Still seeing two more build errors, but at least this one is fixed.
      
      Other one:
      ```pre
      error: set `DATABASE_URL` to use query macros online, or run `cargo sqlx prepare` to update the query cache
         --> substrate/frame/revive/rpc/src/receipt_provider/db.rs:123:17
          |
      123 |               let result = query!(
          |  __________________________^
      124 | |                 r#"
      125 | |                 INSERT OR REPLACE INTO transaction_hashes (transaction_hash, block_hash, transaction_index)
      126 | |                 VALUES ($1, $2, $3)
      ...   |
      130 | |                 transaction_index
      131 | |             )
      ```
      
      and (maybe Rust version related, this is 1.84.1)
      ```pre
      error[E0282]: type annotations needed
         --> substrate/frame/revive/rpc/src/receipt_provider/db.rs:102:34
          |
      102 |         let (tx_result, logs_result) = tokio::join!(delete_transaction_hashes, delete_logs);
          |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
          |
          = note: this error originates in the macro `$crate::join` which comes from the expansion of the macro `tokio::join` (in Nightly builds, run with -Z macro-backtrace for more info)
      ```
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
  3. Mar 04, 2025
  4. Mar 03, 2025
    • Alexander Theißen's avatar
      revive: Rework the instruction benchmark (#7721) · 4b39ff00
      Alexander Theißen authored
      
      Fixes https://github.com/paritytech/polkadot-sdk/issues/6157
      
      This fixes the last remaining benchmark that was not correct since it
      was too low level to be written in Rust. Instead, we opted.
      
      This PR changes the benchmark that determines the scaling from
      `ref_time` to PolkaVM `Gas` by benchmarking the absolute worst case of
      an instruction: One that causes two cache misses by touching two cache
      lines.
      
      The Contract itself is designed to be as simple as possible. It does
      random unaligned reads in a loop until the `r` (repetition) number is
      reached. The randomness is fully generated by the host and written to
      the guests memory before the benchmark is run. This allows the benchmark
      to determine the influence of one loop iteration via linear regression.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarxermicus <cyrill@parity.io>
      Co-authored-by: default avatarPG Herveou <pgherveou@gmail.com>
  5. Feb 28, 2025
    • Alexander Theißen's avatar
      pallet_revive: Change address derivation to use hashing (#7662) · 4087e2d9
      Alexander Theißen authored
      
      Fixes https://github.com/paritytech/polkadot-sdk/issues/6723
      
      ## Motivation
      
      Internal auditors recommended to not truncate Polkadot Addresses when
      deriving Ethereum addresses from it. Reasoning is that they are raw
      public keys where truncating could lead to collisions when weaknesses in
      those curves are discovered in the future. Additionally, some pallets
      generate account addresses in a way where only the suffix we were
      truncating contains any entropy. The changes in this PR act as a safe
      guard against those two points.
      
      ## Changes made
      
      We change the `to_address` function to first hash the AccountId32 and
      then use trailing 20 bytes as `AccountId20`. If the `AccountId32` ends
      with 12x 0xEE we keep our current behaviour of just truncating those
      trailing bytes.
      
      ## Security Discussion
      
      This will allow us to still recover the original `AccountId20` because
      those are constructed by just adding those 12 bytes. Please note that
      generating an ed25519 key pair where the trailing 12 bytes are 0xEE is
      theoretically possible as 96bits is not a huge search space. However,
      this cannot be used as an attack vector. It will merely allow this
      address to interact with `pallet_revive` without registering as the
      fallback account is the same as the actual address. The ultimate vanity
      address. In practice, this is not relevant since the 0xEE addresses are
      not valid public keys for sr25519 which is used almost everywhere.
      
      tl:dr: We keep truncating in case of an Ethereum address derived account
      id. This is safe as those are already derived via keccak. In every other
      case where we have to assume that the account id might be a public key.
      Therefore we first hash and then take the trailing bytes.
      
      ## Do we need a Migration for Westend
      
      No. We changed the name of the mapping. This means the runtime will not
      try to read the old data. Ethereum keys are unaffected by this change.
      We just advise people to re-register their AccountId32 in case they need
      to use it as it is a very small circle of users (just 3 addresses
      registered). This will not cause disturbance on Westend.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • Serban Iorga's avatar
      Derive `DecodeWithMemTracking` for `Block` (#7655) · c11b1f85
      Serban Iorga authored
      Related to https://github.com/paritytech/polkadot-sdk/issues/7360
      
      This PR adds `DecodeWithMemTracking` as a trait bound for `Header`,
      `Block` and `TransactionExtension` and
      derives it for all the types that implement these traits in
      `polkadot-sdk`.
  6. Feb 26, 2025
  7. Feb 24, 2025
  8. Feb 21, 2025
  9. Feb 20, 2025
    • PG Herveou's avatar
      [pallet-revive] tracing improvements (#7614) · 9e75647c
      PG Herveou authored
      
      Various pallet-revive improvements
      
      - add check for precompiles addresses,
      So we can easily identify which one are being called and not supported
      yet
      
      - fixes debug_call for revert call
      If a call revert we still want to get the traces for that call, that
      matches geth behaviors, diff tests will be added to the test suite for
      this
      
      - fixes traces for staticcall
      The call type was not always being reported properly.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarAlexander Theißen <alex.theissen@me.com>
    • Alexander Theißen's avatar
      Update to Rust stable 1.84.1 (#7625) · e2d3da61
      Alexander Theißen authored
      Ref https://github.com/paritytech/ci_cd/issues/1107
      
      We mainly need that so that we can finally compile the `pallet_revive`
      fixtures on stable. I did my best to keep the commits focused on one
      thing to make review easier.
      
      All the changes are needed because rustc introduced more warnings or is
      more strict about existing ones. Most of the stuff could just be fixed
      and the commits should be pretty self explanatory. However, there are a
      few this that are notable:
      
      ## `non_local_definitions `
      
      A lot of runtimes to write `impl` blocks inside functions. This makes
      sense to reduce the amount of conditional compilation. I guess I could
      have moved them into a module instead. But I think allowing it here
      makes sense to avoid the code churn.
      
      ## `unexpected_cfgs`
      
      The FRAME macros emit code that references various features like `std`,
      `runtime-benchmarks` or `try-runtime`. If a create that uses those
      macros does not have those features we get this warning. Those were
      mostly when ...
    • Francisco Aguirre's avatar
      Update dispatchables doc link in pallet-revive's README (#7624) · f2414398
      Francisco Aguirre authored
      Pallet-revive's README has an outdated link for dispatchables
      documentation in its README. It was giving 404. Put the up-to-date one.
  10. Feb 18, 2025
  11. Feb 17, 2025
  12. Feb 14, 2025
  13. Feb 12, 2025
  14. Feb 10, 2025
  15. Feb 08, 2025
  16. Feb 07, 2025
  17. Feb 06, 2025
    • PG Herveou's avatar
      [pallet-revive] tx fee fixes (#7463) · 917052e5
      PG Herveou authored
      
      Apply some fixes to properly estimate ethereum tx fees:
      
      - Set the `extension_weight` on the dispatch_info to properly calculate
      the fee with pallet_transaction_payment
      - Expose the gas_price through Runtime API, just in case we decide to
      tweak the value in future updates, it should be read from the chain
      rather than be a shared constant exposed by the crate
      - add a `evm_gas_to_fee` utility function to properly convert gas to
      substrate fee
      - Fix some minor gas encoding for edge cases
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  18. Feb 04, 2025
    • Alexander Theißen's avatar
      revive: Include immutable storage deposit into the contracts `storage_base_deposit` (#7230) · 4c28354b
      Alexander Theißen authored
      
      This PR is centered around a main fix regarding the base deposit and a
      bunch of drive by or related fixtures that make sense to resolve in one
      go. It could be broken down more but I am constantly rebasing this PR
      and would appreciate getting those fixes in as-one.
      
      **This adds a multi block migration to Westend AssetHub that wipes the
      pallet state clean. This is necessary because of the changes to the
      `ContractInfo` storage item. It will not delete the child storage
      though. This will leave a tiny bit of garbage behind but won't cause any
      problems. They will just be orphaned.**
      
      ## Record the deposit for immutable data into the `storage_base_deposit`
      
      The `storage_base_deposit` are all the deposit a contract has to pay for
      existing. It included the deposit for its own metadata and a deposit
      proportional (< 1.0x) to the size of its code. However, the immutable
      code size was not recorded there. This would lead to the situation where
      on terminate this portion wouldn't be refunded staying locked into the
      contract. It would also make the calculation of the deposit changes on
      `set_code_hash` more complicated when it updates the immutable data (to
      be done in #6985). Reason is because it didn't know how much was payed
      before since the storage prices could have changed in the mean time.
      
      In order for this solution to work I needed to delay the deposit
      calculation for a new contract for after the contract is done executing
      is constructor as only then we know the immutable data size. Before, we
      just charged this eagerly in `charge_instantiate` before we execute the
      constructor. Now, we merely send the ED as free balance before the
      constructor in order to create the account. After the constructor is
      done we calculate the contract base deposit and charge it. This will
      make `set_code_hash` much easier to implement.
      
      As a side effect it is now legal to call `set_immutable_data` multiple
      times per constructor (even though I see no reason to do so). It simply
      overrides the immutable data with the new value. The deposit accounting
      will be done after the constructor returns (as mentioned above) instead
      of when setting the immutable data.
      
      ## Don't pre-charge for reading immutable data
      
      I noticed that we were pre-charging weight for the max allowable
      immutable data when reading those values and then refunding after read.
      This is not necessary as we know its length without reading the storage
      as we store it out of band in contract metadata. This makes reading it
      free. Less pre-charging less problems.
      
      ## Remove delegate locking
      
      Fixes #7092
      
      This is also in the spirit of making #6985 easier to implement. The
      locking complicates `set_code_hash` as we might need to block settings
      the code hash when locks exist. Check #7092 for further rationale.
      
      ## Enforce "no terminate in constructor" eagerly
      
      We used to enforce this rule after the contract execution returned. Now
      we error out early in the host call. This makes it easier to be sure to
      argue that a contract info still exists (wasn't terminated) when a
      constructor successfully returns. All around this his just much simpler
      than dealing this check.
      
      ## Moved refcount functions to `CodeInfo`
      
      They never really made sense to exist on `Stack`. But now with the
      locking gone this makes even less sense. The refcount is stored inside
      `CodeInfo` to lets just move them there.
      
      ## Set `CodeHashLockupDepositPercent` for test runtime
      
      The test runtime was setting `CodeHashLockupDepositPercent` to zero.
      This was trivializing many code paths and excluded them from testing. I
      set it to `30%` which is our default value and fixed up all the tests
      that broke. This should give us confidence that the lockup doeposit
      collections properly works.
      
      ## Reworked the `MockExecutable` to have both a `deploy` and a `call`
      entry point
      
      This type used for testing could only have either entry points but not
      both. In order to fix the `immutable_data_set_overrides` I needed to a
      new function `add_both` to `MockExecutable` that allows to have both
      entry points. Make sure to make use of it in the future :)
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarPG Herveou <pgherveou@gmail.com>
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  19. Feb 03, 2025
  20. Jan 29, 2025
  21. Jan 28, 2025
  22. Jan 24, 2025
  23. Jan 23, 2025
    • runcomet's avatar
      Balances: Configurable Number of Genesis Accounts with Specified Balances for Benchmarking (#6267) · 04847d51
      runcomet authored
      
      # Derived Dev Accounts
      
      Resolves https://github.com/paritytech/polkadot-sdk/issues/6040
      
      ## Description
      This update introduces support for creating an arbitrary number of
      developer accounts at the genesis block based on a specified derivation
      path. This functionality is gated by the runtime-benchmarks feature,
      ensuring it is only enabled during benchmarking scenarios.
      
      ### Key Features
      - Arbitrary Dev Accounts at Genesis: Developers can now specify any
      number of accounts to be generated at genesis using a hard derivation
      path.
      
      - Default Derivation Path: If no derivation path is provided (i.e., when
      `Option<dev_accounts: (..., None)>` is set to `Some` at genesis), the
      system will default to the path `//Sender//{}`.
      
      - No Impact on Total Token Issuance: Developer accounts are excluded
      from the total issuance of the token supply at genesis, ensuring they do
      not affect the overall balance or token distribution.
      
      polkadot address: 14SRqZTC1d8rfxL8W1tBTnfUBPU23ACFVPzp61FyGf4ftUFg
      
      ---------
      
      Co-authored-by: default avatarSebastian Kunert <skunert49@gmail.com>
    • PG Herveou's avatar
      [pallet-revive] fee estimation fixes (#7281) · 5772b9db
      PG Herveou authored
      - Fix the EVM fee cost estimation.
      The estimation shown in EVM wallet was using Native instead of EVM
      decimals
      - Remove the precise code length estimation in dry run call.
      Over-estimating is fine, since extra gas is refunded anyway.
      - Ensure that the estimated fee calculated from gas_price x gas use the
      encoded weight & deposit limit instead of the exact one calculated by
      the dry-run. Else we can end up with a fee that is lower than the actual
      fee paid by the user
      
      ---------
      
      Co-authored-by: command-bot <>
  24. Jan 20, 2025
  25. Jan 17, 2025