-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: MMD-1309 10-to-1 - Off-chain workers #238
Draft
ltfschoen
wants to merge
37
commits into
luke/rewards-allowance-new
Choose a base branch
from
luke/rewards-allowance-new-offchain
base: luke/rewards-allowance-new
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat: MMD-1309 10-to-1 - Off-chain workers #238
ltfschoen
wants to merge
37
commits into
luke/rewards-allowance-new
from
luke/rewards-allowance-new-offchain
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xlc
reviewed
Nov 7, 2021
Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
resolved errors that i was getting in the logsoffchain_workers error fetching mpower and offchain_workers error unknown transaction type , which appears to because i needed to change the GRACE_PERIOD to a shorter period of say 10 seconds instead of 1 minute i also only had a single account Alice in the chain_spec as a value for cooling_off_period_days_remaining, but I also needed Bob since, and because in the hard-coded mpower data response from the API i had two accounts with an mpower value, but they accidently both had Alice’s public key hex, so it was using the same account when iterating over multiple miners. i also wasn’t providing the correct value for the account id to the function set_mpower_of_account_for_date (i was providing the unsigned account id instead of the account id property i’d added as mpower_data_item.account_id_registered_dhx_miner i checked that i could successfully check on-chain storage for MPowerForAccountForDate` by providing the start of a current date that had been stored, and the public key (hex) value that was provided for the account id in the API response (even though we’re storing the key as Vec<u8> it still fetches it correctly in the UI change to store accounts as public keys Vec<u8> instead of AccountId
…t so only Sudo or governance may change
…e does not already exist in storage
ltfschoen
force-pushed
the
luke/rewards-allowance-new-offchain
branch
from
December 2, 2021 07:12
fa7a464
to
18f919a
Compare
ltfschoen
commented
Feb 21, 2022
return Err(DispatchError::Other("Unable to multiply to determine challenge_period_millis")); | ||
} | ||
|
||
let challenge_period_millis = challenge_period_days.clone() * millis_per_day.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a duplicate? we're already using checked_mul a few lines before
ltfschoen
commented
Feb 21, 2022
println!("existing challenge_period_days: {:?}", challenge_period_days.clone()); | ||
} else { | ||
log::error!("Unable to get challenge_period_days"); | ||
return Err(DispatchError::Other("Unable to get challenge_period_days"));; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove double ;;
as only single necessary
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
i added the
offchain_worker
function and some new off-chain workers logic to a pallet where i had already setup other logic and had the mock configured so unit tests were passing.i had it working in mock.rs with
type AccountId = u128
but now i have to update mock.rs so it works with off-chain workers, but i'm not sure how to get it to work.
in frame example-offchain-workers
AccountId
is:(as shown here: https://github.com/paritytech/substrate/blob/master/frame/example-offchain-worker/src/tests.rs#L67
)
where
AccountId
is:(as shown here: https://github.com/paritytech/substrate/blob/master/frame/example-offchain-worker/src/tests.rs#L83)
and it uses
<Signature as Verify>::Signer
in these two places:so far the changes i've made are in this PR in the file pallets/mining/rewards-allowance/src/mock.rs here: https://github.com/DataHighway-DHX/node/pull/238/files#diff-b7ace9b0e8a1d800ea987e0e9b9e117f8fe6a52b923a9e654b65495c90c7ffd5R468
and when i run the tests with
cargo test -p mining-rewards-allowance
, i get the following error:SOLUTION: This was fixed in this commit 9ad33cd
set_mpower_of_account_for_date
we're storing anext_start_date
, but in offchain_workers we might be storing the current date forMPowerForAccountForDate
...i.e. if there are a lot of registered miners and it takes more than a day to receive and process all of the offchain data received and we're storing that under a key of the current day it's being processed on on-chain, then if we don't finish going through all those registered miners in one day then they might be stored under a key for tomorrow's date incorrectly....
so instead we should be providing the date that the account id's mpower relates to from the API with a timestamp, and then in offchain_workers figure out the start of that date, and store it.
Note: See Jira mPower MMD-1584 for latest status