fix: use explicit SQL UPDATE for balance changes and add value field mapping

Changed transaction failure logging from error to warning level in PoA proposer.
Removed immediate session.commit() after state transition as balance changes are now persisted via explicit SQL UPDATE statements.
Added "value" field mapping from "amount" in transaction normalization and PoA proposer to ensure state transition compatibility.
Replaced SQLAlchemy ORM balance updates with explicit SQL UPDATE statements using
This commit is contained in:
aitbc
2026-04-25 20:08:09 +02:00
parent 8d69dd6685
commit e4df4caaeb
3 changed files with 18 additions and 9 deletions

View File

@@ -278,18 +278,16 @@ class PoAProposer:
# Use original tx_data from mempool to preserve type and payload
tx_data_for_transition = tx.content.copy()
tx_data_for_transition["nonce"] = sender_account.nonce
# Map "amount" to "value" for state transition compatibility
tx_data_for_transition["value"] = tx_data_for_transition.get("amount", 0)
success, error_msg = state_transition.apply_transaction(
session, self._config.chain_id, tx_data_for_transition, tx.tx_hash
)
if not success:
self._logger.error(f"[PROPOSE] Failed to apply transaction {tx.tx_hash}: {error_msg}")
self._logger.warning(f"[PROPOSE] Failed to apply transaction {tx.tx_hash}: {error_msg}")
continue
# Commit the balance changes immediately after successful state transition
session.commit()
self._logger.info(f"[PROPOSE] Committed balance changes for tx {tx.tx_hash}")
# Check if transaction already exists in database
existing_tx = session.exec(
select(Transaction).where(