Skip to content

Commit 8481e81

Browse files
authored
feat(dependencies): update grpc (#6429)
avoid CVE-2025-55163,MadeYouReset 1. bump grpc-java from 1.60.0 to 1.75.0 2. bump protobuf from 3.25.5 to 3.25.8 3. add node.rpc.maxRstStream and node.rpc.secondsPerWindow 4. bump libp2p to 2.2.7-SNAPSHOT
1 parent f22c8ae commit 8481e81

File tree

11 files changed

+285
-197
lines changed

11 files changed

+285
-197
lines changed

build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ subprojects {
126126
}
127127
}
128128
}
129+
configurations.configureEach {
130+
resolutionStrategy {
131+
eachDependency { details ->
132+
if (details.requested.group == 'com.google.guava' &&
133+
details.requested.name == 'guava') {
134+
def requestedVersion = details.requested.version
135+
if (requestedVersion.matches(/.*-android$/)) {
136+
def jreVersion = requestedVersion.replaceAll(/-android$/, '-jre')
137+
details.useVersion(jreVersion)
138+
details.because("Automatically replace android guava with jre version: ${requestedVersion} -> ${jreVersion}")
139+
}
140+
}
141+
}
142+
}
143+
}
129144
}
130145

131146
task copyToParent(type: Copy) {

common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies {
2222
api 'org.aspectj:aspectjrt:1.9.8'
2323
api 'org.aspectj:aspectjweaver:1.9.8'
2424
api 'org.aspectj:aspectjtools:1.9.8'
25-
api group: 'io.github.tronprotocol', name: 'libp2p', version: '2.2.6',{
25+
api group: 'com.github.tronprotocol', name: 'libp2p', version: 'release-v2.2.7-SNAPSHOT',{
2626
exclude group: 'io.grpc', module: 'grpc-context'
2727
exclude group: 'io.grpc', module: 'grpc-core'
2828
exclude group: 'io.grpc', module: 'grpc-netty'

common/src/main/java/org/tron/common/parameter/CommonParameter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ public class CommonParameter {
249249
@Getter
250250
@Setter
251251
public int flowControlWindow;
252+
// the positive limit of RST_STREAM frames per connection per period for grpc,
253+
// 0 or Integer.MAX_VALUE for unlimited, by default there is no limit.
254+
@Getter
255+
@Setter
256+
public int rpcMaxRstStream;
257+
// the positive number of seconds per period for grpc
258+
@Getter
259+
@Setter
260+
public int rpcSecondsPerWindow;
252261
@Getter
253262
@Setter
254263
public long maxConnectionIdleInMillis;

common/src/main/java/org/tron/core/Constant.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ public class Constant {
163163
public static final String NODE_RPC_MAX_CONCURRENT_CALLS_PER_CONNECTION = "node.rpc.maxConcurrentCallsPerConnection";
164164
public static final String NODE_RPC_FLOW_CONTROL_WINDOW = "node.rpc.flowControlWindow";
165165
public static final String NODE_RPC_MAX_CONNECTION_IDLE_IN_MILLIS = "node.rpc.maxConnectionIdleInMillis";
166+
public static final String NODE_RPC_MAX_RST_STREAM = "node.rpc.maxRstStream";
167+
public static final String NODE_RPC_SECONDS_PER_WINDOW = "node.rpc.secondsPerWindow";
166168
public static final String NODE_PRODUCED_TIMEOUT = "node.blockProducedTimeOut";
167169
public static final String NODE_MAX_HTTP_CONNECT_NUMBER = "node.maxHttpConnectNumber";
168170

framework/src/main/java/org/tron/common/application/RpcService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ protected NettyServerBuilder initServerBuilder() {
8888
.maxConnectionAge(parameter.getMaxConnectionAgeInMillis(), TimeUnit.MILLISECONDS)
8989
.maxInboundMessageSize(parameter.getMaxMessageSize())
9090
.maxHeaderListSize(parameter.getMaxHeaderListSize());
91+
if (parameter.getRpcMaxRstStream() > 0 && parameter.getRpcSecondsPerWindow() > 0) {
92+
serverBuilder.maxRstFramesPerWindow(
93+
parameter.getRpcMaxRstStream(), parameter.getRpcSecondsPerWindow());
94+
}
9195

9296
if (parameter.isRpcReflectionServiceEnable()) {
9397
serverBuilder.addService(ProtoReflectionService.newInstance());

framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ public static void clearParam() {
251251
PARAMETER.allowTvmCancun = 0;
252252
PARAMETER.allowTvmBlob = 0;
253253
PARAMETER.allowTvmSelfdestructRestriction = 0;
254+
PARAMETER.rpcMaxRstStream = 0;
255+
PARAMETER.rpcSecondsPerWindow = 0;
254256
}
255257

256258
/**
@@ -723,6 +725,12 @@ public static void setParam(final Config config) {
723725
PARAMETER.flowControlWindow = config.hasPath(Constant.NODE_RPC_FLOW_CONTROL_WINDOW)
724726
? config.getInt(Constant.NODE_RPC_FLOW_CONTROL_WINDOW)
725727
: NettyServerBuilder.DEFAULT_FLOW_CONTROL_WINDOW;
728+
if (config.hasPath(Constant.NODE_RPC_MAX_RST_STREAM)) {
729+
PARAMETER.rpcMaxRstStream = config.getInt(Constant.NODE_RPC_MAX_RST_STREAM);
730+
}
731+
if (config.hasPath(Constant.NODE_RPC_SECONDS_PER_WINDOW)) {
732+
PARAMETER.rpcSecondsPerWindow = config.getInt(Constant.NODE_RPC_SECONDS_PER_WINDOW);
733+
}
726734

727735
PARAMETER.maxConnectionIdleInMillis =
728736
config.hasPath(Constant.NODE_RPC_MAX_CONNECTION_IDLE_IN_MILLIS)

framework/src/test/java/org/tron/common/ParameterTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ public void testCommonParameter() {
129129
assertEquals(10, parameter.getMaxConcurrentCallsPerConnection());
130130
parameter.setFlowControlWindow(20);
131131
assertEquals(20, parameter.getFlowControlWindow());
132+
assertEquals(0, parameter.getRpcMaxRstStream());
133+
parameter.setRpcMaxRstStream(10);
134+
assertEquals(10, parameter.getRpcMaxRstStream());
135+
assertEquals(0, parameter.getRpcSecondsPerWindow());
136+
parameter.setRpcSecondsPerWindow(5);
137+
assertEquals(5, parameter.getRpcSecondsPerWindow());
132138
parameter.setMaxConnectionIdleInMillis(1000);
133139
assertEquals(1000, parameter.getMaxConnectionIdleInMillis());
134140
parameter.setBlockProducedTimeOut(500);

framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.IOException;
1313
import java.util.Objects;
1414
import org.junit.AfterClass;
15+
import org.junit.Assert;
1516
import org.junit.BeforeClass;
1617
import org.junit.ClassRule;
1718
import org.junit.FixMethodOrder;
@@ -131,6 +132,8 @@ public class RpcApiServicesTest {
131132
@BeforeClass
132133
public static void init() throws IOException {
133134
Args.setParam(new String[]{"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF);
135+
Assert.assertEquals(5, getInstance().getRpcMaxRstStream());
136+
Assert.assertEquals(10, getInstance().getRpcSecondsPerWindow());
134137
String OWNER_ADDRESS = Wallet.getAddressPreFixString()
135138
+ "548794500882809695a8a687866e76d4271a1abc";
136139
getInstance().setRpcEnable(true);

framework/src/test/resources/config-test.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ node {
209209

210210
# The switch of the reflection service, effective for all gRPC services
211211
reflectionService = true
212+
maxRstStream = 5
213+
secondsPerWindow = 10
212214
}
213215

214216
}

0 commit comments

Comments
 (0)