@keep-network/tbtc-v2 0.1.1-dev.49 → 0.1.1-dev.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/artifacts/Bank.json +3 -3
  2. package/artifacts/Bridge.json +201 -114
  3. package/artifacts/Deposit.json +7 -7
  4. package/artifacts/EcdsaDkgValidator.json +1 -1
  5. package/artifacts/EcdsaInactivity.json +1 -1
  6. package/artifacts/Fraud.json +13 -12
  7. package/artifacts/KeepRegistry.json +1 -1
  8. package/artifacts/KeepStake.json +2 -2
  9. package/artifacts/KeepToken.json +2 -2
  10. package/artifacts/KeepTokenStaking.json +1 -1
  11. package/artifacts/MovingFunds.json +32 -9
  12. package/artifacts/NuCypherStakingEscrow.json +1 -1
  13. package/artifacts/NuCypherToken.json +2 -2
  14. package/artifacts/RandomBeaconStub.json +1 -1
  15. package/artifacts/Redemption.json +9 -9
  16. package/artifacts/ReimbursementPool.json +2 -2
  17. package/artifacts/Relay.json +9 -9
  18. package/artifacts/SortitionPool.json +2 -2
  19. package/artifacts/Sweep.json +7 -7
  20. package/artifacts/T.json +2 -2
  21. package/artifacts/TBTC.json +3 -3
  22. package/artifacts/TBTCToken.json +3 -3
  23. package/artifacts/TokenStaking.json +1 -1
  24. package/artifacts/TokenholderGovernor.json +9 -9
  25. package/artifacts/TokenholderTimelock.json +8 -8
  26. package/artifacts/VendingMachine.json +10 -10
  27. package/artifacts/VendingMachineKeep.json +1 -1
  28. package/artifacts/VendingMachineNuCypher.json +1 -1
  29. package/artifacts/WalletRegistry.json +2 -2
  30. package/artifacts/WalletRegistryGovernance.json +2 -2
  31. package/artifacts/Wallets.json +7 -7
  32. package/artifacts/solcInputs/{8c8e22c3576c135e48bf2abb6045923d.json → c0a2aa3c07bd118332a0dc765c7f6da0.json} +4 -4
  33. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  34. package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
  35. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
  36. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
  37. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  38. package/build/contracts/bridge/Bridge.sol/Bridge.json +115 -38
  39. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  40. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +10 -4
  41. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  42. package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
  43. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  44. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
  45. package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
  46. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  47. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
  48. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +15 -2
  49. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
  50. package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
  51. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
  52. package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
  53. package/build/contracts/bridge/Sweep.sol/Sweep.dbg.json +1 -1
  54. package/build/contracts/bridge/Sweep.sol/Sweep.json +2 -2
  55. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  56. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  57. package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
  58. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  59. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  60. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  61. package/contracts/bridge/Bridge.sol +68 -11
  62. package/contracts/bridge/BridgeState.sol +28 -6
  63. package/contracts/bridge/Fraud.sol +21 -5
  64. package/contracts/bridge/MovingFunds.sol +45 -0
  65. package/export.json +88 -6
  66. package/package.json +1 -1
@@ -105,8 +105,8 @@
105
105
  "type": "event"
106
106
  }
107
107
  ],
108
- "bytecode": "0x610fb261003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100565760003560e01c80634afbe4c91461005b57806399b0b8471461007d578063c87de7f41461009d578063d079fbb1146100bd575b600080fd5b81801561006757600080fd5b5061007b610076366004610d56565b6100dd565b005b81801561008957600080fd5b5061007b610098366004610da0565b610305565b8180156100a957600080fd5b5061007b6100b8366004610df1565b610526565b8180156100c957600080fd5b5061007b6100d8366004610e1d565b61064c565b60028401546001600160a01b0316331461014e5760405162461bcd60e51b815260206004820152602760248201527f43616c6c6572206973206e6f74207468652045434453412057616c6c657420526044820152666567697374727960c81b60648201526084015b60405180910390fd5b600061016261015d848461094b565b6109f5565b6bffffffffffffffffffffffff198116600090815260168701602052604081209192506002820154600160a01b900460ff1660058111156101a5576101a5610e4a565b146102185760405162461bcd60e51b815260206004820152602860248201527f45434453412077616c6c657420686173206265656e20616c726561647920726560448201527f67697374657265640000000000000000000000000000000000000000000000006064820152608401610145565b848155600281018054600160a01b63ffffffff42811668010000000000000000027fffffffffffffffffffffff00ffffffffffffffff00000000ffffffffffffffff90931692909217811790925560148881018054606087901c73ffffffffffffffffffffffffffffffffffffffff19909116178082559390930490911691906102a183610e76565b91906101000a81548163ffffffff021916908363ffffffff16021790555050816bffffffffffffffffffffffff1916857f2dbb47dce81d6b11cca1f1e3b10143d6f7e1e7e92d2dd9aacbb1f875379d308e60405160405180910390a3505050505050565b601483015460601b6bffffffffffffffffffffffff1990811690831614156103955760405162461bcd60e51b815260206004820152602c60248201527f4163746976652077616c6c65742063616e6e6f7420626520636f6e736964657260448201527f656420636c6f736561626c6500000000000000000000000000000000000000006064820152608401610145565b6bffffffffffffffffffffffff1982166000908152601684016020526040902060016002820154600160a01b900460ff1660058111156103d7576103d7610e4a565b1461042f5760405162461bcd60e51b815260206004820152602260248201527f45434453412077616c6c6574206d75737420626520696e204c69766520737461604482015261746560f01b6064820152608401610145565b601384015460028201546000916104639163ffffffff600160a01b9092048216916801000000000000000090910416610e9a565b63ffffffff16421015905080806104a357506013850154640100000000900467ffffffffffffffff16610497868686610a1c565b67ffffffffffffffff16105b6105155760405162461bcd60e51b815260206004820152603660248201527f57616c6c6574206e6565647320746f206265206f6c6420656e6f756768206f7260448201527f206861766520746f6f20666577207361746f73686973000000000000000000006064820152608401610145565b61051f8585610b54565b5050505050565b60028301546001600160a01b031633146105925760405162461bcd60e51b815260206004820152602760248201527f43616c6c6572206973206e6f74207468652045434453412057616c6c657420526044820152666567697374727960c81b6064820152608401610145565b60006105a161015d848461094b565b905060016bffffffffffffffffffffffff1982166000908152601686016020526040902060020154600160a01b900460ff1660058111156105e4576105e4610e4a565b1461063c5760405162461bcd60e51b815260206004820152602260248201527f45434453412077616c6c6574206d75737420626520696e204c69766520737461604482015261746560f01b6064820152608401610145565b6106468482610b54565b50505050565b6002820154604080517fcc56238800000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163cc562388916004808301926020929190829003018186803b1580156106ac57600080fd5b505afa1580156106c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e49190610ec2565b60038111156106f5576106f5610e4a565b146107685760405162461bcd60e51b815260206004820152602360248201527f57616c6c6574206372656174696f6e20616c726561647920696e2070726f677260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610145565b601482015460601b6bffffffffffffffffffffffff198116156108b3576000610792848385610a1c565b6bffffffffffffffffffffffff1983166000908152601686016020526040812060020154601387015492935063ffffffff680100000000000000009091048116926107de911683610e9a565b63ffffffff1642101590508080156108105750601386015467ffffffffffffffff640100000000909104811690841610155b8061083d5750601386015467ffffffffffffffff6c01000000000000000000000000909104811690841610155b6108af5760405162461bcd60e51b815260206004820152602660248201527f57616c6c6574206372656174696f6e20636f6e646974696f6e7320617265206e60448201527f6f74206d657400000000000000000000000000000000000000000000000000006064820152608401610145565b5050505b6040517f31fecb80caf1e1128496dd5a6f1083ba29fd5fe64c3fe04e2d1b6f9cfc27d5a390600090a18260020160009054906101000a90046001600160a01b03166001600160a01b03166372cc8c6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561092e57600080fd5b505af1158015610942573d6000803e3d6000fd5b50505050505050565b6060600061095a600284610eea565b61098557507f02000000000000000000000000000000000000000000000000000000000000006109a8565b507f03000000000000000000000000000000000000000000000000000000000000005b6040517fff00000000000000000000000000000000000000000000000000000000000000821660208201526021810185905260410160405160208183030381529060405291505092915050565b60006020600083516020850160025afa50602060006020600060035afa5050600c51919050565b6bffffffffffffffffffffffff19821660009081526016840160205260408120600101548015610b4c57808335610a596040860160208701610f0c565b610a696060870160408801610f32565b604051602001610ad69392919092835260e09190911b7fffffffff0000000000000000000000000000000000000000000000000000000016602083015260c01b7fffffffffffffffff000000000000000000000000000000000000000000000000166024820152602c0190565b6040516020818303038152906040528051906020012014610b395760405162461bcd60e51b815260206004820152601d60248201527f496e76616c69642077616c6c6574206d61696e205554584f20646174610000006044820152606401610145565b610b496060840160408501610f32565b91505b509392505050565b6bffffffffffffffffffffffff198116600090815260168301602052604090206001810154610b8c57610b878383610ca8565b610c24565b60028101805463ffffffff42166c01000000000000000000000000027fffffffffffffffffffffff00ffffffff00000000ffffffffffffffffffffffff909116177402000000000000000000000000000000000000000017905580546040516bffffffffffffffffffffffff19841691907fbdc9ce990a067e5fd3a5d8dfc68e27e9f221aaa3fe55265e0b7e93c460b3efe290600090a35b601483015460601b6bffffffffffffffffffffffff199081169083161415610c665760148301805473ffffffffffffffffffffffffffffffffffffffff191690555b60148381018054600160a01b900463ffffffff1691610c8483610f5c565b91906101000a81548163ffffffff021916908363ffffffff16021790555050505050565b6bffffffffffffffffffffffff198116600081815260168401602052604080822060028101805463ffffffff4216700100000000000000000000000000000000027fffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffff9091161774030000000000000000000000000000000000000000179055805491519093927f68cb496f5e64383745876664ef119840f154a729c03ba866b8aecb5c9f53d51691a3505050565b60008060008060808587031215610d6c57600080fd5b5050823594602084013594506040840135936060013592509050565b600060608284031215610d9a57600080fd5b50919050565b600080600060a08486031215610db557600080fd5b8335925060208401356bffffffffffffffffffffffff1981168114610dd957600080fd5b9150610de88560408601610d88565b90509250925092565b600080600060608486031215610e0657600080fd5b505081359360208301359350604090920135919050565b60008060808385031215610e3057600080fd5b82359150610e418460208501610d88565b90509250929050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600063ffffffff80831681811415610e9057610e90610e60565b6001019392505050565b600063ffffffff808316818516808303821115610eb957610eb9610e60565b01949350505050565b600060208284031215610ed457600080fd5b815160048110610ee357600080fd5b9392505050565b600082610f0757634e487b7160e01b600052601260045260246000fd5b500690565b600060208284031215610f1e57600080fd5b813563ffffffff81168114610ee357600080fd5b600060208284031215610f4457600080fd5b813567ffffffffffffffff81168114610ee357600080fd5b600063ffffffff821680610f7257610f72610e60565b600019019291505056fea264697066735822122017aeeb2a3ab4dc17f34c716ba3f7077d4cd4f099d76fb527459453add3950cfa64736f6c63430008090033",
109
- "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100565760003560e01c80634afbe4c91461005b57806399b0b8471461007d578063c87de7f41461009d578063d079fbb1146100bd575b600080fd5b81801561006757600080fd5b5061007b610076366004610d56565b6100dd565b005b81801561008957600080fd5b5061007b610098366004610da0565b610305565b8180156100a957600080fd5b5061007b6100b8366004610df1565b610526565b8180156100c957600080fd5b5061007b6100d8366004610e1d565b61064c565b60028401546001600160a01b0316331461014e5760405162461bcd60e51b815260206004820152602760248201527f43616c6c6572206973206e6f74207468652045434453412057616c6c657420526044820152666567697374727960c81b60648201526084015b60405180910390fd5b600061016261015d848461094b565b6109f5565b6bffffffffffffffffffffffff198116600090815260168701602052604081209192506002820154600160a01b900460ff1660058111156101a5576101a5610e4a565b146102185760405162461bcd60e51b815260206004820152602860248201527f45434453412077616c6c657420686173206265656e20616c726561647920726560448201527f67697374657265640000000000000000000000000000000000000000000000006064820152608401610145565b848155600281018054600160a01b63ffffffff42811668010000000000000000027fffffffffffffffffffffff00ffffffffffffffff00000000ffffffffffffffff90931692909217811790925560148881018054606087901c73ffffffffffffffffffffffffffffffffffffffff19909116178082559390930490911691906102a183610e76565b91906101000a81548163ffffffff021916908363ffffffff16021790555050816bffffffffffffffffffffffff1916857f2dbb47dce81d6b11cca1f1e3b10143d6f7e1e7e92d2dd9aacbb1f875379d308e60405160405180910390a3505050505050565b601483015460601b6bffffffffffffffffffffffff1990811690831614156103955760405162461bcd60e51b815260206004820152602c60248201527f4163746976652077616c6c65742063616e6e6f7420626520636f6e736964657260448201527f656420636c6f736561626c6500000000000000000000000000000000000000006064820152608401610145565b6bffffffffffffffffffffffff1982166000908152601684016020526040902060016002820154600160a01b900460ff1660058111156103d7576103d7610e4a565b1461042f5760405162461bcd60e51b815260206004820152602260248201527f45434453412077616c6c6574206d75737420626520696e204c69766520737461604482015261746560f01b6064820152608401610145565b601384015460028201546000916104639163ffffffff600160a01b9092048216916801000000000000000090910416610e9a565b63ffffffff16421015905080806104a357506013850154640100000000900467ffffffffffffffff16610497868686610a1c565b67ffffffffffffffff16105b6105155760405162461bcd60e51b815260206004820152603660248201527f57616c6c6574206e6565647320746f206265206f6c6420656e6f756768206f7260448201527f206861766520746f6f20666577207361746f73686973000000000000000000006064820152608401610145565b61051f8585610b54565b5050505050565b60028301546001600160a01b031633146105925760405162461bcd60e51b815260206004820152602760248201527f43616c6c6572206973206e6f74207468652045434453412057616c6c657420526044820152666567697374727960c81b6064820152608401610145565b60006105a161015d848461094b565b905060016bffffffffffffffffffffffff1982166000908152601686016020526040902060020154600160a01b900460ff1660058111156105e4576105e4610e4a565b1461063c5760405162461bcd60e51b815260206004820152602260248201527f45434453412077616c6c6574206d75737420626520696e204c69766520737461604482015261746560f01b6064820152608401610145565b6106468482610b54565b50505050565b6002820154604080517fcc56238800000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163cc562388916004808301926020929190829003018186803b1580156106ac57600080fd5b505afa1580156106c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e49190610ec2565b60038111156106f5576106f5610e4a565b146107685760405162461bcd60e51b815260206004820152602360248201527f57616c6c6574206372656174696f6e20616c726561647920696e2070726f677260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610145565b601482015460601b6bffffffffffffffffffffffff198116156108b3576000610792848385610a1c565b6bffffffffffffffffffffffff1983166000908152601686016020526040812060020154601387015492935063ffffffff680100000000000000009091048116926107de911683610e9a565b63ffffffff1642101590508080156108105750601386015467ffffffffffffffff640100000000909104811690841610155b8061083d5750601386015467ffffffffffffffff6c01000000000000000000000000909104811690841610155b6108af5760405162461bcd60e51b815260206004820152602660248201527f57616c6c6574206372656174696f6e20636f6e646974696f6e7320617265206e60448201527f6f74206d657400000000000000000000000000000000000000000000000000006064820152608401610145565b5050505b6040517f31fecb80caf1e1128496dd5a6f1083ba29fd5fe64c3fe04e2d1b6f9cfc27d5a390600090a18260020160009054906101000a90046001600160a01b03166001600160a01b03166372cc8c6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561092e57600080fd5b505af1158015610942573d6000803e3d6000fd5b50505050505050565b6060600061095a600284610eea565b61098557507f02000000000000000000000000000000000000000000000000000000000000006109a8565b507f03000000000000000000000000000000000000000000000000000000000000005b6040517fff00000000000000000000000000000000000000000000000000000000000000821660208201526021810185905260410160405160208183030381529060405291505092915050565b60006020600083516020850160025afa50602060006020600060035afa5050600c51919050565b6bffffffffffffffffffffffff19821660009081526016840160205260408120600101548015610b4c57808335610a596040860160208701610f0c565b610a696060870160408801610f32565b604051602001610ad69392919092835260e09190911b7fffffffff0000000000000000000000000000000000000000000000000000000016602083015260c01b7fffffffffffffffff000000000000000000000000000000000000000000000000166024820152602c0190565b6040516020818303038152906040528051906020012014610b395760405162461bcd60e51b815260206004820152601d60248201527f496e76616c69642077616c6c6574206d61696e205554584f20646174610000006044820152606401610145565b610b496060840160408501610f32565b91505b509392505050565b6bffffffffffffffffffffffff198116600090815260168301602052604090206001810154610b8c57610b878383610ca8565b610c24565b60028101805463ffffffff42166c01000000000000000000000000027fffffffffffffffffffffff00ffffffff00000000ffffffffffffffffffffffff909116177402000000000000000000000000000000000000000017905580546040516bffffffffffffffffffffffff19841691907fbdc9ce990a067e5fd3a5d8dfc68e27e9f221aaa3fe55265e0b7e93c460b3efe290600090a35b601483015460601b6bffffffffffffffffffffffff199081169083161415610c665760148301805473ffffffffffffffffffffffffffffffffffffffff191690555b60148381018054600160a01b900463ffffffff1691610c8483610f5c565b91906101000a81548163ffffffff021916908363ffffffff16021790555050505050565b6bffffffffffffffffffffffff198116600081815260168401602052604080822060028101805463ffffffff4216700100000000000000000000000000000000027fffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffff9091161774030000000000000000000000000000000000000000179055805491519093927f68cb496f5e64383745876664ef119840f154a729c03ba866b8aecb5c9f53d51691a3505050565b60008060008060808587031215610d6c57600080fd5b5050823594602084013594506040840135936060013592509050565b600060608284031215610d9a57600080fd5b50919050565b600080600060a08486031215610db557600080fd5b8335925060208401356bffffffffffffffffffffffff1981168114610dd957600080fd5b9150610de88560408601610d88565b90509250925092565b600080600060608486031215610e0657600080fd5b505081359360208301359350604090920135919050565b60008060808385031215610e3057600080fd5b82359150610e418460208501610d88565b90509250929050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600063ffffffff80831681811415610e9057610e90610e60565b6001019392505050565b600063ffffffff808316818516808303821115610eb957610eb9610e60565b01949350505050565b600060208284031215610ed457600080fd5b815160048110610ee357600080fd5b9392505050565b600082610f0757634e487b7160e01b600052601260045260246000fd5b500690565b600060208284031215610f1e57600080fd5b813563ffffffff81168114610ee357600080fd5b600060208284031215610f4457600080fd5b813567ffffffffffffffff81168114610ee357600080fd5b600063ffffffff821680610f7257610f72610e60565b600019019291505056fea264697066735822122017aeeb2a3ab4dc17f34c716ba3f7077d4cd4f099d76fb527459453add3950cfa64736f6c63430008090033",
108
+ "bytecode": "0x610fb261003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100565760003560e01c80634afbe4c91461005b57806399b0b8471461007d578063c87de7f41461009d578063d079fbb1146100bd575b600080fd5b81801561006757600080fd5b5061007b610076366004610d56565b6100dd565b005b81801561008957600080fd5b5061007b610098366004610da0565b610305565b8180156100a957600080fd5b5061007b6100b8366004610df1565b610526565b8180156100c957600080fd5b5061007b6100d8366004610e1d565b61064c565b60028401546001600160a01b0316331461014e5760405162461bcd60e51b815260206004820152602760248201527f43616c6c6572206973206e6f74207468652045434453412057616c6c657420526044820152666567697374727960c81b60648201526084015b60405180910390fd5b600061016261015d848461094b565b6109f5565b6bffffffffffffffffffffffff198116600090815260168701602052604081209192506002820154600160a01b900460ff1660058111156101a5576101a5610e4a565b146102185760405162461bcd60e51b815260206004820152602860248201527f45434453412077616c6c657420686173206265656e20616c726561647920726560448201527f67697374657265640000000000000000000000000000000000000000000000006064820152608401610145565b848155600281018054600160a01b63ffffffff42811668010000000000000000027fffffffffffffffffffffff00ffffffffffffffff00000000ffffffffffffffff90931692909217811790925560148881018054606087901c73ffffffffffffffffffffffffffffffffffffffff19909116178082559390930490911691906102a183610e76565b91906101000a81548163ffffffff021916908363ffffffff16021790555050816bffffffffffffffffffffffff1916857f2dbb47dce81d6b11cca1f1e3b10143d6f7e1e7e92d2dd9aacbb1f875379d308e60405160405180910390a3505050505050565b601483015460601b6bffffffffffffffffffffffff1990811690831614156103955760405162461bcd60e51b815260206004820152602c60248201527f4163746976652077616c6c65742063616e6e6f7420626520636f6e736964657260448201527f656420636c6f736561626c6500000000000000000000000000000000000000006064820152608401610145565b6bffffffffffffffffffffffff1982166000908152601684016020526040902060016002820154600160a01b900460ff1660058111156103d7576103d7610e4a565b1461042f5760405162461bcd60e51b815260206004820152602260248201527f45434453412077616c6c6574206d75737420626520696e204c69766520737461604482015261746560f01b6064820152608401610145565b601384015460028201546000916104639163ffffffff600160a01b9092048216916801000000000000000090910416610e9a565b63ffffffff16421015905080806104a357506013850154640100000000900467ffffffffffffffff16610497868686610a1c565b67ffffffffffffffff16105b6105155760405162461bcd60e51b815260206004820152603660248201527f57616c6c6574206e6565647320746f206265206f6c6420656e6f756768206f7260448201527f206861766520746f6f20666577207361746f73686973000000000000000000006064820152608401610145565b61051f8585610b54565b5050505050565b60028301546001600160a01b031633146105925760405162461bcd60e51b815260206004820152602760248201527f43616c6c6572206973206e6f74207468652045434453412057616c6c657420526044820152666567697374727960c81b6064820152608401610145565b60006105a161015d848461094b565b905060016bffffffffffffffffffffffff1982166000908152601686016020526040902060020154600160a01b900460ff1660058111156105e4576105e4610e4a565b1461063c5760405162461bcd60e51b815260206004820152602260248201527f45434453412077616c6c6574206d75737420626520696e204c69766520737461604482015261746560f01b6064820152608401610145565b6106468482610b54565b50505050565b6002820154604080517fcc56238800000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163cc562388916004808301926020929190829003018186803b1580156106ac57600080fd5b505afa1580156106c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e49190610ec2565b60038111156106f5576106f5610e4a565b146107685760405162461bcd60e51b815260206004820152602360248201527f57616c6c6574206372656174696f6e20616c726561647920696e2070726f677260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610145565b601482015460601b6bffffffffffffffffffffffff198116156108b3576000610792848385610a1c565b6bffffffffffffffffffffffff1983166000908152601686016020526040812060020154601387015492935063ffffffff680100000000000000009091048116926107de911683610e9a565b63ffffffff1642101590508080156108105750601386015467ffffffffffffffff640100000000909104811690841610155b8061083d5750601386015467ffffffffffffffff6c01000000000000000000000000909104811690841610155b6108af5760405162461bcd60e51b815260206004820152602660248201527f57616c6c6574206372656174696f6e20636f6e646974696f6e7320617265206e60448201527f6f74206d657400000000000000000000000000000000000000000000000000006064820152608401610145565b5050505b6040517f31fecb80caf1e1128496dd5a6f1083ba29fd5fe64c3fe04e2d1b6f9cfc27d5a390600090a18260020160009054906101000a90046001600160a01b03166001600160a01b03166372cc8c6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561092e57600080fd5b505af1158015610942573d6000803e3d6000fd5b50505050505050565b6060600061095a600284610eea565b61098557507f02000000000000000000000000000000000000000000000000000000000000006109a8565b507f03000000000000000000000000000000000000000000000000000000000000005b6040517fff00000000000000000000000000000000000000000000000000000000000000821660208201526021810185905260410160405160208183030381529060405291505092915050565b60006020600083516020850160025afa50602060006020600060035afa5050600c51919050565b6bffffffffffffffffffffffff19821660009081526016840160205260408120600101548015610b4c57808335610a596040860160208701610f0c565b610a696060870160408801610f32565b604051602001610ad69392919092835260e09190911b7fffffffff0000000000000000000000000000000000000000000000000000000016602083015260c01b7fffffffffffffffff000000000000000000000000000000000000000000000000166024820152602c0190565b6040516020818303038152906040528051906020012014610b395760405162461bcd60e51b815260206004820152601d60248201527f496e76616c69642077616c6c6574206d61696e205554584f20646174610000006044820152606401610145565b610b496060840160408501610f32565b91505b509392505050565b6bffffffffffffffffffffffff198116600090815260168301602052604090206001810154610b8c57610b878383610ca8565b610c24565b60028101805463ffffffff42166c01000000000000000000000000027fffffffffffffffffffffff00ffffffff00000000ffffffffffffffffffffffff909116177402000000000000000000000000000000000000000017905580546040516bffffffffffffffffffffffff19841691907fbdc9ce990a067e5fd3a5d8dfc68e27e9f221aaa3fe55265e0b7e93c460b3efe290600090a35b601483015460601b6bffffffffffffffffffffffff199081169083161415610c665760148301805473ffffffffffffffffffffffffffffffffffffffff191690555b60148381018054600160a01b900463ffffffff1691610c8483610f5c565b91906101000a81548163ffffffff021916908363ffffffff16021790555050505050565b6bffffffffffffffffffffffff198116600081815260168401602052604080822060028101805463ffffffff4216700100000000000000000000000000000000027fffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffff9091161774030000000000000000000000000000000000000000179055805491519093927f68cb496f5e64383745876664ef119840f154a729c03ba866b8aecb5c9f53d51691a3505050565b60008060008060808587031215610d6c57600080fd5b5050823594602084013594506040840135936060013592509050565b600060608284031215610d9a57600080fd5b50919050565b600080600060a08486031215610db557600080fd5b8335925060208401356bffffffffffffffffffffffff1981168114610dd957600080fd5b9150610de88560408601610d88565b90509250925092565b600080600060608486031215610e0657600080fd5b505081359360208301359350604090920135919050565b60008060808385031215610e3057600080fd5b82359150610e418460208501610d88565b90509250929050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600063ffffffff80831681811415610e9057610e90610e60565b6001019392505050565b600063ffffffff808316818516808303821115610eb957610eb9610e60565b01949350505050565b600060208284031215610ed457600080fd5b815160048110610ee357600080fd5b9392505050565b600082610f0757634e487b7160e01b600052601260045260246000fd5b500690565b600060208284031215610f1e57600080fd5b813563ffffffff81168114610ee357600080fd5b600060208284031215610f4457600080fd5b813567ffffffffffffffff81168114610ee357600080fd5b600063ffffffff821680610f7257610f72610e60565b600019019291505056fea26469706673582212207d3cf61a34f642871967ccd0ce3162434bad7bd4b1b8afb529e618601779e75a64736f6c63430008090033",
109
+ "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100565760003560e01c80634afbe4c91461005b57806399b0b8471461007d578063c87de7f41461009d578063d079fbb1146100bd575b600080fd5b81801561006757600080fd5b5061007b610076366004610d56565b6100dd565b005b81801561008957600080fd5b5061007b610098366004610da0565b610305565b8180156100a957600080fd5b5061007b6100b8366004610df1565b610526565b8180156100c957600080fd5b5061007b6100d8366004610e1d565b61064c565b60028401546001600160a01b0316331461014e5760405162461bcd60e51b815260206004820152602760248201527f43616c6c6572206973206e6f74207468652045434453412057616c6c657420526044820152666567697374727960c81b60648201526084015b60405180910390fd5b600061016261015d848461094b565b6109f5565b6bffffffffffffffffffffffff198116600090815260168701602052604081209192506002820154600160a01b900460ff1660058111156101a5576101a5610e4a565b146102185760405162461bcd60e51b815260206004820152602860248201527f45434453412077616c6c657420686173206265656e20616c726561647920726560448201527f67697374657265640000000000000000000000000000000000000000000000006064820152608401610145565b848155600281018054600160a01b63ffffffff42811668010000000000000000027fffffffffffffffffffffff00ffffffffffffffff00000000ffffffffffffffff90931692909217811790925560148881018054606087901c73ffffffffffffffffffffffffffffffffffffffff19909116178082559390930490911691906102a183610e76565b91906101000a81548163ffffffff021916908363ffffffff16021790555050816bffffffffffffffffffffffff1916857f2dbb47dce81d6b11cca1f1e3b10143d6f7e1e7e92d2dd9aacbb1f875379d308e60405160405180910390a3505050505050565b601483015460601b6bffffffffffffffffffffffff1990811690831614156103955760405162461bcd60e51b815260206004820152602c60248201527f4163746976652077616c6c65742063616e6e6f7420626520636f6e736964657260448201527f656420636c6f736561626c6500000000000000000000000000000000000000006064820152608401610145565b6bffffffffffffffffffffffff1982166000908152601684016020526040902060016002820154600160a01b900460ff1660058111156103d7576103d7610e4a565b1461042f5760405162461bcd60e51b815260206004820152602260248201527f45434453412077616c6c6574206d75737420626520696e204c69766520737461604482015261746560f01b6064820152608401610145565b601384015460028201546000916104639163ffffffff600160a01b9092048216916801000000000000000090910416610e9a565b63ffffffff16421015905080806104a357506013850154640100000000900467ffffffffffffffff16610497868686610a1c565b67ffffffffffffffff16105b6105155760405162461bcd60e51b815260206004820152603660248201527f57616c6c6574206e6565647320746f206265206f6c6420656e6f756768206f7260448201527f206861766520746f6f20666577207361746f73686973000000000000000000006064820152608401610145565b61051f8585610b54565b5050505050565b60028301546001600160a01b031633146105925760405162461bcd60e51b815260206004820152602760248201527f43616c6c6572206973206e6f74207468652045434453412057616c6c657420526044820152666567697374727960c81b6064820152608401610145565b60006105a161015d848461094b565b905060016bffffffffffffffffffffffff1982166000908152601686016020526040902060020154600160a01b900460ff1660058111156105e4576105e4610e4a565b1461063c5760405162461bcd60e51b815260206004820152602260248201527f45434453412077616c6c6574206d75737420626520696e204c69766520737461604482015261746560f01b6064820152608401610145565b6106468482610b54565b50505050565b6002820154604080517fcc56238800000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163cc562388916004808301926020929190829003018186803b1580156106ac57600080fd5b505afa1580156106c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e49190610ec2565b60038111156106f5576106f5610e4a565b146107685760405162461bcd60e51b815260206004820152602360248201527f57616c6c6574206372656174696f6e20616c726561647920696e2070726f677260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610145565b601482015460601b6bffffffffffffffffffffffff198116156108b3576000610792848385610a1c565b6bffffffffffffffffffffffff1983166000908152601686016020526040812060020154601387015492935063ffffffff680100000000000000009091048116926107de911683610e9a565b63ffffffff1642101590508080156108105750601386015467ffffffffffffffff640100000000909104811690841610155b8061083d5750601386015467ffffffffffffffff6c01000000000000000000000000909104811690841610155b6108af5760405162461bcd60e51b815260206004820152602660248201527f57616c6c6574206372656174696f6e20636f6e646974696f6e7320617265206e60448201527f6f74206d657400000000000000000000000000000000000000000000000000006064820152608401610145565b5050505b6040517f31fecb80caf1e1128496dd5a6f1083ba29fd5fe64c3fe04e2d1b6f9cfc27d5a390600090a18260020160009054906101000a90046001600160a01b03166001600160a01b03166372cc8c6d6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561092e57600080fd5b505af1158015610942573d6000803e3d6000fd5b50505050505050565b6060600061095a600284610eea565b61098557507f02000000000000000000000000000000000000000000000000000000000000006109a8565b507f03000000000000000000000000000000000000000000000000000000000000005b6040517fff00000000000000000000000000000000000000000000000000000000000000821660208201526021810185905260410160405160208183030381529060405291505092915050565b60006020600083516020850160025afa50602060006020600060035afa5050600c51919050565b6bffffffffffffffffffffffff19821660009081526016840160205260408120600101548015610b4c57808335610a596040860160208701610f0c565b610a696060870160408801610f32565b604051602001610ad69392919092835260e09190911b7fffffffff0000000000000000000000000000000000000000000000000000000016602083015260c01b7fffffffffffffffff000000000000000000000000000000000000000000000000166024820152602c0190565b6040516020818303038152906040528051906020012014610b395760405162461bcd60e51b815260206004820152601d60248201527f496e76616c69642077616c6c6574206d61696e205554584f20646174610000006044820152606401610145565b610b496060840160408501610f32565b91505b509392505050565b6bffffffffffffffffffffffff198116600090815260168301602052604090206001810154610b8c57610b878383610ca8565b610c24565b60028101805463ffffffff42166c01000000000000000000000000027fffffffffffffffffffffff00ffffffff00000000ffffffffffffffffffffffff909116177402000000000000000000000000000000000000000017905580546040516bffffffffffffffffffffffff19841691907fbdc9ce990a067e5fd3a5d8dfc68e27e9f221aaa3fe55265e0b7e93c460b3efe290600090a35b601483015460601b6bffffffffffffffffffffffff199081169083161415610c665760148301805473ffffffffffffffffffffffffffffffffffffffff191690555b60148381018054600160a01b900463ffffffff1691610c8483610f5c565b91906101000a81548163ffffffff021916908363ffffffff16021790555050505050565b6bffffffffffffffffffffffff198116600081815260168401602052604080822060028101805463ffffffff4216700100000000000000000000000000000000027fffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffff9091161774030000000000000000000000000000000000000000179055805491519093927f68cb496f5e64383745876664ef119840f154a729c03ba866b8aecb5c9f53d51691a3505050565b60008060008060808587031215610d6c57600080fd5b5050823594602084013594506040840135936060013592509050565b600060608284031215610d9a57600080fd5b50919050565b600080600060a08486031215610db557600080fd5b8335925060208401356bffffffffffffffffffffffff1981168114610dd957600080fd5b9150610de88560408601610d88565b90509250925092565b600080600060608486031215610e0657600080fd5b505081359360208301359350604090920135919050565b60008060808385031215610e3057600080fd5b82359150610e418460208501610d88565b90509250929050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600063ffffffff80831681811415610e9057610e90610e60565b6001019392505050565b600063ffffffff808316818516808303821115610eb957610eb9610e60565b01949350505050565b600060208284031215610ed457600080fd5b815160048110610ee357600080fd5b9392505050565b600082610f0757634e487b7160e01b600052601260045260246000fd5b500690565b600060208284031215610f1e57600080fd5b813563ffffffff81168114610ee357600080fd5b600060208284031215610f4457600080fd5b813567ffffffffffffffff81168114610ee357600080fd5b600063ffffffff821680610f7257610f72610e60565b600019019291505056fea26469706673582212207d3cf61a34f642871967ccd0ce3162434bad7bd4b1b8afb529e618601779e75a64736f6c63430008090033",
110
110
  "linkReferences": {},
111
111
  "deployedLinkReferences": {}
112
112
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/62c9b8bdd92c3e06af3174d60bfc6e85.json"
3
+ "buildInfo": "../../../build-info/d3fb7ddf13682b804733089ddc2e3593.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/62c9b8bdd92c3e06af3174d60bfc6e85.json"
3
+ "buildInfo": "../../../build-info/d3fb7ddf13682b804733089ddc2e3593.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/62c9b8bdd92c3e06af3174d60bfc6e85.json"
3
+ "buildInfo": "../../../build-info/d3fb7ddf13682b804733089ddc2e3593.json"
4
4
  }
@@ -119,6 +119,8 @@ contract Bridge is Governable, EcdsaWalletOwner {
119
119
 
120
120
  event MovingFundsTimedOut(bytes20 walletPubKeyHash);
121
121
 
122
+ event MovingFundsBelowDustReported(bytes20 walletPubKeyHash);
123
+
122
124
  event NewWalletRequested();
123
125
 
124
126
  event NewWalletRegistered(
@@ -173,7 +175,8 @@ contract Bridge is Governable, EcdsaWalletOwner {
173
175
 
174
176
  event MovingFundsParametersUpdated(
175
177
  uint64 movingFundsTxMaxTotalFee,
176
- uint32 movingFundsTimeout
178
+ uint32 movingFundsTimeout,
179
+ uint64 movingFundsDustThreshold
177
180
  );
178
181
 
179
182
  event WalletParametersUpdated(
@@ -186,7 +189,7 @@ contract Bridge is Governable, EcdsaWalletOwner {
186
189
  );
187
190
 
188
191
  event FraudParametersUpdated(
189
- uint256 fraudSlashingAmount,
192
+ uint96 fraudSlashingAmount,
190
193
  uint256 fraudNotifierRewardMultiplier,
191
194
  uint256 fraudChallengeDefeatTimeout,
192
195
  uint256 fraudChallengeDepositAmount
@@ -226,6 +229,7 @@ contract Bridge is Governable, EcdsaWalletOwner {
226
229
  self.redemptionTimeout = 172800; // 48 hours
227
230
  self.movingFundsTxMaxTotalFee = 10000; // 10000 satoshi
228
231
  self.movingFundsTimeout = 7 days;
232
+ self.movingFundsDustThreshold = 20000; // 20000 satoshi
229
233
  self.fraudSlashingAmount = 10000 * 1e18; // 10000 T
230
234
  self.fraudNotifierRewardMultiplier = 100; // 100%
231
235
  self.fraudChallengeDefeatTimeout = 7 days;
@@ -581,6 +585,26 @@ contract Bridge is Governable, EcdsaWalletOwner {
581
585
  self.notifyMovingFundsTimeout(walletPubKeyHash);
582
586
  }
583
587
 
588
+ /// @notice Notifies about a moving funds wallet whose BTC balance is
589
+ /// below the moving funds dust threshold. Ends the moving funds
590
+ /// process and begins wallet closing immediately.
591
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet
592
+ /// @param mainUtxo Data of the wallet's main UTXO, as currently known
593
+ /// on the Ethereum chain.
594
+ /// @dev Requirements:
595
+ /// - The wallet must be in the MovingFunds state
596
+ /// - The `mainUtxo` components must point to the recent main UTXO
597
+ /// of the given wallet, as currently known on the Ethereum chain.
598
+ /// If the wallet has no main UTXO, this parameter can be empty as it
599
+ /// is ignored.
600
+ /// - The wallet BTC balance must be below the moving funds threshold
601
+ function notifyMovingFundsBelowDust(
602
+ bytes20 walletPubKeyHash,
603
+ BitcoinTx.UTXO calldata mainUtxo
604
+ ) external {
605
+ self.notifyMovingFundsBelowDust(walletPubKeyHash, mainUtxo);
606
+ }
607
+
584
608
  /// @notice Requests creation of a new wallet. This function just
585
609
  /// forms a request and the creation process is performed
586
610
  /// asynchronously. Once a wallet is created, the ECDSA Wallet
@@ -761,6 +785,7 @@ contract Bridge is Governable, EcdsaWalletOwner {
761
785
  /// rewarded.
762
786
  /// @param walletPublicKey The public key of the wallet in the uncompressed
763
787
  /// and unprefixed format (64 bytes)
788
+ /// @param walletMembersIDs Identifiers of the wallet signing group members
764
789
  /// @param sighash The hash that was used to produce the ECDSA signature
765
790
  /// that is the subject of the fraud claim. This hash is constructed
766
791
  /// by applying double SHA-256 over a serialized subset of the
@@ -768,15 +793,28 @@ contract Bridge is Governable, EcdsaWalletOwner {
768
793
  /// the transaction input the signature is produced for. See BIP-143
769
794
  /// for reference
770
795
  /// @dev Requirements:
771
- /// - `walletPublicKey`and `sighash` must identify an open fraud
796
+ /// - The wallet must be in the Live or MovingFunds or Closing or
797
+ /// Terminated state
798
+ /// - The `walletPublicKey` and `sighash` must identify an open fraud
772
799
  /// challenge
773
- /// - the amount of time indicated by `challengeDefeatTimeout` must
774
- /// pass after the challenge was reported
800
+ /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
801
+ /// be exactly the same as the hash stored under `membersIdsHash`
802
+ /// for the given `walletID`. Those IDs are not directly stored
803
+ /// in the contract for gas efficiency purposes but they can be
804
+ /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
805
+ /// events.
806
+ /// - The amount of time indicated by `challengeDefeatTimeout` must pass
807
+ /// after the challenge was reported
775
808
  function notifyFraudChallengeDefeatTimeout(
776
809
  bytes calldata walletPublicKey,
810
+ uint32[] calldata walletMembersIDs,
777
811
  bytes32 sighash
778
812
  ) external {
779
- self.notifyFraudChallengeDefeatTimeout(walletPublicKey, sighash);
813
+ self.notifyFraudChallengeDefeatTimeout(
814
+ walletPublicKey,
815
+ walletMembersIDs,
816
+ sighash
817
+ );
780
818
  }
781
819
 
782
820
  /// @notice Allows the Governance to mark the given vault address as trusted
@@ -896,16 +934,25 @@ contract Bridge is Governable, EcdsaWalletOwner {
896
934
  /// be reported as timed out. It is counted from the moment when the
897
935
  /// wallet was requested to move their funds and switched to the
898
936
  /// MovingFunds state.
937
+ /// @param movingFundsDustThreshold New value of the moving funds dust
938
+ /// threshold. It is the minimal satoshi amount that makes sense to
939
+ // be transferred during the moving funds process. Moving funds
940
+ // wallets having their BTC balance below that value can begin
941
+ // closing immediately as transferring such a low value may not be
942
+ // possible due to BTC network fees.
899
943
  /// @dev Requirements:
900
944
  /// - Moving funds transaction max total fee must be greater than zero
901
945
  /// - Moving funds timeout must be greater than zero
946
+ /// - Moving funds dust threshold must be greater than zero
902
947
  function updateMovingFundsParameters(
903
948
  uint64 movingFundsTxMaxTotalFee,
904
- uint32 movingFundsTimeout
949
+ uint32 movingFundsTimeout,
950
+ uint64 movingFundsDustThreshold
905
951
  ) external onlyGovernance {
906
952
  self.updateMovingFundsParameters(
907
953
  movingFundsTxMaxTotalFee,
908
- movingFundsTimeout
954
+ movingFundsTimeout,
955
+ movingFundsDustThreshold
909
956
  );
910
957
  }
911
958
 
@@ -969,7 +1016,7 @@ contract Bridge is Governable, EcdsaWalletOwner {
969
1016
  /// - Fraud notifier reward multiplier must be in the range [0, 100]
970
1017
  /// - Fraud challenge defeat timeout must be greater than 0
971
1018
  function updateFraudParameters(
972
- uint256 fraudSlashingAmount,
1019
+ uint96 fraudSlashingAmount,
973
1020
  uint256 fraudNotifierRewardMultiplier,
974
1021
  uint256 fraudChallengeDefeatTimeout,
975
1022
  uint256 fraudChallengeDepositAmount
@@ -1178,13 +1225,23 @@ contract Bridge is Governable, EcdsaWalletOwner {
1178
1225
  /// can be reported as timed out. It is counted from the moment
1179
1226
  /// when the wallet was requested to move their funds and switched
1180
1227
  /// to the MovingFunds state. Value in seconds.
1228
+ /// @return movingFundsDustThreshold The minimal satoshi amount that makes
1229
+ // sense to be transferred during the moving funds process. Moving
1230
+ // funds wallets having their BTC balance below that value can
1231
+ // begin closing immediately as transferring such a low value may
1232
+ // not be possible due to BTC network fees.
1181
1233
  function movingFundsParameters()
1182
1234
  external
1183
1235
  view
1184
- returns (uint64 movingFundsTxMaxTotalFee, uint32 movingFundsTimeout)
1236
+ returns (
1237
+ uint64 movingFundsTxMaxTotalFee,
1238
+ uint32 movingFundsTimeout,
1239
+ uint64 movingFundsDustThreshold
1240
+ )
1185
1241
  {
1186
1242
  movingFundsTxMaxTotalFee = self.movingFundsTxMaxTotalFee;
1187
1243
  movingFundsTimeout = self.movingFundsTimeout;
1244
+ movingFundsDustThreshold = self.movingFundsDustThreshold;
1188
1245
  }
1189
1246
 
1190
1247
  /// @return walletCreationPeriod Determines how frequently a new wallet
@@ -1236,7 +1293,7 @@ contract Bridge is Governable, EcdsaWalletOwner {
1236
1293
  external
1237
1294
  view
1238
1295
  returns (
1239
- uint256 fraudSlashingAmount,
1296
+ uint96 fraudSlashingAmount,
1240
1297
  uint256 fraudNotifierRewardMultiplier,
1241
1298
  uint256 fraudChallengeDefeatTimeout,
1242
1299
  uint256 fraudChallengeDepositAmount
@@ -88,6 +88,12 @@ library BridgeState {
88
88
  // was requested to move their funds and switched to the MovingFunds
89
89
  // state. Value in seconds.
90
90
  uint32 movingFundsTimeout;
91
+ // The minimal satoshi amount that makes sense to be transferred during
92
+ // the moving funds process. Moving funds wallets having their BTC
93
+ // balance below that value can begin closing immediately as
94
+ // transferring such a low value may not be possible due to
95
+ // BTC network fees.
96
+ uint64 movingFundsDustThreshold;
91
97
  // The minimal amount that can be requested for redemption.
92
98
  // Value of this parameter must take into account the value of
93
99
  // `redemptionTreasuryFeeDivisor` and `redemptionTxMaxFee`
@@ -146,7 +152,7 @@ library BridgeState {
146
152
  // `pendingRedemptions` mapping.
147
153
  mapping(uint256 => Redemption.RedemptionRequest) timedOutRedemptions;
148
154
  // The amount of stake slashed from each member of a wallet for a fraud.
149
- uint256 fraudSlashingAmount;
155
+ uint96 fraudSlashingAmount;
150
156
  // The percentage of the notifier reward from the staking contract
151
157
  // the notifier of a fraud receives. The value is in the range [0, 100].
152
158
  uint256 fraudNotifierRewardMultiplier;
@@ -212,7 +218,8 @@ library BridgeState {
212
218
 
213
219
  event MovingFundsParametersUpdated(
214
220
  uint64 movingFundsTxMaxTotalFee,
215
- uint32 movingFundsTimeout
221
+ uint32 movingFundsTimeout,
222
+ uint64 movingFundsDustThreshold
216
223
  );
217
224
 
218
225
  event WalletParametersUpdated(
@@ -225,7 +232,7 @@ library BridgeState {
225
232
  );
226
233
 
227
234
  event FraudParametersUpdated(
228
- uint256 fraudSlashingAmount,
235
+ uint96 fraudSlashingAmount,
229
236
  uint256 fraudNotifierRewardMultiplier,
230
237
  uint256 fraudChallengeDefeatTimeout,
231
238
  uint256 fraudChallengeDepositAmount
@@ -373,13 +380,21 @@ library BridgeState {
373
380
  /// be reported as timed out. It is counted from the moment when the
374
381
  /// wallet was requested to move their funds and switched to the
375
382
  /// MovingFunds state.
383
+ /// @param _movingFundsDustThreshold New value of the moving funds dust
384
+ /// threshold. It is the minimal satoshi amount that makes sense to
385
+ // be transferred during the moving funds process. Moving funds
386
+ // wallets having their BTC balance below that value can begin
387
+ // closing immediately as transferring such a low value may not be
388
+ // possible due to BTC network fees.
376
389
  /// @dev Requirements:
377
390
  /// - Moving funds transaction max total fee must be greater than zero
378
391
  /// - Moving funds timeout must be greater than zero
392
+ /// - Moving funds dust threshold must be greater than zero
379
393
  function updateMovingFundsParameters(
380
394
  Storage storage self,
381
395
  uint64 _movingFundsTxMaxTotalFee,
382
- uint32 _movingFundsTimeout
396
+ uint32 _movingFundsTimeout,
397
+ uint64 _movingFundsDustThreshold
383
398
  ) internal {
384
399
  require(
385
400
  _movingFundsTxMaxTotalFee > 0,
@@ -391,12 +406,19 @@ library BridgeState {
391
406
  "Moving funds timeout must be greater than zero"
392
407
  );
393
408
 
409
+ require(
410
+ _movingFundsDustThreshold > 0,
411
+ "Moving funds dust threshold must be greater than zero"
412
+ );
413
+
394
414
  self.movingFundsTxMaxTotalFee = _movingFundsTxMaxTotalFee;
395
415
  self.movingFundsTimeout = _movingFundsTimeout;
416
+ self.movingFundsDustThreshold = _movingFundsDustThreshold;
396
417
 
397
418
  emit MovingFundsParametersUpdated(
398
419
  _movingFundsTxMaxTotalFee,
399
- _movingFundsTimeout
420
+ _movingFundsTimeout,
421
+ _movingFundsDustThreshold
400
422
  );
401
423
  }
402
424
 
@@ -486,7 +508,7 @@ library BridgeState {
486
508
  /// - Fraud challenge defeat timeout must be greater than 0
487
509
  function updateFraudParameters(
488
510
  Storage storage self,
489
- uint256 _fraudSlashingAmount,
511
+ uint96 _fraudSlashingAmount,
490
512
  uint256 _fraudNotifierRewardMultiplier,
491
513
  uint256 _fraudChallengeDefeatTimeout,
492
514
  uint256 _fraudChallengeDepositAmount
@@ -260,6 +260,7 @@ library Fraud {
260
260
  /// rewarded.
261
261
  /// @param walletPublicKey The public key of the wallet in the uncompressed
262
262
  /// and unprefixed format (64 bytes)
263
+ /// @param walletMembersIDs Identifiers of the wallet signing group members
263
264
  /// @param sighash The hash that was used to produce the ECDSA signature
264
265
  /// that is the subject of the fraud claim. This hash is constructed
265
266
  /// by applying double SHA-256 over a serialized subset of the
@@ -271,11 +272,18 @@ library Fraud {
271
272
  /// Terminated state
272
273
  /// - The `walletPublicKey` and `sighash` must identify an open fraud
273
274
  /// challenge
275
+ /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
276
+ /// be exactly the same as the hash stored under `membersIdsHash`
277
+ /// for the given `walletID`. Those IDs are not directly stored
278
+ /// in the contract for gas efficiency purposes but they can be
279
+ /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
280
+ /// events.
274
281
  /// - The amount of time indicated by `challengeDefeatTimeout` must pass
275
282
  /// after the challenge was reported
276
283
  function notifyFraudChallengeDefeatTimeout(
277
284
  BridgeState.Storage storage self,
278
285
  bytes calldata walletPublicKey,
286
+ uint32[] calldata walletMembersIDs,
279
287
  bytes32 sighash
280
288
  ) external {
281
289
  uint256 challengeKey = uint256(
@@ -312,9 +320,12 @@ library Fraud {
312
320
  walletPublicKey.slice32(32)
313
321
  );
314
322
  bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();
315
- Wallets.WalletState walletState = self
316
- .registeredWallets[walletPubKeyHash]
317
- .state;
323
+
324
+ Wallets.Wallet storage wallet = self.registeredWallets[
325
+ walletPubKeyHash
326
+ ];
327
+
328
+ Wallets.WalletState walletState = wallet.state;
318
329
 
319
330
  if (
320
331
  walletState == Wallets.WalletState.Live ||
@@ -323,8 +334,13 @@ library Fraud {
323
334
  ) {
324
335
  self.terminateWallet(walletPubKeyHash);
325
336
 
326
- // TODO: Perform slashing of the wallet operators, reward the
327
- // challenger, and add unit tests for that.
337
+ self.ecdsaWalletRegistry.seize(
338
+ self.fraudSlashingAmount,
339
+ self.fraudNotifierRewardMultiplier,
340
+ challenge.challenger,
341
+ wallet.ecdsaWalletID,
342
+ walletMembersIDs
343
+ );
328
344
  } else if (walletState == Wallets.WalletState.Terminated) {
329
345
  // This is a special case when the wallet was already terminated
330
346
  // due to a previous deliberate protocol violation. In that
@@ -52,6 +52,8 @@ library MovingFunds {
52
52
 
53
53
  event MovingFundsTimedOut(bytes20 walletPubKeyHash);
54
54
 
55
+ event MovingFundsBelowDustReported(bytes20 walletPubKeyHash);
56
+
55
57
  /// @notice Submits the moving funds target wallets commitment.
56
58
  /// Once all requirements are met, that function registers the
57
59
  /// target wallets commitment and opens the way for moving funds
@@ -463,4 +465,47 @@ library MovingFunds {
463
465
  // slither-disable-next-line reentrancy-events
464
466
  emit MovingFundsTimedOut(walletPubKeyHash);
465
467
  }
468
+
469
+ /// @notice Notifies about a moving funds wallet whose BTC balance is
470
+ /// below the moving funds dust threshold. Ends the moving funds
471
+ /// process and begins wallet closing immediately.
472
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet
473
+ /// @param mainUtxo Data of the wallet's main UTXO, as currently known
474
+ /// on the Ethereum chain.
475
+ /// @dev Requirements:
476
+ /// - The wallet must be in the MovingFunds state
477
+ /// - The `mainUtxo` components must point to the recent main UTXO
478
+ /// of the given wallet, as currently known on the Ethereum chain.
479
+ /// If the wallet has no main UTXO, this parameter can be empty as it
480
+ /// is ignored.
481
+ /// - The wallet BTC balance must be below the moving funds threshold
482
+ function notifyMovingFundsBelowDust(
483
+ BridgeState.Storage storage self,
484
+ bytes20 walletPubKeyHash,
485
+ BitcoinTx.UTXO calldata mainUtxo
486
+ ) external {
487
+ Wallets.Wallet storage wallet = self.registeredWallets[
488
+ walletPubKeyHash
489
+ ];
490
+
491
+ require(
492
+ wallet.state == Wallets.WalletState.MovingFunds,
493
+ "ECDSA wallet must be in MovingFunds state"
494
+ );
495
+
496
+ uint64 walletBtcBalance = self.getWalletBtcBalance(
497
+ walletPubKeyHash,
498
+ mainUtxo
499
+ );
500
+
501
+ require(
502
+ walletBtcBalance < self.movingFundsDustThreshold,
503
+ "Wallet BTC balance must be below the moving funds dust threshold"
504
+ );
505
+
506
+ self.beginWalletClosing(walletPubKeyHash);
507
+
508
+ // slither-disable-next-line reentrancy-events
509
+ emit MovingFundsBelowDustReported(walletPubKeyHash);
510
+ }
466
511
  }
package/export.json CHANGED
@@ -13918,6 +13918,19 @@
13918
13918
  "MovingFunds": {
13919
13919
  "address": "0x1a6a3e7Bb246158dF31d8f924B84D961669Ba4e5",
13920
13920
  "abi": [
13921
+ {
13922
+ "anonymous": false,
13923
+ "inputs": [
13924
+ {
13925
+ "indexed": false,
13926
+ "internalType": "bytes20",
13927
+ "name": "walletPubKeyHash",
13928
+ "type": "bytes20"
13929
+ }
13930
+ ],
13931
+ "name": "MovingFundsBelowDustReported",
13932
+ "type": "event"
13933
+ },
13921
13934
  {
13922
13935
  "anonymous": false,
13923
13936
  "inputs": [
@@ -14196,9 +14209,9 @@
14196
14209
  "inputs": [
14197
14210
  {
14198
14211
  "indexed": false,
14199
- "internalType": "uint256",
14212
+ "internalType": "uint96",
14200
14213
  "name": "fraudSlashingAmount",
14201
- "type": "uint256"
14214
+ "type": "uint96"
14202
14215
  },
14203
14216
  {
14204
14217
  "indexed": false,
@@ -14241,6 +14254,19 @@
14241
14254
  "name": "GovernanceTransferred",
14242
14255
  "type": "event"
14243
14256
  },
14257
+ {
14258
+ "anonymous": false,
14259
+ "inputs": [
14260
+ {
14261
+ "indexed": false,
14262
+ "internalType": "bytes20",
14263
+ "name": "walletPubKeyHash",
14264
+ "type": "bytes20"
14265
+ }
14266
+ ],
14267
+ "name": "MovingFundsBelowDustReported",
14268
+ "type": "event"
14269
+ },
14244
14270
  {
14245
14271
  "anonymous": false,
14246
14272
  "inputs": [
@@ -14299,6 +14325,12 @@
14299
14325
  "internalType": "uint32",
14300
14326
  "name": "movingFundsTimeout",
14301
14327
  "type": "uint32"
14328
+ },
14329
+ {
14330
+ "indexed": false,
14331
+ "internalType": "uint64",
14332
+ "name": "movingFundsDustThreshold",
14333
+ "type": "uint64"
14302
14334
  }
14303
14335
  ],
14304
14336
  "name": "MovingFundsParametersUpdated",
@@ -14817,9 +14849,9 @@
14817
14849
  "name": "fraudParameters",
14818
14850
  "outputs": [
14819
14851
  {
14820
- "internalType": "uint256",
14852
+ "internalType": "uint96",
14821
14853
  "name": "fraudSlashingAmount",
14822
- "type": "uint256"
14854
+ "type": "uint96"
14823
14855
  },
14824
14856
  {
14825
14857
  "internalType": "uint256",
@@ -14898,6 +14930,11 @@
14898
14930
  "internalType": "uint32",
14899
14931
  "name": "movingFundsTimeout",
14900
14932
  "type": "uint32"
14933
+ },
14934
+ {
14935
+ "internalType": "uint64",
14936
+ "name": "movingFundsDustThreshold",
14937
+ "type": "uint64"
14901
14938
  }
14902
14939
  ],
14903
14940
  "stateMutability": "view",
@@ -14945,6 +14982,11 @@
14945
14982
  "name": "walletPublicKey",
14946
14983
  "type": "bytes"
14947
14984
  },
14985
+ {
14986
+ "internalType": "uint32[]",
14987
+ "name": "walletMembersIDs",
14988
+ "type": "uint32[]"
14989
+ },
14948
14990
  {
14949
14991
  "internalType": "bytes32",
14950
14992
  "name": "sighash",
@@ -14956,6 +14998,41 @@
14956
14998
  "stateMutability": "nonpayable",
14957
14999
  "type": "function"
14958
15000
  },
15001
+ {
15002
+ "inputs": [
15003
+ {
15004
+ "internalType": "bytes20",
15005
+ "name": "walletPubKeyHash",
15006
+ "type": "bytes20"
15007
+ },
15008
+ {
15009
+ "components": [
15010
+ {
15011
+ "internalType": "bytes32",
15012
+ "name": "txHash",
15013
+ "type": "bytes32"
15014
+ },
15015
+ {
15016
+ "internalType": "uint32",
15017
+ "name": "txOutputIndex",
15018
+ "type": "uint32"
15019
+ },
15020
+ {
15021
+ "internalType": "uint64",
15022
+ "name": "txOutputValue",
15023
+ "type": "uint64"
15024
+ }
15025
+ ],
15026
+ "internalType": "struct BitcoinTx.UTXO",
15027
+ "name": "mainUtxo",
15028
+ "type": "tuple"
15029
+ }
15030
+ ],
15031
+ "name": "notifyMovingFundsBelowDust",
15032
+ "outputs": [],
15033
+ "stateMutability": "nonpayable",
15034
+ "type": "function"
15035
+ },
14959
15036
  {
14960
15037
  "inputs": [
14961
15038
  {
@@ -15957,9 +16034,9 @@
15957
16034
  {
15958
16035
  "inputs": [
15959
16036
  {
15960
- "internalType": "uint256",
16037
+ "internalType": "uint96",
15961
16038
  "name": "fraudSlashingAmount",
15962
- "type": "uint256"
16039
+ "type": "uint96"
15963
16040
  },
15964
16041
  {
15965
16042
  "internalType": "uint256",
@@ -15993,6 +16070,11 @@
15993
16070
  "internalType": "uint32",
15994
16071
  "name": "movingFundsTimeout",
15995
16072
  "type": "uint32"
16073
+ },
16074
+ {
16075
+ "internalType": "uint64",
16076
+ "name": "movingFundsDustThreshold",
16077
+ "type": "uint64"
15996
16078
  }
15997
16079
  ],
15998
16080
  "name": "updateMovingFundsParameters",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keep-network/tbtc-v2",
3
- "version": "0.1.1-dev.49+main.73325e5cb7b966d3daf56e2d40a75b30f0e6ce91",
3
+ "version": "0.1.1-dev.51+main.2bbde1a93f2bb8ae73f42ac83ee999962a07cfb8",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "artifacts/",