Description
A switch option exists in the configuration used to determine whether to allow shielded transactions API.
node.fullNodeAllowShieldedTransaction
Here are two related optimizations.
zkSnark parameters initialization
The default value of fullNodeAllowShieldedTransaction
is true. However, if we set fullNodeAllowShieldedTransaction = false
, the FullNode will skip the zkSnark parameters initialization process, as follows:
public static void librustzcashInitZksnarkParams() {
logger.info("init zk param begin");
if (!JLibrustzcash.isOpenZen()) {
logger.info("zen switch is off, zen will not start.");
return;
}
String spendPath = getParamsFile("sapling-spend.params");
String spendHash = "25fd9a0d1c1be0526c14662947ae95b758fe9f3d7fb7f55e9b4437830dcc6215a7ce3ea465"
+ "914b157715b7a4d681389ea4aa84438190e185d5e4c93574d3a19a";
String outputPath = getParamsFile("sapling-output.params");
String outputHash = "a1cb23b93256adce5bce2cb09cefbc96a1d16572675ceb691e9a3626ec15b5b546926ff1c"
+ "536cfe3a9df07d796b32fdfc3e5d99d65567257bf286cd2858d71a6";
try {
JLibrustzcash.librustzcashInitZksnarkParams(
new LibrustzcashParam.InitZksnarkParams(spendPath, spendHash, outputPath, outputHash));
} catch (ZksnarkException e) {
logger.error("librustzcashInitZksnarkParams fail!", e);
}
logger.info("init zk param done");
}
In this case, the FullNode cannot process shielded transactions. An error will occur if it attempts to synchronize blocks that contain shielded transactions. Therefore, the zkSnark parameters must be initialized regardless of whether fullNodeAllowShieldedTransaction
is set to true or false.
fullNodeAllowShieldedTransaction
should be kept to control the shielded transaction API. So it is necessary to remove the following code snippet from the zkSnark parameters initialization function:
if (!JLibrustzcash.isOpenZen()) {
logger.info("zen switch is off, zen will not start.");
return;
}
pushTransaction
Furthermore, fullNodeAllowShieldedTransaction
also affects the behavior of pushTransaction
. However, relying on it is not recommended, as the execution of shielded transactions is ultimately governed by the ALLOW_SHIELDED_TRANSACTION
proposal.
if (isShieldedTransaction(trx.getInstance()) && !Args.getInstance()
.isFullNodeAllowShieldedTransactionArgs()) {
return true;
}
So the above code snippet should be replaced by:
if (isShieldedTransaction(trx.getInstance()) && !chainBaseManager.getDynamicPropertiesStore()
.supportShieldedTransaction()) {
return true;
}
Metadata
Metadata
Assignees
Type
Projects
Status