-
Notifications
You must be signed in to change notification settings - Fork 115
Storage node conversion to the runtime version based on Substrate 2.0.0-rc4 #1189
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
Storage node conversion to the runtime version based on Substrate 2.0.0-rc4 #1189
Conversation
| async freeBalance(accountId) { | ||
| const decoded = this.base.identities.keyring.decodeAddress(accountId, true) | ||
| return this.base.api.query.balances.freeBalance(decoded) | ||
| return (await this.base.api.derive.balances.all(decoded)).freeBalance |
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.
In this context I think (await this.base.api.derive.balances.all(decoded)).availableBalance may actually be more suitable, because freeBalance = avaialble + locked and if the balance is locked it seems like it cannot be transferred or used to pay the fee.
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.
@Lezek123 is correct. The way we are using it we were not accounting for locked balance. It is only directly called by hasMinimumBalanceOf() which is the call that is really interested in a minimum transferable balance. We can fix this in a later PR.
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.
Leszek's solution is only a single line. I'm including the fix in the current PR.
| const leadOpeningId = await api.workers.devAddStorageLeadOpening() | ||
| const leadApplicationId = await api.workers.devApplyOnOpening(leadOpeningId, aliceMemberId, alice, alice) | ||
| api.workers.devBeginLeadOpeningReview(leadOpeningId) | ||
| await api.workers.devBeginLeadOpeningReview(leadOpeningId) |
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.
this await was left out so the two transactions can be finalized in the same block.
It works because the second call doesn't need to get any values from event(s) emitted by the first transaction.
Of course the second one will fail if the first fails.
So its just a speed optimization :)
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.
Ok. I'm rolling it back.
| async freeBalance(accountId) { | ||
| const decoded = this.base.identities.keyring.decodeAddress(accountId, true) | ||
| return this.base.api.query.balances.freeBalance(decoded) | ||
| return (await this.base.api.derive.balances.all(decoded)).freeBalance |
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.
@Lezek123 is correct. The way we are using it we were not accounting for locked balance. It is only directly called by hasMinimumBalanceOf() which is the call that is really interested in a minimum transferable balance. We can fix this in a later PR.
| providers[id] = new Worker(value) | ||
| } | ||
| } | ||
| const entries = (await this.base.api.query.storageWorkingGroup.workerById.entries()); |
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.
love the new api
|
The changes look good. To build I had to fix call to |
|
I'm seeing 9 linter errors that need to be fixed, we can fix in a separate PR? Running |
|
That is strange - I had successfully uploaded the video file during the testing. |
Is it possible that the packages wasn't rebuilt and used some pre-compiled code you had? I noticed storage-node is the only project we have where a |
|
Did some additional testing. LGTM. One bug I just realized in the |
Main changes:
IsFinalizedwas changed toasCompleted