Skip to content

feat: Treasury#34

Merged
czareko merged 21 commits intomainfrom
feat/treasury
Jun 6, 2025
Merged

feat: Treasury#34
czareko merged 21 commits intomainfrom
feat/treasury

Conversation

@czareko
Copy link
Collaborator

@czareko czareko commented May 27, 2025

Please check how this change.
For a better understanding of the concept, please check the documentation first.
https://quantus-network.github.io/docs/governance/

@czareko czareko marked this pull request as ready for review May 28, 2025 09:56
@czareko czareko requested review from dastansam, illuzen, n13 and vrom911 June 2, 2025 03:16
targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "wasm32-unknown-unknown"]

[dependencies]
codec = { workspace=true, default-features = false, features = ["derive"] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why the formatting was still off here even after we did fmt...

Copy link
Contributor

Choose a reason for hiding this comment

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

did we run taplo as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No

Copy link
Collaborator

Choose a reason for hiding this comment

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

Was kinda expecting fmt to also format toml files. But we could just taplo everything.

Copy link
Contributor

@dastansam dastansam left a comment

Choose a reason for hiding this comment

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

some comments so far. but I would probably consider using OnUnbalanced trait instead of manually resolving imbalance.

Also, please, use debug or trace for logs, ideally, get rid of them. You already have an event that indicates the funds directed to treasury.
pallet shouldn't emit so much info logs (see substrate pallets for reference). if you want to debug in unit tests, add the logs and remove them once unit tests are passing.

targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "wasm32-unknown-unknown"]

[dependencies]
codec = { workspace=true, default-features = false, features = ["derive"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

did we run taplo as well?

bytes[0] = id;
AccountId32::new(bytes)
}
pub struct TestCommons;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub struct TestCommons;
pub struct TestEnv


impl TestCommons {
// Add #[allow(dead_code)] attribute to suppress warnings
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

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

you won't have to add #[allow(dead_code)] if you create a tests/mod.rs file and mark the module in lib.rs as a test.

#[cfg(test)]
mod tests;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For integration tests, we don't have anything included in lib.rs, but I moved this attribute one level higher.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, why don't we include it in the runtime/lib.rs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's one level higher, it's not one file in the same folder.

@illuzen
Copy link
Contributor

illuzen commented Jun 3, 2025

In general, it looks good to me. This might not be the right PR to change this, but we want a portion of the every block reward to go to the treasury, not just voluntary ones. Happy to discuss this more if you like, but the general idea is, let's have guaranteed funding for the treasury.

Copy link
Contributor

@illuzen illuzen left a comment

Choose a reason for hiding this comment

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

The only critical thing I think is check_payment seems seems off. Is the function unnecessary?

@czareko
Copy link
Collaborator Author

czareko commented Jun 4, 2025

@illuzen check_payment method is from the Pay trait, and later the treasury pallet uses it.

@czareko
Copy link
Collaborator Author

czareko commented Jun 4, 2025

@dastansam Our idea for rewards is quite simple. I already have OnUnbalanced working for transactions, but I don’t see a straightforward way to apply it to the treasury percentage. If you have a minute, could you show me how I can do this?

// Call on_initialize for pallets that need it
System::on_initialize(b + 1);
resonance_runtime::Scheduler::on_initialize(b + 1);
pub fn print_balances() {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this necessary? why not just print it directly?


impl TestCommons {
// Add #[allow(dead_code)] attribute to suppress warnings
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, why don't we include it in the runtime/lib.rs?

@czareko czareko merged commit 65965a0 into main Jun 6, 2025
2 checks passed
@n13 n13 deleted the feat/treasury branch September 25, 2025 02:24
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.

4 participants