BlockScience / aztec-gddt

Aztec Granular Design Digital Twin
Apache License 2.0
10 stars 0 forks source link

Potential Bug: In s_agent_transfer, for provers being slashed is their stake not what is supposed to be decreased? #298

Closed SeanMcOwen closed 2 months ago

SeanMcOwen commented 2 months ago

Current implementation reduces their balance instead of their staked amount

Code:

def s_agent_transfer(
    params: AztecModelParams,
    _2,
    _3,
    state: AztecModelState,
    signal: SignalEvolveProcess,
):
    """
    Logic for transferring tokens between agents and burn sink.
    """
    updated_agents = state["agents"].copy()
    transfers: Sequence[Transfer] = signal.get("transfers", [])  # type: ignore

    for transfer in transfers:
        if transfer.kind == TransferKind.conventional:
            updated_agents[transfer.source].balance -= transfer.amount
            updated_agents[transfer.destination].balance += transfer.amount
        elif transfer.kind == TransferKind.slash_sequencer:
            updated_agents[transfer.source].staked_amount -= transfer.amount
            updated_agents[transfer.destination].balance += transfer.amount
        elif transfer.kind == TransferKind.slash_prover:
            updated_agents[transfer.source].balance -= transfer.amount
            updated_agents[transfer.destination].balance += transfer.amount
        else:
            raise Exception(f'Transfer logic is undefined for {transfer.kind}')

    return ("agents", updated_agents)
jackhack00 commented 2 months ago

Provers don't "stake", instead provers provide a commitment_bond.

We made a decision to reduce complexity here. Option A was not chosen: When Prover provides commitment_bond, reduce balance, track bond, then later send balance back (or slash from there). Option B was chosen: When a Prover needs to provide commitment_bond, first check whether they have enough balance, then track Prover, if they misbehave we slash balance, if they behave we don't need to send back