Repository: Chia-Network/chia-blockchain
File: chia/full_node/mempool_manager.py (Python)

Code before:
        if spend.seconds_relative is not None:
            s = uint64(removal_coin_records[bytes32(spend.coin_id)].timestamp + spend.seconds_relative)
            ret.assert_seconds = max(ret.assert_seconds, s)

        if spend.before_height_relative is not None:
            h = uint32(
                removal_coin_records[bytes32(spend.coin_id)].confirmed_block_index + spend.before_height_relative
            )
            if ret.assert_before_height is not None:
                ret.assert_before_height = min(ret.assert_before_height, h)
            else:
                ret.assert_before_height = h

        if spend.before_seconds_relative is not None:
            s = uint64(removal_coin_records[bytes32(spend.coin_id)].timestamp + spend.before_seconds_relative)
            if ret.assert_before_seconds is not None:
                ret.assert_before_seconds = min(ret.assert_before_seconds, s)
            else:
                ret.assert_before_seconds = s

    return ret


@dataclass
class SpendBundleAddInfo:
    cost: uint64
    status: MempoolInclusionStatus
    removals: list[MempoolRemoveInfo]
    error: Optional[Err]


@dataclass
class NewPeakInfo:
    items: list[NewPeakItem]
    removals: list[MempoolRemoveInfo]


@dataclass
class NewPeakItem:
    transaction_id: bytes32
    spend_bundle: SpendBundle
    conds: SpendBundleConditions


# For block overhead cost calculation
QUOTE_BYTES = 2
QUOTE_EXECUTION_COST = 20


def is_atom_canonical(clvm_buffer: bytes, offset: int) -> tuple[int, bool]:
    b = clvm_buffer[offset]

Review comment (bug):
This is unrelated to the patch, it's a result of altering `add_spendbundle`'s failure path (addressed in the addendum).

Code after:
        if spend.seconds_relative is not None:
            s = uint64(removal_coin_records[bytes32(spend.coin_id)].timestamp + spend.seconds_relative)
            ret.assert_seconds = max(ret.assert_seconds, s)

        if spend.before_height_relative is not None:
            h = uint32(
                removal_coin_records[bytes32(spend.coin_id)].confirmed_block_index + spend.before_height_relative
            )
            if ret.assert_before_height is not None:
                ret.assert_before_height = min(ret.assert_before_height, h)
            else:
                ret.assert_before_height = h

        if spend.before_seconds_relative is not None:
            s = uint64(removal_coin_records[bytes32(spend.coin_id)].timestamp + spend.before_seconds_relative)
            if ret.assert_before_seconds is not None:
                ret.assert_before_seconds = min(ret.assert_before_seconds, s)
            else:
                ret.assert_before_seconds = s

    return ret


@dataclass
class SpendBundleAddInfo:
    cost: Optional[uint64]
    status: MempoolInclusionStatus
    removals: list[MempoolRemoveInfo]
    error: Optional[Err]


@dataclass
class NewPeakInfo:
    items: list[NewPeakItem]
    removals: list[MempoolRemoveInfo]


@dataclass
class NewPeakItem:
    transaction_id: bytes32
    spend_bundle: SpendBundle
    conds: SpendBundleConditions


# For block overhead cost calculation
QUOTE_BYTES = 2
QUOTE_EXECUTION_COST = 20


def is_atom_canonical(clvm_buffer: bytes, offset: int) -> tuple[int, bool]:
    b = clvm_buffer[offset]