Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
45e3bf8
feat(*): disable exchange transaction (#6507)
halibobo1205 Jan 12, 2026
25b35f5
update a new version. version name:GreatVoyage-v4.8.0-1-g45e3bf88ca,v…
halibobo1205 Jan 12, 2026
44a4bc8
Merge release_v4.8.1 to master (#6541)
kuny0707 Feb 4, 2026
87baada
update a new version. version name:GreatVoyage-v4.8.0.1-1-g44a4bc8263…
halibobo1205 Feb 4, 2026
ddd8c7b
feat(vm): optimize the check for create2
aabbssaa Jun 1, 2026
30752bf
feat(vm): optimize the check for ModExp
aabbssaa Jun 2, 2026
a45af58
test(vm): add tests for create2/modExp checks
aabbssaa Jun 2, 2026
144571a
feat(version): update version to 4.8.1.1
aabbssaa Jun 2, 2026
d5d9f46
feat(ci): add PR pipeline and system-test workflows
halibobo1205 Jun 2, 2026
52d7d9d
feat(config): fix git.properties NPE
halibobo1205 Jun 2, 2026
a79693e
update a new version. version name:GreatVoyage-v4.8.1-6-g52d7d9d23e,v…
halibobo1205 Jun 2, 2026
bb3312c
fix readme typo and format (#6556)
Sunny6889 Feb 27, 2026
a18e0f3
refactor: move test constant out of production code and rename NET_CO…
vividctrlalt Feb 27, 2026
2d783f3
ci: enhance PR lint and add PR guidelines to CONTRIBUTING.md (#6564)
vividctrlalt Feb 28, 2026
a358e7f
refactor(config): extract ConfigKey and remove testnet config (#6565)
vividctrlalt Mar 3, 2026
63832e1
refactor(config): remove unused config files (#6566)
halibobo1205 Mar 3, 2026
3de20f7
fix(docs): github issue template (#6572)
abn2357 Mar 6, 2026
0a2abbe
ci: add multi-platform build tests and system-test workflows (#6574)
0xbigapple Mar 11, 2026
2d71a45
refactor(config): extract CLIParameter and restructure Args init flow…
vividctrlalt Mar 12, 2026
a1a2a1d
modify the template title (#6589)
Sunny6889 Mar 19, 2026
bcb5faf
fix(doc): update issue template (#6594)
Sunny6889 Mar 23, 2026
edb96ef
test(framework): add dual DB engine coverage with flaky test fixes (#…
vividctrlalt Mar 24, 2026
5a638b3
fix(config): deprecate CLI params and add guardrails (#6580)
vividctrlalt Mar 26, 2026
d375c30
ci: add coverage check workflow (#6582)
0xbigapple Mar 26, 2026
10017f0
remove codecov ci (#6605)
0xbigapple Mar 26, 2026
c402a43
docs: fix shieldedTransaction typos in comments
operagxsasha Mar 13, 2026
43c85c9
feat(actuator): prevent duplicate registration and stabilize CI
halibobo1205 Feb 27, 2026
8c51311
fix(test): catch Throwable instead of Exception in concurrent registr…
halibobo1205 Apr 1, 2026
9e8bd69
func(proposal): add Osaka proposal for TVM
ouy95917 Feb 25, 2026
d2f74bd
func(vm): implement eip-7823
ouy95917 Feb 25, 2026
67aaf4c
func(vm): add unit test for eip-7823
ouy95917 Feb 25, 2026
4b00429
fix(vm): correct osaka proposal id, default config and modexp behavior
ouy95917 Mar 30, 2026
5c036cf
test(vm): add boundary and edge case tests for eip-7823 modexp limit
ouy95917 Mar 31, 2026
0916635
chore(github): add CODEOWNERS for PR review assignments (#6636)
Sunny6889 Apr 2, 2026
3353eb6
add desc about how to create an issue and fix "submit code"
abn2357 Mar 10, 2026
fe467de
Revise two sentences to make the description clearer
abn2357 Mar 10, 2026
65f8ac2
fix official repository name
abn2357 Mar 11, 2026
4ecdf33
opt(common): GenesisBlock timestamp valid message error
imalasong Apr 21, 2025
33fd47a
feat(ci): add coverage check workflow and auto reviewer assignment (#…
bladehan1 Apr 8, 2026
a069c81
imporove feature template (#6657)
317787106 Apr 9, 2026
30b1c26
refactor(tvm): optimize energy cost calculation for vote witness opcode
yanghang8612 Mar 31, 2026
545d3be
fix(test): correct comment in testZeroLengthOneArray
yanghang8612 Apr 9, 2026
7b94819
fix(actuator): correct protobuf unpack types in getOwnerAddress()
halibobo1205 Apr 9, 2026
77b4a66
feat(protocol): add protoLint check for enum validation (#6631)
0xbigapple Apr 16, 2026
444884d
test(framework): consolidate and stabilize CredentialsTest (#6614)
3for Apr 21, 2026
93f0931
chore: fix outdated content across docs/ and root-level docs (#6662)
Little-Peony Apr 27, 2026
6d1dc00
fix(trie): make TrieImpl.insert() idempotent for duplicate key-value …
halibobo1205 Apr 27, 2026
0791a7c
refactor(config): replace manual parsing with ConfigBeanFactory bindi…
vividctrlalt Apr 28, 2026
6a9dee4
feat(plugins): migrate keystore CLI from FullNode to Toolkit (#6637)
barbatos2011 Apr 28, 2026
e993fef
fix(db): resolve resource leakage in CheckPointV2Store `close()` (#6688)
warku123 Apr 28, 2026
23ef376
fix(framework): fix SolidityNode shutdown and improve test quality (#…
Little-Peony Apr 28, 2026
b4d565c
feat(metrics): add block transaction count and SR set change monitori…
warku123 Apr 29, 2026
98e5f7a
refactor(jsonrpc): centralize block selector parsing into JsonRpcApiU…
0xbigapple Apr 30, 2026
10528e6
feat(jsonrpc): add blockTimestamp to logs and receipts (#6671)
0xbigapple Apr 30, 2026
41e6a91
fix(jsonrpc): accept "input" as alias for "data" in call args (#6722)
waynercheung May 7, 2026
cc7da22
build(crypto,rpc,http,event): bump bundled libs for security fixes (#…
halibobo1205 May 7, 2026
2e9feef
feat(vm,consensus): harden resource calculations(TIP-833) (#6721)
halibobo1205 May 7, 2026
aaeaf28
feat: fix TRX inv rate limit bug and add BLOCK inv rate limit (#6731)
xxo1shine May 7, 2026
e4b46de
feat(db,lite): add --exclude-historical-balance for lite snapshot (#6…
halibobo1205 May 7, 2026
97adae3
feat(api): optimize and harden HTTP/JSON-RPC API layer (#6693)
bladehan1 May 8, 2026
5ad5605
fix(plugins): exclude transitive leveldbjni-all from :crypto (#6738)
barbatos2011 May 8, 2026
b7f1bab
fix(jsonrpc): correct TransactionResult.nonce per JSON-RPC spec (#6709)
waynercheung May 8, 2026
454396e
feat(api): support int64_as_string parameter for GET requests (#6699)
waynercheung May 8, 2026
6419ab0
fix(jsonrpc): harden ABI parser bounds and revert reason decoding (#6…
0xbigapple May 8, 2026
856f94a
feat(crypto): shielded transaction API security enhancement (#6694)
Federico2014 May 8, 2026
6151ab0
feat(log): improve log for gRPC, DB, and shutdown (#6700)
halibobo1205 May 8, 2026
c08488e
fix(crypto): deprecate events field in shielded TRC20 scan APIs (#6683)
Federico2014 May 8, 2026
c8aa6a1
feat(actuator,consensus): harden exchange calculations (TIP-836) (#6710)
halibobo1205 May 8, 2026
262f93f
feat(http): add SizeLimitHandler to enforce request body size limit (…
bladehan1 May 8, 2026
546c3fa
fix(consensus,framework,actuator): use Locale.ROOT for case-insensiti…
halibobo1205 May 8, 2026
ff493cd
refactor(config): simplify applyEventConfig to gate on isEnable() (#6…
vividctrlalt May 8, 2026
011a8b3
feat(metrics): refine block_transaction_count buckets, add changelog …
warku123 May 8, 2026
1467c4c
refactor(protocol): prune grpc-gateway proto and support go compile (…
317787106 May 8, 2026
ad236f6
feat(vm): add P256VERIFY precompile (TIP-7951)
yanghang8612 May 7, 2026
d750a28
test(vm): add ECRecover vs P256VERIFY microbenchmarks
yanghang8612 May 7, 2026
563443b
test(vm): make precompile benchmarks opt-in
yanghang8612 May 8, 2026
bb52fe4
feat(vm): serve historical block hashes from state (TIP-2935)
yanghang8612 May 8, 2026
69d2e5b
fix(vm): write TIP-2935 parent hash before tx loop in generateBlock
yanghang8612 May 8, 2026
f90a3af
test(vm): consolidate TIP-2935 unit tests into integration suite
yanghang8612 May 8, 2026
35178cd
feat(vm): implement TIP-7939 CLZ opcode
yanghang8612 May 6, 2026
3a7356b
test(vm): cover CLZ unsigned cast and proposal-gate rejection
yanghang8612 May 6, 2026
83c3ed4
test(vm): reset Osaka flag after CLZ coverage
yanghang8612 May 8, 2026
3b14b8f
fix(net): fix RejectedExecutionException during shutdown trxHandlePoo…
0xbigapple May 8, 2026
24e9492
feat(vm): implement TIP-7883 ModExp gas cost increase
yanghang8612 Apr 29, 2026
2d332a4
test(vm): cover TIP-7883 ModExp pricing across nagydani vectors
yanghang8612 Apr 29, 2026
360b778
refactor(vm): wrap TIP-7883 energy arithmetic with StrictMathWrapper
yanghang8612 May 7, 2026
ecc776d
refactor(vm): extract TIP-7883 ModExp minimum energy constants
yanghang8612 May 8, 2026
41411c8
feat(api): make API calls non-blocking (#6733)
xxo1shine May 8, 2026
49a99dd
fix(actuator): remove actuator whitelist to avoid fork (#6723)
317787106 May 8, 2026
5649c6b
refactor(metrics): delete influxdb storage for metrics (#6725)
317787106 May 8, 2026
171f8cc
fix(event): filter removed=true from solidity maps and sync contract …
xxo1shine May 8, 2026
65f03dc
feat(sync): reduce memory pressure by deferring block deserialization…
xxo1shine May 8, 2026
838ead8
feat(framework,actuator,common): replace fastjson with jackson (#6701)
halibobo1205 May 8, 2026
1809e5c
feat(net): optimize transaction rate limiting with accurate cache siz…
xxo1shine May 9, 2026
edf87da
feat(vm): canonicalize calldata length for validateMultiSign / batchV…
yanghang8612 May 6, 2026
fa4fb7f
test(vm): cover TIP-854 calldata canonicalization for sign-validation…
yanghang8612 May 6, 2026
41b9d97
fix(vm): reject header-only calldata in canonical ABI check
yanghang8612 May 7, 2026
102440c
feat(vm): add node-level vm.constantCallTimeoutMs for constant calls
yanghang8612 May 8, 2026
ff3c613
test(vm): cover constantCallTimeoutMs explicit-configure validation
yanghang8612 May 8, 2026
c4be43a
fix(vm): harden constant call timeout deadline
yanghang8612 May 9, 2026
ef16da8
feat(net): add P2P message deduplication and length validation (#6712)
xxo1shine May 9, 2026
fac5cc8
fix(security): validate merkle root before broadcast and reset isVeri…
xxo1shine May 9, 2026
5297ee3
refactor(db): remove function for periodic backup of RocksDB database…
317787106 May 9, 2026
9cf9380
feat(version):bump tron version from 4.8.1 to 4.8.2 (#6754)
halibobo1205 May 9, 2026
5e2c462
feat(net): optimize disconnectRandom by tracking block receive time p…
xxo1shine May 9, 2026
6bf8a50
feat(net): support domain names in peer configuration (#6727)
317787106 May 9, 2026
00723b3
feat(framework): support solidity conditional shutdown (#6734)
317787106 May 9, 2026
baa2a2e
fix(jsonrpc): enforce log filter cap and improve match efficiency (#6…
317787106 May 9, 2026
dc220ac
feat(jsonrpc): add resource restrict for jsonrpc (#6728)
317787106 May 9, 2026
01bfeb3
fix(config): optimizes config binding for node (#6755)
317787106 May 10, 2026
050ecff
fix(config): fix the issue where --es fails to start (#6757)
317787106 May 10, 2026
47ae465
restore useNativeQueue to false default (#6759)
317787106 May 10, 2026
c0cf561
fix(event): reject incompatible event-plugin versions below 3.0.0 (#6…
halibobo1205 May 11, 2026
0b56775
feat(ratelimiter): add configurable blocking mode for API rate limite…
xxo1shine May 12, 2026
48d3761
refactor(config,protocol,ci): optimize config binding (#6762)
317787106 May 14, 2026
64338af
fix(jsonrpc): make the JSON-RPC output more compliant with specificat…
317787106 May 15, 2026
df446d3
fix(net): map BLOCK_MERKLE_INVALID to BAD_BLOCK disconnect reason (#6…
xxo1shine May 21, 2026
9c2d556
fix(security): re-verify block signature during fork replay (#6777)
xxo1shine May 21, 2026
cc680b9
fix(security): cover consumed permission-change tx in getVerifyTxs (#…
xxo1shine May 22, 2026
06e435d
fix(vm): canonicalize ModExp zero modulus output (TIP-871) (#6780)
yanghang8612 May 25, 2026
9693b27
feat(net): normalize inbound messages (#6797)
halibobo1205 May 25, 2026
ad7ee75
fix(vm): write TIP-2935 parent hash after witness permission check (#…
yanghang8612 May 25, 2026
65b76e4
feat(ci): enforce reference.conf CI check (#6795)
bladehan1 May 26, 2026
d4c7faa
refactor(config): remove unused storage index and json parsing config…
317787106 May 26, 2026
463eddd
fix(net): restrict admission signature length (#6782)
Federico2014 May 26, 2026
3f12f50
fix(log): suppress spurious error logs when solidity node exits (#6801)
317787106 May 26, 2026
28c825e
refactor(config): merge test config files (#6788)
317787106 May 26, 2026
d977604
fix(crypto): bind burn cipher nonce to nullifier (#6775)
Federico2014 May 27, 2026
65a7fb1
refactor(config): overhaul config docs, fix defaults, remove dead par…
317787106 May 28, 2026
6c5926a
fix(db): fix storage config properties (#6806)
317787106 Jun 2, 2026
4bc641e
Merge branch 'release_v4.8.2' into feat/merge_4.8.1.1
halibobo1205 Jun 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,10 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
int expLen = parseLen(data, 1);
int modLen = parseLen(data, 2);

if (baseLen == 0 && modLen == 0 && expLen > UPPER_BOUND) {
MUtil.checkCPUTimeForModExp();
Comment on lines +697 to +698

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor Osaka's ModExp length rejection first

When ALLOW_TVM_OSAKA is enabled after the 4.8.2 fork, VERSION_4_8_1_1 will also have passed, so calldata with baseLen == 0, modLen == 0, and expLen > 1024 now throws OutOfTimeException here before reaching the Osaka branch that should return Pair.of(false, EMPTY_BYTE_ARRAY) for oversized lengths. That changes the TIP-7823/Osaka behavior for this input from a failed precompile call to an exceptional CPU-time abort; move the Osaka length rejection ahead of this legacy timeout check or skip the timeout when Osaka is active.

Useful? React with 👍 / 👎.

}

if (VMConfig.allowTvmOsaka()
&& (baseLen > UPPER_BOUND || expLen > UPPER_BOUND || modLen > UPPER_BOUND)) {
return Pair.of(false, EMPTY_BYTE_ARRAY);
Expand Down
3 changes: 3 additions & 0 deletions actuator/src/main/java/org/tron/core/vm/program/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,9 @@ public void createContract2(DataWord value, DataWord memStart, DataWord memSize,
stackPushZero();
return;
}
if (getCallDeep() == MAX_DEPTH) {
MUtil.checkCPUTimeForCreate2();
}
if (VMConfig.allowTvmIstanbul()) {
senderAddress = getContextAddress();
} else {
Expand Down
12 changes: 12 additions & 0 deletions actuator/src/main/java/org/tron/core/vm/utils/MUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ public static void checkCPUTime() {
throw new OutOfTimeException("CPU timeout for 0x0a executing");
}
}

public static void checkCPUTimeForCreate2() {
if (ForkController.instance().pass(Parameter.ForkBlockVersionEnum.VERSION_4_8_1_1)) {
throw new OutOfTimeException("CPU timeout for create2 executing");
}
}

public static void checkCPUTimeForModExp() {
if (ForkController.instance().pass(Parameter.ForkBlockVersionEnum.VERSION_4_8_1_1)) {
throw new OutOfTimeException("CPU timeout for modExp executing");
}
}
}
5 changes: 3 additions & 2 deletions common/src/main/java/org/tron/core/config/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public enum ForkBlockVersionEnum {
VERSION_4_8_0(32, 1596780000000L, 80),
VERSION_4_8_0_1(33, 1596780000000L, 70),
VERSION_4_8_1(34, 1596780000000L, 80),
VERSION_4_8_2(35, 1596780000000L, 80);
VERSION_4_8_1_1(35, 1596780000000L, 70),
VERSION_4_8_2(36, 1596780000000L, 80);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the 4.8.2 fork version value

Because VERSION_4_8_2 was already value 35 in the parent commit, moving it to 36 makes any stored version-35 fork stats or previously produced version-35 blocks map to VERSION_4_8_1_1 instead. On a chain that has already observed/activated 4.8.2 at 35, pass(VERSION_4_8_2) becomes false until a new round of 36 votes, while pass(VERSION_4_8_1_1) can become true from the old 4.8.2 votes, enabling these CPU-time behavior changes at the wrong fork and causing this release to produce a different block version for an existing fork; keep the existing 4.8.2 numeric value stable or add an explicit migration for stored fork stats.

Useful? React with 👍 / 👎.

// if add a version, modify BLOCK_VERSION simultaneously

@Getter
Expand Down Expand Up @@ -78,7 +79,7 @@ public class ChainConstant {
public static final int SINGLE_REPEAT = 1;
public static final int BLOCK_FILLED_SLOTS_NUMBER = 128;
public static final int MAX_FROZEN_NUMBER = 1;
public static final int BLOCK_VERSION = 35;
public static final int BLOCK_VERSION = 36;
public static final long FROZEN_PERIOD = 86_400_000L;
public static final long DELEGATE_PERIOD = 3 * 86_400_000L;
public static final long TRX_PRECISION = 1000_000L;
Expand Down
2 changes: 2 additions & 0 deletions framework/src/main/java/org/tron/core/config/args/Args.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.tron.core.config.args;

import static java.lang.System.exit;
import static org.fusesource.jansi.Ansi.ansi;
import static org.tron.common.math.Maths.max;
import static org.tron.core.Constant.ADD_PRE_FIX_BYTE_MAINNET;
import static org.tron.core.Constant.ENERGY_LIMIT_IN_CONSTANT_TX;
Expand Down Expand Up @@ -36,6 +37,7 @@
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.fusesource.jansi.AnsiConsole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.tron.common.arch.Arch;
Expand Down
4 changes: 2 additions & 2 deletions framework/src/main/java/org/tron/program/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class Version {

public static final String VERSION_NAME = "GreatVoyage-v4.8.0.1-1-g44a4bc8263";
public static final String VERSION_CODE = "18636";
public static final String VERSION_NAME = "GreatVoyage-v4.8.1-6-g52d7d9d23e";
public static final String VERSION_CODE = "18643";
private static final String VERSION = "4.8.2";

public static String getVersion() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
package org.tron.common.runtime.vm;

import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.parameter.CommonParameter;
import org.tron.common.runtime.InternalTransaction;
import org.tron.common.utils.ForkController;
import org.tron.core.Constant;
import org.tron.core.config.Parameter.ForkBlockVersionEnum;
import org.tron.core.config.args.Args;
import org.tron.core.exception.ContractValidateException;
import org.tron.core.store.StoreFactory;
import org.tron.core.vm.PrecompiledContracts;
import org.tron.core.vm.PrecompiledContracts.PrecompiledContract;
import org.tron.core.vm.config.ConfigLoader;
import org.tron.core.vm.config.VMConfig;
import org.tron.core.vm.program.Program;
import org.tron.core.vm.program.Program.OutOfTimeException;
import org.tron.core.vm.program.invoke.ProgramInvokeMockImpl;
import org.tron.core.vm.utils.MUtil;
import org.tron.protos.Protocol;


@Slf4j
public class Create2ModExpForkTest extends BaseTest {

// mirrors the private Program.MAX_DEPTH
private static final int MAX_CALL_DEPTH = 64;

// mirrors PrecompiledContracts.ModExp.UPPER_BOUND
private static final int MOD_EXP_UPPER_BOUND = 1024;

// ModExp precompile address (0x05)
private static final DataWord MOD_EXP_ADDR = new DataWord(
"0000000000000000000000000000000000000000000000000000000000000005");

@BeforeClass
public static void init() {
Args.setParam(new String[] {"--output-directory", dbPath(), "--debug"}, Constant.TEST_CONF);
CommonParameter.getInstance().setDebug(true);
}

@AfterClass
public static void destroy() {
ConfigLoader.disable = false;
VMConfig.initVmHardFork(false);
VMConfig.initAllowTvmCompatibleEvm(0);
Args.clearParam();
}

@Before
public void setUp() {
ForkController.instance().init(chainBaseManager);
deactivateFork(ForkBlockVersionEnum.VERSION_4_8_1_1);
}

@Test
public void checkCPUTimeForCreate2_isGatedByFork() {
MUtil.checkCPUTimeForCreate2();

activateFork(ForkBlockVersionEnum.VERSION_4_8_1_1);

OutOfTimeException ex =
Assert.assertThrows(OutOfTimeException.class, MUtil::checkCPUTimeForCreate2);
Assert.assertEquals("CPU timeout for create2 executing", ex.getMessage());
}

@Test
public void checkCPUTimeForModExp_isGatedByFork() {
MUtil.checkCPUTimeForModExp();

activateFork(ForkBlockVersionEnum.VERSION_4_8_1_1);

OutOfTimeException ex =
Assert.assertThrows(OutOfTimeException.class, MUtil::checkCPUTimeForModExp);
Assert.assertEquals("CPU timeout for modExp executing", ex.getMessage());
}

@Test
public void modExp_degenerateInput_throwsOnlyAfterFork() {
PrecompiledContract modExp = PrecompiledContracts.getContractForAddress(MOD_EXP_ADDR);
byte[] data = buildModExpInput(MOD_EXP_UPPER_BOUND + 1);

Pair<Boolean, byte[]> out = modExp.execute(data);
Assert.assertTrue(out.getLeft());

activateFork(ForkBlockVersionEnum.VERSION_4_8_1_1);

OutOfTimeException ex =
Assert.assertThrows(OutOfTimeException.class, () -> modExp.execute(data));
Assert.assertEquals("CPU timeout for modExp executing", ex.getMessage());
}

@Test
public void modExp_atUpperBound_doesNotThrowAfterFork() {
activateFork(ForkBlockVersionEnum.VERSION_4_8_1_1);

PrecompiledContract modExp = PrecompiledContracts.getContractForAddress(MOD_EXP_ADDR);
Pair<Boolean, byte[]> out = modExp.execute(buildModExpInput(MOD_EXP_UPPER_BOUND));
Assert.assertTrue(out.getLeft());
}

@Test
public void createContract2_atMaxDepth_legacyPath_throwsAfterFork()
throws ContractValidateException {
VMConfig.initAllowTvmCompatibleEvm(0);
activateFork(ForkBlockVersionEnum.VERSION_4_8_1_1);

Program program = buildProgramAtMaxDepth();
OutOfTimeException ex = Assert.assertThrows(OutOfTimeException.class,
() -> program.createContract2(
DataWord.ZERO(), DataWord.ZERO(), DataWord.ZERO(), DataWord.ZERO()));
Assert.assertEquals("CPU timeout for create2 executing", ex.getMessage());
}

@Test
public void createContract2_atMaxDepth_compatibleEvmOn_doesNotThrow()
throws ContractValidateException {
VMConfig.initAllowTvmCompatibleEvm(1);
activateFork(ForkBlockVersionEnum.VERSION_4_8_1_1);

Program program = buildProgramAtMaxDepth();
program.createContract2(DataWord.ZERO(), DataWord.ZERO(), DataWord.ZERO(), DataWord.ZERO());
Assert.assertEquals(DataWord.ZERO(), program.getStack().pop());
}

// ---- helpers ---------------------------------------------------------------------------------

private Program buildProgramAtMaxDepth() throws ContractValidateException {
StoreFactory.init();
StoreFactory storeFactory = StoreFactory.getInstance();
storeFactory.setChainBaseManager(chainBaseManager);
byte[] ops = new byte[] {0};
ProgramInvokeMockImpl invoke = new ProgramInvokeMockImpl(storeFactory, ops, ops) {
@Override
public int getCallDeep() {
return MAX_CALL_DEPTH;
}
};
Program program = new Program(ops, ops, invoke,
new InternalTransaction(Protocol.Transaction.getDefaultInstance(),
InternalTransaction.TrxType.TRX_UNKNOWN_TYPE));
program.setRootTransactionId(new byte[32]);
return program;
}

private byte[] buildModExpInput(int expLen) {
byte[] data = new byte[96];
byte[] expLenWord = new DataWord(expLen).getData();
System.arraycopy(expLenWord, 0, data, 32, 32);
return data;
}

private void activateFork(ForkBlockVersionEnum forkVersion) {
byte[] stats = new byte[27];
Arrays.fill(stats, (byte) 1);
chainBaseManager.getDynamicPropertiesStore().statsByVersion(forkVersion.getValue(), stats);
long maintenanceTimeInterval =
chainBaseManager.getDynamicPropertiesStore().getMaintenanceTimeInterval();
long hardForkTime = ((forkVersion.getHardForkTime() - 1) / maintenanceTimeInterval + 1)
* maintenanceTimeInterval;
chainBaseManager.getDynamicPropertiesStore().saveLatestBlockHeaderTimestamp(hardForkTime + 1);
}

private void deactivateFork(ForkBlockVersionEnum forkVersion) {
chainBaseManager.getDynamicPropertiesStore()
.statsByVersion(forkVersion.getValue(), new byte[27]);
chainBaseManager.getDynamicPropertiesStore().saveLatestBlockHeaderTimestamp(0L);
}
}
Loading