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

Feature/1204080823207081 staking collect mechanism #14

Merged
merged 18 commits into from
Nov 21, 2023

Conversation

neutrinoks
Copy link

No description provided.

@neutrinoks neutrinoks requested a review from sfffaaa May 3, 2023 11:08
tools/utils.py Outdated
# Example 3: ex_stack = ExtrinsicStack()
@dataclass
class ExtrinsicStack:
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we talk about the stack, the first thing that comes into my mind is first in, last out. Does this follow this sequence?

Copy link
Author

Choose a reason for hiding this comment

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

Oh you want to name it ExtrinsicFifo? 😄 Yeah, in that meaning, it maybe is not a stack actually... I just had something in my mind like a batch... Or ExtrinisicBatch? Shall we rename it for more clarity?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the ExtrinisicBatch is good

tools/pallet_block_reward_test.py Outdated Show resolved Hide resolved
# extrinsics for both validators again
print('Waiting for round about 3 blocks to be finalized...')
time.sleep(WAIT_TIME_PERIOD)
# Only increment rewards to check these without Tx-Fees
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does that mean we remove the claim_rewards extrinsic? Is it clear that we are using the below code?

with ExtrinsicStack(substrate, kp_alice) as ex_stack_new:
    setup the increment_collator_rewards on ex_stack_new

Copy link
Author

Choose a reason for hiding this comment

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

At this position, I removed the extrinsic claim_rewards because it enables to check the transferred rewards accurately. When transferring to the Alice's or Bob's account you have to consider the transaction fee payment somehow... and calculating transaction fees is still difficult without good model... But the extrinsic 'claim_rewards' will be executed before, when taking care, that there are no more rewards able to be claimed... Usually this will occur for sure, when running all test cases, because then a number of blocks fill be finalized before and a lot of rewards can be claimed by Alice and Bob, until this test will start - BUT, We can make sure, that this will definitely happen, by adding another waiting time, in the beginning of the test... what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

About the code logic, I agree with you. However, I just started to think about how to make these codes easier to maintain. When I saw the pop, I needed to understand three things, what is inside the ex_stack, why do we remove that, and whether here are related to each other.

Therefore, I would suggest using the new ex_stack instead of pop that in your case, or is the cost of creating the ex_stack high? What do you think?

tools/reward_distribution_test.py Outdated Show resolved Hide resolved
tools/pallet_block_reward_test.py Outdated Show resolved Hide resolved
tools/utils.py Outdated
# Example 3: ex_stack = ExtrinsicStack()
@dataclass
class ExtrinsicStack:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the ExtrinisicBatch is good

tools/reward_distribution_test.py Outdated Show resolved Hide resolved
# extrinsics for both validators again
print('Waiting for round about 3 blocks to be finalized...')
time.sleep(WAIT_TIME_PERIOD)
# Only increment rewards to check these without Tx-Fees
Copy link
Collaborator

Choose a reason for hiding this comment

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

About the code logic, I agree with you. However, I just started to think about how to make these codes easier to maintain. When I saw the pop, I needed to understand three things, what is inside the ex_stack, why do we remove that, and whether here are related to each other.

Therefore, I would suggest using the new ex_stack instead of pop that in your case, or is the cost of creating the ex_stack high? What do you think?

bl_hash_bob_start = ex_stack.execute(kp_bob)

# Debug: Double check that number of authored is equal to rewarded
if DEBUG:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are checking more in this debug, but why do we check that only the debug symbol is on? If that's important, then it shouldn't be skipped. Or if we restart the parachain, does that help?

Because in your below debug branch, you only show the information but not check

@neutrinoks neutrinoks marked this pull request as draft September 12, 2023 10:22
@neutrinoks neutrinoks marked this pull request as ready for review November 21, 2023 11:25
@neutrinoks neutrinoks merged commit 7c8f433 into main Nov 21, 2023
2 checks passed
@neutrinoks neutrinoks deleted the feature/1204080823207081_staking-collect-mechanism branch November 21, 2023 11:26
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.

2 participants