mirror of
https://github.com/logos-messaging/logos-messaging-simulator.git
synced 2026-01-04 06:53:08 +00:00
Update block time to be the same as linea and add retries for token cast send functions (#111)
This commit is contained in:
parent
e5bb677abe
commit
f3e3ee5011
@ -24,7 +24,7 @@ services:
|
||||
--host=0.0.0.0
|
||||
--accounts=520
|
||||
--allow-origin=*
|
||||
--block-time=12
|
||||
--block-time=3
|
||||
--chain-id=1234
|
||||
--gas-limit=30000000
|
||||
--gas-price=1
|
||||
|
||||
@ -78,8 +78,9 @@ class NodeTokenInitializer:
|
||||
|
||||
def mint_tokens(self) -> bool:
|
||||
"""Mint tokens to this node's address using the node's own private key."""
|
||||
for attempt in range(3):
|
||||
try:
|
||||
logger.info(f"Minting {self.mint_amount} tokens to {self.node_address}")
|
||||
logger.info(f"Minting {self.mint_amount} tokens to {self.node_address} (attempt {attempt + 1}/3)")
|
||||
|
||||
# Use the node's own private key since mint() is public
|
||||
nonce = self.w3.eth.get_transaction_count(self.node_address)
|
||||
@ -109,17 +110,27 @@ class NodeTokenInitializer:
|
||||
logger.info(f"✓ Mint successful for node {self.node_index}")
|
||||
return True
|
||||
else:
|
||||
logger.error(f"✗ Mint failed for node {self.node_index}")
|
||||
return False
|
||||
logger.error(f"✗ Mint failed for node {self.node_index} (attempt {attempt + 1})")
|
||||
if attempt < 2:
|
||||
logger.info(f"Retrying mint in 5 seconds...")
|
||||
time.sleep(5)
|
||||
continue
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"✗ Mint failed for node {self.node_index}: {str(e)}")
|
||||
logger.error(f"✗ Mint failed for node {self.node_index} (attempt {attempt + 1}): {str(e)}")
|
||||
if attempt < 2:
|
||||
logger.info(f"Retrying mint in 5 seconds...")
|
||||
time.sleep(5)
|
||||
continue
|
||||
|
||||
logger.error(f"✗ Mint failed for node {self.node_index} after 3 attempts")
|
||||
return False
|
||||
|
||||
def approve_tokens(self) -> bool:
|
||||
"""Approve RLN contract to spend tokens."""
|
||||
for attempt in range(3):
|
||||
try:
|
||||
logger.info(f"Approving {self.mint_amount} tokens for contract {self.contract_address}")
|
||||
logger.info(f"Approving {self.mint_amount} tokens for contract {self.contract_address} (attempt {attempt + 1}/3)")
|
||||
|
||||
nonce = self.w3.eth.get_transaction_count(self.node_address)
|
||||
|
||||
@ -148,11 +159,20 @@ class NodeTokenInitializer:
|
||||
logger.info(f"✓ Approval successful for node {self.node_index}")
|
||||
return True
|
||||
else:
|
||||
logger.error(f"✗ Approval failed for node {self.node_index}")
|
||||
return False
|
||||
logger.error(f"✗ Approval failed for node {self.node_index} (attempt {attempt + 1})")
|
||||
if attempt < 2:
|
||||
logger.info(f"Retrying approval in 5 seconds...")
|
||||
time.sleep(5)
|
||||
continue
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"✗ Approval failed for node {self.node_index}: {str(e)}")
|
||||
logger.error(f"✗ Approval failed for node {self.node_index} (attempt {attempt + 1}): {str(e)}")
|
||||
if attempt < 2:
|
||||
logger.info(f"Retrying approval in 5 seconds...")
|
||||
time.sleep(5)
|
||||
continue
|
||||
|
||||
logger.error(f"✗ Approval failed for node {self.node_index} after 3 attempts")
|
||||
return False
|
||||
|
||||
def run(self) -> bool:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user