Coverage Summary for Class: BridgeRegTestConstants (co.rsk.config)

Class Class, % Method, % Line, %
BridgeRegTestConstants 100% (1/1) 100% (4/4) 100% (53/53)


1 /* 2  * This file is part of RskJ 3  * Copyright (C) 2017 RSK Labs Ltd. 4  * 5  * This program is free software: you can redistribute it and/or modify 6  * it under the terms of the GNU Lesser General Public License as published by 7  * the Free Software Foundation, either version 3 of the License, or 8  * (at your option) any later version. 9  * 10  * This program is distributed in the hope that it will be useful, 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13  * GNU Lesser General Public License for more details. 14  * 15  * You should have received a copy of the GNU Lesser General Public License 16  * along with this program. If not, see <http://www.gnu.org/licenses/>. 17  */ 18  19 package co.rsk.config; 20  21 import co.rsk.bitcoinj.core.BtcECKey; 22 import co.rsk.bitcoinj.core.Coin; 23 import co.rsk.bitcoinj.core.NetworkParameters; 24 import co.rsk.peg.AddressBasedAuthorizer; 25 import co.rsk.peg.Federation; 26 import co.rsk.peg.FederationMember; 27 import org.bouncycastle.util.encoders.Hex; 28 import org.ethereum.crypto.ECKey; 29 import org.ethereum.crypto.HashUtil; 30  31 import java.nio.charset.StandardCharsets; 32 import java.time.Instant; 33 import java.time.ZonedDateTime; 34 import java.util.Arrays; 35 import java.util.List; 36 import java.util.stream.Collectors; 37  38 public class BridgeRegTestConstants extends BridgeConstants { 39  // IMPORTANT: BTC, RSK and MST keys are the same. 40  // Change upon implementation of the <INSERT FORK NAME HERE> fork. 41  public static final List<BtcECKey> REGTEST_FEDERATION_PRIVATE_KEYS = Arrays.asList( 42  BtcECKey.fromPrivate(HashUtil.keccak256("federator1".getBytes(StandardCharsets.UTF_8))), 43  BtcECKey.fromPrivate(HashUtil.keccak256("federator2".getBytes(StandardCharsets.UTF_8))), 44  BtcECKey.fromPrivate(HashUtil.keccak256("federator3".getBytes(StandardCharsets.UTF_8))) 45  ); 46  public static final List<BtcECKey> REGTEST_FEDERATION_PUBLIC_KEYS = REGTEST_FEDERATION_PRIVATE_KEYS.stream() 47  .map(key -> BtcECKey.fromPublicOnly(key.getPubKey())) 48  .collect(Collectors.toList()); 49  50  private static final BridgeRegTestConstants instance = new BridgeRegTestConstants(REGTEST_FEDERATION_PUBLIC_KEYS); 51  52  public BridgeRegTestConstants(List<BtcECKey> federationPublicKeys) { 53  btcParamsString = NetworkParameters.ID_REGTEST; 54  55  List<FederationMember> federationMembers = FederationMember.getFederationMembersFromKeys(federationPublicKeys); 56  57  Instant genesisFederationCreatedAt = ZonedDateTime.parse("2016-01-01T00:00:00Z").toInstant(); 58  59  genesisFederation = new Federation( 60  federationMembers, 61  genesisFederationCreatedAt, 62  1L, 63  getBtcParams() 64  ); 65  66  btc2RskMinimumAcceptableConfirmations = 3; 67  btc2RskMinimumAcceptableConfirmationsOnRsk = 5; 68  rsk2BtcMinimumAcceptableConfirmations = 3; 69  70  updateBridgeExecutionPeriod = 1 * 15 * 1000; //15 seconds in millis 71  72  maxBtcHeadersPerRskBlock = 500; 73  74  legacyMinimumPeginTxValueInSatoshis = Coin.COIN; 75  legacyMinimumPegoutTxValueInSatoshis = Coin.valueOf(500_000); 76  minimumPeginTxValueInSatoshis = Coin.COIN.div(2); 77  minimumPegoutTxValueInSatoshis = Coin.valueOf(250_000); 78  79  80  // Keys generated with GenNodeKey using generators 'auth-a' through 'auth-e' 81  List<ECKey> federationChangeAuthorizedKeys = Arrays.stream(new String[]{ 82  "04dde17c5fab31ffc53c91c2390136c325bb8690dc135b0840075dd7b86910d8ab9e88baad0c32f3eea8833446a6bc5ff1cd2efa99ecb17801bcb65fc16fc7d991", 83  "04af886c67231476807e2a8eee9193878b9d94e30aa2ee469a9611d20e1e1c1b438e5044148f65e6e61bf03e9d72e597cb9cdea96d6fc044001b22099f9ec403e2", 84  "045d4dedf9c69ab3ea139d0f0da0ad00160b7663d01ce7a6155cd44a3567d360112b0480ab6f31cac7345b5f64862205ea7ccf555fcf218f87fa0d801008fecb61", 85  "04709f002ac4642b6a87ea0a9dc76eeaa93f71b3185985817ec1827eae34b46b5d869320efb5c5cbe2a5c13f96463fe0210710b53352a4314188daffe07bd54154", 86  "04aff62315e9c18004392a5d9e39496ff5794b2d9f43ab4e8ade64740d7fdfe896969be859b43f26ef5aa4b5a0d11808277b4abfa1a07cc39f2839b89cc2bc6b4c" 87  }).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList()); 88  89  federationChangeAuthorizer = new AddressBasedAuthorizer( 90  federationChangeAuthorizedKeys, 91  AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY 92  ); 93  94  federationActivationAge = 10L; 95  96  fundsMigrationAgeSinceActivationBegin = 15L; 97  fundsMigrationAgeSinceActivationEnd = 150L; 98  99  // Key generated with GenNodeKey using generator 'auth-lock-whitelist' 100  List<ECKey> lockWhitelistAuthorizedKeys = Arrays.stream(new String[]{ 101  "04641fb250d7ca7a1cb4f530588e978013038ec4294d084d248869dd54d98873e45c61d00ceeaeeb9e35eab19fa5fbd8f07cb8a5f0ddba26b4d4b18349c09199ad" 102  }).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList()); 103  104  lockWhitelistChangeAuthorizer = new AddressBasedAuthorizer( 105  lockWhitelistAuthorizedKeys, 106  AddressBasedAuthorizer.MinimumRequiredCalculation.ONE 107  ); 108  109  // Key generated with GenNodeKey using generator 'auth-fee-per-kb' 110  List<ECKey> feePerKbAuthorizedKeys = Arrays.stream(new String[]{ 111  "0430c7d0146029db553d60cf11e8d39df1c63979ee2e4cd1e4d4289a5d88cfcbf3a09b06b5cbc88b5bfeb4b87a94cefab81c8d44655e7e813fc3e18f51cfe7e8a0" 112  }).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList()); 113  114  feePerKbChangeAuthorizer = new AddressBasedAuthorizer( 115  feePerKbAuthorizedKeys, 116  AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY 117  ); 118  119  genesisFeePerKb = Coin.MILLICOIN; 120  121  maxFeePerKb = Coin.valueOf(5_000_000L); 122  123  initialLockingCap = Coin.COIN.multiply(1_000L); // 1_000 BTC 124  125  lockingCapIncrementsMultiplier = 2; 126  127  minSecondsBetweenCallsReceiveHeader = 300; // 5 minutes in Seconds 128  129  maxDepthBlockchainAccepted = 25; 130  131  // Key generated with GenNodeKey using generator 'auth-increase_locking_cap' 132  List<ECKey> increaseLockingCapAuthorizedKeys = Arrays.stream(new String[]{ 133  "04450bbaab83ec48b3cb8fbb077c950ee079733041c039a8c4f1539e5181ca1a27589eeaf0fbf430e49d2909f14c767bf6909ad6845831f683416ee12b832e36ed" 134  }).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList()); 135  136  increaseLockingCapAuthorizer = new AddressBasedAuthorizer( 137  increaseLockingCapAuthorizedKeys, 138  AddressBasedAuthorizer.MinimumRequiredCalculation.ONE 139  ); 140  141  btcHeightWhenBlockIndexActivates = 10; 142  maxDepthToSearchBlocksBelowIndexActivation = 1_000; //TODO define this value with Sergio 143  144  erpFedActivationDelay = 1000; 145  146  // Keys generated with GenNodeKey using generators 'erp-fed-01' through 'erp-fed-05' 147  erpFedPubKeysList = Arrays.stream(new String[]{ 148  "03b9fc46657cf72a1afa007ecf431de1cd27ff5cc8829fa625b66ca47b967e6b24", 149  "029cecea902067992d52c38b28bf0bb2345bda9b21eca76b16a17c477a64e43301", 150  "03284178e5fbcc63c54c3b38e3ef88adf2da6c526313650041b0ef955763634ebd", 151  "03776b1fd8f86da3c1db3d69699e8250a15877d286734ea9a6da8e9d8ad25d16c1", 152  "03ab0e2cd7ed158687fc13b88019990860cdb72b1f5777b58513312550ea1584bc" 153  }).map(hex -> BtcECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList() 154  ); 155  156  // Multisig address created in bitcoind with the following private keys: 157  // 47129ffed2c0273c75d21bb8ba020073bb9a1638df0e04853407461fdd9e8b83 158  // 9f72d27ba603cfab5a0201974a6783ca2476ec3d6b4e2625282c682e0e5f1c35 159  // e1b17fcd0ef1942465eee61b20561b16750191143d365e71de08b33dd84a9788 160  oldFederationAddress = "2N7ZgQyhFKm17RbaLqygYbS7KLrQfapyZzu"; 161  162  minimumPegoutValuePercentageToReceiveAfterFee = 20; 163  } 164  165  public static BridgeRegTestConstants getInstance() { 166  return instance; 167  } 168 }