mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
One market — a constant-product pool and a limit order book over the same ledger — deployed to the Go, C++ and Rust implementations, driven through one script by the same three keys, with the resulting book compared. The comparison is of contract storage, not of the block's state root. Three chains with three genesis allocations cannot share a state root however perfectly they agree, so comparing roots would report a disagreement on every run and mean nothing by it. Ten fixed slots are folded instead, two of which are themselves folds: every fill in match order, and every resting order. The fills fold is the point. Matching order is consensus: two nodes that produce the same fills in a different sequence hold different books and will match the next order differently, and a comparison of totals would call them equal. So the book is built with two asks at one price, separated only by arrival, and a third resting better — a correct sweep must take price first and arrival second. An agreement is worthless if disagreement was unreachable, so the harness runs the script a second time with those two asks arriving in the other order and nothing else changed. Every count and amount must come out identical and only the sequence differs. If the fold does not move under that, the harness says the comparison is not evidence rather than claiming a pass. Reads go through eth_getStorageAt alone because the three do not serve the same RPC: the C++ chain answers no eth_call, no receipts and no logs, and the Rust chain no logs. Inclusion is judged by the sender's accepted nonce — not a receipt, which two of three could not supply, and never the pending nonce, which counts transactions a bootstrapping node has admitted but not accepted. The three traders are pinned to the same addresses in the same roles on every chain. Both folds take msg.sender, so letting each genesis choose its own maker folds different addresses and reports a false disagreement about matching order; which account pays is answered per chain.
370 lines
5.5 KiB
JSON
370 lines
5.5 KiB
JSON
[
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "address[]",
|
|
"name": "traders",
|
|
"type": "address[]"
|
|
},
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "base_",
|
|
"type": "uint128"
|
|
},
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "quote_",
|
|
"type": "uint128"
|
|
}
|
|
],
|
|
"stateMutability": "nonpayable",
|
|
"type": "constructor"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "Dead",
|
|
"type": "error"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "Empty",
|
|
"type": "error"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "NotYours",
|
|
"type": "error"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "SelfTrade",
|
|
"type": "error"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "Unfunded",
|
|
"type": "error"
|
|
},
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "base_",
|
|
"type": "uint128"
|
|
},
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "quote_",
|
|
"type": "uint128"
|
|
}
|
|
],
|
|
"name": "addLiquidity",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "minted",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "nonpayable",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "book",
|
|
"outputs": [
|
|
{
|
|
"internalType": "bytes32",
|
|
"name": "",
|
|
"type": "bytes32"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "id",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"name": "cancel",
|
|
"outputs": [],
|
|
"stateMutability": "nonpayable",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "fillCount",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "fills",
|
|
"outputs": [
|
|
{
|
|
"internalType": "bytes32",
|
|
"name": "",
|
|
"type": "bytes32"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "liveOrders",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "nextId",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"name": "orders",
|
|
"outputs": [
|
|
{
|
|
"internalType": "address",
|
|
"name": "who",
|
|
"type": "address"
|
|
},
|
|
{
|
|
"internalType": "uint96",
|
|
"name": "price",
|
|
"type": "uint96"
|
|
},
|
|
{
|
|
"internalType": "uint96",
|
|
"name": "qty",
|
|
"type": "uint96"
|
|
},
|
|
{
|
|
"internalType": "bool",
|
|
"name": "buy",
|
|
"type": "bool"
|
|
},
|
|
{
|
|
"internalType": "bool",
|
|
"name": "live",
|
|
"type": "bool"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "bool",
|
|
"name": "buy",
|
|
"type": "bool"
|
|
},
|
|
{
|
|
"internalType": "uint96",
|
|
"name": "price",
|
|
"type": "uint96"
|
|
},
|
|
{
|
|
"internalType": "uint96",
|
|
"name": "qty",
|
|
"type": "uint96"
|
|
}
|
|
],
|
|
"name": "place",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "id",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "nonpayable",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "poolBase",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "poolQuote",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "poolShares",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "address",
|
|
"name": "",
|
|
"type": "address"
|
|
}
|
|
],
|
|
"name": "purse",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "base",
|
|
"type": "uint128"
|
|
},
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "quote",
|
|
"type": "uint128"
|
|
},
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "lockedBase",
|
|
"type": "uint128"
|
|
},
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "lockedQuote",
|
|
"type": "uint128"
|
|
},
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "shares",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "refusals",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "amount",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"name": "removeLiquidity",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "base_",
|
|
"type": "uint128"
|
|
},
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "quote_",
|
|
"type": "uint128"
|
|
}
|
|
],
|
|
"stateMutability": "nonpayable",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "bool",
|
|
"name": "buyBase",
|
|
"type": "bool"
|
|
},
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "amountIn",
|
|
"type": "uint128"
|
|
}
|
|
],
|
|
"name": "swap",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint128",
|
|
"name": "out",
|
|
"type": "uint128"
|
|
}
|
|
],
|
|
"stateMutability": "nonpayable",
|
|
"type": "function"
|
|
},
|
|
{
|
|
"inputs": [],
|
|
"name": "tradedQty",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function"
|
|
}
|
|
] |