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

Runtime: Argo Bridge #5155

Merged
merged 17 commits into from
Jun 4, 2024
Merged

Conversation

freakstatic
Copy link
Contributor

Still missing the benchmark tests

runtime-modules/argo-bridge/src/Untitled-2 Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/errors.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/events.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/errors.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/lib.rs Show resolved Hide resolved
runtime-modules/argo-bridge/src/lib.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/tests/mod.rs Show resolved Hide resolved
runtime-modules/argo-bridge/src/tests/mod.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/tests/mod.rs Outdated Show resolved Hide resolved
runtime/src/proposals_configuration/defaults.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ignazio-bovo ignazio-bovo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pallet looks solid, the only issues that I have found are:

  • remote chain address formatting : 12 most significant bytes should be zero IMHO
  • If you can provide a case where the operator account is None
    The tests needs some touching

runtime-modules/argo-bridge/src/lib.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/lib.rs Show resolved Hide resolved
runtime-modules/argo-bridge/src/lib.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/types.rs Show resolved Hide resolved
runtime-modules/argo-bridge/src/types.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/tests/mod.rs Show resolved Hide resolved
runtime-modules/argo-bridge/src/tests/mod.rs Show resolved Hide resolved
runtime-modules/argo-bridge/src/tests/mod.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/tests/mod.rs Outdated Show resolved Hide resolved
runtime-modules/argo-bridge/src/tests/mod.rs Show resolved Hide resolved
Copy link
Contributor

@ignazio-bovo ignazio-bovo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pallet looks solid, the only issues that I have found are:

  • remote chain address formatting : 12 most significant bytes should be zero IMHO
  • If you can provide a case where the operator account is None
    The tests needs some touching, especially in the happy path assertions (especially on event production)
    Also: wouldn't it be easier for you to have multiple commits 😅 , instead of a single huge one ?

@ignazio-bovo ignazio-bovo self-requested a review May 28, 2024 17:27
Copy link
Contributor

@ignazio-bovo ignazio-bovo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this, I accidentally re requested a review

@@ -0,0 +1,21 @@
use node_runtime::{argo_bridge::types::BridgeStatus, ArgoBridgeConfig};

pub fn production_config() -> ArgoBridgeConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think that you can set the mint allowance storage variable to be 0 by default since I don't think any other initial value is plausible

@ignazio-bovo ignazio-bovo self-requested a review May 28, 2024 17:35
Copy link
Contributor

@ignazio-bovo ignazio-bovo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did another quick review round

runtime/src/lib.rs Show resolved Hide resolved
pub PauserAccounts get(fn pauser_accounts): BoundedVec<T::AccountId, T::MaxPauserAccounts>;

/// Number of tokens that the bridge pallet is able to mint
pub MintAllowance get(fn mint_allowance) config(): BalanceOf<T>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can set default value of this to 0 if I correctly understood the bridging accounting logic, as there shouldn't be any other possible initial value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the tests is handy to be able to set a value for the mint allowance in the config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or were you really just suggesting a default value and not removing it from the genesis config?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the storage value mint_allowance is increased during Outbound transfer and decreased during Inbound transfer and it represent the total amount of JOY we have outside of the Joystream mainnet network.
If so my observation was: since the only plausible initial value is zero, we can set the default value when declearing the storage variable inside the decl_storage macro instead of manually setting the value in the chainspec config. (Even though I remember with confidence that in case a storage variable is not initialised it will be set to the fault value when accessed for the first time, so 0 for mint allowance which in production will be a u128)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a minor comment however, I am fine even with the existing solution

runtime/src/lib.rs Outdated Show resolved Hide resolved
@freakstatic
Copy link
Contributor Author

The pallet looks solid, the only issues that I have found are:

  • remote chain address formatting : 12 most significant bytes should be zero IMHO
  • If you can provide a case where the operator account is None
    The tests needs some touching

Thanks for the review 👍
The operator account being None is because I wasn't sure which account should be the default one 🤔

@ignazio-bovo ignazio-bovo self-requested a review May 29, 2024 19:24
@ignazio-bovo
Copy link
Contributor

All my previous comments have been addressed. So for now LGTM
Should I wait for the benchmarks?

@freakstatic
Copy link
Contributor Author

freakstatic commented May 30, 2024

@ignazio-bovo and @kdembler I have added the benchmark tests please take a look.
the weight calculation is not finding the benchmarks so I'm most likely missing something...

./scripts/../target/debug/joystream-node benchmark pallet --pallet=argo_bridge --extrinsic="*" --chain=prod-test --steps=50 --repeat=20 --execution=wasm --template=./scripts/../devops/joystream-pallet-weight-template.hbs --output=./scripts/../runtime-modules/argo-bridge/src/weights.rs

2024-05-30 05:28:07 [0] 💸 generated 1 npos voters, 1 from validators and 0 nominators    
2024-05-30 05:28:07 [0] 💸 generated 1 npos targets    
Error: Input("No benchmarks found which match your input.")

runtime/src/lib.rs Outdated Show resolved Hide resolved
@kdembler
Copy link
Member

@ignazio-bovo @freakstatic I think the discussion on storage initialization is still not resolved. @ignazio-bovo could you expand on what you had in mind?

@mnaamani
Copy link
Member

mnaamani commented May 30, 2024

@ignazio-bovo and @kdembler I have added the benchmark tests please take a look. the weight calculation is not finding the benchmarks so I'm most likely missing something...

./scripts/../target/debug/joystream-node benchmark pallet --pallet=argo_bridge --extrinsic="*" --chain=prod-test --steps=50 --repeat=20 --execution=wasm --template=./scripts/../devops/joystream-pallet-weight-template.hbs --output=./scripts/../runtime-modules/argo-bridge/src/weights.rs

2024-05-30 05:28:07 [0] 💸 generated 1 npos voters, 1 from validators and 0 nominators    
2024-05-30 05:28:07 [0] 💸 generated 1 npos targets    
Error: Input("No benchmarks found which match your input.")

I think you need to add the argo bridge pallet to the define_benchmarks! macro in runtime/src/runtime_api.rs

diff --git a/runtime/src/runtime_api.rs b/runtime/src/runtime_api.rs
index 8d3a06316a..c57e968e51 100644
--- a/runtime/src/runtime_api.rs
+++ b/runtime/src/runtime_api.rs
@@ -127,6 +127,7 @@ mod benches {
         [content, Content]
         [project_token, ProjectToken]
         [pallet_proxy, Proxy]
+        [argo_bridge, ArgoBridge]
     );
 }

@freakstatic
Copy link
Contributor Author

@ignazio-bovo and @kdembler I have added the benchmark tests please take a look. the weight calculation is not finding the benchmarks so I'm most likely missing something...
./scripts/../target/debug/joystream-node benchmark pallet --pallet=argo_bridge --extrinsic="*" --chain=prod-test --steps=50 --repeat=20 --execution=wasm --template=./scripts/../devops/joystream-pallet-weight-template.hbs --output=./scripts/../runtime-modules/argo-bridge/src/weights.rs

2024-05-30 05:28:07 [0] 💸 generated 1 npos voters, 1 from validators and 0 nominators    
2024-05-30 05:28:07 [0] 💸 generated 1 npos targets    
Error: Input("No benchmarks found which match your input.")

I think you need to add the argo bridge pallet to the define_benchmarks! macro in runtime/src/runtime_api.rs

diff --git a/runtime/src/runtime_api.rs b/runtime/src/runtime_api.rs
index 8d3a06316a..c57e968e51 100644
--- a/runtime/src/runtime_api.rs
+++ b/runtime/src/runtime_api.rs
@@ -127,6 +127,7 @@ mod benches {
         [content, Content]
         [project_token, ProjectToken]
         [pallet_proxy, Proxy]
+        [argo_bridge, ArgoBridge]
     );
 }

thanks very much 🙏
yeah that was exactly what I was missing

@freakstatic
Copy link
Contributor Author

@ignazio-bovo and @kdembler can you please review the benchmarking tests?

@freakstatic freakstatic marked this pull request as ready for review May 31, 2024 23:24
Copy link
Contributor

@ignazio-bovo ignazio-bovo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks looks ok in terms of worst case scenario accounting

@ignazio-bovo ignazio-bovo self-requested a review June 2, 2024 10:14
Copy link
Contributor

@ignazio-bovo ignazio-bovo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some errors that needs to be fixed (see CI).
You can test the benchmarking code with cargo test -p "pallet-argo-bridge" --features "runtime-benchmarks" (you can also use clippy with the same feature enabled)

@kdembler
Copy link
Member

kdembler commented Jun 2, 2024

@freakstatic @ignazio-bovo

I opened a PR with fixes for clippy issues that we should merge into this PR: freakstatic#2

I have also opened a new PR based on this to add a revert extrinsic: #5158

Please check

Copy link
Member

@kdembler kdembler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending benchmark&weights approval from @ignazio-bovo

We also need to add overflow protection in some extrinsics but will do in a subsequent PR

Copy link
Contributor

@ignazio-bovo ignazio-bovo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the mac osx checks will be fixed in my PR here: #5157

@kdembler kdembler merged commit 9d0f3b7 into Joystream:petra Jun 4, 2024
12 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants