From f73a2280d94e6d61dc8590025850772215bbd40b Mon Sep 17 00:00:00 2001 From: shaozhuguang Date: Fri, 21 Jun 2019 15:38:10 +0800 Subject: [PATCH] =?UTF-8?q?Delete=20the=20public=20key=20part=20involved?= =?UTF-8?q?=20in=20the=20bftsmart=20file=20=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bftsmart/BftsmartCommitBlockConfig.java | 70 ++++++------ .../bftsmart/BftsmartCommitBlockSettings.java | 34 +++--- .../bftsmart/BftsmartConsensusConfig.java | 26 +++-- .../bftsmart/BftsmartConsensusSettings.java | 4 +- .../BftsmartConsensusSettingsBuilder.java | 106 ++++++++++-------- .../BftsmartConsensusManageService.java | 18 +-- .../bftsmart/service/BftsmartNodeServer.java | 2 +- .../service/BftsmartServerSettingConfig.java | 3 - .../service/BftsmartServerSettings.java | 1 - ...xyClientTest.java => ProxyClientTest.java} | 11 +- source/consensus/consensus-framework/pom.xml | 5 + .../consensus/ConsensusSettingsBuilder.java | 10 +- .../mq/MsgQueueConsensusSettingsBuilder.java | 3 +- .../resources/config/init/bftsmart.config | 15 --- .../main/resources/config/init/ledger.init | 53 +++------ .../src/main/resources/config/init/local.conf | 3 +- .../resources/config/init/mq/ledger-init.conf | 66 ----------- .../main/resources/config/init/mq/ledger.init | 74 ++++++++++++ .../main/resources/config/init/mq/local.conf | 23 ++-- .../src/main/resources/scripts/ledger-init.sh | 2 +- .../jd/blockchain/intgr/IntegrationTest.java | 5 +- .../intgr/consensus/ConsensusTest.java | 4 +- .../intgr/perf/GlobalPerformanceTest.java | 4 +- .../intgr/perf/LedgerInitializeWebTest.java | 8 +- .../intgr/perf/LedgerPerformanceTest.java | 4 +- .../com/jd/blockchain/intgr/perf/Utils.java | 52 +++++++++ .../blockchain/intgr/IntegrationBaseTest.java | 5 +- .../jd/blockchain/intgr/IntegrationTest2.java | 5 +- .../intgr/IntegrationTestDataAccount.java | 5 +- .../LedgerInitializeWeb4Nodes.java | 5 +- .../LedgerInitializeWeb4SingleStepsTest.java | 5 +- .../ledger/LedgerBlockGeneratingTest.java | 5 +- .../src/test/resources/bftsmart.config | 25 +---- .../src/test/resources/ledger.init | 1 - .../initializer/LedgerInitProperties.java | 10 +- .../web/LedgerInitializeWebController.java | 9 +- 36 files changed, 366 insertions(+), 315 deletions(-) rename source/consensus/consensus-bftsmart/src/test/java/test/com/jd/blockchain/consensus/bftsmart/{proxyClientTest.java => ProxyClientTest.java} (93%) delete mode 100644 source/deployment/deployment-peer/src/main/resources/config/init/mq/ledger-init.conf create mode 100644 source/deployment/deployment-peer/src/main/resources/config/init/mq/ledger.init diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartCommitBlockConfig.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartCommitBlockConfig.java index 23f682ce..5fa31a11 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartCommitBlockConfig.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartCommitBlockConfig.java @@ -1,35 +1,35 @@ -package com.jd.blockchain.consensus.bftsmart; - -public class BftsmartCommitBlockConfig implements BftsmartCommitBlockSettings { - - private int txSizePerBlock; - - private long maxDelayMilliSecondsPerBlock; - - - public BftsmartCommitBlockConfig() { - - } - - public BftsmartCommitBlockConfig(int txSizePerBlock, long maxDelayMilliSecondsPerBlock) { - this.txSizePerBlock = txSizePerBlock; - this.maxDelayMilliSecondsPerBlock = maxDelayMilliSecondsPerBlock; - } - @Override - public int getTxSizePerBlock() { - return txSizePerBlock; - } - - public void setTxSizePerBlock(int txSizePerBlock) { - this.txSizePerBlock = txSizePerBlock; - } - - @Override - public long getMaxDelayMilliSecondsPerBlock() { - return maxDelayMilliSecondsPerBlock; - } - - public void setMaxDelayMilliSecondsPerBlock(long maxDelayMilliSecondsPerBlock) { - this.maxDelayMilliSecondsPerBlock = maxDelayMilliSecondsPerBlock; - } -} +//package com.jd.blockchain.consensus.bftsmart; +// +//public class BftsmartCommitBlockConfig implements BftsmartCommitBlockSettings { +// +// private int txSizePerBlock; +// +// private long maxDelayMilliSecondsPerBlock; +// +// +// public BftsmartCommitBlockConfig() { +// +// } +// +// public BftsmartCommitBlockConfig(int txSizePerBlock, long maxDelayMilliSecondsPerBlock) { +// this.txSizePerBlock = txSizePerBlock; +// this.maxDelayMilliSecondsPerBlock = maxDelayMilliSecondsPerBlock; +// } +// @Override +// public int getTxSizePerBlock() { +// return txSizePerBlock; +// } +// +// public void setTxSizePerBlock(int txSizePerBlock) { +// this.txSizePerBlock = txSizePerBlock; +// } +// +// @Override +// public long getMaxDelayMilliSecondsPerBlock() { +// return maxDelayMilliSecondsPerBlock; +// } +// +// public void setMaxDelayMilliSecondsPerBlock(long maxDelayMilliSecondsPerBlock) { +// this.maxDelayMilliSecondsPerBlock = maxDelayMilliSecondsPerBlock; +// } +//} diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartCommitBlockSettings.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartCommitBlockSettings.java index 675344da..2924c9f0 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartCommitBlockSettings.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartCommitBlockSettings.java @@ -1,17 +1,17 @@ -package com.jd.blockchain.consensus.bftsmart; - -import com.jd.blockchain.binaryproto.DataContract; -import com.jd.blockchain.binaryproto.DataField; -import com.jd.blockchain.binaryproto.PrimitiveType; -import com.jd.blockchain.consts.DataCodes; - - -@DataContract(code = DataCodes.CONSENSUS_BFTSMART_BLOCK_SETTINGS) -public interface BftsmartCommitBlockSettings { - - @DataField(order = 0, primitiveType = PrimitiveType.INT32) - int getTxSizePerBlock(); - - @DataField(order = 1, primitiveType = PrimitiveType.INT64) - long getMaxDelayMilliSecondsPerBlock(); -} +//package com.jd.blockchain.consensus.bftsmart; +// +//import com.jd.blockchain.binaryproto.DataContract; +//import com.jd.blockchain.binaryproto.DataField; +//import com.jd.blockchain.binaryproto.PrimitiveType; +//import com.jd.blockchain.consts.DataCodes; +// +// +//@DataContract(code = DataCodes.CONSENSUS_BFTSMART_BLOCK_SETTINGS) +//public interface BftsmartCommitBlockSettings { +// +// @DataField(order = 0, primitiveType = PrimitiveType.INT32) +// int getTxSizePerBlock(); +// +// @DataField(order = 1, primitiveType = PrimitiveType.INT64) +// long getMaxDelayMilliSecondsPerBlock(); +//} diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusConfig.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusConfig.java index ca3a301e..48d5acb9 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusConfig.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusConfig.java @@ -9,7 +9,7 @@ public class BftsmartConsensusConfig implements BftsmartConsensusSettings { private BftsmartNodeSettings[] nodes; - private BftsmartCommitBlockSettings commitBlockSettings; +// private BftsmartCommitBlockSettings commitBlockSettings; static { DataContractRegistry.register(BftsmartConsensusSettings.class); @@ -24,9 +24,11 @@ public class BftsmartConsensusConfig implements BftsmartConsensusSettings { * @param bftsmartSystemConfigs * bftsmart系统配置; */ - public BftsmartConsensusConfig(BftsmartNodeSettings[] nodes, BftsmartCommitBlockSettings commitBlockSettings, Property[] bftsmartSystemConfigs) { + public BftsmartConsensusConfig(BftsmartNodeSettings[] nodes, +// BftsmartCommitBlockSettings commitBlockSettings, + Property[] bftsmartSystemConfigs) { this.nodes = nodes; - this.commitBlockSettings = commitBlockSettings; +// this.commitBlockSettings = commitBlockSettings; this.bftsmartSystemConfig = bftsmartSystemConfigs; } @@ -40,13 +42,13 @@ public class BftsmartConsensusConfig implements BftsmartConsensusSettings { return bftsmartSystemConfig; } - @Override - public BftsmartCommitBlockSettings getCommitBlockSettings() { - return commitBlockSettings; - } - - - public void setCommitBlockSettings(BftsmartCommitBlockSettings commitBlockSettings) { - this.commitBlockSettings = commitBlockSettings; - } +// @Override +// public BftsmartCommitBlockSettings getCommitBlockSettings() { +// return commitBlockSettings; +// } +// +// +// public void setCommitBlockSettings(BftsmartCommitBlockSettings commitBlockSettings) { +// this.commitBlockSettings = commitBlockSettings; +// } } diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettings.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettings.java index f4e24cf5..d3ce6494 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettings.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettings.java @@ -14,7 +14,7 @@ public interface BftsmartConsensusSettings extends ConsensusSettings { @DataField(order = 1, primitiveType = PrimitiveType.BYTES, list=true) Property[] getSystemConfigs(); - @DataField(order = 2, refContract = true) - BftsmartCommitBlockSettings getCommitBlockSettings(); +// @DataField(order = 2, refContract = true) +// BftsmartCommitBlockSettings getCommitBlockSettings(); } diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettingsBuilder.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettingsBuilder.java index 1311a3a2..e72f866a 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettingsBuilder.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettingsBuilder.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; +import com.jd.blockchain.ledger.ParticipantNode; import com.jd.blockchain.tools.keygen.KeyGenCommand; import com.jd.blockchain.utils.PropertiesUtils; import com.jd.blockchain.utils.codec.Base58Utils; @@ -24,6 +25,8 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde private static final String CONFIG_TEMPLATE_FILE = "bftsmart.config"; + private static final String CONFIG_LEDGER_INIT = "ledger.init"; + /** * 参数键:节点数量; */ @@ -61,6 +64,8 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde */ public static final String CONSENSUS_SECURE_PATTERN = "system.server.%s.network.secure"; + + private static Properties CONFIG_TEMPLATE; static { ClassPathResource configResource = new ClassPathResource(CONFIG_TEMPLATE_FILE); @@ -74,31 +79,31 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde } //解析得到结块的相关配置信息 - public BftsmartCommitBlockConfig createBlockConfig(Properties resolvingProps) { - BftsmartCommitBlockConfig blockConfig = new BftsmartCommitBlockConfig(); - - String txSizeString = PropertiesUtils.getRequiredProperty(resolvingProps, BFTSMART_BLOCK_TXSIZE_KEY); - resolvingProps.remove(BFTSMART_BLOCK_TXSIZE_KEY); - - if (txSizeString == null || txSizeString.length() == 0) { - blockConfig.setTxSizePerBlock(DEFAULT_TXSIZE); - } - else { - blockConfig.setTxSizePerBlock(Integer.parseInt(txSizeString)); - } - - String maxDelayString = PropertiesUtils.getRequiredProperty(resolvingProps, BFTSMART_BLOCK_MAXDELAY_KEY); - resolvingProps.remove(BFTSMART_BLOCK_MAXDELAY_KEY); - - if (maxDelayString == null || maxDelayString.length() == 0) { - blockConfig.setMaxDelayMilliSecondsPerBlock(DEFAULT_MAXDELAY); - } - else { - blockConfig.setMaxDelayMilliSecondsPerBlock(Long.parseLong(maxDelayString)); - } - - return blockConfig; - } +// public BftsmartCommitBlockConfig createBlockConfig(Properties resolvingProps) { +// BftsmartCommitBlockConfig blockConfig = new BftsmartCommitBlockConfig(); +// +// String txSizeString = PropertiesUtils.getRequiredProperty(resolvingProps, BFTSMART_BLOCK_TXSIZE_KEY); +// resolvingProps.remove(BFTSMART_BLOCK_TXSIZE_KEY); +// +// if (txSizeString == null || txSizeString.length() == 0) { +// blockConfig.setTxSizePerBlock(DEFAULT_TXSIZE); +// } +// else { +// blockConfig.setTxSizePerBlock(Integer.parseInt(txSizeString)); +// } +// +// String maxDelayString = PropertiesUtils.getRequiredProperty(resolvingProps, BFTSMART_BLOCK_MAXDELAY_KEY); +// resolvingProps.remove(BFTSMART_BLOCK_MAXDELAY_KEY); +// +// if (maxDelayString == null || maxDelayString.length() == 0) { +// blockConfig.setMaxDelayMilliSecondsPerBlock(DEFAULT_MAXDELAY); +// } +// else { +// blockConfig.setMaxDelayMilliSecondsPerBlock(Long.parseLong(maxDelayString)); +// } +// +// return blockConfig; +// } @Override public Properties createPropertiesTemplate() { @@ -106,7 +111,7 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde } @Override - public BftsmartConsensusSettings createSettings(Properties props) { + public BftsmartConsensusSettings createSettings(Properties props, ParticipantNode[] participantNodes) { Properties resolvingProps = PropertiesUtils.cloneFrom(props); int serversNum = PropertiesUtils.getInt(resolvingProps, SERVER_NUM_KEY); if (serversNum < 0) { @@ -115,18 +120,26 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde if (serversNum < 4) { throw new IllegalArgumentException(String.format("Property[%s] is less than 4!", SERVER_NUM_KEY)); } + if (participantNodes == null) { + throw new IllegalArgumentException("ParticipantNodes is Empty !!!"); + } + if (serversNum != participantNodes.length) { + throw new IllegalArgumentException(String.format("Property[%s] which is [%s] unequal " + + "ParticipantNodes's length which is [%s] !", SERVER_NUM_KEY, serversNum, participantNodes.length)); + } - BftsmartCommitBlockConfig blockConfig = createBlockConfig(resolvingProps); +// BftsmartCommitBlockConfig blockConfig = createBlockConfig(resolvingProps); BftsmartNodeSettings[] nodesSettings = new BftsmartNodeSettings[serversNum]; for (int i = 0; i < serversNum; i++) { int id = i; - String keyOfPubkey = keyOfNode(PUBKEY_PATTERN, id); - String base58PubKey = PropertiesUtils.getRequiredProperty(resolvingProps, keyOfPubkey); +// String keyOfPubkey = keyOfNode(PUBKEY_PATTERN, id); +// String base58PubKey = PropertiesUtils.getRequiredProperty(resolvingProps, keyOfPubkey); // PubKey pubKey = new PubKey(Base58Utils.decode(base58PubKey)); - PubKey pubKey = KeyGenCommand.decodePubKey(base58PubKey); - resolvingProps.remove(keyOfPubkey); +// PubKey pubKey = KeyGenCommand.decodePubKey(base58PubKey); + PubKey pubKey = participantNodes[i].getPubKey(); +// resolvingProps.remove(keyOfPubkey); String keyOfHost = keyOfNode(CONSENSUS_HOST_PATTERN, id); String networkAddressHost = PropertiesUtils.getRequiredProperty(resolvingProps, keyOfHost); @@ -145,7 +158,8 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde nodesSettings[i] = nodeConfig; } - BftsmartConsensusConfig config = new BftsmartConsensusConfig(nodesSettings, blockConfig, + BftsmartConsensusConfig config = new BftsmartConsensusConfig(nodesSettings, +// blockConfig, PropertiesUtils.getOrderedValues(resolvingProps)); return config; } @@ -160,8 +174,8 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde if (serversNum > 0) { for (int i = 0; i < serversNum; i++) { int id = i; - String keyOfPubkey = keyOfNode(PUBKEY_PATTERN, id); - props.remove(keyOfPubkey); +// String keyOfPubkey = keyOfNode(PUBKEY_PATTERN, id); +// props.remove(keyOfPubkey); String keyOfHost = keyOfNode(CONSENSUS_HOST_PATTERN, id); props.remove(keyOfHost); @@ -180,22 +194,22 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde props.setProperty(SERVER_NUM_KEY, serversNum + ""); //获得结块相关的属性信息 - BftsmartCommitBlockSettings blockSettings = bftsmartSettings.getCommitBlockSettings(); - if (blockSettings == null) { - props.setProperty(BFTSMART_BLOCK_TXSIZE_KEY, DEFAULT_TXSIZE + ""); - props.setProperty(BFTSMART_BLOCK_MAXDELAY_KEY, DEFAULT_MAXDELAY + ""); - } else { - int txSize = blockSettings.getTxSizePerBlock(); - long maxDelay = blockSettings.getMaxDelayMilliSecondsPerBlock(); - props.setProperty(BFTSMART_BLOCK_TXSIZE_KEY, txSize + ""); - props.setProperty(BFTSMART_BLOCK_MAXDELAY_KEY, maxDelay + ""); - } +// BftsmartCommitBlockSettings blockSettings = bftsmartSettings.getCommitBlockSettings(); +// if (blockSettings == null) { +// props.setProperty(BFTSMART_BLOCK_TXSIZE_KEY, DEFAULT_TXSIZE + ""); +// props.setProperty(BFTSMART_BLOCK_MAXDELAY_KEY, DEFAULT_MAXDELAY + ""); +// } else { +// int txSize = blockSettings.getTxSizePerBlock(); +// long maxDelay = blockSettings.getMaxDelayMilliSecondsPerBlock(); +// props.setProperty(BFTSMART_BLOCK_TXSIZE_KEY, txSize + ""); +// props.setProperty(BFTSMART_BLOCK_MAXDELAY_KEY, maxDelay + ""); +// } for (int i = 0; i < serversNum; i++) { BftsmartNodeSettings ns = nodesSettings[i]; int id = i; - String keyOfPubkey = keyOfNode(PUBKEY_PATTERN, id); - props.setProperty(keyOfPubkey, ns.getPubKey().toBase58()); +// String keyOfPubkey = keyOfNode(PUBKEY_PATTERN, id); +// props.setProperty(keyOfPubkey, ns.getPubKey().toBase58()); String keyOfHost = keyOfNode(CONSENSUS_HOST_PATTERN, id); props.setProperty(keyOfHost, ns.getNetworkAddress() == null ? "" : ns.getNetworkAddress().getHost()); diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartConsensusManageService.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartConsensusManageService.java index 215486d0..1e82ee0f 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartConsensusManageService.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartConsensusManageService.java @@ -34,26 +34,28 @@ public class BftsmartConsensusManageService implements ConsensusManageService { @Override public BftsmartClientIncomingSettings authClientIncoming(ClientIdentification authId) { if (verify(authId)) { - BftsmartClientIncomingSettings clientIncomingSettings = new BftsmartClientIncomingConfig(); + BftsmartClientIncomingConfig clientIncomingSettings = new BftsmartClientIncomingConfig(); - ((BftsmartClientIncomingConfig) clientIncomingSettings) + clientIncomingSettings .setTopology(BinarySerializeUtils.serialize(nodeServer.getTopology())); - ((BftsmartClientIncomingConfig) clientIncomingSettings) + + clientIncomingSettings .setTomConfig(BinarySerializeUtils.serialize(nodeServer.getTomConfig())); - ((BftsmartClientIncomingConfig) clientIncomingSettings) + + clientIncomingSettings .setConsensusSettings(nodeServer.getConsensusSetting()); - ((BftsmartClientIncomingConfig) clientIncomingSettings).setPubKey(authId.getPubKey()); + + clientIncomingSettings.setPubKey(authId.getPubKey()); // compute gateway id + authLock.lock(); try { - authLock.lock(); - ((BftsmartClientIncomingConfig) clientIncomingSettings).setClientId(clientId++); + clientIncomingSettings.setClientId(clientId++); clientId += CLIENT_SIZE_PER_GATEWAY; } finally { authLock.unlock(); } return clientIncomingSettings; - } return null; diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java index ce97797a..162ff130 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java @@ -107,7 +107,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer setting = ((BftsmartServerSettings) serverSettings).getConsensusSettings(); - List configList = new ArrayList(); + List configList = new ArrayList<>(); NodeSettings[] nodeSettingsArray = setting.getNodes(); for (NodeSettings nodeSettings : nodeSettingsArray) { diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartServerSettingConfig.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartServerSettingConfig.java index 16420932..3b42bb0d 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartServerSettingConfig.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartServerSettingConfig.java @@ -1,10 +1,7 @@ package com.jd.blockchain.consensus.bftsmart.service; import com.jd.blockchain.consensus.NodeSettings; -import com.jd.blockchain.consensus.bftsmart.BftsmartCommitBlockSettings; import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusSettings; -import com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings; -import com.jd.blockchain.consensus.service.ServerSettings; public class BftsmartServerSettingConfig implements BftsmartServerSettings { private NodeSettings replicaSettings; diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartServerSettings.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartServerSettings.java index 1cf627d2..f6806b96 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartServerSettings.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartServerSettings.java @@ -1,6 +1,5 @@ package com.jd.blockchain.consensus.bftsmart.service; -import com.jd.blockchain.consensus.bftsmart.BftsmartCommitBlockSettings; import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusSettings; import com.jd.blockchain.consensus.service.ServerSettings; diff --git a/source/consensus/consensus-bftsmart/src/test/java/test/com/jd/blockchain/consensus/bftsmart/proxyClientTest.java b/source/consensus/consensus-bftsmart/src/test/java/test/com/jd/blockchain/consensus/bftsmart/ProxyClientTest.java similarity index 93% rename from source/consensus/consensus-bftsmart/src/test/java/test/com/jd/blockchain/consensus/bftsmart/proxyClientTest.java rename to source/consensus/consensus-bftsmart/src/test/java/test/com/jd/blockchain/consensus/bftsmart/ProxyClientTest.java index f597d8d0..3f32fd6b 100644 --- a/source/consensus/consensus-bftsmart/src/test/java/test/com/jd/blockchain/consensus/bftsmart/proxyClientTest.java +++ b/source/consensus/consensus-bftsmart/src/test/java/test/com/jd/blockchain/consensus/bftsmart/ProxyClientTest.java @@ -26,7 +26,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -public class proxyClientTest { +public class ProxyClientTest { int number = 1500000; @@ -69,13 +69,14 @@ public class proxyClientTest { nodesSettings[i] = (BftsmartNodeSettings) node; } - BftsmartConsensusConfig consensusConfig = new BftsmartConsensusConfig(nodesSettings, null, + BftsmartConsensusConfig consensusConfig = new BftsmartConsensusConfig(nodesSettings, +// null, PropertiesUtils.getOrderedValues(bftsmartConf)); for (int j = 0; j < nodeNum; j++) { - ServerSettings serverSettings = new BftsmartServerSettingConfig(); - ((BftsmartServerSettingConfig) serverSettings).setReplicaSettings(nodesSettings[j]); - ((BftsmartServerSettingConfig) serverSettings).setConsensusSettings(consensusConfig); + BftsmartServerSettingConfig serverSettings = new BftsmartServerSettingConfig(); + serverSettings.setReplicaSettings(nodesSettings[j]); + serverSettings.setConsensusSettings(consensusConfig); BftsmartNodeServer server = new BftsmartNodeServer(serverSettings, null, null); nodeServers[j] = server; nodeStartPools.execute(() -> { diff --git a/source/consensus/consensus-framework/pom.xml b/source/consensus/consensus-framework/pom.xml index dd1150ea..a810d22b 100644 --- a/source/consensus/consensus-framework/pom.xml +++ b/source/consensus/consensus-framework/pom.xml @@ -25,5 +25,10 @@ utils-common ${project.version} + + com.jd.blockchain + ledger-model + ${project.version} + \ No newline at end of file diff --git a/source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/ConsensusSettingsBuilder.java b/source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/ConsensusSettingsBuilder.java index 8adc61dd..c4f46776 100644 --- a/source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/ConsensusSettingsBuilder.java +++ b/source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/ConsensusSettingsBuilder.java @@ -1,5 +1,7 @@ package com.jd.blockchain.consensus; +import com.jd.blockchain.ledger.ParticipantNode; + import java.util.Properties; public interface ConsensusSettingsBuilder { @@ -9,13 +11,11 @@ public interface ConsensusSettingsBuilder { * * @param props * 属性表; - * @param keyPrefix - * 属性的key 的前缀;
- * 在解析过程中,以具体协议实现的标准参数的key 加入此前缀后从属性表中检索参数值;
- * 如果指定为 null 或者空白,则忽略此参数; + * @param participantNodes + * 参与方列表;
* @return */ - ConsensusSettings createSettings(Properties props); + ConsensusSettings createSettings(Properties props, ParticipantNode[] participantNodes); Properties createPropertiesTemplate(); diff --git a/source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/MsgQueueConsensusSettingsBuilder.java b/source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/MsgQueueConsensusSettingsBuilder.java index 839be6e0..85b1fbc3 100644 --- a/source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/MsgQueueConsensusSettingsBuilder.java +++ b/source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/MsgQueueConsensusSettingsBuilder.java @@ -21,6 +21,7 @@ import com.jd.blockchain.consensus.mq.settings.MsgQueueNetworkSettings; import com.jd.blockchain.consensus.mq.settings.MsgQueueNodeSettings; import com.jd.blockchain.crypto.AddressEncoding; import com.jd.blockchain.crypto.PubKey; +import com.jd.blockchain.ledger.ParticipantNode; import com.jd.blockchain.tools.keygen.KeyGenCommand; import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.PropertiesUtils; @@ -97,7 +98,7 @@ public class MsgQueueConsensusSettingsBuilder implements ConsensusSettingsBuilde } @Override - public MsgQueueConsensusSettings createSettings(Properties props) { + public MsgQueueConsensusSettings createSettings(Properties props, ParticipantNode[] participantNodes) { MsgQueueNetworkConfig networkConfig = new MsgQueueNetworkConfig(); Properties resolvingProps = PropertiesUtils.cloneFrom(props); diff --git a/source/deployment/deployment-peer/src/main/resources/config/init/bftsmart.config b/source/deployment/deployment-peer/src/main/resources/config/init/bftsmart.config index 8c2ba5af..57e905b0 100644 --- a/source/deployment/deployment-peer/src/main/resources/config/init/bftsmart.config +++ b/source/deployment/deployment-peer/src/main/resources/config/init/bftsmart.config @@ -13,22 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. - -############################################ -###### Consensus Commit Block Parameters: transaction count ###### -############################################ -system.block.txsize=15 - -############################################ -###### Consensus Commit Block Parameters: delay time ###### -############################################ -system.block.maxdelay=500 - ############################################ ###### #Consensus Participant0 ###### ############################################ -system.server.0.pubkey= system.server.0.network.host=127.0.0.1 system.server.0.network.port=16000 system.server.0.network.secure=false @@ -37,7 +25,6 @@ system.server.0.network.secure=false ###### #Consensus Participant1 ###### ############################################ -system.server.1.pubkey= system.server.1.network.host=127.0.0.1 system.server.1.network.port=16010 system.server.1.network.secure=false @@ -46,7 +33,6 @@ system.server.1.network.secure=false ###### #Consensus Participant2 ###### ############################################ -system.server.2.pubkey= system.server.2.network.host=127.0.0.1 system.server.2.network.port=16020 system.server.2.network.secure=false @@ -55,7 +41,6 @@ system.server.2.network.secure=false ###### #Consensus Participant3 ###### ############################################ -system.server.3.pubkey= system.server.3.network.host=127.0.0.1 system.server.3.network.port=16030 system.server.3.network.secure=false diff --git a/source/deployment/deployment-peer/src/main/resources/config/init/ledger.init b/source/deployment/deployment-peer/src/main/resources/config/init/ledger.init index 9df38d79..057e9966 100644 --- a/source/deployment/deployment-peer/src/main/resources/config/init/ledger.init +++ b/source/deployment/deployment-peer/src/main/resources/config/init/ledger.init @@ -1,10 +1,11 @@ - #账本的种子;一段16进制字符,最长可以包含64个字符;可以用字符“-”分隔,以便更容易读取; ledger.seed=932dfe23-fe23232f-283f32fa-dd32aa76-8322ca2f-56236cda-7136b322-cb323ffe #账本的描述名称;此属性不参与共识,仅仅在当前参与方的本地节点用于描述用途; ledger.name= +#声明的账本创建时间;格式为 “yyyy-MM-dd HH:mm:ss.SSSZ”,表示”年-月-日 时:分:秒:毫秒时区“;例如:“2019-08-01 14:26:58.069+0800”,其中,+0800 表示时区是东8区 +created-time=2019-08-01 14:26:58.069+0800 #共识服务提供者;必须; consensus.service-provider=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider @@ -21,36 +22,24 @@ com.jd.blockchain.crypto.service.sm.SMCryptoService cons_parti.count=4 #第0个参与方的名称; -cons_parti.0.name=jd.com +cons_parti.0.name= #第0个参与方的公钥文件路径; -cons_parti.0.pubkey-path=keys/jd-com.pub +cons_parti.0.pubkey-path= #第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; -cons_parti.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9 -#第0个参与方的共识服务的主机地址; -cons_parti.0.consensus.host=127.0.0.1 -#第0个参与方的共识服务的端口; -cons_parti.0.consensus.port=8900 -#第0个参与方的共识服务是否开启安全连接; -cons_parti.0.consensus.secure=true +cons_parti.0.pubkey= #第0个参与方的账本初始服务的主机; cons_parti.0.initializer.host=127.0.0.1 #第0个参与方的账本初始服务的端口; cons_parti.0.initializer.port=8800 #第0个参与方的账本初始服务是否开启安全连接; -cons_parti.0.initializer.secure=true +cons_parti.0.initializer.secure=false #第1个参与方的名称; -cons_parti.1.name=at.com +cons_parti.1.name= #第1个参与方的公钥文件路径; -cons_parti.1.pubkey-path=keys/at-com.pub +cons_parti.1.pubkey-path= #第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; -cons_parti.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX -#第1个参与方的共识服务的主机地址; -cons_parti.1.consensus.host=127.0.0.1 -#第1个参与方的共识服务的端口; -cons_parti.1.consensus.port=8910 -#第1个参与方的共识服务是否开启安全连接; -cons_parti.1.consensus.secure=false +cons_parti.1.pubkey= #第1个参与方的账本初始服务的主机; cons_parti.1.initializer.host=127.0.0.1 #第1个参与方的账本初始服务的端口; @@ -59,36 +48,24 @@ cons_parti.1.initializer.port=8810 cons_parti.1.initializer.secure=false #第2个参与方的名称; -cons_parti.2.name=bt.com +cons_parti.2.name= #第2个参与方的公钥文件路径; -cons_parti.2.pubkey-path=classpath:keys/parti2.pub +cons_parti.2.pubkey-path= #第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; cons_parti.2.pubkey= -#第2个参与方的共识服务的主机地址; -cons_parti.2.consensus.host=127.0.0.1 -#第2个参与方的共识服务的端口; -cons_parti.2.consensus.port=8920 -#第2个参与方的共识服务是否开启安全连接; -cons_parti.2.consensus.secure=false #第2个参与方的账本初始服务的主机; cons_parti.2.initializer.host=127.0.0.1 #第2个参与方的账本初始服务的端口; cons_parti.2.initializer.port=8820 #第2个参与方的账本初始服务是否开启安全连接; -cons_parti.2.initializer.secure=true +cons_parti.2.initializer.secure=false #第3个参与方的名称; -cons_parti.3.name=xt.com +cons_parti.3.name= #第3个参与方的公钥文件路径; -cons_parti.3.pubkey-path=keys/xt-com.pub +cons_parti.3.pubkey-path= #第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; -cons_parti.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk -#第3个参与方的共识服务的主机地址; -cons_parti.3.consensus.host=127.0.0.1 -#第3个参与方的共识服务的端口; -cons_parti.3.consensus.port=8930 -#第3个参与方的共识服务是否开启安全连接; -cons_parti.3.consensus.secure=false +cons_parti.3.pubkey= #第3个参与方的账本初始服务的主机; cons_parti.3.initializer.host=127.0.0.1 #第3个参与方的账本初始服务的端口; diff --git a/source/deployment/deployment-peer/src/main/resources/config/init/local.conf b/source/deployment/deployment-peer/src/main/resources/config/init/local.conf index 27652184..2a5392c5 100644 --- a/source/deployment/deployment-peer/src/main/resources/config/init/local.conf +++ b/source/deployment/deployment-peer/src/main/resources/config/init/local.conf @@ -20,5 +20,4 @@ ledger.binding.out=../ ledger.db.uri= #账本数据库的连接口令 -ledger.db.pwd= - +ledger.db.pwd= \ No newline at end of file diff --git a/source/deployment/deployment-peer/src/main/resources/config/init/mq/ledger-init.conf b/source/deployment/deployment-peer/src/main/resources/config/init/mq/ledger-init.conf deleted file mode 100644 index 38b1788a..00000000 --- a/source/deployment/deployment-peer/src/main/resources/config/init/mq/ledger-init.conf +++ /dev/null @@ -1,66 +0,0 @@ -#账本的种子;一段16进制字符,最长可以包含64个字符;可以用字符“-”分隔,以便更容易读取; -ledger.seed=932dfe23-fe23232f-283f32fa-dd32aa76-8322ca2f-56236cda-7136b322-cb323ffe - -#账本的描述名称;此属性不参与共识,仅仅在当前参与方的本地节点用于描述用途; -#ledger.name= - -#参与方的个数,后续以 cons_parti.id 分别标识每一个参与方的配置; -cons_parti.count=4 - - -#第0个参与方的名称 -cons_parti.0.name=xx-0.com -#第0个参与方的公钥文件路径 -cons_parti.0.pubkey-path= -#第0个参与方的公钥内容(由keygen工具生成),此参数优先于 pubkey-path 参数 -cons_parti.0.pubkey=endPsK36koyFr1D245Sa9j83vt6pZUdFBJoJRB3xAsWM6cwhRbna -#第0个参与方的账本初始服务的主机 -cons_parti.0.initializer.host=127.0.0.1 -#第0个参与方的账本初始服务的端口 -cons_parti.0.initializer.port=17000 -#第0个参与方的账本初始服务是否开启安全连接 -cons_parti.0.initializer.secure=false - - -#第1个参与方的名称 -cons_parti.1.name=xx-1.com -#第1个参与方的公钥文件路径 -cons_parti.1.pubkey-path= -#第1个参与方的公钥内容(由keygen工具生成),此参数优先于 pubkey-path 参数 -cons_parti.1.pubkey=endPsK36sC5JdPCDPDAXUwZtS3sxEmqEhFcC4whayAsTTh8Z6eoZ -#第1个参与方的账本初始服务的主机 -cons_parti.1.initializer.host=127.0.0.1 -#第1个参与方的账本初始服务的端口 -cons_parti.1.initializer.port=17010 -#第1个参与方的账本初始服务是否开启安全连接 -cons_parti.1.initializer.secure=false - - -#第2个参与方的名称 -cons_parti.2.name=xx-2.com -#第2个参与方的公钥文件路径 -cons_parti.2.pubkey-path= -#第2个参与方的公钥内容(由keygen工具生成),此参数优先于 pubkey-path 参数 -cons_parti.2.pubkey=endPsK36jEG281HMHeh6oSqzqLkT95DTnCM6REDURjdb2c67uR3R -#第2个参与方的账本初始服务的主机 -cons_parti.2.initializer.host=127.0.0.1 -#第2个参与方的账本初始服务的端口 -cons_parti.2.initializer.port=17020 -#第2个参与方的账本初始服务是否开启安全连接 -cons_parti.2.initializer.secure=false - - -#第3个参与方的名称 -cons_parti.3.name=xx-3.com -#第3个参与方的公钥文件路径 -cons_parti.3.pubkey-path= -#第3个参与方的公钥内容(由keygen工具生成),此参数优先于 pubkey-path 参数 -cons_parti.3.pubkey=endPsK36nse1dck4uF19zPvAMijCV336Y3zWdgb4rQG8QoRj5ktR -#第3个参与方的账本初始服务的主机 -cons_parti.3.initializer.host=127.0.0.1 -#第3个参与方的账本初始服务的端口 -cons_parti.3.initializer.port=17030 -#第3个参与方的账本初始服务是否开启安全连接 -cons_parti.3.initializer.secure=false - - diff --git a/source/deployment/deployment-peer/src/main/resources/config/init/mq/ledger.init b/source/deployment/deployment-peer/src/main/resources/config/init/mq/ledger.init new file mode 100644 index 00000000..f7e7d593 --- /dev/null +++ b/source/deployment/deployment-peer/src/main/resources/config/init/mq/ledger.init @@ -0,0 +1,74 @@ +#账本的种子;一段16进制字符,最长可以包含64个字符;可以用字符“-”分隔,以便更容易读取; +ledger.seed=932dfe23-fe23232f-283f32fa-dd32aa76-8322ca2f-56236cda-7136b322-cb323ffe + +#账本的描述名称;此属性不参与共识,仅仅在当前参与方的本地节点用于描述用途; +ledger.name= + +#声明的账本创建时间;格式为 “yyyy-MM-dd HH:mm:ss.SSSZ”,表示”年-月-日 时:分:秒:毫秒时区“;例如:“2019-08-01 14:26:58.069+0800”,其中,+0800 表示时区是东8区 +created-time=2019-08-01 14:26:58.069+0800 + +#共识服务提供者;必须; +consensus.service-provider=com.jd.blockchain.consensus.mq.MsgQueueConsensusProvider + +#共识服务的参数配置;必须; +consensus.conf=classpath:mq.config + +#密码服务提供者列表,以英文逗点“,”分隔;必须; +crypto.service-providers=com.jd.blockchain.crypto.service.classic.ClassicCryptoService, \ +com.jd.blockchain.crypto.service.sm.SMCryptoService + + +#参与方的个数,后续以 cons_parti.id 分别标识每一个参与方的配置; +cons_parti.count=4 + +#第0个参与方的名称; +cons_parti.0.name=jd.com +#第0个参与方的公钥文件路径; +cons_parti.0.pubkey-path=keys/jd-com.pub +#第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; +cons_parti.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9 +#第0个参与方的账本初始服务的主机; +cons_parti.0.initializer.host=127.0.0.1 +#第0个参与方的账本初始服务的端口; +cons_parti.0.initializer.port=8800 +#第0个参与方的账本初始服务是否开启安全连接; +cons_parti.0.initializer.secure=false + +#第1个参与方的名称; +cons_parti.1.name=at.com +#第1个参与方的公钥文件路径; +cons_parti.1.pubkey-path=keys/at-com.pub +#第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; +cons_parti.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX +#第1个参与方的账本初始服务的主机; +cons_parti.1.initializer.host=127.0.0.1 +#第1个参与方的账本初始服务的端口; +cons_parti.1.initializer.port=8810 +#第1个参与方的账本初始服务是否开启安全连接; +cons_parti.1.initializer.secure=false + +#第2个参与方的名称; +cons_parti.2.name=bt.com +#第2个参与方的公钥文件路径; +cons_parti.2.pubkey-path=classpath:keys/parti2.pub +#第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; +cons_parti.2.pubkey= +#第2个参与方的账本初始服务的主机; +cons_parti.2.initializer.host=127.0.0.1 +#第2个参与方的账本初始服务的端口; +cons_parti.2.initializer.port=8820 +#第2个参与方的账本初始服务是否开启安全连接; +cons_parti.2.initializer.secure=false + +#第3个参与方的名称; +cons_parti.3.name=xt.com +#第3个参与方的公钥文件路径; +cons_parti.3.pubkey-path=keys/xt-com.pub +#第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; +cons_parti.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk +#第3个参与方的账本初始服务的主机; +cons_parti.3.initializer.host=127.0.0.1 +#第3个参与方的账本初始服务的端口; +cons_parti.3.initializer.port=8830 +#第3个参与方的账本初始服务是否开启安全连接; +cons_parti.3.initializer.secure=false diff --git a/source/deployment/deployment-peer/src/main/resources/config/init/mq/local.conf b/source/deployment/deployment-peer/src/main/resources/config/init/mq/local.conf index 08e99b84..2a5392c5 100644 --- a/source/deployment/deployment-peer/src/main/resources/config/init/mq/local.conf +++ b/source/deployment/deployment-peer/src/main/resources/config/init/mq/local.conf @@ -2,31 +2,22 @@ local.parti.id=0 #当前参与方的公钥 -local.parti.pubkey=endPsK36koyFr1D245Sa9j83vt6pZUdFBJoJRB3xAsWM6cwhRbna +local.parti.pubkey= #当前参与方的私钥(密文编码) -local.parti.privkey=177gjsj5PHeCpbAtJE7qnbmhuZMHAEKuMsd45zHkv8F8AWBvTBbff8yRKdCyT3kwrmAjSnY +local.parti.privkey= #当前参与方的私钥解密密钥(原始口令的一次哈希,Base58格式),如果不设置,则启动过程中需要从控制台输入 -local.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY +local.parti.pwd= #账本初始化完成后生成的"账本绑定配置文件"的输出目录 #推荐使用绝对路径,相对路径以当前文件(local.conf)所在目录为基准 ledger.binding.out=../ #账本数据库的连接字符 -#rocksdb数据库连接格式:rocksdb://{path} -#redis数据库连接格式:redis://{ip}:{prot}/{db} -ledger.db.uri=rocksdb:///export/App08/peer/rocks.db/rocksdb0.db +#rocksdb数据库连接格式:rocksdb://{path},例如:rocksdb:///export/App08/peer/rocks.db/rocksdb0.db +#redis数据库连接格式:redis://{ip}:{prot}/{db},例如:redis://127.0.0.1:6379/0 +ledger.db.uri= #账本数据库的连接口令 -ledger.db.pwd= - -#共识配置文件路径 -#推荐使用绝对路径,相对路径以当前文件(local.conf)所在目录为基准 -consensus.conf=mq.config - -#共识Providers配置 -#BftSmart共识Provider:com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider -#简单消息共识Provider:com.jd.blockchain.consensus.mq.MsgQueueConsensusProvider -consensus.service-provider=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider +ledger.db.pwd= \ No newline at end of file diff --git a/source/deployment/deployment-peer/src/main/resources/scripts/ledger-init.sh b/source/deployment/deployment-peer/src/main/resources/scripts/ledger-init.sh index e30a91c6..c9f3db47 100644 --- a/source/deployment/deployment-peer/src/main/resources/scripts/ledger-init.sh +++ b/source/deployment/deployment-peer/src/main/resources/scripts/ledger-init.sh @@ -5,5 +5,5 @@ boot_file=$(ls ../libs | grep tools-initializer-booter-) if [ ! -n "$boot_file" ]; then echo "tools-initializer-booter is null" else - java -jar $HOME/libs/$boot_file -l $HOME/config/init/local.conf -i $HOME/config/init/ledger-init.conf $* + java -jar $HOME/libs/$boot_file -l $HOME/config/init/local.conf -i $HOME/config/init/ledger.init $* fi diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java index d83272f7..a7051431 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java @@ -52,6 +52,7 @@ import com.jd.blockchain.utils.net.NetworkAddress; import test.com.jd.blockchain.intgr.IntegratedContext.Node; import test.com.jd.blockchain.intgr.perf.LedgerInitializeWebTest; +import test.com.jd.blockchain.intgr.perf.Utils; public class IntegrationTest { // 合约测试使用的初始化数据; @@ -435,7 +436,9 @@ public class IntegrationTest { LedgerInitProperties initSetting = loadInitSetting_integration(); Properties props = LedgerInitializeWebTest.loadConsensusSetting(); ConsensusProvider csProvider = getConsensusProvider(); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java index d7f66545..9eb45aee 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java @@ -188,7 +188,9 @@ public class ConsensusTest { LedgerInitProperties initSetting = loadInitSetting_integration(); Properties props = Utils.loadConsensusSetting(); ConsensusProvider csProvider = getConsensusProvider(); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java index a35584c0..f4c21fe7 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java @@ -186,7 +186,9 @@ public class GlobalPerformanceTest { LedgerInitProperties initSetting = loadInitSetting_integration(); Properties props = Utils.loadConsensusSetting(); ConsensusProvider csProvider = getConsensusProvider(); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeWebTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeWebTest.java index fe0d8bbc..569472d9 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeWebTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeWebTest.java @@ -75,7 +75,9 @@ public class LedgerInitializeWebTest { Properties props = loadConsensusSetting(); // ConsensusProperties csProps = new ConsensusProperties(props); ConsensusProvider csProvider = getConsensusProvider(); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); @@ -240,7 +242,9 @@ public class LedgerInitializeWebTest { Properties props = loadConsensusSetting(); // ConsensusProperties csProps = new ConsensusProperties(props); ConsensusProvider csProvider = getConsensusProvider(); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java index 25a40ad0..76f3a1e7 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java @@ -495,7 +495,9 @@ public class LedgerPerformanceTest { LedgerInitProperties initSetting = loadInitSetting(); Properties props = loadConsensusSetting(config); ConsensusProvider csProvider = getConsensusProvider(provider); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); DBSetting dbsetting0; DBSetting dbsetting1; diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java index b5bcd809..80b133ad 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java @@ -9,6 +9,8 @@ import java.util.concurrent.ConcurrentHashMap; import com.jd.blockchain.crypto.*; import com.jd.blockchain.crypto.service.classic.ClassicCryptoService; import com.jd.blockchain.crypto.service.sm.SMCryptoService; +import com.jd.blockchain.ledger.ParticipantNode; +import com.jd.blockchain.tools.keygen.KeyGenCommand; import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.consensus.ConsensusProvider; @@ -72,6 +74,14 @@ public class Utils { } } + public static ParticipantNode[] loadParticipantNodes() { + ParticipantNode[] participantNodes = new ParticipantNode[PUB_KEYS.length]; + for (int i = 0; i < PUB_KEYS.length; i++) { + participantNodes[i] = new PartNode(i, KeyGenCommand.decodePubKey(PUB_KEYS[i])); + } + return participantNodes; + } + public static class NodeContext { private LedgerManager ledgerManager = new LedgerManager(); @@ -215,4 +225,46 @@ public class Utils { } + private static class PartNode implements ParticipantNode { + + private int id; + + private String address; + + private String name; + + private PubKey pubKey; + + public PartNode(int id, PubKey pubKey) { + this(id, id + "", pubKey); + } + + public PartNode(int id, String name, PubKey pubKey) { + this.id = id; + this.name = name; + this.pubKey = pubKey; + this.address = pubKey.toBase58(); + } + + @Override + public int getId() { + return id; + } + + @Override + public String getAddress() { + return address; + } + + @Override + public String getName() { + return name; + } + + @Override + public PubKey getPubKey() { + return pubKey; + } + } + } diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java index 0703ef98..0fb2d461 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java @@ -29,6 +29,7 @@ import com.jd.blockchain.utils.net.NetworkAddress; import test.com.jd.blockchain.intgr.IntegratedContext.Node; import test.com.jd.blockchain.intgr.initializer.LedgerInitializeWeb4SingleStepsTest; import test.com.jd.blockchain.intgr.initializer.LedgerInitializeWeb4SingleStepsTest.NodeWebContext; +import test.com.jd.blockchain.intgr.perf.Utils; public class IntegrationBaseTest { @@ -122,7 +123,9 @@ public class IntegrationBaseTest { LedgerInitProperties initSetting = loadInitSetting_integration(); Properties props = LedgerInitializeWeb4SingleStepsTest.loadConsensusSetting(configPath); ConsensusProvider csProvider = LedgerInitConsensusConfig.getConsensusProvider(providerName); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java index f1f5288c..3e5a1e85 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java @@ -42,6 +42,7 @@ import test.com.jd.blockchain.intgr.IntegratedContext.Node; import test.com.jd.blockchain.intgr.contract.AssetContract; import test.com.jd.blockchain.intgr.initializer.LedgerInitializeWeb4SingleStepsTest; import test.com.jd.blockchain.intgr.initializer.LedgerInitializeWeb4SingleStepsTest.NodeWebContext; +import test.com.jd.blockchain.intgr.perf.Utils; /** * 测试合约,提交后不立即进行验证,因为此时可能还没有完成正式结块; @@ -160,7 +161,9 @@ public class IntegrationTest2 { LedgerInitProperties initSetting = loadInitSetting_integration(); Properties props = LedgerInitializeWeb4SingleStepsTest.loadConsensusSetting(config.getConfigPath()); ConsensusProvider csProvider = LedgerInitConsensusConfig.getConsensusProvider(config.getProvider()); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java index e031d763..41d8c800 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java @@ -46,6 +46,7 @@ import com.jd.blockchain.utils.net.NetworkAddress; import test.com.jd.blockchain.intgr.IntegratedContext.Node; import test.com.jd.blockchain.intgr.initializer.LedgerInitializeWeb4SingleStepsTest; import test.com.jd.blockchain.intgr.initializer.LedgerInitializeWeb4SingleStepsTest.NodeWebContext; +import test.com.jd.blockchain.intgr.perf.Utils; public class IntegrationTestDataAccount { @@ -257,7 +258,9 @@ public class IntegrationTestDataAccount { LedgerInitProperties initSetting = loadInitSetting_integration(); Properties props = LedgerInitializeWeb4SingleStepsTest.loadConsensusSetting(config.getConfigPath()); ConsensusProvider csProvider = LedgerInitConsensusConfig.getConsensusProvider(config.getProvider()); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeWeb4Nodes.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeWeb4Nodes.java index ef18078f..a37afc62 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeWeb4Nodes.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeWeb4Nodes.java @@ -27,6 +27,7 @@ import org.springframework.core.io.ClassPathResource; import test.com.jd.blockchain.intgr.IntegrationBase; import test.com.jd.blockchain.intgr.LedgerInitConsensusConfig; import test.com.jd.blockchain.intgr.PresetAnswerPrompter; +import test.com.jd.blockchain.intgr.perf.Utils; import java.io.IOException; import java.io.InputStream; @@ -70,7 +71,9 @@ public class LedgerInitializeWeb4Nodes { LedgerInitProperties initSetting = loadInitSetting_2(); Properties props = loadConsensusSetting(config.getConfigPath()); ConsensusProvider csProvider = LedgerInitConsensusConfig.getConsensusProvider(config.getProvider()); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeWeb4SingleStepsTest.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeWeb4SingleStepsTest.java index 3426b296..875dda05 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeWeb4SingleStepsTest.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeWeb4SingleStepsTest.java @@ -50,6 +50,7 @@ import com.jd.blockchain.utils.net.NetworkAddress; import test.com.jd.blockchain.intgr.LedgerInitConsensusConfig; import test.com.jd.blockchain.intgr.PresetAnswerPrompter; +import test.com.jd.blockchain.intgr.perf.Utils; public class LedgerInitializeWeb4SingleStepsTest { @@ -77,7 +78,9 @@ public class LedgerInitializeWeb4SingleStepsTest { // 加载共识配置; Properties props = loadConsensusSetting(consensusConfig.getConfigPath()); ConsensusProvider csProvider = LedgerInitConsensusConfig.getConsensusProvider(consensusConfig.getProvider()); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); // 启动服务器; NetworkAddress initAddr0 = initSetting.getConsensusParticipant(0).getInitializerAddress(); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java index 77bdef66..306d065f 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java @@ -45,6 +45,7 @@ import com.jd.blockchain.utils.net.NetworkAddress; import test.com.jd.blockchain.intgr.PresetAnswerPrompter; import test.com.jd.blockchain.intgr.initializer.LedgerInitializeTest; import test.com.jd.blockchain.intgr.initializer.LedgerInitializeTest.NodeContext; +import test.com.jd.blockchain.intgr.perf.Utils; public class LedgerBlockGeneratingTest { @@ -128,7 +129,9 @@ public class LedgerBlockGeneratingTest { LedgerInitProperties initSetting = loadInitSetting(); Properties props = loadConsensusSetting(); ConsensusProvider csProvider = getConsensusProvider(); - ConsensusSettings csProps = csProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(props); + ConsensusSettings csProps = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(props, Utils.loadParticipantNodes()); NodeContext node0 = new NodeContext(initSetting.getConsensusParticipant(0).getInitializerAddress(), serviceRegisterMap); diff --git a/source/test/test-integration/src/test/resources/bftsmart.config b/source/test/test-integration/src/test/resources/bftsmart.config index c68e39fd..80ed0f6a 100644 --- a/source/test/test-integration/src/test/resources/bftsmart.config +++ b/source/test/test-integration/src/test/resources/bftsmart.config @@ -14,58 +14,36 @@ # limitations under the License. -############################################ -###### Consensus Commit Block Parameters: transaction count ###### -############################################ -system.block.txsize=15 - -############################################ -###### Consensus Commit Block Parameters: delay time ###### -############################################ -system.block.maxdelay=500 - ############################################ ###### Consensus Participant0 ###### ############################################ -system.server.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9 system.server.0.network.host=127.0.0.1 - system.server.0.network.port=8910 - system.server.0.network.secure=false ############################################ ###### #Consensus Participant1 ###### ############################################ -system.server.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX system.server.1.network.host=127.0.0.1 - system.server.1.network.port=8920 - system.server.1.network.secure=false ############################################ ###### #Consensus Participant2 ###### ############################################ -system.server.2.pubkey=3snPdw7i7PZi6TStiyc6mzjprnNhgs2atSGNS8wPYzhbKaUWGFJt7x system.server.2.network.host=127.0.0.1 - system.server.2.network.port=8930 - system.server.2.network.secure=false ############################################ ###### Consensus Participant3 ###### ############################################ -system.server.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk system.server.3.network.host=127.0.0.1 - system.server.3.network.port=8940 - system.server.3.network.secure=false ############################################ @@ -174,5 +152,4 @@ system.ttp.id = 7002 system.bft = true #Custom View Storage; -#view.storage.handler=bftsmart.reconfiguration.views.DefaultViewStorage - +#view.storage.handler=bftsmart.reconfiguration.views.DefaultViewStorage \ No newline at end of file diff --git a/source/test/test-integration/src/test/resources/ledger.init b/source/test/test-integration/src/test/resources/ledger.init index 9df38d79..48e74994 100644 --- a/source/test/test-integration/src/test/resources/ledger.init +++ b/source/test/test-integration/src/test/resources/ledger.init @@ -5,7 +5,6 @@ ledger.seed=932dfe23-fe23232f-283f32fa-dd32aa76-8322ca2f-56236cda-7136b322-cb323 #账本的描述名称;此属性不参与共识,仅仅在当前参与方的本地节点用于描述用途; ledger.name= - #共识服务提供者;必须; consensus.service-provider=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider diff --git a/source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/LedgerInitProperties.java b/source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/LedgerInitProperties.java index ee6be810..5a6ed045 100644 --- a/source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/LedgerInitProperties.java +++ b/source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/LedgerInitProperties.java @@ -95,6 +95,14 @@ public class LedgerInitProperties { return consensusParticipants; } + public ParticipantNode[] getConsensusParticipantNodes() { + if (consensusParticipants.isEmpty()) { + return null; + } + ParticipantNode[] participantNodes = new ParticipantNode[consensusParticipants.size()]; + return consensusParticipants.toArray(participantNodes); + } + public String[] getCryptoProviders() { return cryptoProviders.clone(); } @@ -106,7 +114,7 @@ public class LedgerInitProperties { /** * 返回参与者; * - * @param address 从 1 开始; 小于等于 {@link #getConsensusParticipantCount()}; + * @param id 从 1 开始; 小于等于 {@link #getConsensusParticipantCount()}; * @return */ public ConsensusParticipantConfig getConsensusParticipant(int id) { diff --git a/source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/web/LedgerInitializeWebController.java b/source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/web/LedgerInitializeWebController.java index 15546d9e..22002841 100644 --- a/source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/web/LedgerInitializeWebController.java +++ b/source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/web/LedgerInitializeWebController.java @@ -181,8 +181,9 @@ public class LedgerInitializeWebController implements LedgerInitProcess, LedgerI Properties csProps = ledgerInitProps.getConsensusConfig(); ConsensusProvider csProvider = ConsensusProviders.getProvider(ledgerInitProps.getConsensusProvider()); - ConsensusSettings csSettings = csProvider.getSettingsFactory().getConsensusSettingsBuilder() - .createSettings(csProps); + ConsensusSettings csSettings = csProvider.getSettingsFactory() + .getConsensusSettingsBuilder() + .createSettings(csProps, ledgerInitProps.getConsensusParticipantNodes()); setConsensusProvider(csProvider); prompter.info("Init settings and sign permision..."); @@ -335,7 +336,9 @@ public class LedgerInitializeWebController implements LedgerInitProcess, LedgerI initSetting.setCryptoSetting(cryptoSetting); List partiList = ledgerProps.getConsensusParticipants(); - ConsensusParticipantConfig[] parties = partiList.toArray(new ConsensusParticipantConfig[partiList.size()]); + ConsensusParticipantConfig[] parties = new ConsensusParticipantConfig[partiList.size()]; + parties = partiList.toArray(parties); +// ConsensusParticipantConfig[] parties = partiList.toArray(new ConsensusParticipantConfig[partiList.size()]); ConsensusParticipantConfig[] orderedParties = sortAndVerify(parties); initSetting.setConsensusParticipants(orderedParties); initSetting.setCreatedTime(ledgerProps.getCreatedTime());