Skip to content

Commit

Permalink
Merge pull request #1902 from rsksmart/new-erp-script
Browse files Browse the repository at this point in the history
New redeem script format for the federation
  • Loading branch information
aeidelman authored Nov 15, 2022
2 parents 42afd35 + 02d53ef commit 6a855b8
Show file tree
Hide file tree
Showing 41 changed files with 1,569 additions and 870 deletions.
10 changes: 5 additions & 5 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
<sha256 value="6f9c5578df1e4dd58debf5b6693e88cd7a76653908e8e675e9a74ca093231aae" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="co.rsk.bitcoinj" name="bitcoinj-thin" version="0.14.4-rsk-12">
<artifact name="bitcoinj-thin-0.14.4-rsk-12.jar">
<sha256 value="c7089559775c62d212fe839cf5bfeb3592f4545dd41f54d2fe474cf6b8f9641a" origin="Generated by Gradle"/>
<component group="co.rsk.bitcoinj" name="bitcoinj-thin" version="0.14.4-rsk-14">
<artifact name="bitcoinj-thin-0.14.4-rsk-14.jar">
<sha256 value="76c16c354cdbe1844ab7501eb536b3f8da31c8679f1765813af4748e7af31abe" origin="Generated by Gradle"/>
</artifact>
<artifact name="bitcoinj-thin-0.14.4-rsk-12.pom">
<sha256 value="e79cb080ed7569b7e6e4c1533edeb62ba9b81c784b3da9dca5d7aa473402aa46" origin="Generated by Gradle"/>
<artifact name="bitcoinj-thin-0.14.4-rsk-14.pom">
<sha256 value="3e650b44d944cbbf886f2b04fb03f9d829a0b73c084d602ea481ff8571fba8cb" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.fasterxml" name="oss-parent" version="27">
Expand Down
2 changes: 1 addition & 1 deletion rskj-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ext {
jsonrpc4jVer : '1.5.1',
jaxwsRtVer : '2.3.3',

bitcoinjThinVer: '0.14.4-rsk-12',
bitcoinjThinVer: '0.14.4-rsk-14',
rskjNativeVer: '1.2.1',
]

Expand Down
16 changes: 12 additions & 4 deletions rskj-core/src/main/java/co/rsk/config/BridgeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import co.rsk.peg.AddressBasedAuthorizer;
import co.rsk.peg.Federation;
import java.util.List;
import org.ethereum.config.blockchain.upgrades.ActivationConfig;
import org.ethereum.config.blockchain.upgrades.ConsensusRule;

public class BridgeConstants {
public abstract class BridgeConstants {
protected String btcParamsString;

protected Federation genesisFederation;
Expand All @@ -44,9 +46,11 @@ public class BridgeConstants {
protected Coin minimumPegoutTxValueInSatoshis;

protected long federationActivationAge;
protected long specialCaseFederationActivationAge;

protected long fundsMigrationAgeSinceActivationBegin;
protected long fundsMigrationAgeSinceActivationEnd;
protected long specialCaseFundsMigrationAgeSinceActivationEnd;

protected AddressBasedAuthorizer federationChangeAuthorizer;

Expand Down Expand Up @@ -116,14 +120,18 @@ public int getRsk2BtcMinimumAcceptableConfirmations() {

public Coin getMinimumPegoutTxValueInSatoshis() { return minimumPegoutTxValueInSatoshis; }

public long getFederationActivationAge() { return federationActivationAge; }
public long getFederationActivationAge() {
return federationActivationAge;
}

public long getFundsMigrationAgeSinceActivationBegin() {
return fundsMigrationAgeSinceActivationBegin;
}

public long getFundsMigrationAgeSinceActivationEnd() {
return fundsMigrationAgeSinceActivationEnd;
public long getFundsMigrationAgeSinceActivationEnd(ActivationConfig.ForBlock activations) {
return activations.isActive(ConsensusRule.RSKIP357) ?
specialCaseFundsMigrationAgeSinceActivationEnd :
fundsMigrationAgeSinceActivationEnd;
}

public AddressBasedAuthorizer getFederationChangeAuthorizer() { return federationChangeAuthorizer; }
Expand Down
58 changes: 32 additions & 26 deletions rskj-core/src/main/java/co/rsk/config/BridgeDevNetConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ public class BridgeDevNetConstants extends BridgeConstants {
// IMPORTANT: BTC, RSK and MST keys are the same.
// Change upon implementation of the <INSERT FORK NAME HERE> fork.
public static final List<BtcECKey> DEVNET_FEDERATION_PUBLIC_KEYS = Arrays.asList(
BtcECKey.fromPublicOnly(Hex.decode("03d68975ab0f6ab782febc37aaa486ae19cc5e72c6900e34e21317285c88915ed6")),
BtcECKey.fromPublicOnly(Hex.decode("02914c05df0b11862ac6931c226ad40ebc4f5624ee6dca34278d3bbfa73b914cbd")),
BtcECKey.fromPublicOnly(Hex.decode("0309d9df35855aa45235a04e30d228889eb03e462874588e631359d5f9cdea6519"))
BtcECKey.fromPublicOnly(
Hex.decode("03d68975ab0f6ab782febc37aaa486ae19cc5e72c6900e34e21317285c88915ed6")
),
BtcECKey.fromPublicOnly(
Hex.decode("02914c05df0b11862ac6931c226ad40ebc4f5624ee6dca34278d3bbfa73b914cbd")
),
BtcECKey.fromPublicOnly(
Hex.decode("0309d9df35855aa45235a04e30d228889eb03e462874588e631359d5f9cdea6519")
)
);

public BridgeDevNetConstants(List<BtcECKey> federationPublicKeys) {
Expand All @@ -53,10 +59,10 @@ public BridgeDevNetConstants(List<BtcECKey> federationPublicKeys) {
// Expected federation address is:
// 2NCEo1RdmGDj6MqiipD6DUSerSxKv79FNWX
genesisFederation = new Federation(
federationMembers,
genesisFederationAddressCreatedAt,
1L,
getBtcParams()
federationMembers,
genesisFederationAddressCreatedAt,
1L,
getBtcParams()
);

btc2RskMinimumAcceptableConfirmations = 1;
Expand All @@ -72,46 +78,46 @@ public BridgeDevNetConstants(List<BtcECKey> federationPublicKeys) {
minimumPeginTxValueInSatoshis = Coin.valueOf(500_000);
minimumPegoutTxValueInSatoshis = Coin.valueOf(250_000);


// Keys generated with GenNodeKey using generators 'auth-a' through 'auth-e'
List<ECKey> federationChangeAuthorizedKeys = Arrays.stream(new String[]{
"04dde17c5fab31ffc53c91c2390136c325bb8690dc135b0840075dd7b86910d8ab9e88baad0c32f3eea8833446a6bc5ff1cd2efa99ecb17801bcb65fc16fc7d991",
"04af886c67231476807e2a8eee9193878b9d94e30aa2ee469a9611d20e1e1c1b438e5044148f65e6e61bf03e9d72e597cb9cdea96d6fc044001b22099f9ec403e2",
"045d4dedf9c69ab3ea139d0f0da0ad00160b7663d01ce7a6155cd44a3567d360112b0480ab6f31cac7345b5f64862205ea7ccf555fcf218f87fa0d801008fecb61",
"04709f002ac4642b6a87ea0a9dc76eeaa93f71b3185985817ec1827eae34b46b5d869320efb5c5cbe2a5c13f96463fe0210710b53352a4314188daffe07bd54154",
// "04aff62315e9c18004392a5d9e39496ff5794b2d9f43ab4e8ade64740d7fdfe896969be859b43f26ef5aa4b5a0d11808277b4abfa1a07cc39f2839b89cc2bc6b4c"
"0447b4aba974c61c6c4045893267346730ec965b308e7ca04a899cf06a901face3106e1eef1bdad04928cd8263522eda4872d20d3fe1ef5e551785c4a482656a6e"
"04dde17c5fab31ffc53c91c2390136c325bb8690dc135b0840075dd7b86910d8ab9e88baad0c32f3eea8833446a6bc5ff1cd2efa99ecb17801bcb65fc16fc7d991",
"04af886c67231476807e2a8eee9193878b9d94e30aa2ee469a9611d20e1e1c1b438e5044148f65e6e61bf03e9d72e597cb9cdea96d6fc044001b22099f9ec403e2",
"045d4dedf9c69ab3ea139d0f0da0ad00160b7663d01ce7a6155cd44a3567d360112b0480ab6f31cac7345b5f64862205ea7ccf555fcf218f87fa0d801008fecb61",
"04709f002ac4642b6a87ea0a9dc76eeaa93f71b3185985817ec1827eae34b46b5d869320efb5c5cbe2a5c13f96463fe0210710b53352a4314188daffe07bd54154",
// "04aff62315e9c18004392a5d9e39496ff5794b2d9f43ab4e8ade64740d7fdfe896969be859b43f26ef5aa4b5a0d11808277b4abfa1a07cc39f2839b89cc2bc6b4c"
"0447b4aba974c61c6c4045893267346730ec965b308e7ca04a899cf06a901face3106e1eef1bdad04928cd8263522eda4872d20d3fe1ef5e551785c4a482656a6e"
}).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList());

federationChangeAuthorizer = new AddressBasedAuthorizer(
federationChangeAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY
federationChangeAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY
);

// Key generated with GenNodeKey using generator 'auth-lock-whitelist'
List<ECKey> lockWhitelistAuthorizedKeys = Arrays.stream(new String[]{
// "04641fb250d7ca7a1cb4f530588e978013038ec4294d084d248869dd54d98873e45c61d00ceeaeeb9e35eab19fa5fbd8f07cb8a5f0ddba26b4d4b18349c09199ad"
"0447b4aba974c61c6c4045893267346730ec965b308e7ca04a899cf06a901face3106e1eef1bdad04928cd8263522eda4872d20d3fe1ef5e551785c4a482656a6e"
// "04641fb250d7ca7a1cb4f530588e978013038ec4294d084d248869dd54d98873e45c61d00ceeaeeb9e35eab19fa5fbd8f07cb8a5f0ddba26b4d4b18349c09199ad"
"0447b4aba974c61c6c4045893267346730ec965b308e7ca04a899cf06a901face3106e1eef1bdad04928cd8263522eda4872d20d3fe1ef5e551785c4a482656a6e"
}).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList());

lockWhitelistChangeAuthorizer = new AddressBasedAuthorizer(
lockWhitelistAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.ONE
lockWhitelistAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.ONE
);

federationActivationAge = 10L;

fundsMigrationAgeSinceActivationBegin = 15L;
fundsMigrationAgeSinceActivationEnd = 100L;
specialCaseFundsMigrationAgeSinceActivationEnd = 100L;

// Key generated with GenNodeKey using generator 'auth-fee-per-kb'
List<ECKey> feePerKbAuthorizedKeys = Arrays.stream(new String[]{
"0430c7d0146029db553d60cf11e8d39df1c63979ee2e4cd1e4d4289a5d88cfcbf3a09b06b5cbc88b5bfeb4b87a94cefab81c8d44655e7e813fc3e18f51cfe7e8a0"
"0430c7d0146029db553d60cf11e8d39df1c63979ee2e4cd1e4d4289a5d88cfcbf3a09b06b5cbc88b5bfeb4b87a94cefab81c8d44655e7e813fc3e18f51cfe7e8a0"
}).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList());

feePerKbChangeAuthorizer = new AddressBasedAuthorizer(
feePerKbAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY
feePerKbAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY
);

genesisFeePerKb = Coin.MILLICOIN;
Expand All @@ -120,12 +126,12 @@ public BridgeDevNetConstants(List<BtcECKey> federationPublicKeys) {

// Key generated with GenNodeKey using generator 'auth-increase_locking_cap'
List<ECKey> increaseLockingCapAuthorizedKeys = Arrays.stream(new String[]{
"04450bbaab83ec48b3cb8fbb077c950ee079733041c039a8c4f1539e5181ca1a27589eeaf0fbf430e49d2909f14c767bf6909ad6845831f683416ee12b832e36ed"
"04450bbaab83ec48b3cb8fbb077c950ee079733041c039a8c4f1539e5181ca1a27589eeaf0fbf430e49d2909f14c767bf6909ad6845831f683416ee12b832e36ed"
}).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList());

increaseLockingCapAuthorizer = new AddressBasedAuthorizer(
increaseLockingCapAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.ONE
increaseLockingCapAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.ONE
);

initialLockingCap = Coin.COIN.multiply(1_000L); // 1_000 BTC
Expand Down
44 changes: 21 additions & 23 deletions rskj-core/src/main/java/co/rsk/config/BridgeMainNetConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import co.rsk.peg.Federation;
import co.rsk.peg.FederationMember;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import org.bouncycastle.util.encoders.Hex;
import org.ethereum.crypto.ECKey;

Expand Down Expand Up @@ -55,10 +54,10 @@ public class BridgeMainNetConstants extends BridgeConstants {
Instant genesisFederationAddressCreatedAt = Instant.ofEpochMilli(1514948400l);

genesisFederation = new Federation(
federationMembers,
genesisFederationAddressCreatedAt,
1L,
getBtcParams()
federationMembers,
genesisFederationAddressCreatedAt,
1L,
getBtcParams()
);

btc2RskMinimumAcceptableConfirmations = 100;
Expand All @@ -74,37 +73,36 @@ public class BridgeMainNetConstants extends BridgeConstants {
minimumPeginTxValueInSatoshis = Coin.valueOf(500_000);
minimumPegoutTxValueInSatoshis = Coin.valueOf(400_000);

// Keys generated with GenNodeKey using generators 'auth-a' through 'auth-e'
List<ECKey> federationChangeAuthorizedKeys = Arrays.stream(new String[]{
"04e593d4cde25137b13f19462bc4c02e97ba2ed5a3860813497abf9b4eeb9259e37e0384d12cfd2d9a7a0ba606b31ee34317a9d7f4a8591c6bcf5dfd5563248b2f",
"045e7f2563e73d44d149c19cffca36e1898597dc759d76166b8104103c0d3f351a8a48e3a224544e9a649ad8ebcfdbd6c39744ddb85925f19c7e3fd48f07fc1c06",
"0441945e4e272936106f6200b36162f3510e8083535c15e175ac82deaf828da955b85fd72b7534f2a34cedfb45fa63b728cc696a2bd3c5d39ec799ec2618e9aa9f"
"04e593d4cde25137b13f19462bc4c02e97ba2ed5a3860813497abf9b4eeb9259e37e0384d12cfd2d9a7a0ba606b31ee34317a9d7f4a8591c6bcf5dfd5563248b2f",
"045e7f2563e73d44d149c19cffca36e1898597dc759d76166b8104103c0d3f351a8a48e3a224544e9a649ad8ebcfdbd6c39744ddb85925f19c7e3fd48f07fc1c06",
"0441945e4e272936106f6200b36162f3510e8083535c15e175ac82deaf828da955b85fd72b7534f2a34cedfb45fa63b728cc696a2bd3c5d39ec799ec2618e9aa9f"
}).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList());

federationChangeAuthorizer = new AddressBasedAuthorizer(
federationChangeAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY
federationChangeAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.MAJORITY
);

// Key generated with GenNodeKey using generator 'auth-lock-whitelist'
List<ECKey> lockWhitelistAuthorizedKeys = Arrays.stream(new String[]{
"041a2449e9d63409c5a8ea3a21c4109b1a6634ee88fd57176d45ea46a59713d5e0b688313cf252128a3e49a0b2effb4b413e5a2525a6fa5894d059f815c9d9efa6"
"041a2449e9d63409c5a8ea3a21c4109b1a6634ee88fd57176d45ea46a59713d5e0b688313cf252128a3e49a0b2effb4b413e5a2525a6fa5894d059f815c9d9efa6"
}).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList());

lockWhitelistChangeAuthorizer = new AddressBasedAuthorizer(
lockWhitelistAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.ONE
lockWhitelistAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.ONE
);

federationActivationAge = 18500L;

fundsMigrationAgeSinceActivationBegin = 0L;
fundsMigrationAgeSinceActivationEnd = 10585L;
specialCaseFundsMigrationAgeSinceActivationEnd = 172_800L; // 60 days, considering 1 block every 30 seconds

List<ECKey> feePerKbAuthorizedKeys = Arrays.stream(new String[]{
"0448f51638348b034995b1fd934fe14c92afde783e69f120a46ee16eb6bdc2e4f6b5e37772094c68c0dea2b1be3d96ea9651a9eebda7304914c8047f4e3e251378",
"0484c66f75548baf93e322574adac4e4579b6a53f8d11fab640e14c90118e6983ef24b0de349a3e88f72e81e771ae1c897cef446fd7f4da71778c532aee3b6c41b",
"04bb6435dc1ea12da843ebe213893d136c1624acd681fff82551498ae00bf28e9323164b00daf925fa75177463b8254a2aae8a1713e4d851a84ea369c193e9ce51"
"0448f51638348b034995b1fd934fe14c92afde783e69f120a46ee16eb6bdc2e4f6b5e37772094c68c0dea2b1be3d96ea9651a9eebda7304914c8047f4e3e251378",
"0484c66f75548baf93e322574adac4e4579b6a53f8d11fab640e14c90118e6983ef24b0de349a3e88f72e81e771ae1c897cef446fd7f4da71778c532aee3b6c41b",
"04bb6435dc1ea12da843ebe213893d136c1624acd681fff82551498ae00bf28e9323164b00daf925fa75177463b8254a2aae8a1713e4d851a84ea369c193e9ce51"
}).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList());

feePerKbChangeAuthorizer = new AddressBasedAuthorizer(
Expand All @@ -117,14 +115,14 @@ public class BridgeMainNetConstants extends BridgeConstants {
maxFeePerKb = Coin.valueOf(5_000_000L);

List<ECKey> increaseLockingCapAuthorizedKeys = Arrays.stream(new String[]{
"0448f51638348b034995b1fd934fe14c92afde783e69f120a46ee16eb6bdc2e4f6b5e37772094c68c0dea2b1be3d96ea9651a9eebda7304914c8047f4e3e251378",
"0484c66f75548baf93e322574adac4e4579b6a53f8d11fab640e14c90118e6983ef24b0de349a3e88f72e81e771ae1c897cef446fd7f4da71778c532aee3b6c41b",
"04bb6435dc1ea12da843ebe213893d136c1624acd681fff82551498ae00bf28e9323164b00daf925fa75177463b8254a2aae8a1713e4d851a84ea369c193e9ce51"
"0448f51638348b034995b1fd934fe14c92afde783e69f120a46ee16eb6bdc2e4f6b5e37772094c68c0dea2b1be3d96ea9651a9eebda7304914c8047f4e3e251378",
"0484c66f75548baf93e322574adac4e4579b6a53f8d11fab640e14c90118e6983ef24b0de349a3e88f72e81e771ae1c897cef446fd7f4da71778c532aee3b6c41b",
"04bb6435dc1ea12da843ebe213893d136c1624acd681fff82551498ae00bf28e9323164b00daf925fa75177463b8254a2aae8a1713e4d851a84ea369c193e9ce51"
}).map(hex -> ECKey.fromPublicOnly(Hex.decode(hex))).collect(Collectors.toList());

increaseLockingCapAuthorizer = new AddressBasedAuthorizer(
increaseLockingCapAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.ONE
increaseLockingCapAuthorizedKeys,
AddressBasedAuthorizer.MinimumRequiredCalculation.ONE
);

lockingCapIncrementsMultiplier = 2;
Expand Down
Loading

0 comments on commit 6a855b8

Please sign in to comment.