Files
aitbc/scripts/deployment/deploy_hermes_dao.py
aitbc 852f2e5a8a
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
CLI Tests / test-cli (push) Has been cancelled
Blockchain Synchronization Verification / sync-verification (push) Successful in 11s
Contract Performance Benchmarks / benchmark-gas-usage (push) Successful in 1m36s
Contract Performance Benchmarks / benchmark-execution-time (push) Successful in 1m24s
Contract Performance Benchmarks / benchmark-throughput (push) Successful in 1m25s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 2s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 5s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 3s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 2s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 3s
P2P Network Verification / p2p-verification (push) Successful in 2s
Smart Contract Tests / test-solidity (map[name:aitbc-contracts path:contracts]) (push) Failing after 1m28s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 21s
Smart Contract Tests / test-foundry (push) Failing after 20s
Smart Contract Tests / lint-solidity (push) Successful in 30s
Smart Contract Tests / deploy-contracts (push) Successful in 1m40s
Systemd Sync / sync-systemd (push) Successful in 26s
Contract Performance Benchmarks / compare-benchmarks (push) Successful in 4s
Rename openclaw to hermes across documentation and workflows
- Update workflow paths from docs/openclaw to docs/hermes
- Rename skill prefixes from openclaw-* to hermes-*
- Update agent skill references in refactoring and analysis docs
- Rename OPENCLAW_AITBC_MASTERY_PLAN.md to reflect hermes branding
- Update CLI examples and command references throughout documentation
2026-05-07 11:42:06 +02:00

286 lines
12 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
hermes DAO Deployment Script
Deploys and configures the complete hermes DAO governance system
"""
import asyncio
import json
import time
from web3 import Web3
from web3.contract import Contract
class hermesDAODeployment:
def __init__(self, web3_provider: str, private_key: str):
self.w3 = Web3(Web3.HTTPProvider(web3_provider))
self.account = self.w3.eth.account.from_key(private_key)
self.address = self.account.address
# Contract addresses (will be set after deployment)
self.dao_contract = None
self.agent_wallet_template = None
self.gpu_staking = None
self.timelock = None
self.governance_token = None
async def deploy_all(self, governance_token_address: str) -> dict:
"""Deploy complete hermes DAO system"""
print("🚀 Deploying hermes DAO Governance System...")
# 1. Deploy TimelockController
print("1⃣ Deploying TimelockController...")
self.timelock = await self.deploy_timelock()
# 2. Deploy hermesDAO
print("2⃣ Deploying hermesDAO...")
self.dao_contract = await self.deploy_dao(governance_token_address)
# 3. Deploy AgentWallet template
print("3⃣ Deploying AgentWallet template...")
self.agent_wallet_template = await self.deploy_agent_wallet_template()
# 4. Deploy GPUStaking
print("4⃣ Deploying GPUStaking...")
self.gpu_staking = await self.deploy_gpu_staking(governance_token_address)
# 5. Configure system
print("5⃣ Configuring system...")
await self.configure_system()
# 6. Create initial snapshot
print("6⃣ Creating initial voting snapshot...")
await self.create_initial_snapshot()
# 7. Register initial agents
print("7⃣ Registering initial agents...")
await self.register_initial_agents()
# 8. Create initial staking pool
print("8⃣ Creating initial staking pool...")
await self.create_staking_pool()
deployment_info = {
"dao_address": self.dao_contract.address,
"timelock_address": self.timelock.address,
"agent_wallet_template": self.agent_wallet_template.address,
"gpu_staking_address": self.gpu_staking.address,
"governance_token": governance_token_address,
"deployer": self.address,
"deployment_time": time.time(),
"network": self.w3.eth.chain_id
}
print("✅ hermes DAO deployment complete!")
return deployment_info
async def deploy_timelock(self) -> Contract:
"""Deploy TimelockController contract"""
# Timelock constructor parameters
min_delay = 2 * 24 * 60 * 60 # 2 days
proposers = [self.address] # Deployer as initial proposer
executors = [self.address] # Deployer as initial executor
# Timelock bytecode (simplified - use actual compiled bytecode)
timelock_bytecode = "0x..." # Actual bytecode needed
timelock_abi = [] # Actual ABI needed
# Deploy contract
contract = self.w3.eth.contract(abi=timelock_abi, bytecode=timelock_bytecode)
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'data': contract.constructor(min_delay, proposers, executors).encode_transaction_data(),
'gas': 3000000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
return self.w3.eth.contract(address=receipt.contractAddress, abi=timelock_abi)
async def deploy_dao(self, governance_token_address: str) -> Contract:
"""Deploy hermesDAO contract"""
# DAO bytecode and ABI (from compiled contract)
dao_bytecode = "0x..." # Actual bytecode needed
dao_abi = [] # Actual ABI needed
contract = self.w3.eth.contract(abi=dao_abi, bytecode=dao_bytecode)
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'data': contract.constructor(governance_token_address, self.timelock.address).encode_transaction_data(),
'gas': 5000000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
return self.w3.eth.contract(address=receipt.contractAddress, abi=dao_abi)
async def deploy_agent_wallet_template(self) -> Contract:
"""Deploy AgentWallet template contract"""
agent_wallet_bytecode = "0x..." # Actual bytecode needed
agent_wallet_abi = [] # Actual ABI needed
contract = self.w3.eth.contract(abi=agent_wallet_abi, bytecode=agent_wallet_bytecode)
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'data': contract.constructor(
self.address,
1, # PROVIDER role as default
self.dao_contract.address,
self.governance_token
).encode_transaction_data(),
'gas': 2000000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
return self.w3.eth.contract(address=receipt.contractAddress, abi=agent_wallet_abi)
async def deploy_gpu_staking(self, governance_token_address: str) -> Contract:
"""Deploy GPUStaking contract"""
gpu_staking_bytecode = "0x..." # Actual bytecode needed
gpu_staking_abi = [] # Actual ABI needed
contract = self.w3.eth.contract(abi=gpu_staking_abi, bytecode=gpu_staking_bytecode)
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'data': contract.constructor(governance_token_address).encode_transaction_data(),
'gas': 3000000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
return self.w3.eth.contract(address=receipt.contractAddress, abi=gpu_staking_abi)
async def configure_system(self):
"""Configure the deployed system"""
# Transfer timelock ownership to DAO
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'to': self.timelock.address,
'data': self.timelock.functions.transferOwnership(self.dao_contract.address).encode_transaction_data(),
'gas': 100000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
self.w3.eth.wait_for_transaction_receipt(tx_hash)
# Set up multi-sig signers
multi_sig_signers = [
self.address,
"0x1234567890123456789012345678901234567890", # Additional signer 1
"0x2345678901234567890123456789012345678901", # Additional signer 2
]
for signer in multi_sig_signers:
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'to': self.dao_contract.address,
'data': self.dao_contract.functions.addMultiSigSigner(signer).encode_transaction_data(),
'gas': 100000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
self.w3.eth.wait_for_transaction_receipt(tx_hash)
async def create_initial_snapshot(self):
"""Create initial voting snapshot"""
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'to': self.dao_contract.address,
'data': self.dao_contract.functions.createVotingSnapshot().encode_transaction_data(),
'gas': 200000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
self.w3.eth.wait_for_transaction_receipt(tx_hash)
async def register_initial_agents(self):
"""Register initial agent wallets"""
agent_configs = [
{"address": "0x3456789012345678901234567890123456789012", "role": 1}, # PROVIDER
{"address": "0x4567890123456789012345678901234567890123", "role": 2}, # CONSUMER
{"address": "0x5678901234567890123456789012345678901234", "role": 3}, # BUILDER
{"address": "0x6789012345678901234567890123456789012345", "role": 4}, # COORDINATOR
]
for config in agent_configs:
# Deploy agent wallet
agent_wallet = await self.deploy_agent_wallet(
config["address"],
config["role"]
)
# Register with DAO
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'to': self.dao_contract.address,
'data': self.dao_contract.functions.registerAgentWallet(
agent_wallet.address,
config["role"]
).encode_transaction_data(),
'gas': 200000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
self.w3.eth.wait_for_transaction_receipt(tx_hash)
async def deploy_agent_wallet(self, owner_address: str, role: int) -> Contract:
"""Deploy individual agent wallet"""
agent_wallet_bytecode = "0x..." # Actual bytecode needed
agent_wallet_abi = [] # Actual ABI needed
contract = self.w3.eth.contract(abi=agent_wallet_abi, bytecode=agent_wallet_bytecode)
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'data': contract.constructor(
owner_address,
role,
self.dao_contract.address,
self.governance_token
).encode_transaction_data(),
'gas': 2000000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
return self.w3.eth.contract(address=receipt.contractAddress, abi=agent_wallet_abi)
async def create_staking_pool(self):
"""Create initial GPU staking pool"""
tx_hash = self.w3.eth.send_transaction({
'from': self.address,
'to': self.gpu_staking.address,
'data': self.gpu_staking.functions.createPool(
"Initial GPU Pool",
1e15 # Base reward rate
).encode_transaction_data(),
'gas': 300000,
'gasPrice': self.w3.eth.gas_price,
'nonce': self.w3.eth.get_transaction_count(self.address)
})
self.w3.eth.wait_for_transaction_receipt(tx_hash)
async def main():
"""Main deployment function"""
# Configuration
WEB3_PROVIDER = "http://localhost:8545" # Local Ethereum node
PRIVATE_KEY = "0x..." # Deployer private key
GOVERNANCE_TOKEN = "0x..." # Existing AITBC token address
# Deploy system
deployer = hermesDAODeployment(WEB3_PROVIDER, PRIVATE_KEY)
deployment_info = await deployer.deploy_all(GOVERNANCE_TOKEN)
# Save deployment info
with open("hermes_dao_deployment.json", "w") as f:
json.dump(deployment_info, f, indent=2)
print(f"🎉 Deployment complete! Check hermes_dao_deployment.json for details")
if __name__ == "__main__":
asyncio.run(main())