Skip to content

Commit

Permalink
Dummy2 (leapdao#64)
Browse files Browse the repository at this point in the history
* Select random outputs to scale on multiple users

Problem: many users might handshake at the same time, selecting the same
output for their transaction. This will create double spends, failed
transactions, and unhappy users.

Solution: given that all outputs have enough tokens to spend, select and
use a random one for the transaction. This requires also to make
multiple outputs available to the contract address before the start of
the game.

* fix everything

* update contracts
  • Loading branch information
vrde authored Aug 8, 2019
1 parent 8e889fa commit d2b1fec
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/planeta/contracts/Air.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"address": "0x088f79464f9a4b6bfe9bc76b4388c1ee2b591d0d",
"code": "0x608060405234801561001057600080fd5b50600436106100445760e060020a60003504630aef446d8114610049578063c521fbac14610087578063f7c5823e1461012b575b600080fd5b6100856004803603608081101561005f57600080fd5b50803590600160a060020a036020820135811691604081013591606090910135166101e4565b005b6100856004803603602081101561009d57600080fd5b810190602081018135602060020a8111156100b757600080fd5b8201836020820111156100c957600080fd5b803590602001918460018302840111602060020a831117156100ea57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610419945050505050565b6100856004803603606081101561014157600080fd5b813591600160a060020a0360208201351691810190606081016040820135602060020a81111561017057600080fd5b82018360208201111561018257600080fd5b803590602001918460018302840111602060020a831117156101a357600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105b9945050505050565b6000839050600081600160a060020a0316636352211e856040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561023257600080fd5b505afa158015610246573d6000803e3d6000fd5b505050506040513d602081101561025c57600080fd5b50516040805160e060020a6323b872dd028152600160a060020a0383166004820152306024820152604481018990529051919250731f89fb2199220a350287b162b9d0a330a2d2efad9182916323b872dd9160648083019260209291908290030181600087803b1580156102cf57600080fd5b505af11580156102e3573d6000803e3d6000fd5b505050506040513d60208110156102f957600080fd5b50506040805160e060020a6337ebbc03028152600481018790529051600091600160a060020a038616916337ebbc0391602480820192602092909190829003018186803b15801561034957600080fd5b505afa15801561035d573d6000803e3d6000fd5b505050506040513d602081101561037357600080fd5b50516040805160e060020a63a9059cbb028152600160a060020a038816600482015260108b026024820152905191925073f64ffbc4a69631d327590f4151b79816a193a8c691829163a9059cbb9160448083019260209291908290030181600087803b1580156103e257600080fd5b505af11580156103f6573d6000803e3d6000fd5b505050506040513d602081101561040c57600080fd5b5050505050505050505050565b600061043b6001606060020a0319606060020a3002168363ffffffff6106e816565b9050600160a060020a03811673af0939af286a35dbfab7ded7c777a5f6e8be26a8146104ac576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a6370a08231028152306004820152905173f64ffbc4a69631d327590f4151b79816a193a8c69160009183916370a08231916024808301926020929190829003018186803b15801561050557600080fd5b505afa158015610519573d6000803e3d6000fd5b505050506040513d602081101561052f57600080fd5b50516040805160e060020a63a9059cbb028152306004820152602481018390529051919250600160a060020a0384169163a9059cbb916044808201926020929091908290030181600087803b15801561058757600080fd5b505af115801561059b573d6000803e3d6000fd5b505050506040513d60208110156105b157600080fd5b505050505050565b60006105db6001606060020a0319606060020a3002168363ffffffff6106e816565b9050600160a060020a03811673af0939af286a35dbfab7ded7c777a5f6e8be26a81461064c576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a63a9059cbb028152600160a060020a038516600482015260248101869052905173f64ffbc4a69631d327590f4151b79816a193a8c691829163a9059cbb916044808201926020929091908290030181600087803b1580156106b557600080fd5b505af11580156106c9573d6000803e3d6000fd5b505050506040513d60208110156106df57600080fd5b50505050505050565b6000806000808451604114151561070557600093505050506107ba565b50505060208201516040830151606084015160001a601b60ff8216101561072a57601b015b8060ff16601b1415801561074257508060ff16601c14155b1561075357600093505050506107ba565b6040805160008152602080820180845289905260ff8416828401526060820186905260808201859052915160019260a0808401939192601f1981019281900390910190855afa1580156107aa573d6000803e3d6000fd5b5050506020604051035193505050505b9291505056fea165627a7a72305820ff2c1a5f5becc754bd90facfa8061989f3d3a9574cb67b0cab9973cee0703f060029",
"address": "0x5380fb2ed21580964191856479c2761c1eabe14f",
"code": "0x608060405234801561001057600080fd5b50600436106100445760e060020a60003504630aef446d8114610049578063c521fbac14610087578063f7c5823e1461012b575b600080fd5b6100856004803603608081101561005f57600080fd5b50803590600160a060020a036020820135811691604081013591606090910135166101e4565b005b6100856004803603602081101561009d57600080fd5b810190602081018135602060020a8111156100b757600080fd5b8201836020820111156100c957600080fd5b803590602001918460018302840111602060020a831117156100ea57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610497945050505050565b6100856004803603606081101561014157600080fd5b813591600160a060020a0360208201351691810190606081016040820135602060020a81111561017057600080fd5b82018360208201111561018257600080fd5b803590602001918460018302840111602060020a831117156101a357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610637945050505050565b6000839050600081600160a060020a0316636352211e856040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561023257600080fd5b505afa158015610246573d6000803e3d6000fd5b505050506040513d602081101561025c57600080fd5b50516040805160e060020a6323b872dd028152600160a060020a0383166004820152306024820152604481018990529051919250731f89fb2199220a350287b162b9d0a330a2d2efad9182916323b872dd9160648083019260209291908290030181600087803b1580156102cf57600080fd5b505af11580156102e3573d6000803e3d6000fd5b505050506040513d60208110156102f957600080fd5b50506040805160e060020a6337ebbc03028152600481018790529051600091600160a060020a038616916337ebbc0391602480820192602092909190829003018186803b15801561034957600080fd5b505afa15801561035d573d6000803e3d6000fd5b505050506040513d602081101561037357600080fd5b50519050600160a060020a03841663a983d43f8761039d8466038d7ea4c6800060108e0204610766565b6040518363ffffffff1660e060020a0281526004018083815260200182815260200192505050600060405180830381600087803b1580156103dd57600080fd5b505af11580156103f1573d6000803e3d6000fd5b50506040805160e060020a63a9059cbb028152600160a060020a038916600482015260108c026024820152905173f64ffbc4a69631d327590f4151b79816a193a8c6935083925063a9059cbb916044808201926020929091908290030181600087803b15801561046057600080fd5b505af1158015610474573d6000803e3d6000fd5b505050506040513d602081101561048a57600080fd5b5050505050505050505050565b60006104b96001606060020a0319606060020a3002168363ffffffff6107f216565b9050600160a060020a03811673af0939af286a35dbfab7ded7c777a5f6e8be26a81461052a576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a6370a08231028152306004820152905173f64ffbc4a69631d327590f4151b79816a193a8c69160009183916370a08231916024808301926020929190829003018186803b15801561058357600080fd5b505afa158015610597573d6000803e3d6000fd5b505050506040513d60208110156105ad57600080fd5b50516040805160e060020a63a9059cbb028152306004820152602481018390529051919250600160a060020a0384169163a9059cbb916044808201926020929091908290030181600087803b15801561060557600080fd5b505af1158015610619573d6000803e3d6000fd5b505050506040513d602081101561062f57600080fd5b505050505050565b60006106596001606060020a0319606060020a3002168363ffffffff6107f216565b9050600160a060020a03811673af0939af286a35dbfab7ded7c777a5f6e8be26a8146106ca576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a63a9059cbb028152600160a060020a038516600482015260248101869052905173f64ffbc4a69631d327590f4151b79816a193a8c691829163a9059cbb916044808201926020929091908290030181600087803b15801561073357600080fd5b505af1158015610747573d6000803e3d6000fd5b505050506040513d602081101561075d57600080fd5b50505050505050565b600080610772846108ca565b905082810163ffffffff808316908216116107cc576040805160e560020a62461bcd02815260206004820152600f6024820152608860020a6e627566666572206f766572666c6f7702604482015290519081900360640190fd5b602060020a63ffffffff9091160267ffffffff0000000019909416939093179392505050565b6000806000808451604114151561080f57600093505050506108c4565b50505060208201516040830151606084015160001a601b60ff8216101561083457601b015b8060ff16601b1415801561084c57508060ff16601c14155b1561085d57600093505050506108c4565b6040805160008152602080820180845289905260ff8416828401526060820186905260808201859052915160019260a0808401939192601f1981019281900390910190855afa1580156108b4573d6000803e3d6000fd5b5050506020604051035193505050505b92915050565b602060020a90049056fea165627a7a723058209d34e4bafbee36beed8190a243c2c952d1f0a199b59d02faa7de6caddcb761690029",
"abi": [
{
"constant": false,
Expand Down
4 changes: 2 additions & 2 deletions src/planeta/contracts/Earth.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"address": "0x7e0d9c560471f773dc3949bcc116bb6abec8dc0d",
"code": "0x608060405234801561001057600080fd5b50600436106100445760e060020a600035046394d615b58114610049578063d43491371461007d578063f67fcc4c14610144575b600080fd5b61007b6004803603608081101561005f57600080fd5b5080359060ff6020820135169060408101359060600135610170565b005b61007b600480360360c081101561009357600080fd5b813591602081013591810190606081016040820135602060020a8111156100b957600080fd5b8201836020820111156100cb57600080fd5b803590602001918460018302840111602060020a831117156100ec57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550508235935050600160a060020a036020830135811692604001351690506102eb565b61007b6004803603606081101561015a57600080fd5b5060ff813516906020810135906040013561088a565b604080516000815260208082018084523060a060020a890217905260ff8616828401526060820185905260808201849052915173af0939af286a35dbfab7ded7c777a5f6e8be26a89260019260a081810193601f1981019281900390910190855afa1580156101e3573d6000803e3d6000fd5b50505060206040510351600160a060020a0316141515610248576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a63a9059cbb02815273088f79464f9a4b6bfe9bc76b4388c1ee2b591d0d600482015260248101869052905173f64ffbc4a69631d327590f4151b79816a193a8c69163a9059cbb9160448083019260209291908290030181600087803b1580156102b957600080fd5b505af11580156102cd573d6000803e3d6000fd5b505050506040513d60208110156102e357600080fd5b505050505050565b6000829050600066038d7ea4c6800082600160a060020a03166337ebbc038a6040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561034157600080fd5b505afa158015610355573d6000803e3d6000fd5b505050506040513d602081101561036b57600080fd5b505163ffffffff9081169089160302905068015af1d78b58c400008111156103d3576040805160e560020a62461bcd0281526020600482015260106024820152608160020a6f34b73b30b634b21032b6b4b9b9b4b7b702604482015290519081900360640190fd5b6000731f89fb2199220a350287b162b9d0a330a2d2efad905080600160a060020a031663a9059cbb84600160a060020a0316636352211e8c6040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561044257600080fd5b505afa158015610456573d6000803e3d6000fd5b505050506040513d602081101561046c57600080fd5b505168015af1d78b58c40000670853a0d2313c00008602046040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b1580156104d657600080fd5b505af11580156104ea573d6000803e3d6000fd5b505050506040513d602081101561050057600080fd5b50506040805160e160020a6331a9108f0281526004810188905290518591600160a060020a038085169263a9059cbb9291851691636352211e916024808301926020929190829003018186803b15801561055957600080fd5b505afa15801561056d573d6000803e3d6000fd5b505050506040513d602081101561058357600080fd5b505168015af1d78b58c40000670853a0d2313c00008702046040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b1580156105ed57600080fd5b505af1158015610601573d6000803e3d6000fd5b505050506040513d602081101561061757600080fd5b505060405160e060020a6336c9c457028152600481018b8152602482018b90526060604483019081528a5160648401528a51600160a060020a038816936336c9c457938f938f938f9360840190602085019080838360005b8381101561068757818101518382015260200161066f565b50505050905090810190601f1680156106b45780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156106d557600080fd5b505af11580156106e9573d6000803e3d6000fd5b50505050600081600160a060020a03166337ebbc03896040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561073657600080fd5b505afa15801561074a573d6000803e3d6000fd5b505050506040513d602081101561076057600080fd5b50516040805160e060020a63a983d43f028152600481018b905266038d7ea4c680008704830160248201529051919250600160a060020a0384169163a983d43f9160448082019260009290919082900301818387803b1580156107c257600080fd5b505af11580156107d6573d6000803e3d6000fd5b50506040805160e060020a63a9059cbb02815273088f79464f9a4b6bfe9bc76b4388c1ee2b591d0d6004820152600288026024820152905173f64ffbc4a69631d327590f4151b79816a193a8c6935083925063a9059cbb916044808201926020929091908290030181600087803b15801561085057600080fd5b505af1158015610864573d6000803e3d6000fd5b505050506040513d602081101561087a57600080fd5b5050505050505050505050505050565b604080516000815260208082018084526001606060020a0319606060020a300216905260ff8616828401526060820185905260808201849052915173af0939af286a35dbfab7ded7c777a5f6e8be26a89260019260a080820193601f1981019281900390910190855afa158015610905573d6000803e3d6000fd5b50505060206040510351600160a060020a031614151561096a576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a6370a082310281523060048201819052915173f64ffbc4a69631d327590f4151b79816a193a8c692839263a9059cbb9284916370a08231916024808301926020929190829003018186803b1580156109ca57600080fd5b505afa1580156109de573d6000803e3d6000fd5b505050506040513d60208110156109f457600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a03909316600484015260248301919091525160448083019260209291908290030181600087803b1580156102b957600080fdfea165627a7a723058207a1e488a9179ae4f4f53903251a17ef4970889e7ddcafb0a335ebc79ae2100210029",
"address": "0x74222249ce72d417ae1793970b1a61a69996f52b",
"code": "0x608060405234801561001057600080fd5b50600436106100445760e060020a600035046394d615b58114610049578063d43491371461007d578063f67fcc4c14610144575b600080fd5b61007b6004803603608081101561005f57600080fd5b5080359060ff6020820135169060408101359060600135610170565b005b61007b600480360360c081101561009357600080fd5b813591602081013591810190606081016040820135602060020a8111156100b957600080fd5b8201836020820111156100cb57600080fd5b803590602001918460018302840111602060020a831117156100ec57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550508235935050600160a060020a036020830135811692604001351690506102eb565b61007b6004803603606081101561015a57600080fd5b5060ff813516906020810135906040013561088a565b604080516000815260208082018084523060a060020a890217905260ff8616828401526060820185905260808201849052915173af0939af286a35dbfab7ded7c777a5f6e8be26a89260019260a081810193601f1981019281900390910190855afa1580156101e3573d6000803e3d6000fd5b50505060206040510351600160a060020a0316141515610248576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a63a9059cbb028152735380fb2ed21580964191856479c2761c1eabe14f600482015260248101869052905173f64ffbc4a69631d327590f4151b79816a193a8c69163a9059cbb9160448083019260209291908290030181600087803b1580156102b957600080fd5b505af11580156102cd573d6000803e3d6000fd5b505050506040513d60208110156102e357600080fd5b505050505050565b6000829050600066038d7ea4c6800082600160a060020a03166337ebbc038a6040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561034157600080fd5b505afa158015610355573d6000803e3d6000fd5b505050506040513d602081101561036b57600080fd5b505163ffffffff9081169089160302905068015af1d78b58c400008111156103d3576040805160e560020a62461bcd0281526020600482015260106024820152608160020a6f34b73b30b634b21032b6b4b9b9b4b7b702604482015290519081900360640190fd5b6000731f89fb2199220a350287b162b9d0a330a2d2efad905080600160a060020a031663a9059cbb84600160a060020a0316636352211e8c6040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561044257600080fd5b505afa158015610456573d6000803e3d6000fd5b505050506040513d602081101561046c57600080fd5b505168015af1d78b58c40000670853a0d2313c00008602046040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b1580156104d657600080fd5b505af11580156104ea573d6000803e3d6000fd5b505050506040513d602081101561050057600080fd5b50506040805160e160020a6331a9108f0281526004810188905290518591600160a060020a038085169263a9059cbb9291851691636352211e916024808301926020929190829003018186803b15801561055957600080fd5b505afa15801561056d573d6000803e3d6000fd5b505050506040513d602081101561058357600080fd5b505168015af1d78b58c40000670853a0d2313c00008702046040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b1580156105ed57600080fd5b505af1158015610601573d6000803e3d6000fd5b505050506040513d602081101561061757600080fd5b505060405160e060020a6336c9c457028152600481018b8152602482018b90526060604483019081528a5160648401528a51600160a060020a038816936336c9c457938f938f938f9360840190602085019080838360005b8381101561068757818101518382015260200161066f565b50505050905090810190601f1680156106b45780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156106d557600080fd5b505af11580156106e9573d6000803e3d6000fd5b50505050600081600160a060020a03166337ebbc03896040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561073657600080fd5b505afa15801561074a573d6000803e3d6000fd5b505050506040513d602081101561076057600080fd5b50516040805160e060020a63a983d43f028152600481018b905266038d7ea4c680008704830160248201529051919250600160a060020a0384169163a983d43f9160448082019260009290919082900301818387803b1580156107c257600080fd5b505af11580156107d6573d6000803e3d6000fd5b50506040805160e060020a63a9059cbb028152735380fb2ed21580964191856479c2761c1eabe14f6004820152600288026024820152905173f64ffbc4a69631d327590f4151b79816a193a8c6935083925063a9059cbb916044808201926020929091908290030181600087803b15801561085057600080fd5b505af1158015610864573d6000803e3d6000fd5b505050506040513d602081101561087a57600080fd5b5050505050505050505050505050565b604080516000815260208082018084526001606060020a0319606060020a300216905260ff8616828401526060820185905260808201849052915173af0939af286a35dbfab7ded7c777a5f6e8be26a89260019260a080820193601f1981019281900390910190855afa158015610905573d6000803e3d6000fd5b50505060206040510351600160a060020a031614151561096a576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a6370a082310281523060048201819052915173f64ffbc4a69631d327590f4151b79816a193a8c692839263a9059cbb9284916370a08231916024808301926020929190829003018186803b1580156109ca57600080fd5b505afa1580156109de573d6000803e3d6000fd5b505050506040513d60208110156109f457600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a03909316600484015260248301919091525160448083019260209291908290030181600087803b1580156102b957600080fdfea165627a7a723058203d8c3932f21f5b9af2da82cde4e5ed34d3b77f2796e3c8444ba18181d3693eda0029",
"abi": [
{
"constant": false,
Expand Down
Loading

0 comments on commit d2b1fec

Please sign in to comment.