From 8af883a494230df47807ff935cddf748664908e0 Mon Sep 17 00:00:00 2001 From: monan <651932351@qq.com> Date: Wed, 9 Oct 2024 19:30:54 +0800 Subject: [PATCH] Remove binary of consensus precompiled, add version check --- .../consensus/ConsensusPrecompiled.java | 20 ++----------------- .../consensus/ConsensusService.java | 10 ++++++++++ .../model/PrecompiledVersionCheck.java | 2 ++ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/consensus/ConsensusPrecompiled.java b/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/consensus/ConsensusPrecompiled.java index 4262aee07..05c1db1fe 100644 --- a/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/consensus/ConsensusPrecompiled.java +++ b/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/consensus/ConsensusPrecompiled.java @@ -23,16 +23,12 @@ @SuppressWarnings("unchecked") public class ConsensusPrecompiled extends Contract { - public static final String[] BINARY_ARRAY = { - "608060405234801561001057600080fd5b50610411806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632800efc01461005c578063359168561461008c57806380599e4b146100bc5780639c9675b7146100ec578063ce6fa5c51461011c575b600080fd5b610076600480360381019061007191906102cc565b61014c565b604051610083919061032e565b60405180910390f35b6100a660048036038101906100a1919061037f565b610153565b6040516100b3919061032e565b60405180910390f35b6100d660048036038101906100d191906102cc565b61015b565b6040516100e3919061032e565b60405180910390f35b6101066004803603810190610101919061037f565b610162565b604051610113919061032e565b60405180910390f35b6101366004803603810190610131919061037f565b61016a565b604051610143919061032e565b60405180910390f35b6000919050565b600092915050565b6000919050565b600092915050565b600092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6101d982610190565b810181811067ffffffffffffffff821117156101f8576101f76101a1565b5b80604052505050565b600061020b610172565b905061021782826101d0565b919050565b600067ffffffffffffffff821115610237576102366101a1565b5b61024082610190565b9050602081019050919050565b82818337600083830152505050565b600061026f61026a8461021c565b610201565b90508281526020810184848401111561028b5761028a61018b565b5b61029684828561024d565b509392505050565b600082601f8301126102b3576102b2610186565b5b81356102c384826020860161025c565b91505092915050565b6000602082840312156102e2576102e161017c565b5b600082013567ffffffffffffffff811115610300576102ff610181565b5b61030c8482850161029e565b91505092915050565b6000819050919050565b61032881610315565b82525050565b6000602082019050610343600083018461031f565b92915050565b6000819050919050565b61035c81610349565b811461036757600080fd5b50565b60008135905061037981610353565b92915050565b600080604083850312156103965761039561017c565b5b600083013567ffffffffffffffff8111156103b4576103b3610181565b5b6103c08582860161029e565b92505060206103d18582860161036a565b915050925092905056fea264697066735822122047f5d2f496fb0b4a5838d33a0ac5cbdbc87257e95b46bf2362b7eb01559d4f7e64736f6c634300080b0033" - }; + public static final String[] BINARY_ARRAY = {""}; public static final String BINARY = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", BINARY_ARRAY); - public static final String[] SM_BINARY_ARRAY = { - "608060405234801561001057600080fd5b50610411806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806325e85d161461005c57806350f4c5091461008c57806386b733f9146100bc5780639fdc9df8146100ec578063d0ab0c331461011c575b600080fd5b610076600480360381019061007191906102cc565b61014c565b604051610083919061032e565b60405180910390f35b6100a660048036038101906100a1919061037f565b610153565b6040516100b3919061032e565b60405180910390f35b6100d660048036038101906100d191906102cc565b61015b565b6040516100e3919061032e565b60405180910390f35b6101066004803603810190610101919061037f565b610162565b604051610113919061032e565b60405180910390f35b6101366004803603810190610131919061037f565b61016a565b604051610143919061032e565b60405180910390f35b6000919050565b600092915050565b6000919050565b600092915050565b600092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7fb95aa35500000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6101d982610190565b810181811067ffffffffffffffff821117156101f8576101f76101a1565b5b80604052505050565b600061020b610172565b905061021782826101d0565b919050565b600067ffffffffffffffff821115610237576102366101a1565b5b61024082610190565b9050602081019050919050565b82818337600083830152505050565b600061026f61026a8461021c565b610201565b90508281526020810184848401111561028b5761028a61018b565b5b61029684828561024d565b509392505050565b600082601f8301126102b3576102b2610186565b5b81356102c384826020860161025c565b91505092915050565b6000602082840312156102e2576102e161017c565b5b600082013567ffffffffffffffff811115610300576102ff610181565b5b61030c8482850161029e565b91505092915050565b6000819050919050565b61032881610315565b82525050565b6000602082019050610343600083018461031f565b92915050565b6000819050919050565b61035c81610349565b811461036757600080fd5b50565b60008135905061037981610353565b92915050565b600080604083850312156103965761039561017c565b5b600083013567ffffffffffffffff8111156103b4576103b3610181565b5b6103c08582860161029e565b92505060206103d18582860161036a565b915050925092905056fea264697066735822122099c593010df491a0ccc8a94d7b99660661b10c3de3589b2587d20cd44682a11664736f6c634300080b0033" - }; + public static final String[] SM_BINARY_ARRAY = {""}; public static final String SM_BINARY = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", SM_BINARY_ARRAY); @@ -486,16 +482,4 @@ public static ConsensusPrecompiled load( String contractAddress, Client client, CryptoKeyPair credential) { return new ConsensusPrecompiled(contractAddress, client, credential); } - - public static ConsensusPrecompiled deploy(Client client, CryptoKeyPair credential) - throws ContractException { - return deploy( - ConsensusPrecompiled.class, - client, - credential, - getBinary(client.getCryptoSuite()), - getABI(), - null, - null); - } } diff --git a/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/consensus/ConsensusService.java b/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/consensus/ConsensusService.java index 242821def..e3dbb7990 100644 --- a/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/consensus/ConsensusService.java +++ b/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/consensus/ConsensusService.java @@ -22,6 +22,7 @@ import org.fisco.bcos.sdk.v3.client.protocol.response.SealerList; import org.fisco.bcos.sdk.v3.client.protocol.response.SyncStatus; import org.fisco.bcos.sdk.v3.contract.precompiled.model.PrecompiledAddress; +import org.fisco.bcos.sdk.v3.contract.precompiled.model.PrecompiledVersionCheck; import org.fisco.bcos.sdk.v3.crypto.keypair.CryptoKeyPair; import org.fisco.bcos.sdk.v3.model.PrecompiledRetCode; import org.fisco.bcos.sdk.v3.model.RetCode; @@ -133,6 +134,15 @@ public RetCode setWeight(String nodeId, BigInteger weight) throws ContractExcept } public RetCode setTermWeight(String nodeId, BigInteger weight) throws ContractException { + long currentVersion = + client.getGroupInfo() + .getResult() + .getNodeList() + .get(0) + .getProtocol() + .getCompatibilityVersion(); + PrecompiledVersionCheck.TERM_WEIGHT_MIN_SUPPORT_VERSION.checkVersion(currentVersion); + TransactionReceipt receipt = consensusPrecompiled.setTermWeight(nodeId, weight); return ReceiptParser.parseTransactionReceipt( receipt, tr -> consensusPrecompiled.getSetTermWeightOutput(tr).getValue1()); diff --git a/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/model/PrecompiledVersionCheck.java b/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/model/PrecompiledVersionCheck.java index b0ee60a2a..169341560 100644 --- a/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/model/PrecompiledVersionCheck.java +++ b/src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/model/PrecompiledVersionCheck.java @@ -12,4 +12,6 @@ public class PrecompiledVersionCheck { public static final Version V330_FIX_BFS_VERSION = new Version("fixBfs", "3.3.0"); public static final Version BALANCE_PRECOMPILED_VERSION = new Version("balance", "3.6.0"); + public static final Version TERM_WEIGHT_MIN_SUPPORT_VERSION = + new Version("consensus", "3.12.0"); }