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: consensus deploy contract when finalized #712

Closed
Closed
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
12 changes: 6 additions & 6 deletions backend/consensus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ async def exec_transaction(
transaction_hash=transaction.hash,
)
)
self.update_contract_state(transaction, contract_snapshot_factory)

def update_contract_state(
self,
Expand Down Expand Up @@ -411,7 +410,6 @@ def commit_reveal_accept_transaction(
self,
transaction: Transaction,
transactions_processor: TransactionsProcessor,
contract_snapshot_factory: Callable[[str], ContractSnapshot],
):
# temporary, reuse existing code
# and add other possible states the transaction can go to
Expand Down Expand Up @@ -441,13 +439,15 @@ def commit_reveal_accept_transaction(
self.msg_handler,
)
transactions_processor.create_rollup_transaction(transaction.hash)
self.update_contract_state(transaction, contract_snapshot_factory)

def finalize_transaction(
self,
transaction: Transaction,
transactions_processor: TransactionsProcessor,
contract_snapshot_factory: Callable[[str], ContractSnapshot],
):
self.update_contract_state(transaction, contract_snapshot_factory)

consensus_data = transaction.consensus_data
leader_receipt = consensus_data["leader_receipt"]
# Finalize transaction
Expand Down Expand Up @@ -586,6 +586,9 @@ async def _appeal_window(self):
self.finalize_transaction(
transaction,
transactions_processor,
lambda contract_address: contract_snapshot_factory(
contract_address, session, transaction
),
)
session.commit()
else:
Expand All @@ -595,9 +598,6 @@ async def _appeal_window(self):
self.commit_reveal_accept_transaction(
transaction,
transactions_processor,
lambda contract_address: contract_snapshot_factory(
contract_address, session, transaction
),
)
session.commit()

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useTransactionsStore = defineStore('transactionsStore', () => {
data: tx,
});

if (currentTx.type === 'deploy' && tx.status === 'ACCEPTED') {
if (currentTx.type === 'deploy' && tx.status === 'FINALIZED') {
contractsStore.addDeployedContract({
contractId: currentTx.localContractId,
address: tx.data.contract_address,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/consensus/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ async def _appeal_window(
consensus.finalize_transaction(
transaction,
transactions_processor,
contract_snapshot_factory=contract_snapshot_factory,
)
else:
transactions_processor.set_transaction_appeal(transaction.hash, False)
consensus.commit_reveal_accept_transaction(
transaction,
transactions_processor,
contract_snapshot_factory=contract_snapshot_factory,
)

await asyncio.sleep(1)
Expand Down
Loading