Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Availability Cores Talk for PBA@UCB #632

Merged
merged 20 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 24 additions & 22 deletions syllabus/6-FRAME/2-FRAME_Basics/Pallet_Hooks_Slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ duration: 1 hour

## Hooks: All In One

* Onchain / STF
* `on_runtime_upgrade`
* `on_initialize`
* `poll` (WIP)
* `on_finalize`
* `on_idle`
* Offchain:
* `genesis_build`
* `offchain_worker`
* `integrity_test`
* `try_state`
- Onchain / STF
- `on_runtime_upgrade`
- `on_initialize`
- `poll` (WIP)
- `on_finalize`
- `on_idle`
- Offchain:
- `genesis_build`
- `offchain_worker`
- `integrity_test`
- `try_state`

Notes:

Expand Down Expand Up @@ -96,7 +96,6 @@ fn on_initialize() -> Weight {
- &shy;<!-- .element: class="fragment" --> Question: If your runtime panics `on_initialize`, how can you recover from it?
- &shy;<!-- .element: class="fragment" --> Question: If your `on_initialize` consumes more than the maximum block weight?


Notes:

- The order comes from `construct_runtime!` macro.
Expand All @@ -119,7 +118,7 @@ fn on_finalize() -> Weight {} // ❌

<!-- .element: class="fragment" -->

- Nothing to do with *finality* in the consensus context.
- Nothing to do with _finality_ in the consensus context.

<!-- .element: class="fragment" -->

Expand Down Expand Up @@ -190,8 +189,9 @@ graph LR
end

subgraph Optional
OnRuntimeUpgrade
end

OnRuntimeUpgrade
end

subgraph BeforeExtrinsics
OnInitialize
Expand All @@ -204,8 +204,8 @@ graph LR
subgraph Inherents
Inherent1 --> Inherent2
end
</diagram>

</diagram>

Notes:

Expand Down Expand Up @@ -233,6 +233,7 @@ pub struct GenesisConfig<T: Config> {
pub bar: Vec<u8>,
}
```

<!-- .element: class="fragment" -->

```rust
Expand All @@ -242,6 +243,7 @@ impl<T: Config> Default for GenesisConfig<T> {
}
}
```

<!-- .element: class="fragment" -->

```rust
Expand All @@ -252,6 +254,7 @@ impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
}
}
```

<!-- .element: class="fragment" -->

---v
Expand Down Expand Up @@ -317,15 +320,13 @@ founders to be careful with this!

https://paritytech.github.io/substrate/master/pallet_examples/index.html


---v

### Hooks: `offchain_worker`

- Execution entirely up to the client.
- Has a totally separate thread pool than the normal execution.


```
--offchain-worker <ENABLED>
Possible values:
Expand Down Expand Up @@ -449,8 +450,9 @@ graph LR
end

subgraph Optional
OnRuntimeUpgrade
end

OnRuntimeUpgrade
end

subgraph BeforeExtrinsics
OnInitialize
Expand All @@ -463,6 +465,7 @@ graph LR
subgraph Inherents
Inherent1 --> Inherent2
end

</diagram>

- What other hooks can you think of?
Expand All @@ -472,11 +475,10 @@ Notes:
What other ideas you can think of?

- a hook called once a pallet is first initialized.
https://github.com/paritytech/substrate/issues/14098
https://github.com/paritytech/substrate/issues/14098
- Local on Post/Pre dispatch: https://github.com/paritytech/substrate/issues/12047
- Global on Post/Pre dispatch is in fact a signed extension. It has to live in the runtime, because you have to specify order.


---

## Additional Resources! 😋
Expand Down
17 changes: 8 additions & 9 deletions syllabus/6-FRAME/3-FRAME_Runtime/Construct_Runtime_slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ duration: 1 hour
instructors: ["Kian Paimani"]
---


# `construct_runtime!` and Testing 🔨

---
Expand Down Expand Up @@ -73,7 +72,6 @@ impl pallet_dpos::Config for Runtime { .. }

> Anywhere in your pallet code that you have `<T: Config>` can now be replaced with `Runtime`.


```rust[1-2|3-4|5-6]
// a normal pub function defined in
frame_system::Pallet::<Runtime>::block_number();
Expand Down Expand Up @@ -294,10 +292,10 @@ A test requires a mock runtime, so we need to do a full `construct_runtime` 😱

### Testing and Mocks

* `u32` account id.
* `u128` balance.
* `u32` block number.
* ...
- `u32` account id.
- `u128` balance.
- `u32` block number.
- ...

---

Expand All @@ -322,7 +320,6 @@ parameter_types! {
}
```


```rust
impl pallet_template::Config for Runtime {
type MaxVoters = MyMaxVoters;
Expand Down Expand Up @@ -517,7 +514,7 @@ pub fn next_block() {

### Progressing Blocks

```rust
````rust
```rust
#[test]
fn test() {
Expand All @@ -537,7 +534,8 @@ fn test() {
// repeat..
});
}
```
````

```

---
Expand Down Expand Up @@ -584,3 +582,4 @@ The `construct_runtime!` itself does a few things under the hood:

- Ordering in `construct_runtime` matters.
- Pallet parts can be optional in `construct_runtime!`.
```
Loading