-
Notifications
You must be signed in to change notification settings - Fork 116
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: Disable balance accounting in the ledger #3192
Conversation
9d87eb4
to
d6021e6
Compare
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.
I'm a little confused about what the entry point for this is going to be. Can you add some insight to the description? Like is there going to be a UI button that calls setExternalCurrency? What entry points will there be for disableAccounting?
I have some pretty structural comments in this review, so I will review unit tests once those are settle. First comment you should address: #3192 (comment)
@blueridger thanks for requesting this. Just added the following to the description: The current entry point is integration currency config in the grain.json config file. However, I'd really like to set up a CLI dialog for setting this and other integration config in the near-term. This is a hard requirement for the smart contract deployment for the merkle distribution integration, so I might as well include these few extra dialogs as a part of that story. |
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.
For best clarity, I recommend that you add a consistent comment structure for all 4 of the new actions (both enable/set and disable/remove) of the form:
When <the other> is enabled: effect/behavior
When <the other> is disabled: effect/behavior
When utilizing an on chain grain integration, tracking account balances in the sourcecred ledger makes little sense. These changes disable balance accounting, while preserving the functionality key to SourceCred, which is tracking distributions across identities. While balances are no longer tracked, paid totals will continue to be. This feature, combined with Distribution execution tracking, narrows the scope of the ledgers focus to the state of distributions, and whether or not they have been executed outside of SourceCred. When account balance tracking is disabled, the following changes are made to ledger behavior: - all grain balances are zeroed out in mutable accounts tracked by the ledger - grain transfers are disabled - distributed grain is not added to a user's balance. the paid total is updated, however. Undistributed balances are tracked as a whole through the distribution tracking functionality added earlier. - identities without a relevant payout address will be deactivated - identities that have no relevant payout addresses configured cannot be activated. relevant means the external currency configured in the ledger's state. Test plan: Unit tests included
Now that all intergration funcitonality has settled in the ledger, this interface can be simplified and cleaned up. No information has been lost; Config details can now simply be queried from the ledger directly. Config inconsistencies are now tracked in the main/grain.js API file. The main api will be tracking changes to the external currency config and update the ledger dynamically before any integrations run. test plan: unit tests have been updated
Completely decoupled setting External Currencies from disabling accounting. However, disabling accounting still requires an external currency is set. Cleaned up a bunch of cruft that I missed from the other changes
The new design centers the ledger as an audit log. All config changes (except for the sink identity) should be recorded in the ledger before any grain processing occurs. This setup is definitely inelegant, and I'm looking forward to migrating away from it when we can manage configs via some UI instead. test plan: unit tests are updated for the config parser
- update docstrings to clearly communicate config effects - naming functions - ordering of functions
Ledger config was happening after the first grain distribution executed. Now it runs as a hook before any grain distributions run.
19299b1
to
a96c7e9
Compare
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.
It looks like you are using git please
even though you are committing new changes as new commits. This makes it a little harder to track which commits are new. I'd recommend just using git push
if you are not using git commit --amend
if (!this._balanceAccountingEnabled) { | ||
this._deactivateAccountsWithoutPayoutAddress(); | ||
} |
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 should go in the private method under the mutations line, right?
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.
it can't. Calls to public methods from private "processAction" methods that both ultimtely append to the ledger result in out-of-order timestamps.
This is an acceptable location because it only calls public methods under the hood. I'd like to keep this as a private method even though it only invokes a public method though because I don't want it to be a documented part of the API right now.
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.
Ah cool
@blueridger this PR has been open for a while, and I rebased to keep the changes up to date with the most recent updates in |
Ahhh I see. No need to deep link, I can look for the timestamps. Thanks. |
8615b20
to
02bb6e9
Compare
A grain integration might want to store some details within an instance, such as a smart contract address. This update allows arbitrary updates to a scoped object within the grain config file. Test Plan: Unit tests are provided at the grain integration interface. Integration testing will be demonstrated in the test instance using the merkle integration.
Description
When utilizing an on chain grain integration, tracking account balances
in the SourceCred ledger makes little sense. These changes disable
balance accounting, while preserving the functionality key to
SourceCred, which is tracking distributions across identities. While
balances are no longer tracked, paid totals will continue to be. This
feature, combined with Distribution execution tracking, narrows the
scope of the ledgers focus to the state of distributions, and whether or
not they have been executed outside of SourceCred.
When account balance tracking is disabled, the following changes are
made to ledger behavior:
ledger
integrationCurrency
at the instantaccounting is disabled as
externalCurrency
. This allows for the configurationto be historically tracked in case the configuration is accidentally changed, and
allows for more predictable behavior in the ledger in this mode. If the
integrationCurrency
needs to be updated, the
disableAccounting
method can just be re-run with thenew currency to update the configuration within the ledger.
updated, however. Undistributed balances are tracked as a whole through
the distribution tracking functionality added earlier.
activated. relevant means the external currency configured in the
ledger's state.
Now that all integration functionality has settled in the ledger, the
executeGrainIntegration
interface can be simplified and cleaned up. No information has been
lost; Config details can now simply be queried from the ledger directly.
Config inconsistencies are now tracked in the main/grain.js API file.
The main api will be tracking changes to the external currency config and
update the ledger dynamically before any integrations run. This seemed like
the best compromise between "magic" and usability. I think it's important that
the ledger tracks all integration currency changes for the purpose of transparency,
but also using a config file seems to be the best input method for now. This
tracking can be deprecated when we migrate to a webUI for config management.
test plan: unit tests have been updated
Test Plan
Unit tests included
Merge Plan
merge plan can be found here
Future Work
The current entry point is integration currency config in thegrain.json
config file. However, I'd really like to set up a CLI dialog for setting this and other integration config in the near-term. This is a hard requirement for the smart contract deployment for the merkle distribution integration, so I might as well include these few extra dialogs as a part of that story.Update: I ended up just creating config entries in config/grain.json that are checked against the ledger every time grain distribution runs via the CLI.