-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lite fullnode Implementation (#3031)
* TIP128: finish split&checkpoint * TIP128: finish the transactionCache initial logic * TIP128: finish history merge into snapshot * TIP128: add jcommander tool * TIP128: bugfix: multi processes copy file problem * TIP128: bugfix and refactor some code * TIP128: add build logic * TIP128: finish http&GRPC filter, also fix some bugs & unit test * TIP128: fix some bugs & unit test * TIP128: improve unit test coverage * TIP128: fix sonar check, redirect log output * TIP128: bugfix, set validContractProtoThreadNum default value * TIP128: add filter in RpcApiServiceOnSolidity * TIP128: optimize logs output * TIP128: merge develop, mainly for pbft * TIP128: optimize snapshot dbs list * TIP128: optimize snapshot dbs list * TIP128: remove unnecessary code * TIP128: bugfix: using copy if creating hard link failed * bugfix: adjust the order of the http filters
- Loading branch information
1 parent
c93541d
commit 3d34e7d
Showing
35 changed files
with
2,467 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
framework/src/main/java/org/tron/core/services/filter/LiteFnQueryGrpcInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.tron.core.services.filter; | ||
|
||
import com.beust.jcommander.internal.Sets; | ||
import io.grpc.ForwardingServerCall; | ||
import io.grpc.Metadata; | ||
import io.grpc.ServerCall; | ||
import io.grpc.ServerCallHandler; | ||
import io.grpc.ServerInterceptor; | ||
import io.grpc.Status; | ||
import java.util.Set; | ||
import org.springframework.stereotype.Component; | ||
import org.tron.common.parameter.CommonParameter; | ||
|
||
@Component | ||
public class LiteFnQueryGrpcInterceptor implements ServerInterceptor { | ||
|
||
private static final Set<String> filterMethods = Sets.newHashSet(); | ||
|
||
// for test | ||
public static Set<String> getFilterMethods() { | ||
return filterMethods; | ||
} | ||
|
||
static { | ||
// wallet | ||
filterMethods.add("protocol.Wallet/GetBlockById"); | ||
filterMethods.add("protocol.Wallet/GetBlockByLatestNum"); | ||
filterMethods.add("protocol.Wallet/GetBlockByLatestNum2"); | ||
filterMethods.add("protocol.Wallet/GetBlockByLimitNext"); | ||
filterMethods.add("protocol.Wallet/GetBlockByLimitNext2"); | ||
filterMethods.add("protocol.Wallet/GetBlockByNum"); | ||
filterMethods.add("protocol.Wallet/GetBlockByNum2"); | ||
filterMethods.add("protocol.Wallet/GetMerkleTreeVoucherInfo"); | ||
filterMethods.add("protocol.Wallet/GetTransactionById"); | ||
filterMethods.add("protocol.Wallet/GetTransactionCountByBlockNum"); | ||
filterMethods.add("protocol.Wallet/GetTransactionInfoById"); | ||
filterMethods.add("protocol.Wallet/IsSpend"); | ||
filterMethods.add("protocol.Wallet/ScanAndMarkNoteByIvk"); | ||
filterMethods.add("protocol.Wallet/ScanNoteByIvk"); | ||
filterMethods.add("protocol.Wallet/ScanNoteByOvk"); | ||
filterMethods.add("protocol.Wallet/TotalTransaction"); | ||
|
||
// walletSolidity | ||
filterMethods.add("protocol.WalletSolidity/GetBlockByNum"); | ||
filterMethods.add("protocol.WalletSolidity/GetBlockByNum2"); | ||
filterMethods.add("protocol.WalletSolidity/GetMerkleTreeVoucherInfo"); | ||
filterMethods.add("protocol.WalletSolidity/GetTransactionById"); | ||
filterMethods.add("protocol.WalletSolidity/GetTransactionCountByBlockNum"); | ||
filterMethods.add("protocol.WalletSolidity/GetTransactionInfoById"); | ||
filterMethods.add("protocol.WalletSolidity/IsSpend"); | ||
filterMethods.add("protocol.WalletSolidity/ScanAndMarkNoteByIvk"); | ||
filterMethods.add("protocol.WalletSolidity/ScanNoteByIvk"); | ||
filterMethods.add("protocol.WalletSolidity/ScanNoteByOvk"); | ||
|
||
// database | ||
filterMethods.add("protocol.Database/GetBlockByNum"); | ||
} | ||
|
||
@Override | ||
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, | ||
Metadata headers, ServerCallHandler<ReqT, RespT> next) { | ||
boolean shouldBeFiltered = false; | ||
if (CommonParameter.getInstance().isLiteFullNode | ||
&& !CommonParameter.getInstance().openHistoryQueryWhenLiteFN | ||
&& filterMethods.contains(call.getMethodDescriptor().getFullMethodName())) { | ||
shouldBeFiltered = true; | ||
} | ||
if (shouldBeFiltered) { | ||
call.close(Status.UNAVAILABLE | ||
.withDescription("this API is closed because this node is a lite fullnode"), headers); | ||
return new ServerCall.Listener<ReqT>() {}; | ||
} else { | ||
return next.startCall(call, headers); | ||
} | ||
} | ||
} |
Oops, something went wrong.