Skip to content

Fix/mech support #121

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 0 additions & 4 deletions operate/quickstart/run_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@
"quickstart_beta_mech_marketplace_expert_8": "trader",
"mech_marketplace": "mech",
"marketplace_supply_alpha": "mech",
"marketplace_demand_alpha_1": "mech",
"marketplace_demand_alpha_2": "mech",
},
Chain.OPTIMISTIC: {
"optimus_alpha_2": "optimus",
Expand All @@ -111,8 +109,6 @@
Chain.BASE: {
"meme_base_alpha_2": "memeooorr",
"marketplace_supply_alpha": "mech",
"marketplace_demand_alpha_1": "mech",
"marketplace_demand_alpha_2": "mech",
"agents_fun_1": "memeooorr",
"agents_fun_2": "memeooorr",
"agents_fun_3": "memeooorr",
Expand Down
25 changes: 9 additions & 16 deletions operate/services/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,7 @@ def load_or_create(
)

if not service.keys:
service.keys = [
self.keys_manager.get(self.keys_manager.create())
for _ in range(service.helper.config.number_of_agents)
]
service.keys = [self.keys_manager.get(self.keys_manager.create())]
service.store()

return service
Expand Down Expand Up @@ -265,10 +262,7 @@ def create(
)

if not service.keys:
service.keys = [
self.keys_manager.get(self.keys_manager.create())
for _ in range(service.helper.config.number_of_agents)
]
service.keys = [self.keys_manager.get(self.keys_manager.create())]
service.store()

return service
Expand Down Expand Up @@ -437,7 +431,7 @@ def _deploy_service_onchain( # pylint: disable=too-many-statements,too-many-loc
ocm.mint(
package_path=service.package_absolute_path_absolute_path,
agent_id=staking_params["agent_ids"][0],
number_of_slots=service.helper.config.number_of_agents,
number_of_slots=1,
cost_of_bond=(
staking_params["min_staking_deposit"]
if user_params.use_staking
Expand Down Expand Up @@ -707,10 +701,9 @@ def _deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,to
protocol_asset_requirements = self._compute_protocol_asset_requirements(
service_config_id, chain
)
protocol_asset_requirements[target_staking_params["staking_token"]] = (
target_staking_params["min_staking_deposit"]
* service.helper.config.number_of_agents
)
protocol_asset_requirements[
target_staking_params["staking_token"]
] = target_staking_params["min_staking_deposit"]
else:
protocol_asset_requirements = {}

Expand Down Expand Up @@ -791,7 +784,7 @@ def _deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,to
sftxb.get_mint_tx_data(
package_path=service.package_absolute_path,
agent_id=agent_id,
number_of_slots=service.helper.config.number_of_agents,
number_of_slots=1,
cost_of_bond=(
target_staking_params["min_staking_deposit"]
if user_params.use_staking
Expand Down Expand Up @@ -841,7 +834,7 @@ def _deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,to
sftxb.get_mint_tx_data(
package_path=service.package_absolute_path,
agent_id=agent_id,
number_of_slots=service.helper.config.number_of_agents,
number_of_slots=1,
cost_of_bond=(
target_staking_params["min_staking_deposit"]
if user_params.use_staking
Expand Down Expand Up @@ -2504,7 +2497,7 @@ def _compute_protocol_asset_requirements( # pylint: disable=too-many-locals
chain_config = service.chain_configs[chain]
user_params = chain_config.chain_data.user_params
ledger_config = chain_config.ledger_config
number_of_agents = service.helper.config.number_of_agents
number_of_agents = 1
os.environ["CUSTOM_CHAIN_RPC"] = ledger_config.rpc
sftxb = self.get_eth_safe_tx_builder(ledger_config=ledger_config)
service_asset_requirements: defaultdict = defaultdict(int)
Expand Down
6 changes: 3 additions & 3 deletions operate/services/utils/mech.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def deploy_mech(sftxb: EthSafeTxBuilder, service: Service) -> Tuple[str, str]:
mech_type
]

# 0.01xDAI hardcoded for price
# better to be configurable and part of local config
mech_request_price = unit_to_wei(0.01)
mech_request_price = unit_to_wei(
float(service.env_variables.get("MECH_REQUEST_PRICE", {}).get("value", 0.01))
)
contract = sftxb.ledger_api.api.eth.contract(
address=Web3.to_checksum_address(mech_marketplace_address), abi=abi
)
Expand Down
Loading