Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
022798a
docs(archive): add archiveV3 design corpus, verification report and a…
halibobo1205 Jun 27, 2026
5cbc625
feat(archive): L1 config/no-op/dbName scaffolding for default-off sid…
halibobo1205 Jun 27, 2026
aa2582e
feat(archive): L2 in-memory txNum index + execution context (non-cons…
halibobo1205 Jun 27, 2026
750a594
docs(archive): refine decision 5 arm64 module boundary to L5 (L2-L4 s…
halibobo1205 Jun 27, 2026
d078d66
feat(archive): L2 DefaultArchiveService + factory enablement (non-con…
halibobo1205 Jun 27, 2026
1b3b3b2
docs(archive): L2 Manager-hooks handoff packet (anchors, structural t…
halibobo1205 Jun 27, 2026
2667db0
feat(archive): L2 Manager lifecycle hooks + enabled integration test …
halibobo1205 Jun 27, 2026
dca73a2
docs(archive): record L4 todo — updateFork txNum attribution (post-pr…
halibobo1205 Jun 27, 2026
b4f9eda
feat(archive): L3 domain registry schema core (dbName classification,…
halibobo1205 Jun 27, 2026
0a96c3a
feat(archive): L3 canonical key/value codecs + dynamic-properties key…
halibobo1205 Jun 27, 2026
5776875
feat(archive): L3 ACCOUNT canonical value codec (decision 4: strip as…
halibobo1205 Jun 27, 2026
4261749
style(archive): wrap comments/signatures to 100 cols, ASCII-only source
halibobo1205 Jun 27, 2026
1808992
feat(archive): L3 domain catalog + coverage (per-domain codecs, deter…
halibobo1205 Jun 27, 2026
ff6ee64
feat(archive): L4a capture engine (dbName->binding->codec routing, ex…
halibobo1205 Jun 27, 2026
11652ce
feat(archive): L4b store-path capture hooks (base put/delete + contra…
halibobo1205 Jun 27, 2026
0d34217
feat(archive): L4c ACCOUNT_ASSET semantic capture (assetV2 value-diff…
halibobo1205 Jun 27, 2026
5cf1ed1
feat(archive): L4c CONTRACT_STORAGE semantic capture (VM Storage.comm…
halibobo1205 Jun 27, 2026
68ded81
docs(archive): soften ACCOUNT_ASSET comment per L4c verify (read-indu…
halibobo1205 Jun 27, 2026
becfcd7
feat(archive): L5 temporal store foundation (getAsOf/latest + in-memo…
halibobo1205 Jun 27, 2026
a05160d
feat(archive): L5 RocksDB temporal store (single-CF prefix layout, se…
halibobo1205 Jun 27, 2026
3c9d640
feat(archive): L5 wire RocksDB temporal store into service (factory p…
halibobo1205 Jun 27, 2026
df22dc8
feat(archive): L5 temporal unwind/pruning (changeset index, drop reve…
halibobo1205 Jun 27, 2026
57f75c0
fix(archive): L5 unwind correctness per verify (length-prefix keys, a…
halibobo1205 Jun 27, 2026
cc98d81
feat(archive): L6 state reader core (historical getAccount/getContrac…
halibobo1205 Jun 27, 2026
7fd8f79
docs(archive): L6 getStorage version-probe rationale + create2 caveat…
halibobo1205 Jun 27, 2026
d4c1ac4
feat(archive): L6 reader glue (ArchiveStorageKeyCodec + ArchiveStateR…
halibobo1205 Jun 27, 2026
9b7be91
feat(archive): L6 persistent txNum index (RocksDB block-range store +…
halibobo1205 Jun 27, 2026
b1ed7d5
docs(archive): note persistent-index unwind edge per verify (store-on…
halibobo1205 Jun 27, 2026
5130673
feat(archive): L6 wire persistent txNum index + reader factory into s…
halibobo1205 Jun 27, 2026
c5dffbc
feat(archive): L6 framework RPC -- historical eth_getBalance/getStora…
halibobo1205 Jun 27, 2026
94d75ab
fix(archive): L6 reject null storage slot in historical getStorageAt …
halibobo1205 Jun 27, 2026
5d49948
test(archive): L6 end-to-end historical eth_getBalance through real c…
halibobo1205 Jun 27, 2026
9050539
feat(archive): L8 Slice 1 -- VmDynamicProperties interface + ConfigLo…
halibobo1205 Jun 27, 2026
748d05c
feat(archive): L8 Slice 2 -- ArchiveRepositoryAdapter (archive-backed…
halibobo1205 Jun 28, 2026
3596386
feat(archive): L8 Slice 3a -- ArchiveRepositoryAdapter copy-on-write …
halibobo1205 Jun 28, 2026
98d0dc9
feat(archive): L8 Slice 3b-1 -- VMActuator historical injection seam …
halibobo1205 Jun 28, 2026
c6a9630
feat(archive): L8 Slice 3b-2a -- migrate VMActuator constant-call con…
halibobo1205 Jun 28, 2026
8f61086
feat(archive): L8 Slice 3b-2b -- HistoricalConstantCallExecutor (arch…
halibobo1205 Jun 28, 2026
6dacd68
test(archive): L8 Slice 3b-2c -- end-to-end historical constant call …
halibobo1205 Jun 28, 2026
6c8b5ef
fix(archive): L8 Slice 3 adversarial-verify fixes -- isolate energy-l…
halibobo1205 Jun 28, 2026
dfec4c1
feat(archive): L8 Slice 4 -- historical eth_call RPC (HistoricalEthCa…
halibobo1205 Jun 28, 2026
92d802a
fix(archive): L8 Slice 4 adversarial-verify fixes -- object-form hist…
halibobo1205 Jun 28, 2026
69bce30
fix(archive): L8 Fix 7 -- materialize fresh accounts in overlay for v…
halibobo1205 Jun 28, 2026
94359c1
feat(archive): L8 historical energy price for eth_call -- BASEFEE/GAS…
halibobo1205 Jun 28, 2026
5c20fcb
feat(archive): L8 historical hard-fork flag reconstruction for eth_ca…
halibobo1205 Jun 28, 2026
d37525b
fix(archive): L8 reconstruct 3 more result-affecting flags caught by …
halibobo1205 Jun 28, 2026
e4426d2
test(archive): L8 PUSH0 opcode gated on reconstructed Shanghai flag -…
halibobo1205 Jun 28, 2026
73be573
feat(archive): root FreezeV2/shielded-TRC20/multi-sign keys as VM_CON…
halibobo1205 Jun 28, 2026
4a4b354
test(archive): L8 end-to-end RPC integration -- HistoricalEthCallSupp…
halibobo1205 Jun 28, 2026
20dcdcd
feat(archive): historical debug_traceCall -- replay a read-only call …
halibobo1205 Jun 28, 2026
0aff674
feat(archive): historical debug_traceTransaction -- replay a past tx'…
halibobo1205 Jun 29, 2026
d2632df
fix(archive): L6 adversarial-verify fixes -- genesis-coverage gate on…
halibobo1205 Jun 29, 2026
05f4273
test(archive): L6 positive integration -- genesis-complete archive re…
halibobo1205 Jun 29, 2026
c892e1b
docs(archive): project B charter -- migrate L4/L5 temporal to Erigon-…
halibobo1205 Jun 29, 2026
47920db
docs(archive): project B-core execution handoff -- exact code anchors…
halibobo1205 Jun 29, 2026
82f54b0
feat(archive): B-core B1+B2 -- migrate temporal to Erigon-v3 prev-val…
halibobo1205 Jun 29, 2026
620ba05
test(archive): B-core B3 -- unwind restart-persistence + InMemory<->R…
halibobo1205 Jun 29, 2026
327ac12
test(archive): B-core B4 mid-chain store-reader verification
halibobo1205 Jun 30, 2026
955c0fd
fix(archive): harden B-core persistence fail-closed
halibobo1205 Jun 30, 2026
774b4d0
fix(archive): harden temporal unwind recovery
halibobo1205 Jun 30, 2026
c60c74a
fix(archive): harden unwind and historical reads
halibobo1205 Jun 30, 2026
ed7db51
fix(archive): fail closed on persisted corruption
halibobo1205 Jun 30, 2026
709b7e6
fix(archive): read contract state historically
halibobo1205 Jun 30, 2026
a3fcf0e
fix(archive): enforce contiguous txnum coverage
halibobo1205 Jun 30, 2026
5a478b5
fix(archive): replay vm config historically
halibobo1205 Jun 30, 2026
8cc98aa
fix(archive): validate canonical head on startup
halibobo1205 Jun 30, 2026
e435f4c
fix(archive): fail closed on mid-chain missing state
halibobo1205 Jun 30, 2026
7e376d8
fix(archive): harden replay and startup validation
halibobo1205 Jul 1, 2026
e793214
fix(archive): fail closed on rpc and persisted corruption
halibobo1205 Jul 1, 2026
81bacfa
fix(archive): tighten genesis coverage and vm params
halibobo1205 Jul 1, 2026
41503fc
fix(archive): harden capture coverage and temporal schema
halibobo1205 Jul 1, 2026
bd1b00c
fix(archive): fail closed unsupported trace replay
halibobo1205 Jul 1, 2026
f1b3528
fix(archive): require block hashes for committed ranges
halibobo1205 Jul 1, 2026
f0e188d
fix(archive): capture genesis and reject orphan temporal data
halibobo1205 Jul 3, 2026
a0724fd
fix(archive): align asset capture and dynamic key policy
halibobo1205 Jul 3, 2026
72e8801
fix(archive): fail closed runtime inconsistencies
halibobo1205 Jul 3, 2026
2b3d684
fix(archive): harden runtime consistency barriers
halibobo1205 Jul 3, 2026
abbe55e
fix(archive): tighten policy and replay guards
halibobo1205 Jul 3, 2026
2852e7c
fix(archive): isolate historical VM fork state
halibobo1205 Jul 3, 2026
6167fa4
fix(archive): harden trace replay and unwind cleanup
halibobo1205 Jul 5, 2026
7c4c54c
fix(archive): strengthen historical replay consistency
halibobo1205 Jul 5, 2026
2cc21be
fix(archive): tighten historical replay gates
halibobo1205 Jul 5, 2026
565d98d
fix(archive): keep unknown dynamic keys out of roots
halibobo1205 Jul 5, 2026
b71e42e
fix(archive): require canonical head coverage
halibobo1205 Jul 5, 2026
443dd5f
fix(archive): gate unsupported archive stores
halibobo1205 Jul 5, 2026
a282cbf
fix(archive): record trace opcode gas cost
halibobo1205 Jul 5, 2026
27d3e9e
fix(archive): align temporal key layout
halibobo1205 Jul 5, 2026
72715b3
fix(archive): derive block index lookups
halibobo1205 Jul 5, 2026
0662d19
fix(archive): migrate txnum keys to L5 prefixes
halibobo1205 Jul 5, 2026
79aba00
fix(archive): harden txnum schema validation
halibobo1205 Jul 5, 2026
853ae3b
fix(archive): harden state consistency checks
halibobo1205 Jul 6, 2026
74dfa3a
fix(archive): close review gaps in historical reads
halibobo1205 Jul 6, 2026
b05f5fb
fix(archive): harden genesis coverage validation
halibobo1205 Jul 6, 2026
60d3797
fix(archive): enforce genesis dynamic coverage
halibobo1205 Jul 6, 2026
aa954ab
fix(archive): publish only solidified history
halibobo1205 Jul 6, 2026
e7ebd2e
fix(archive): reconcile startup state
halibobo1205 Jul 6, 2026
c7110b2
fix(archive): harden review findings
halibobo1205 Jul 9, 2026
6db0304
fix(archive): harden config and historical resolution
halibobo1205 Jul 9, 2026
dbc28bd
fix(archive): harden historical calls and config
halibobo1205 Jul 9, 2026
127f3ec
fix(archive): harden historical trace calls
halibobo1205 Jul 9, 2026
b88911d
test(archive): guard historical dynamic property keys
halibobo1205 Jul 9, 2026
f7c1cf6
fix(archive): harden historical read-through
halibobo1205 Jul 9, 2026
778fe7d
fix(archive): harden recovery and historical state
halibobo1205 Jul 10, 2026
d0de85b
fix(archive): harden trace and capture isolation
halibobo1205 Jul 11, 2026
e7d3849
fix(archive): default bare manager to noop service
halibobo1205 Jul 11, 2026
be57cb6
test(archive): cover the 3 new value/key codecs + StructLogReconstruc…
halibobo1205 Jul 11, 2026
99ed200
test(archive): cover untested temporal branches -- RocksDb multi-drop…
halibobo1205 Jul 11, 2026
a72a235
test(archive): cover ArchiveRepositoryAdapter SELFDESTRUCT isolation …
halibobo1205 Jul 11, 2026
4dc5bca
test(archive): cover RocksDb duplicate-changeset rejection + ChainBas…
halibobo1205 Jul 11, 2026
961dec3
test(archive): cover multi-block in-flight read-through + reorg unwin…
halibobo1205 Jul 11, 2026
9381e3c
test(archive): cover mid-chain TOMBSTONE rendering as default zero (d…
halibobo1205 Jul 11, 2026
eb26655
fix(archive): harden restart and index lifecycle
halibobo1205 Jul 11, 2026
33bffd3
docs(archive): add round-2 adversarial-review fix checklist
halibobo1205 Jul 12, 2026
0a6ab82
fix(archive): resolve historical VM TOMBSTONE flags to default
halibobo1205 Jul 12, 2026
2f419e2
fix(archive): guard InMemory unwindBlock to head-only like RocksDb
halibobo1205 Jul 12, 2026
ea6c56d
docs(archive): mark G2/G6 implemented in round-2 checklist
halibobo1205 Jul 12, 2026
a06859c
test(archive): add InMemory<->RocksDb unwindBlock head-guard parity
halibobo1205 Jul 12, 2026
bdc576b
test(archive): cover audit-surfaced fail-closed branches
halibobo1205 Jul 12, 2026
18496ec
fix(archive): resolve tombstone to config default, not hardwired zero
halibobo1205 Jul 12, 2026
1888144
fix(archive): track empty blocks in InMemory unwindBlock head guard
halibobo1205 Jul 12, 2026
64e42f2
fix(archive): check rocksdb iterator status to fail-stop on read errors
halibobo1205 Jul 12, 2026
ff7bc2f
fix(archive): validate genesis coverage after reconcile, not before
halibobo1205 Jul 12, 2026
1dc4aff
perf(archive): index in-flight read-through by key instead of scanning
halibobo1205 Jul 12, 2026
8963e6c
feat(archive): cap in-flight buffer to fail-stop a solidification stall
halibobo1205 Jul 12, 2026
9fe0172
docs(archive): design snapshot-backed reader to unblock eth_call
halibobo1205 Jul 12, 2026
81dce48
feat(archive): add ArchiveTemporalReadView for point-in-time reads
halibobo1205 Jul 12, 2026
ca28746
refactor(archive): make the reader read via ArchiveTemporalReadView
halibobo1205 Jul 12, 2026
8746e4a
feat(archive): add openReader that snapshots genesis-complete reads
halibobo1205 Jul 12, 2026
e90f586
perf(archive): run historical eth_call/trace off the write lock
halibobo1205 Jul 13, 2026
8d24830
test(archive): prove openReader unblocks commit for genesis-complete
halibobo1205 Jul 13, 2026
b0ba592
docs(archive): mark item-1 Phase 1 implemented in design doc
halibobo1205 Jul 13, 2026
140a6f5
docs(archive): record Phase 2 assessment and decision to decline
halibobo1205 Jul 13, 2026
29ff132
feat(archive): harden lifecycle, recovery and queries
halibobo1205 Jul 14, 2026
3139f3a
docs(archive): add round-3 review checklist for codex
halibobo1205 Jul 14, 2026
b609d93
fix(archive): address round-3 review findings
halibobo1205 Jul 14, 2026
d0eeae7
fix(archive): close snapshot reader if managed-reader ctor fails
halibobo1205 Jul 14, 2026
997f970
docs(archive): add from-0 production validation runbook
halibobo1205 Jul 14, 2026
7b9ac29
docs(archive): add UNIFIED_V1 wiring requirements spec
halibobo1205 Jul 14, 2026
6b580b1
docs(archive): point round-3 checklist to UNIFIED_V1 spec and runbook
halibobo1205 Jul 14, 2026
04769a7
feat(archive): wire UNIFIED_V1 backend
halibobo1205 Jul 14, 2026
0d306b5
fix(archive): fold UNIFIED block digest in changeset-key order
halibobo1205 Jul 14, 2026
7cfb812
docs(archive): record round-4 review outcome and M3 gate deliverables
halibobo1205 Jul 14, 2026
c1885c0
docs(archive): add round-5 execution checklist for codex
halibobo1205 Jul 15, 2026
6b49520
docs(archive): add round-6 probe results and closure conditions
halibobo1205 Jul 16, 2026
54b3be8
feat(archive): harden unified-only implementation
halibobo1205 Jul 16, 2026
717d0ea
docs(archive): add audit implementation scoreboard for unified rework
halibobo1205 Jul 16, 2026
1f0f197
perf(archive): harden unified startup and resource bounds
halibobo1205 Jul 16, 2026
c50ea0f
fix(archive): close round 8 adversarial findings
halibobo1205 Jul 16, 2026
e4cac64
fix(archive): complete round 8 fail-stop hardening
halibobo1205 Jul 16, 2026
7e0fb04
fix(archive): harden block begin failure recovery
halibobo1205 Jul 17, 2026
8e1602c
fix(archive): complete adversarial hardening rounds 10-24
halibobo1205 Jul 18, 2026
5e93fd7
refactor(archive): simplify publication and lifecycle contracts
halibobo1205 Jul 18, 2026
c5cef4a
refactor(archive): optimize temporal storage and query isolation
halibobo1205 Jul 18, 2026
d8aad6a
docs(archive): record schema 6 E2E results
halibobo1205 Jul 18, 2026
fae9c26
fix(archive): finalize dynamic property schema
halibobo1205 Jul 20, 2026
3e8c875
refactor(archive): remove obsolete helpers
halibobo1205 Jul 20, 2026
de9a823
docs(archive): add round-7 delta review results and priorities
halibobo1205 Jul 20, 2026
a3d4834
fix(archive): close workflow audit findings
halibobo1205 Jul 23, 2026
a9dc952
fix(archive): harden admission and recovery paths
halibobo1205 Jul 23, 2026
0015cd5
fix(archive): close admission and query error races
halibobo1205 Jul 23, 2026
e284097
fix(archive): satisfy cross-JDK build validation
halibobo1205 Jul 27, 2026
807d237
fix(archive): preserve eth_call selector validation
halibobo1205 Jul 27, 2026
ff7e2b6
feat(archive): add historical debug trace v1
halibobo1205 Jul 27, 2026
dd08fd2
feat(archive): complete historical selfdestruct replay
halibobo1205 Jul 28, 2026
1387d90
fix(archive): harden historical debug trace replay
halibobo1205 Jul 28, 2026
c03b17b
test(archive): isolate shared state and background services
halibobo1205 Jul 28, 2026
4eb060f
docs(archive): add round-8 review results and action items
halibobo1205 Jul 28, 2026
a0616c8
fix(archive): close round-8 review findings
halibobo1205 Jul 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
195 changes: 133 additions & 62 deletions actuator/src/main/java/org/tron/core/actuator/VMActuator.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ public enum ChainParameterEnum {

INVALID_PARAMETER_KEY(0, ignored -> 0L),

TOTAL_NET_LIMIT(1, repository -> repository.getDynamicPropertiesStore().getTotalNetLimit()),
TOTAL_NET_LIMIT(1, repository -> repository.getVmDynamicProperties().getTotalNetLimit()),

TOTAL_NET_WEIGHT(2, Repository::getTotalNetWeight),

TOTAL_ENERGY_CURRENT_LIMIT(3,
repository -> repository.getDynamicPropertiesStore().getTotalEnergyCurrentLimit()),
repository -> repository.getVmDynamicProperties().getTotalEnergyCurrentLimit()),

TOTAL_ENERGY_WEIGHT(4, Repository::getTotalEnergyWeight),

UNFREEZE_DELAY_DAYS(5,
repository -> repository.getDynamicPropertiesStore().getUnfreezeDelayDays()),
repository -> repository.getVmDynamicProperties().getUnfreezeDelayDays()),

;

Expand Down
6 changes: 5 additions & 1 deletion actuator/src/main/java/org/tron/core/vm/JumpTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public JumpTable() {
// fill all op slots to undefined
Arrays.fill(table, UNDEFINED);
}


public JumpTable(JumpTable source) {
System.arraycopy(source.table, 0, table, 0, table.length);
}

public Operation get(int op) {
return table[op];
}
Expand Down
8 changes: 4 additions & 4 deletions actuator/src/main/java/org/tron/core/vm/OperationActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public static void gasPriceAction(Program program) {
DataWord energyPrice = DataWord.ZERO();
if (VMConfig.allowTvmCompatibleEvm() && program.getContractVersion() == 1) {
energyPrice = new DataWord(program.getContractState()
.getDynamicPropertiesStore().getEnergyFee());
.getVmDynamicProperties().getEnergyFee());
}
program.stackPush(energyPrice);
program.step();
Expand Down Expand Up @@ -549,7 +549,7 @@ public static void selfBalanceAction(Program program) {

public static void baseFeeAction(Program program) {
DataWord energyFee =
new DataWord(program.getContractState().getDynamicPropertiesStore().getEnergyFee());
new DataWord(program.getContractState().getVmDynamicProperties().getEnergyFee());

program.stackPush(energyFee);
program.step();
Expand Down Expand Up @@ -1046,8 +1046,8 @@ public static void exeCall(Program program, DataWord adjustedCallEnergy,
PrecompiledContracts.PrecompiledContract contract =
PrecompiledContracts.getContractForAddress(codeAddress);
if (contract != null) {
if (program.isConstantCall()) {
contract = PrecompiledContracts.getOptimizedContractForConstant(contract);
if (program.usesIsolatedExecutionHelpers()) {
contract = PrecompiledContracts.newIsolatedContract(contract);
}
program.callToPrecompiledAddress(msg, contract);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ public static JumpTable newTronV15OperationSet() {
public static void init() {}

public static JumpTable getTable() {
// always get the table which has the newest version
JumpTable table = tableMap.get(Version.TRON_V1_5);
// Always start from the newest immutable base table; per-call VMConfig adjustments must not
// mutate the shared base or a latest fork view can leak into historical replay/trace calls.
JumpTable table = new JumpTable(tableMap.get(Version.TRON_V1_5));

// next make the corresponding changes, exclude activating opcode
if (VMConfig.allowHigherLimitForMaxCpuTimeOfOneTx()) {
Expand Down
194 changes: 181 additions & 13 deletions actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -70,6 +74,10 @@
import org.tron.common.utils.Sha256Hash;
import org.tron.common.zksnark.JLibrustzcash;
import org.tron.common.zksnark.LibrustzcashParam;
import org.tron.core.archive.query.ArchiveQueryLimits;
import org.tron.core.archive.query.HistoricalQueryLimitException;
import org.tron.core.archive.query.QueryContext;
import org.tron.core.archive.query.QueryContextHolder;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.capsule.TransactionCapsule;
import org.tron.core.capsule.WitnessCapsule;
Expand Down Expand Up @@ -212,7 +220,7 @@ public class PrecompiledContracts {
private static final DataWord p256VerifyAddr = new DataWord(
"0000000000000000000000000000000000000000000000000000000000000100");

public static PrecompiledContract getOptimizedContractForConstant(PrecompiledContract contract) {
public static PrecompiledContract newIsolatedContract(PrecompiledContract contract) {
try {
Constructor<?> constructor = contract.getClass().getDeclaredConstructor();
return (PrecompiledContracts.PrecompiledContract) constructor.newInstance();
Expand Down Expand Up @@ -479,14 +487,18 @@ public void setResult(ProgramResult result) {
}

protected long getCPUTimeLeftInNanoSecond() {
long left = getVmShouldEndInUs() * VMConstant.ONE_THOUSAND - System.nanoTime();
long left = getCPUTimeRemainingInNanoSecond(System.nanoTime());
if (left <= 0) {
throw Program.Exception.notEnoughTime("call");
} else {
return left;
}
}

protected long getCPUTimeRemainingInNanoSecond(long sampledNanos) {
return getVmShouldEndInUs() * VMConstant.ONE_THOUSAND - sampledNanos;
}

protected byte[] dataOne() {
byte[] ret = new byte[WORD_SIZE];
ret[31] = 1;
Expand Down Expand Up @@ -1446,13 +1458,21 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
public static class VerifyTransferProof extends VerifyProof {

private static final Integer[] SIZE = {2080, 2368, 2464, 2752};
private static final int HISTORICAL_QUEUE_CAPACITY = 64;
private static final ExecutorService workersInConstantCall;
private static final ThreadPoolExecutor workersInHistoricalConstantCall;
private static final ExecutorService workersInNonConstantCall;
private static final String constantCallName = "verify-transfer-constant-call";
private static final String historicalConstantCallName =
"verify-transfer-historical-constant-call";
private static final String nonConstantCallName = "verify-transfer-non-constant-call";

static {
workersInConstantCall = ExecutorServiceManager.newFixedThreadPool(constantCallName, 5);
workersInHistoricalConstantCall = (ThreadPoolExecutor)
ExecutorServiceManager.newThreadPoolExecutor(
5, 5, 0L, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<>(HISTORICAL_QUEUE_CAPACITY), historicalConstantCallName);
workersInNonConstantCall = ExecutorServiceManager.newFixedThreadPool(nonConstantCallName, 5);
}

Expand All @@ -1463,6 +1483,8 @@ public long getEnergyForData(byte[] data) {

@Override
public Pair<Boolean, byte[]> execute(byte[] data) {
boolean historicalCall = isHistoricalArchiveCall();
List<Future<Boolean>> futures = new ArrayList<>(5);
if (data == null) {
return Pair.of(true, DataWord.ZERO().getData());
}
Expand Down Expand Up @@ -1558,9 +1580,10 @@ public Pair<Boolean, byte[]> execute(byte[] data) {

int threadCount = spendCount + receiveCount + 1;
CountDownLatch countDownLatch = new CountDownLatch(threadCount);
List<Future<Boolean>> futures = new ArrayList<>(threadCount);
ExecutorService workers;
if (isConstantCall()) {
if (historicalCall) {
workers = workersInHistoricalConstantCall;
} else if (isConstantCall()) {
workers = workersInConstantCall;
} else {
workers = workersInNonConstantCall;
Expand All @@ -1586,31 +1609,176 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
signHash, spendCvs, spendCount * 32, receiveCvs, receiveCount * 32));
futures.add(futureCheckBindingSig);

boolean withNoTimeout = countDownLatch.await(getCPUTimeLeftInNanoSecond(),
TimeUnit.NANOSECONDS);
boolean checkResult = true;
for (Future<Boolean> future : futures) {
boolean eachTaskResult = future.get();
checkResult = checkResult && eachTaskResult;
}
boolean checkResult = historicalCall
? awaitHistoricalProofTasks(countDownLatch, futures)
: awaitLegacyProofTasks(countDownLatch, futures);
if (checkResult) {
return insertLeaves(frontier, leafCount, receiveCm);
} else {
return Pair.of(true, DataWord.ZERO().getData());
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
rethrowHistoricalInterrupt(historicalCall, e);
logger.info("VerifyTransferProof exception: " + e.getMessage());
} catch (Throwable any) {
rethrowHistoricalHardFailure(historicalCall, any);
String errorMsg = any.getMessage();
if (errorMsg == null && any.getCause() != null) {
errorMsg = any.getCause().getMessage();
}
logger.info("VerifyTransferProof exception: " + errorMsg);
} finally {
if (historicalCall) {
cancelUnfinished(futures);
}
}
return Pair.of(true, DataWord.ZERO().getData());
}

protected boolean awaitHistoricalProofTasks(
CountDownLatch countDownLatch, List<Future<Boolean>> futures)
throws InterruptedException, ExecutionException {
HistoricalWaitBudget latchBudget = getHistoricalWaitBudget();
if (!countDownLatch.await(latchBudget.remainingNanos, TimeUnit.NANOSECONDS)) {
throw historicalProofTimeout(null, latchBudget.archiveDeadlineLimited);
}
boolean result = true;
for (Future<Boolean> future : futures) {
HistoricalWaitBudget futureBudget = getHistoricalWaitBudget();
try {
result = future.get(futureBudget.remainingNanos, TimeUnit.NANOSECONDS) && result;
} catch (TimeoutException e) {
throw historicalProofTimeout(e, futureBudget.archiveDeadlineLimited);
}
}
return result;
}

private HistoricalWaitBudget getHistoricalWaitBudget() {
QueryContext queryContext = QueryContextHolder.current();
if (queryContext == null) {
return new HistoricalWaitBudget(getCPUTimeLeftInNanoSecond(), false);
}
QueryContext.DeadlineSnapshot archiveDeadline = queryContext.sampleDeadline();
long archiveRemainingNanos = archiveDeadline.getRemainingNanos();
long vmRemainingNanos = getCPUTimeRemainingInNanoSecond(
archiveDeadline.getSampledNanos());
boolean archiveDeadlineLimited = archiveRemainingNanos <= vmRemainingNanos;
long remainingNanos = archiveDeadlineLimited ? archiveRemainingNanos : vmRemainingNanos;
if (remainingNanos <= 0L) {
if (archiveDeadlineLimited) {
queryContext.checkDeadline();
}
throw Program.Exception.notEnoughTime("call VerifyTransferProof precompile method");
}
return new HistoricalWaitBudget(remainingNanos, archiveDeadlineLimited);
}

static OutOfTimeException historicalProofTimeout(
Throwable cause, boolean archiveDeadlineLimited) {
if (archiveDeadlineLimited) {
QueryContext queryContext = QueryContextHolder.current();
if (queryContext != null) {
// Re-check only when this deadline supplied the wait duration. A later-expiring archive
// deadline must not retroactively replace an earlier VM timeout.
queryContext.checkDeadline();
}
}
OutOfTimeException timeout =
Program.Exception.notEnoughTime("call VerifyTransferProof precompile method");
if (cause != null) {
try {
timeout.addSuppressed(cause);
} catch (Throwable ignored) {
// Preserve the VM timeout if suppression cannot allocate.
}
}
return timeout;
}

private static final class HistoricalWaitBudget {

private final long remainingNanos;
private final boolean archiveDeadlineLimited;

private HistoricalWaitBudget(long remainingNanos, boolean archiveDeadlineLimited) {
this.remainingNanos = remainingNanos;
this.archiveDeadlineLimited = archiveDeadlineLimited;
}
}

private boolean awaitLegacyProofTasks(
CountDownLatch countDownLatch, List<Future<Boolean>> futures)
throws InterruptedException, ExecutionException {
countDownLatch.await(getCPUTimeLeftInNanoSecond(), TimeUnit.NANOSECONDS);
boolean result = true;
for (Future<Boolean> future : futures) {
result = future.get() && result;
}
return result;
}

protected static void cancelUnfinished(List<Future<Boolean>> futures) {
for (Future<Boolean> future : futures) {
try {
if (!future.isDone()) {
future.cancel(true);
}
if (future instanceof Runnable) {
workersInHistoricalConstantCall.remove((Runnable) future);
}
} catch (RuntimeException ignored) {
// Cancellation is best-effort; preserve the historical call's primary result/failure.
}
}
}

private boolean isHistoricalArchiveCall() {
Repository repository = getDeposit();
return isConstantCall() && repository != null && repository.isHistoricalArchive();

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 Route non-constant historical replays through bounded proof execution

When debug_traceTransaction replays a transaction that invokes VerifyTransferProof, HistoricalDebugTraceExecutor passes constantCall=false even though the repository is historical. This predicate therefore returns false, selecting the canonical workersInNonConstantCall pool and awaitLegacyProofTasks; after its timed latch wait, that path performs unbounded Future.get() calls and does not cancel unfinished work. Such traces can exceed the archive query deadline, occupy the dedicated trace worker, and contend with canonical proof execution. Classify any historical archive repository as historical here, independently of the constant-call flag.

Useful? React with 👍 / 👎.

}

static void rethrowHistoricalHardFailure(boolean historicalCall, Throwable failure) {
if (!historicalCall) {
return;
}
Throwable terminal = failure instanceof ExecutionException && failure.getCause() != null
? failure.getCause() : failure;
if (terminal instanceof HistoricalQueryLimitException) {
throw (HistoricalQueryLimitException) terminal;
}
if (terminal instanceof Error) {
throw (Error) terminal;
}
if (terminal instanceof OutOfTimeException) {
throw (OutOfTimeException) terminal;
}
if (terminal instanceof RejectedExecutionException) {
throw new HistoricalQueryLimitException(
HistoricalQueryLimitException.Reason.RESOURCE_EXHAUSTED,
HistoricalQueryLimitException.Limit.QUERY_ADMISSION,
ArchiveQueryLimits.UNLIMITED,
ArchiveQueryLimits.UNLIMITED,
"historical proof worker capacity exhausted",
terminal);
}
}

static void rethrowHistoricalInterrupt(
boolean historicalCall, InterruptedException failure) {
if (!historicalCall) {
return;
}
throw new HistoricalQueryLimitException(
HistoricalQueryLimitException.Reason.RESOURCE_EXHAUSTED,
HistoricalQueryLimitException.Limit.INTERRUPTED,
ArchiveQueryLimits.UNLIMITED,
ArchiveQueryLimits.UNLIMITED,
"historical proof wait interrupted",
failure);
}

private static class SaplingCheckSpendTask implements Callable<Boolean> {

private byte[] cv;
Expand Down Expand Up @@ -1962,8 +2130,8 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
if (accountCapsule == null) {
tronPower = 0;
} else {
if (getDeposit().getDynamicPropertiesStore().supportUnfreezeDelay()
&& getDeposit().getDynamicPropertiesStore().supportAllowNewResourceModel()) {
if (getDeposit().getVmDynamicProperties().supportUnfreezeDelay()
&& getDeposit().getVmDynamicProperties().supportAllowNewResourceModel()) {
tronPower = accountCapsule.getAllTronPower();
} else {
tronPower = accountCapsule.getTronPower();
Expand Down
Loading
Loading