Skip to content

Commit

Permalink
Merge branch 'master' into cl/pallet-sessions-bench-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi authored Nov 29, 2024
2 parents 26ef444 + 1d519a1 commit 9aa51eb
Show file tree
Hide file tree
Showing 41 changed files with 1,471 additions and 1,062 deletions.
1 change: 0 additions & 1 deletion .github/workflows/checks-quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ jobs:
--exclude
"substrate/frame/contracts/fixtures/build"
"substrate/frame/contracts/fixtures/contracts/common"
"substrate/frame/revive/fixtures/build"
"substrate/frame/revive/fixtures/contracts/common"
- name: deny git deps
run: python3 .github/scripts/deny-git-deps.py .
Expand Down
81 changes: 42 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ sc-tracing-proc-macro = { path = "substrate/client/tracing/proc-macro", default-
sc-transaction-pool = { path = "substrate/client/transaction-pool", default-features = false }
sc-transaction-pool-api = { path = "substrate/client/transaction-pool/api", default-features = false }
sc-utils = { path = "substrate/client/utils", default-features = false }
scale-info = { version = "2.11.1", default-features = false }
scale-info = { version = "2.11.6", default-features = false }
schemars = { version = "0.8.13", default-features = false }
schnellru = { version = "0.2.3" }
schnorrkel = { version = "0.11.4", default-features = false }
Expand Down
35 changes: 35 additions & 0 deletions prdoc/pr_6565.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
title: 'pallet_revive: Switch to 64bit RISC-V'
doc:
- audience: Runtime Dev
description: |-
This PR updates pallet_revive to the newest PolkaVM version and adapts the test fixtures and syscall interface to work under 64bit.

Please note that after this PR no 32bit contracts can be deployed (they will be rejected at deploy time). Pre-deployed 32bit contracts are now considered defunct since we changes how parameters are passed for functions with more than 6 arguments.

## Fixtures

The fixtures are now built for the 64bit target. I also removed the temporary directory mechanism that triggered a full rebuild every time. It also makes it easier to find the compiled fixtures since they are now always in `target/pallet-revive-fixtures`.

## Syscall interface

### Passing pointer

Registers and pointers are now 64bit wide. This allows us to pass u64 arguments in a single register. Before we needed two registers to pass them. This means that just as before we need one register per pointer we pass. We keep pointers as `u32` argument by truncating the register. This is done since the memory space of PolkaVM is 32bit.

### Functions with more than 6 arguments

We only have 6 registers to pass arguments. This is why we pass a pointer to a struct when we need more than 6. Before this PR we expected a packed struct and interpreted it as SCALE encoded tuple. However, this was buggy because the `MaxEncodedLen` returned something that was larger than the packed size of the structure. This wasn't a problem before. But now the memory space changed in a way that things were placed at the edges of the memory space and those extra bytes lead to an out of bound access.

This is why this PR drops SCALE and expects the arguments to be passed as a pointer to a `C` aligned struct. This avoids unaligned accesses. However, revive needs to adapt its codegen to properly align the structure fields.

## TODO
- [ ] Add multi block migration that wipes all existing contracts as we made breaking changes to the syscall interface
crates:
- name: pallet-revive
bump: major
- name: pallet-revive-fixtures
bump: major
- name: pallet-revive-proc-macro
bump: major
- name: pallet-revive-uapi
bump: major
15 changes: 15 additions & 0 deletions prdoc/pr_6665.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
title: Fix runtime api impl detection by construct runtime
doc:
- audience: Runtime Dev
description: |-
Construct runtime uses autoref-based specialization to fetch the metadata about the implemented runtime apis. This is done to not fail to compile when there are no runtime apis implemented. However, there was an issue with detecting runtime apis when they were implemented in a different file. The problem is solved by moving the trait implemented by `impl_runtime_apis!` to the metadata ir crate.


Closes: https://github.com/paritytech/polkadot-sdk/issues/6659
crates:
- name: frame-support-procedural
bump: patch
- name: sp-api-proc-macro
bump: patch
- name: sp-metadata-ir
bump: patch
Loading

0 comments on commit 9aa51eb

Please sign in to comment.