Skip to content

Commit

Permalink
fix: funds splitting logic
Browse files Browse the repository at this point in the history
  • Loading branch information
0xArdi committed Apr 16, 2024
1 parent 0179545 commit cd20e6b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@
"custom/napthaai/prediction_request_rag/0.1.0": "bafybeibp3hfeywllhmepvqyah763go4i5vtvo4wwihy6h4x7sylsjm5cam",
"custom/napthaai/prediction_request_reasoning/0.1.0": "bafybeiexotxqt3o4mmbjr7gp74hhcsbfhvldlrcqbj573oliljqxeilh44",
"custom/valory/prepare_tx/0.1.0": "bafybeifnanct3pkknaxiffm7cq4rgenfii4grf3srhlj5clmwtxmvmyaay",
"custom/valory/short_maker/0.1.0": "bafybeif63rt4lkopu3rc3l7sg6tebrrwg2lxqufjx6dx4hoda5yzax43fa",
"custom/napthaai/prediction_url_cot/0.1.0": "bafybeif46dmf5vvp725u2msppcz7ixtm3z6t7czsywtqph7qpwuz3xb4wm",
"custom/napthaai/prediction_url_cot_claude/0.1.0": "bafybeibbnmnxumsu663q22ifp2iivy2i4cv3tmbtzyptsvna2xvw26pasi",
"custom/napthaai/prediction_request_reasoning_claude/0.1.0": "bafybeib3gpssxbykqgbgn6pwovobxvxyaufh2wndeabpqsgqrlmku57wbu",
"custom/napthaai/prediction_request_rag_claude/0.1.0": "bafybeib7pslkmh5pthp2u5627wqnyubc6gqgs54kjkuxnk4wifash6hini",
"custom/valory/short_maker/0.1.0": "bafybeif63rt4lkopu3rc3l7sg6tebrrwg2lxqufjx6dx4hoda5yzax43fa",
"protocol/valory/acn_data_share/0.1.0": "bafybeih5ydonnvrwvy2ygfqgfabkr47s4yw3uqxztmwyfprulwfsoe7ipq",
"protocol/valory/websocket_client/0.1.0": "bafybeih43mnztdv3v2hetr2k3gezg7d3yj4ur7cxdvcyaqhg65e52s5sf4",
"contract/valory/agent_mech/0.1.0": "bafybeidsau5x2vjofpcdzxkg7airwkrdag65ohtxcby2ut27tfjizgnrnm",
"contract/valory/agent_registry/0.1.0": "bafybeiargayav6yiztdnwzejoejstcx4idssch2h4f5arlgtzj3tgsgfmu",
"contract/valory/hash_checkpoint/0.1.0": "bafybeigv2bceirhy72yajxzibi4a5wrcfptfbkjbzzko6pqdq2f4dzr3xa",
"connection/valory/websocket_client/0.1.0": "bafybeiflmystocxaqblhpzqlcop2vkhsknpzjx2jomohomaxamwskeokzm",
"skill/valory/contract_subscription/0.1.0": "bafybeicyugrkx5glat4p4ezwf6i7oduh26eycfie6ftd4uxrknztzl3ik4",
"skill/valory/mech_abci/0.1.0": "bafybeighsfwef33msfzkxbkkikfyvt3beijqlua37x667a6kfjcwzfug3u",
"skill/valory/task_submission_abci/0.1.0": "bafybeidmkzpqpvyol3636eeprkloy3z3t2nipmwvu6da3dtk2q4tjlab6u",
"skill/valory/mech_abci/0.1.0": "bafybeicbbjkmxgkluzpckhqncijsmhall4etnjonb7powfyzxylptsabve",
"skill/valory/task_submission_abci/0.1.0": "bafybeifzyj7a5urrst6ven4k5pe5vawnfhesn4xgogifpqg2auhhqlkizu",
"skill/valory/task_execution/0.1.0": "bafybeiao3k5pwzt63fmn5q5vqofms6qmzy3f5x35wsr552gzhiwt4gelxu",
"skill/valory/websocket_client/0.1.0": "bafybeidwntmkk4b2ixq5454ycbkknclqx7a6vpn7aqpm2nw3duszqrxvta",
"skill/valory/subscription_abci/0.1.0": "bafybeidoqeznyhbh3znaqbfdnftzq6fdh77m35qgftdwz46nz2iwda4yam",
"agent/valory/mech/0.1.0": "bafybeihzgbm35ykx3xvlbfbvqzhmttz3bec4ehh2wcaqi2d7pg6wrjme6e",
"service/valory/mech/0.1.0": "bafybeieyecbpgeo57xrklghgdxikur5uaop3xdqpcw3py6q7osgscuwdrm"
"agent/valory/mech/0.1.0": "bafybeig6wiyje6347k64tvojqingx2wpuqtwrtjpojpcgecwv7fabpdfsq",
"service/valory/mech/0.1.0": "bafybeibmeptw744sigb5oclxlxfqmdsrvafsc6kmeilt7i62d55f7xaufq"
},
"third_party": {
"protocol/valory/default/1.0.0": "bafybeifqcqy5hfbnd7fjv4mqdjrtujh2vx3p2xhe33y67zoxa6ph7wdpaq",
Expand Down
4 changes: 2 additions & 2 deletions packages/valory/agents/mech/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ skills:
- valory/abstract_abci:0.1.0:bafybeihat4giyc4bz6zopvahcj4iw53356pbtwfn7p4d5yflwly2qhahum
- valory/abstract_round_abci:0.1.0:bafybeih3enhagoql7kzpeyzzu2scpkif6y3ubakpralfnwxcvxexdyvy5i
- valory/contract_subscription:0.1.0:bafybeicyugrkx5glat4p4ezwf6i7oduh26eycfie6ftd4uxrknztzl3ik4
- valory/mech_abci:0.1.0:bafybeighsfwef33msfzkxbkkikfyvt3beijqlua37x667a6kfjcwzfug3u
- valory/mech_abci:0.1.0:bafybeicbbjkmxgkluzpckhqncijsmhall4etnjonb7powfyzxylptsabve
- valory/registration_abci:0.1.0:bafybeiek7zcsxbucjwzgqfftafhfrocvc7q4yxllh2q44jeemsjxg3rcfm
- valory/reset_pause_abci:0.1.0:bafybeidw4mbx3os3hmv7ley7b3g3gja7ydpitr7mxbjpwzxin2mzyt5yam
- valory/subscription_abci:0.1.0:bafybeidoqeznyhbh3znaqbfdnftzq6fdh77m35qgftdwz46nz2iwda4yam
- valory/task_execution:0.1.0:bafybeiao3k5pwzt63fmn5q5vqofms6qmzy3f5x35wsr552gzhiwt4gelxu
- valory/task_submission_abci:0.1.0:bafybeidmkzpqpvyol3636eeprkloy3z3t2nipmwvu6da3dtk2q4tjlab6u
- valory/task_submission_abci:0.1.0:bafybeifzyj7a5urrst6ven4k5pe5vawnfhesn4xgogifpqg2auhhqlkizu
- valory/termination_abci:0.1.0:bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44
- valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq
- valory/websocket_client:0.1.0:bafybeidwntmkk4b2ixq5454ycbkknclqx7a6vpn7aqpm2nw3duszqrxvta
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/mech/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeif7ia4jdlazy6745ke2k2x5yoqlwsgwr6sbztbgqtwvs3ndm2p7ba
fingerprint_ignore_patterns: []
agent: valory/mech:0.1.0:bafybeihzgbm35ykx3xvlbfbvqzhmttz3bec4ehh2wcaqi2d7pg6wrjme6e
agent: valory/mech:0.1.0:bafybeig6wiyje6347k64tvojqingx2wpuqtwrtjpojpcgecwv7fabpdfsq
number_of_agents: 4
deployment:
agent:
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/mech_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ skills:
- valory/abstract_round_abci:0.1.0:bafybeih3enhagoql7kzpeyzzu2scpkif6y3ubakpralfnwxcvxexdyvy5i
- valory/registration_abci:0.1.0:bafybeiek7zcsxbucjwzgqfftafhfrocvc7q4yxllh2q44jeemsjxg3rcfm
- valory/reset_pause_abci:0.1.0:bafybeidw4mbx3os3hmv7ley7b3g3gja7ydpitr7mxbjpwzxin2mzyt5yam
- valory/task_submission_abci:0.1.0:bafybeidmkzpqpvyol3636eeprkloy3z3t2nipmwvu6da3dtk2q4tjlab6u
- valory/task_submission_abci:0.1.0:bafybeifzyj7a5urrst6ven4k5pe5vawnfhesn4xgogifpqg2auhhqlkizu
- valory/termination_abci:0.1.0:bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44
- valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq
- valory/subscription_abci:0.1.0:bafybeidoqeznyhbh3znaqbfdnftzq6fdh77m35qgftdwz46nz2iwda4yam
Expand Down
14 changes: 13 additions & 1 deletion packages/valory/skills/task_submission_abci/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"f017012200000000000000000000000000000000000000000000000000000000000000000"
)
FILENAME = "usage"
ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"


class TaskExecutionBaseBehaviour(BaseBehaviour, ABC):
Expand Down Expand Up @@ -515,6 +516,17 @@ def _get_funds_by_operator(
)
return None

# 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

for agent, reqs in accumulated_reqs_by_operator.items():
accumulated_reqs_by_operator[agent] = int(
operator_share * (reqs / total_reqs)
Expand All @@ -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,
contract_id=str(ServiceRegistryContract.contract_id),
contract_callable="get_operators_mapping",
agent_instances=agent_instances,
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/task_submission_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeiholqak7ltw6bbmn2c5tn3j7xgzkdlfzp3kcskiqsvmxoih6m4muq
behaviours.py: bafybeifirwywbj433tyu45hhkuftlbxjg4hc7qsgtl3hppah77kcl7keye
behaviours.py: bafybeidokqhcoafpqgjkm5tcikuydi2wwluu7ssorbhkw572o43inoyeu4
dialogues.py: bafybeibmac3m5u5h6ucoyjr4dazay72dyga656wvjl6z6saapluvjo54ne
fsm_specification.yaml: bafybeidtmsmpunr3t77pshd3k2s6dd6hlvhze6inu3gj7xyvlg4wi3tnuu
handlers.py: bafybeibe5n7my2vd2wlwo73sbma65epjqc7kxgtittewlylcmvnmoxtxzq
Expand Down

0 comments on commit cd20e6b

Please sign in to comment.