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: misc issues with mech during marketplace #261

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@
"custom/dvilela/gemini_prediction/0.1.0": "bafybeigvwflupxzbjgmaxcxml5vkez3obl4fjo6bxzhquq56urnviq32u4",
"protocol/valory/acn_data_share/0.1.0": "bafybeih5ydonnvrwvy2ygfqgfabkr47s4yw3uqxztmwyfprulwfsoe7ipq",
"protocol/valory/websocket_client/0.1.0": "bafybeifjk254sy65rna2k32kynzenutujwqndap2r222afvr3zezi27mx4",
"contract/valory/agent_mech/0.1.0": "bafybeifj253ojkdr75ckrzb55su3j2v2hyb3v2ppqjwvvqyzbxanptebne",
"contract/valory/agent_mech/0.1.0": "bafybeibvupi37fvzxlwpdokrd6eyxuo64j45icsti3atoprk6pvx6cpiye",
"contract/valory/agent_registry/0.1.0": "bafybeiarzhzs2wm2sl47qg37tqoc3qok54enxlcj6vx3hldozg537uslnq",
"contract/valory/hash_checkpoint/0.1.0": "bafybeicbycr6rxods7sg3f2qlhgkjqrbh7kymmy2yw7bewxdwjyp7ibtg4",
"contract/valory/mech_marketplace/0.1.0": "bafybeich3a3oh5w4u533w6y7ideojudqp2m5gxta7pqmsfiaohdhuw7yz4",
"contract/valory/mech_marketplace/0.1.0": "bafybeib2cuv2tdrjp44y57drllpyh34t66y67zibefxmzyvmoupcb476uu",
"connection/valory/websocket_client/0.1.0": "bafybeic4ag3gqc7kd3k2o3pucddj2odck5yrfbgmwh5veqny7zao5qayli",
"skill/valory/contract_subscription/0.1.0": "bafybeiefuemlp75obgpxrp6iuleb3hn6vcviwh5oetk5djbuprf4xsmgjy",
"skill/valory/mech_abci/0.1.0": "bafybeiajz42vtyvmm3bjmft7d6y3dodped2kh7h75zgqocym76twvpyejq",
"skill/valory/task_submission_abci/0.1.0": "bafybeigoda6koeghcboflmz5e6r7yluk7fanpjso64b4am3w2szo2a65w4",
"skill/valory/task_execution/0.1.0": "bafybeif7jsxbue6l7fhn5ahf7jbks5td6me55b42dy7k6s3j72zvu2p7ie",
"skill/valory/mech_abci/0.1.0": "bafybeicbmmiw5wx26i3vs5nlh66d7oi74ezsyl7wshwrosxvibkyu6a6ze",
"skill/valory/task_submission_abci/0.1.0": "bafybeigb3synomrwmducrnli6b6goykqxcp5dt6mdhcx7iemd6xtslf7um",
"skill/valory/task_execution/0.1.0": "bafybeieyikx3pvdjhya2qppbzywa2o2hgobn47enkygcf24ns3r7phdm7i",
"skill/valory/websocket_client/0.1.0": "bafybeif7rrvsu6z4evqkhblxj3u6wwv2eqou576hgkyoehxuj7cntw7o2m",
"skill/valory/subscription_abci/0.1.0": "bafybeicnum426c4te77enoalhmthqirrhvswvyunvanjbljlhs2cob6zsa",
"agent/valory/mech/0.1.0": "bafybeib4wzpyfopo7curjyp5jvt35clri7mmpzyzbtmv5246bjxrkieelu",
"service/valory/mech/0.1.0": "bafybeic7uew3lt2kiely3a5jvizir5pcbnuuwzr6rmj75yydseiz744wqu"
"skill/valory/subscription_abci/0.1.0": "bafybeihmwomgbieeuo6ee3bnpmlmukvk46a6h6jyhjbloj3qqxjvbqsjsy",
"agent/valory/mech/0.1.0": "bafybeidhb465sfku4wozcrgq6ylsyek5vwgpwaeuiwujluh537f2j6vzgq",
"service/valory/mech/0.1.0": "bafybeia44aom4gr2oixulfbubs5thnaj4dcqsm2mysjepp5clcmg5rn3im"
},
"third_party": {
"protocol/valory/default/1.0.0": "bafybeifqcqy5hfbnd7fjv4mqdjrtujh2vx3p2xhe33y67zoxa6ph7wdpaq",
Expand Down
12 changes: 6 additions & 6 deletions packages/valory/agents/mech/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ connections:
- valory/p2p_libp2p_client:0.1.0:bafybeid3xg5k2ol5adflqloy75ibgljmol6xsvzvezebsg7oudxeeolz7e
- valory/websocket_client:0.1.0:bafybeic4ag3gqc7kd3k2o3pucddj2odck5yrfbgmwh5veqny7zao5qayli
contracts:
- valory/agent_mech:0.1.0:bafybeifj253ojkdr75ckrzb55su3j2v2hyb3v2ppqjwvvqyzbxanptebne
- valory/agent_mech:0.1.0:bafybeibvupi37fvzxlwpdokrd6eyxuo64j45icsti3atoprk6pvx6cpiye
- valory/agent_registry:0.1.0:bafybeiarzhzs2wm2sl47qg37tqoc3qok54enxlcj6vx3hldozg537uslnq
- valory/gnosis_safe:0.1.0:bafybeibq77mgzhyb23blf2eqmia3kc6io5karedfzhntvpcebeqdzrgyqa
- valory/gnosis_safe_proxy_factory:0.1.0:bafybeib6podeifufgmawvicm3xyz3uaplbcrsptjzz4unpseh7qtcpar74
- valory/hash_checkpoint:0.1.0:bafybeicbycr6rxods7sg3f2qlhgkjqrbh7kymmy2yw7bewxdwjyp7ibtg4
- valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y
- valory/service_registry:0.1.0:bafybeicbxmbzt757lbmyh6762lrkcrp3oeum6dk3z7pvosixasifsk6xlm
- valory/mech_marketplace:0.1.0:bafybeich3a3oh5w4u533w6y7ideojudqp2m5gxta7pqmsfiaohdhuw7yz4
- valory/mech_marketplace:0.1.0:bafybeib2cuv2tdrjp44y57drllpyh34t66y67zibefxmzyvmoupcb476uu
protocols:
- open_aea/signing:1.0.0:bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi
- valory/abci:0.1.0:bafybeiaqmp7kocbfdboksayeqhkbrynvlfzsx4uy4x6nohywnmaig4an7u
Expand All @@ -39,12 +39,12 @@ skills:
- valory/abstract_abci:0.1.0:bafybeihat4giyc4bz6zopvahcj4iw53356pbtwfn7p4d5yflwly2qhahum
- valory/abstract_round_abci:0.1.0:bafybeih3enhagoql7kzpeyzzu2scpkif6y3ubakpralfnwxcvxexdyvy5i
- valory/contract_subscription:0.1.0:bafybeiefuemlp75obgpxrp6iuleb3hn6vcviwh5oetk5djbuprf4xsmgjy
- valory/mech_abci:0.1.0:bafybeiajz42vtyvmm3bjmft7d6y3dodped2kh7h75zgqocym76twvpyejq
- valory/mech_abci:0.1.0:bafybeicbmmiw5wx26i3vs5nlh66d7oi74ezsyl7wshwrosxvibkyu6a6ze
- valory/registration_abci:0.1.0:bafybeiek7zcsxbucjwzgqfftafhfrocvc7q4yxllh2q44jeemsjxg3rcfm
- valory/reset_pause_abci:0.1.0:bafybeidw4mbx3os3hmv7ley7b3g3gja7ydpitr7mxbjpwzxin2mzyt5yam
- valory/subscription_abci:0.1.0:bafybeicnum426c4te77enoalhmthqirrhvswvyunvanjbljlhs2cob6zsa
- valory/task_execution:0.1.0:bafybeif7jsxbue6l7fhn5ahf7jbks5td6me55b42dy7k6s3j72zvu2p7ie
- valory/task_submission_abci:0.1.0:bafybeigoda6koeghcboflmz5e6r7yluk7fanpjso64b4am3w2szo2a65w4
- valory/subscription_abci:0.1.0:bafybeihmwomgbieeuo6ee3bnpmlmukvk46a6h6jyhjbloj3qqxjvbqsjsy
- valory/task_execution:0.1.0:bafybeieyikx3pvdjhya2qppbzywa2o2hgobn47enkygcf24ns3r7phdm7i
- valory/task_submission_abci:0.1.0:bafybeigb3synomrwmducrnli6b6goykqxcp5dt6mdhcx7iemd6xtslf7um
- valory/termination_abci:0.1.0:bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44
- valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq
- valory/websocket_client:0.1.0:bafybeif7rrvsu6z4evqkhblxj3u6wwv2eqou576hgkyoehxuj7cntw7o2m
Expand Down
8 changes: 6 additions & 2 deletions packages/valory/contracts/agent_mech/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ def get_deliver_to_market_tx(
cls,
ledger_api: LedgerApi,
contract_address: str,
sender_address: str,
request_id: int,
data: str,
mech_staking_instance: str,
Expand All @@ -500,9 +501,12 @@ def get_deliver_to_market_tx(
fn_name="deliverToMarketplace",
args=[
request_id,
data,
bytes.fromhex(data),
Web3.to_checksum_address(mech_staking_instance),
mech_service_id,
],
)
return {"data": bytes.fromhex(tx_data[2:])} # type: ignore
simulation_ok = cls.simulate_tx(
ledger_api, contract_address, sender_address, tx_data
).pop("data")
return {"data": bytes.fromhex(tx_data[2:]), "simulation_ok": simulation_ok} # type: ignore
2 changes: 1 addition & 1 deletion packages/valory/contracts/agent_mech/contract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeigpq5lxfj2aza6ok3fjuywtdafelkbvoqwaits7regfbgu4oynmku
build/AgentMech.json: bafybeifbx2dovjm7ufoufvxwb5n3tyfcwysecaggpcds4caanqlpfg5dqm
contract.py: bafybeib2wss3fjozfnocvt4yqpwso5ufdaln56q4ug7hwriqfx6u4e7fdu
contract.py: bafybeig5pnbegw4qw3vltgfaay5edf55bkeoewy5dqz6q7dsdclu2doxji
fingerprint_ignore_patterns: []
class_name: AgentMechContract
contract_interface_paths:
Expand Down
27 changes: 17 additions & 10 deletions packages/valory/contracts/mech_marketplace/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
"name": "_marketplace",
"type": "address"
},
{
"internalType": "address",
"name": "me",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "_requestIds",
Expand All @@ -57,7 +62,7 @@
"type": "constructor"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5060405161078c38038061078c8339818101604052810190610032919061046d565b60008151905060008167ffffffffffffffff811115610054576100536102f4565b5b6040519080825280602002602001820160405280156100825781602001602082028036833780820191505090505b5090506000805b8381101561018d5760008673ffffffffffffffffffffffffffffffffffffffff1663cb261bec8784815181106100c2576100c16104c9565b5b60200260200101516040518263ffffffff1660e01b81526004016100e69190610507565b608060405180830381865afa158015610103573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101279190610607565b9050806060015163ffffffff1642106101815785828151811061014d5761014c6104c9565b5b6020026020010151848481518110610168576101676104c9565b5b6020026020010181815250508261017e90610663565b92505b81600101915050610089565b5060008167ffffffffffffffff8111156101aa576101a96102f4565b5b6040519080825280602002602001820160405280156101d85781602001602082028036833780820191505090505b50905060005b8281101561022b578381815181106101f9576101f86104c9565b5b6020026020010151828281518110610214576102136104c9565b5b6020026020010181815250508060010190506101de565b5060008160405160200161023f9190610769565b60405160208183030381529060405290506020810180590381f35b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102998261026e565b9050919050565b60006102ab8261028e565b9050919050565b6102bb816102a0565b81146102c657600080fd5b50565b6000815190506102d8816102b2565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61032c826102e3565b810181811067ffffffffffffffff8211171561034b5761034a6102f4565b5b80604052505050565b600061035e61025a565b905061036a8282610323565b919050565b600067ffffffffffffffff82111561038a576103896102f4565b5b602082029050602081019050919050565b600080fd5b6000819050919050565b6103b3816103a0565b81146103be57600080fd5b50565b6000815190506103d0816103aa565b92915050565b60006103e96103e48461036f565b610354565b9050808382526020820190506020840283018581111561040c5761040b61039b565b5b835b81811015610435578061042188826103c1565b84526020840193505060208101905061040e565b5050509392505050565b600082601f830112610454576104536102de565b5b81516104648482602086016103d6565b91505092915050565b6000806040838503121561048457610483610264565b5b6000610492858286016102c9565b925050602083015167ffffffffffffffff8111156104b3576104b2610269565b5b6104bf8582860161043f565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610501816103a0565b82525050565b600060208201905061051c60008301846104f8565b92915050565b600080fd5b6105308161028e565b811461053b57600080fd5b50565b60008151905061054d81610527565b92915050565b600063ffffffff82169050919050565b61056c81610553565b811461057757600080fd5b50565b60008151905061058981610563565b92915050565b6000608082840312156105a5576105a4610522565b5b6105af6080610354565b905060006105bf8482850161053e565b60008301525060206105d38482850161053e565b60208301525060406105e78482850161053e565b60408301525060606105fb8482850161057a565b60608301525092915050565b60006080828403121561061d5761061c610264565b5b600061062b8482850161058f565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061066e826103a0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036106a05761069f610634565b5b600182019050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6106e0816103a0565b82525050565b60006106f283836106d7565b60208301905092915050565b6000602082019050919050565b6000610716826106ab565b61072081856106b6565b935061072b836106c7565b8060005b8381101561075c57815161074388826106e6565b975061074e836106fe565b92505060018101905061072f565b5085935050505092915050565b60006020820190508181036000830152610783818461070b565b90509291505056fe",
"bytecode": "0x608060405234801561001057600080fd5b5060405161081738038061081783398181016040528101906100329190610511565b60008151905060008167ffffffffffffffff81111561005457610053610398565b5b6040519080825280602002602001820160405280156100825781602001602082028036833780820191505090505b5090506000805b838110156102055760008773ffffffffffffffffffffffffffffffffffffffff1663cb261bec8784815181106100c2576100c1610580565b5b60200260200101516040518263ffffffff1660e01b81526004016100e691906105be565b608060405180830381865afa158015610103573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101279190610692565b90508673ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614806101715750806060015163ffffffff164210155b80156101ad5750600073ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16145b156101f9578582815181106101c5576101c4610580565b5b60200260200101518484815181106101e0576101df610580565b5b602002602001018181525050826101f6906106ee565b92505b81600101915050610089565b5060008167ffffffffffffffff81111561022257610221610398565b5b6040519080825280602002602001820160405280156102505781602001602082028036833780820191505090505b50905060005b828110156102a35783818151811061027157610270610580565b5b602002602001015182828151811061028c5761028b610580565b5b602002602001018181525050806001019050610256565b506000816040516020016102b791906107f4565b60405160208183030381529060405290506020810180590381f35b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610311826102e6565b9050919050565b600061032382610306565b9050919050565b61033381610318565b811461033e57600080fd5b50565b6000815190506103508161032a565b92915050565b61035f81610306565b811461036a57600080fd5b50565b60008151905061037c81610356565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6103d082610387565b810181811067ffffffffffffffff821117156103ef576103ee610398565b5b80604052505050565b60006104026102d2565b905061040e82826103c7565b919050565b600067ffffffffffffffff82111561042e5761042d610398565b5b602082029050602081019050919050565b600080fd5b6000819050919050565b61045781610444565b811461046257600080fd5b50565b6000815190506104748161044e565b92915050565b600061048d61048884610413565b6103f8565b905080838252602082019050602084028301858111156104b0576104af61043f565b5b835b818110156104d957806104c58882610465565b8452602084019350506020810190506104b2565b5050509392505050565b600082601f8301126104f8576104f7610382565b5b815161050884826020860161047a565b91505092915050565b60008060006060848603121561052a576105296102dc565b5b600061053886828701610341565b93505060206105498682870161036d565b925050604084015167ffffffffffffffff81111561056a576105696102e1565b5b610576868287016104e3565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6105b881610444565b82525050565b60006020820190506105d360008301846105af565b92915050565b600080fd5b600063ffffffff82169050919050565b6105f7816105de565b811461060257600080fd5b50565b600081519050610614816105ee565b92915050565b6000608082840312156106305761062f6105d9565b5b61063a60806103f8565b9050600061064a8482850161036d565b600083015250602061065e8482850161036d565b60208301525060406106728482850161036d565b604083015250606061068684828501610605565b60608301525092915050565b6000608082840312156106a8576106a76102dc565b5b60006106b68482850161061a565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006106f982610444565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361072b5761072a6106bf565b5b600182019050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61076b81610444565b82525050565b600061077d8383610762565b60208301905092915050565b6000602082019050919050565b60006107a182610736565b6107ab8185610741565b93506107b683610752565b8060005b838110156107e75781516107ce8882610771565b97506107d983610789565b9250506001810190506107ba565b5085935050505092915050565b6000602082019050818103600083015261080e8184610796565b90509291505056fe",
}


Expand Down Expand Up @@ -153,7 +158,7 @@ def get_deliver_data(
fn_name="deliverMarketplace",
args=[
request_id,
data,
bytes.fromhex(data),
delivery_mech_staking_instance,
delivery_mech_service_id,
],
Expand Down Expand Up @@ -186,7 +191,7 @@ def get_request_events(
"tx_hash": entry.transactionHash.hex(),
"block_number": entry.blockNumber,
**entry["args"],
"contract_address": contract_address,
"sender": entry["args"]["requester"],
}
for entry in entries
)
Expand Down Expand Up @@ -239,18 +244,19 @@ def has_priority_passed(
cls,
ledger_api: LedgerApi,
contract_address: str,
my_mech: str,
request_ids: List[int],
) -> Dict[str, Any]:
"""Check the priority of the requests."""
"""Check if requests are ready to be delivered."""
# BatchPriorityData contract is a special contract used specifically for checking if the requests have passed
# the priority timeout. It is not deployed anywhere, nor it needs to be deployed
batch_workable_contract = ledger_api.api.eth.contract(
abi=BATCH_PRIORITY_PASSED_DATA["abi"], bytecode=BATCH_PRIORITY_PASSED_DATA["bytecode"]
)

# Encode the input data (constructor params)
encoded_input_data = ledger_api.api.codec.encode_abi(
["address", "address[]"], [contract_address, request_ids]
encoded_input_data = ledger_api.api.codec.encode(
["address", "address", "uint256[]"], [contract_address, my_mech, request_ids]
)

# Concatenate the bytecode with the encoded input data to create the contract creation code
Expand All @@ -259,12 +265,12 @@ def has_priority_passed(
# Call the function with the contract creation code
# Note that we are not sending any transaction, we are just calling the function
# This is a special contract creation code that will return some result
encoded_strategies = ledger_api.api.eth.call({"data": contract_creation_code})
encoded_req_ids = ledger_api.api.eth.call({"data": contract_creation_code})

# Decode the raw response
# the decoding returns a Tuple with a single element so we need to access the first element of the tuple,
request_ids = ledger_api.api.codec.decode_abi(
["uint256[]"], encoded_strategies
request_ids = ledger_api.api.codec.decode(
["uint256[]"], encoded_req_ids
)[0]
return dict(request_ids=request_ids)

Expand All @@ -274,6 +280,7 @@ def get_undelivered_reqs(
cls,
ledger_api: LedgerApi,
contract_address: str,
my_mech: str,
from_block: BlockIdentifier = "earliest",
to_block: BlockIdentifier = "latest",
max_block_window: int = 1000,
Expand Down Expand Up @@ -306,7 +313,7 @@ def get_undelivered_reqs(
pending_tasks.append(request)

request_ids = [req["requestId"] for req in pending_tasks]
eligible_request_ids = cls.has_priority_passed(ledger_api, contract_address, request_ids).pop("request_ids")
eligible_request_ids = cls.has_priority_passed(ledger_api, contract_address, my_mech, request_ids).pop("request_ids")
pending_tasks = [req for req in pending_tasks if req["requestId"] in eligible_request_ids]
return {"data": pending_tasks}

Expand Down
2 changes: 1 addition & 1 deletion packages/valory/contracts/mech_marketplace/contract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fingerprint:
BatchPriorityPassedCheck.sol: bafybeie3hfpyss43sggqh5rjzwsqe7o37td4v4k6f3hlweiosnayyseo4i
__init__.py: bafybeigqedpnruwcvjarngql7yfnpqwozvvgzcei2xcrp7mjf4ccspa62y
build/MechMarketplace.json: bafybeiavaelxgltfzquszveskzn732c47tbkyoqd6gwbk3by6ky2n73rcm
contract.py: bafybeibuyclvqogginsusuf5h77iuhwsyustys2thptwcdilu6lk5oo7iq
contract.py: bafybeidwynzoz23yulmxdpe5ae6dx75ozbxm6v3zghzs7pyr6zfhkfkm4q
fingerprint_ignore_patterns: []
class_name: MechMarketplaceContract
contract_interface_paths:
Expand Down
Loading
Loading