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

fix: funds splitting logic #213

Merged
merged 2 commits into from
Apr 16, 2024
Merged

fix: funds splitting logic #213

merged 2 commits into from
Apr 16, 2024

Conversation

0xArdi
Copy link
Collaborator

@0xArdi 0xArdi commented Apr 16, 2024

This PR fixes the funds splitting logic.

@@ -529,7 +541,7 @@ def _accumulate_reqs_by_operator(
agent_instances = list(reqs_by_agent.keys())
contract_api_msg = yield from self.get_contract_api_response(
performative=ContractApiMessage.Performative.GET_STATE, # type: ignore
contract_address=self.params.agent_registry_address,
contract_address=self.params.service_registry_address,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure how this was ever working with this issue

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remember to set the env var when deploying, because the default is zero address:

service_registry_address: ${SERVICE_REGISTRY_ADDRESS:str:0x0000000000000000000000000000000000000000}

Comment on lines +519 to +528
# in case an agent maps to an operator that is the zero address
# we need to remove it from the list of addresses that will receive funds
# this can happen in case of changing agent instances in the service registry
# old agent instances will map to the zero address, because they are still part of
# usage history
invalid_operator_reqs = accumulated_reqs_by_operator.pop(ZERO_ADDRESS, 0)

# remove the invalid operator reqs from the total reqs,
# so that we share 100% of the funds among the valid operators
total_reqs -= invalid_operator_reqs
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is critical, otherwise funds would be transferred to zero address

@0xArdi 0xArdi merged commit fd55093 into main Apr 16, 2024
6 checks passed
@0xArdi 0xArdi deleted the fix/funds-splitting branch April 16, 2024 09:59
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.

3 participants