-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lite fullnode Implementation #3031
Merged
tomatoishealthy
merged 20 commits into
tronprotocol:develop
from
tomatoishealthy:lite_fullnode
Aug 10, 2020
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f4dcbf2
TIP128: finish split&checkpoint
tomatoishealthy 3c3f7b8
TIP128: finish the transactionCache initial logic
tomatoishealthy 23b2b5e
TIP128: finish history merge into snapshot
tomatoishealthy 901f0b7
TIP128: add jcommander tool
tomatoishealthy 258e252
TIP128: bugfix: multi processes copy file problem
tomatoishealthy 00ba7cc
TIP128: bugfix and refactor some code
tomatoishealthy 904d099
TIP128: add build logic
tomatoishealthy eb227aa
TIP128: finish http&GRPC filter, also fix some bugs & unit test
tomatoishealthy 7321dfd
TIP128: fix some bugs & unit test
tomatoishealthy 65c7071
TIP128: improve unit test coverage
tomatoishealthy 40aaac7
TIP128: fix sonar check, redirect log output
tomatoishealthy 35f13d7
TIP128: bugfix, set validContractProtoThreadNum default value
tomatoishealthy 4ccae2d
TIP128: add filter in RpcApiServiceOnSolidity
tomatoishealthy c4ec076
TIP128: optimize logs output
tomatoishealthy 25a6ba6
TIP128: merge develop, mainly for pbft
tomatoishealthy e4b53ac
TIP128: optimize snapshot dbs list
tomatoishealthy 57efb48
TIP128: optimize snapshot dbs list
tomatoishealthy e1141f2
TIP128: remove unnecessary code
tomatoishealthy b63080a
TIP128: bugfix: using copy if creating hard link failed
tomatoishealthy 6e498a4
bugfix: adjust the order of the http filters
tomatoishealthy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,12 @@ public class Constant { | |
|
||
public static final String DATABASE_DIR = "storage.directory"; | ||
|
||
// locate in storageDbDirectory, store the db infos, | ||
// now only has the split block number | ||
public static final String INFO_FILE_NAME = "info.properties"; | ||
// the block number that split between the snapshot and history | ||
public static final String SPLIT_BLOCK_NUM = "split_block_num"; | ||
|
||
public static final byte ADD_PRE_FIX_BYTE_MAINNET = (byte) 0x41; //41 + address | ||
public static final String ADD_PRE_FIX_STRING_MAINNET = "41"; | ||
public static final byte ADD_PRE_FIX_BYTE_TESTNET = (byte) 0xa0; //a0 + address | ||
|
@@ -105,6 +111,8 @@ public class Constant { | |
|
||
public static final String NODE_RPC_MAX_HEADER_LIST_SIZE = "node.rpc.maxHeaderListSize"; | ||
|
||
public static final String NODE_OPEN_HISTORY_QUERY_WHEN_LITEFN = "node.openHistoryQueryWhenLiteFN"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. too long and difficult to figure out the meaning. |
||
|
||
public static final String BLOCK_MAINTENANCE_TIME_INTERVAL = "block.maintenanceTimeInterval"; | ||
public static final String BLOCK_PROPOSAL_EXPIRE_TIME = "block.proposalExpireTime"; | ||
|
||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mixed use of
snake_case
andcamelCase
keys.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming rule of constant in java is just this