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: appeals implement sequential appeals fail #637

Merged
merged 24 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
021f10e
feat: add rollup transaction db table
kstroobants Oct 22, 2024
eca17e5
fix: drop audit table, change id and nonce of rollup, only make one f…
kstroobants Oct 23, 2024
9184749
create rollup transaction for every validator
kstroobants Nov 6, 2024
6daee80
add function to mock in consensus test
kstroobants Nov 6, 2024
90ea2c1
feat: add appeal window, accepted queue, basic test
kstroobants Nov 7, 2024
bb30590
fix: old tests were stuck on accepted state, add usage of thread
kstroobants Nov 7, 2024
1e1958c
refactor consensus into states
kstroobants Nov 11, 2024
2708f13
feat: added appeal flow when transaction is accepted including the lo…
kstroobants Nov 13, 2024
e3fffde
fix: adding tests for appeals and fixing minor bugs
kstroobants Nov 15, 2024
3d00e34
refactor: merge main and PR #573 into this branch
kstroobants Nov 18, 2024
f5c3af1
feat: add appeal_failed in db, select new validators when appealed ba…
kstroobants Nov 24, 2024
27624bb
docs: cleanup consensus mechanism base file
kstroobants Nov 24, 2024
d315fd1
test: checking the number of validators for different appeals
kstroobants Nov 25, 2024
b843377
refactor: merge 593-appeals-add-validators-when-appealed into 604-app…
kstroobants Dec 2, 2024
be2be7d
refactor: merge main into 604-appeals-implement-sequential-appeals-fail
kstroobants Dec 12, 2024
afb13f6
refactor: merging changed file permissions
kstroobants Dec 12, 2024
1311304
Merge branch 'main' into 604-appeals-implement-sequential-appeals-fail
kstroobants Dec 12, 2024
a14ef91
fix: appealing a write method gave a KeyError because of wrong conver…
kstroobants Dec 12, 2024
70a85cf
docs: update transaction_processor argument description
kstroobants Dec 12, 2024
f34870e
fix: all appeals disagreed because of pending_transactions type
kstroobants Dec 12, 2024
3601ccd
docs: describe calculation of get_extra_validators
kstroobants Dec 13, 2024
62bce0a
refactor: make calculation in get_extra_validators clearer
kstroobants Dec 13, 2024
93eb175
refactor: make get_extra_validators more clear
kstroobants Dec 16, 2024
569b038
Merge branch 'main' into 604-appeals-implement-sequential-appeals-fail
kstroobants Dec 16, 2024
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ BACKEND_BUILD_TARGET = 'debug' # change to 'prod' or remove to run in pro
HARDHAT_URL = 'http://hardhat'
HARDHAT_PORT = '8545'
HARDHAT_PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'

# LLM Providers Configuration
# If you want to use OpenAI LLMs, add your key here
OPENAIKEY = '<add_your_openai_api_key_here>'
Expand Down
516 changes: 458 additions & 58 deletions backend/consensus/base.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""appeal_failed

Revision ID: 2a4ac5eb9455
Revises: b9421e9f12aa
Create Date: 2024-11-22 09:48:50.048787

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "2a4ac5eb9455"
down_revision: Union[str, None] = "b9421e9f12aa"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"transactions", sa.Column("appeal_failed", sa.Integer(), nullable=True)
)
# Set all existing 'appeal_failed' values to 0
op.execute("UPDATE transactions SET appeal_failed = 0 WHERE appeal_failed IS NULL")
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("transactions", "appeal_failed")
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions backend/database_handler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Transactions(Base):
s: Mapped[Optional[int]] = mapped_column(Integer)
v: Mapped[Optional[int]] = mapped_column(Integer)
ghost_contract_address: Mapped[Optional[str]] = mapped_column(String(255))
appeal_failed: Mapped[Optional[int]] = mapped_column(Integer)

# Relationship for triggered transactions
triggered_by_hash: Mapped[Optional[str]] = mapped_column(
Expand Down
10 changes: 10 additions & 0 deletions backend/database_handler/transactions_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def _parse_transaction_data(transaction_data: Transactions) -> dict:
"ghost_contract_address": transaction_data.ghost_contract_address,
"appealed": transaction_data.appealed,
"timestamp_accepted": transaction_data.timestamp_accepted,
"appeal_failed": transaction_data.appeal_failed,
}

@staticmethod
Expand Down Expand Up @@ -225,6 +226,7 @@ def insert_transaction(
ghost_contract_address=ghost_contract_address,
appealed=False,
timestamp_accepted=None,
appeal_failed=0,
)

self.session.add(new_transaction)
Expand Down Expand Up @@ -356,3 +358,11 @@ def set_transaction_timestamp_accepted(
transaction.timestamp_accepted = timestamp_accepted
else:
transaction.timestamp_accepted = int(time.time())

def set_transaction_appeal_failed(self, transaction_hash: str, appeal_failed: int):
if appeal_failed < 0:
raise ValueError("appeal_failed must be a non-negative integer")
transaction = (
self.session.query(Transactions).filter_by(hash=transaction_hash).one()
)
transaction.appeal_failed = appeal_failed
3 changes: 3 additions & 0 deletions backend/domain/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Transaction:
ghost_contract_address: str | None = None
appealed: bool = False
timestamp_accepted: int | None = None
appeal_failed: int = 0

def to_dict(self):
return {
Expand All @@ -106,6 +107,7 @@ def to_dict(self):
"ghost_contract_address": self.ghost_contract_address,
"appealed": self.appealed,
"timestamp_accepted": self.timestamp_accepted,
"appeal_failed": self.appeal_failed,
}

@classmethod
Expand All @@ -130,4 +132,5 @@ def from_dict(cls, input: dict) -> "Transaction":
ghost_contract_address=input.get("ghost_contract_address"),
appealed=input.get("appealed"),
timestamp_accepted=input.get("timestamp_accepted"),
appeal_failed=input.get("appeal_failed", 0),
)
6 changes: 3 additions & 3 deletions backend/node/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ def from_dict(cls, input: dict) -> Optional["Receipt"]:
mode=ExecutionMode.from_string(input.get("mode")),
contract_state=input.get("contract_state"),
node_config=input.get("node_config"),
eq_outputs=input.get("eq_outputs"),
pending_transactions=tuple(
eq_outputs={int(k): v for k, v in input.get("eq_outputs", {}).items()},
pending_transactions=[
PendingTransaction.from_dict(pending_transaction)
for pending_transaction in input.get("pending_transactions", [])
),
],
)
else:
return None
Loading
Loading