Skip to content

Commit

Permalink
Fix #1200 (#1201)
Browse files Browse the repository at this point in the history
This puts in place a fix for legacy transactions which don't have a
CHAINID.  Previously, such transactions were being rejected because they
given a chain id value (e.g. 1337 or 0), none of which is acceptable.

**NOTE:** there is still perhaps an issue with some legacy transactions
having an incorrect tx hash.  Example is block 296519 which is tested in
traceTxStartNotTheSameAsTxPrepare().
  • Loading branch information
DavePearce authored Sep 16, 2024
1 parent 80f2fb4 commit 8be54ac
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public class TransactionSnapshot {
@Getter private final Optional<List<AccessListEntrySnapshot>> accessList;
@Getter @Setter private TransactionResultSnapshot outcome;

public static final BigInteger CHAIN_ID = BigInteger.valueOf(1337);

/**
* Construct an initial snapshot from a given transaction. Observe that this is not yet complete
* since it doesn't include the transaction outcomes.
Expand All @@ -81,7 +79,7 @@ public TransactionSnapshot(Transaction tx) {
this.maxFeePerGas = tx.getMaxFeePerGas().map(Quantity::toHexString);
this.maxFeePerBlobGas = tx.getMaxFeePerBlobGas().map(Quantity::toHexString);
this.gasLimit = tx.getGasLimit();
this.chainId = tx.getChainId().orElse(CHAIN_ID);
this.chainId = tx.getChainId().orElse(null);
this.accessList =
tx.getAccessList().map(l -> l.stream().map(AccessListEntrySnapshot::from).toList());
}
Expand Down Expand Up @@ -120,11 +118,13 @@ public Transaction toTransaction() {
.nonce(this.nonce)
.value(Wei.fromHexString(this.value))
.payload(Bytes.fromHexString(this.payload))
.chainId(this.chainId)
.gasLimit(this.gasLimit)
.signature(
SignatureAlgorithmFactory.getInstance().createSignature(r, s, v.byteValueExact()));

// Set the chainID only if it makes sense to do so.
if (this.type != TransactionType.FRONTIER || v.compareTo(REPLAY_PROTECTED_V_MIN) > 0) {
tx.chainId(this.chainId);
}
this.to.ifPresent(to -> tx.to(Words.toAddress(Bytes.fromHexString(to))));
this.gasPrice.ifPresent(gasPrice -> tx.gasPrice(Wei.fromHexString(gasPrice)));
this.maxPriorityFeePerGas.ifPresent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
import static net.consensys.linea.testing.ReplayExecutionEnvironment.LINEA_MAINNET;
import static net.consensys.linea.zktracer.ReplayTests.replay;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/** Insufficient balance at some address */
@Tag("nightly")
public class Issue1116Tests {

// @Disabled
@Test
void issue_1116_block_8019521() {
replay(LINEA_MAINNET, "8019521-8019521.json.gz", false);
replay(LINEA_MAINNET, "8019521-8019521.json.gz");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public class Issue1145Tests {

@Test
public void issue_1145_block_3318494_ReturnPrecondition() {
replay(LINEA_SEPOLIA, "3318494.sepolia.json.gz", false);
replay(LINEA_SEPOLIA, "3318494.sepolia.json.gz");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
import static net.consensys.linea.testing.ReplayExecutionEnvironment.LINEA_MAINNET;
import static net.consensys.linea.zktracer.ReplayTests.replay;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

// @Tag("nightly")
@Tag("nightly")
public class Issue1169Tests {

@Test
public void issue_1145_block_3318494_InsufficientBalanceMainnet() {
replay(LINEA_MAINNET, "2746060.mainnet.json.gz", false);
replay(LINEA_MAINNET, "2746060.mainnet.json.gz");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Issue1180Tests {
@Tag("replay")
@Test
void split_range_2321470_2321479() {
replay(LINEA_MAINNET, "2321470-2321479.json.gz", false);
replay(LINEA_MAINNET, "2321470-2321479.json.gz");
}

@Tag("nightly")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static void bulkReplay(BigInteger chainId, String directory) {

@Test
void traceTxStartNotTheSameAsTxPrepare() {
replay(LINEA_MAINNET, "start-vs-prepare-tx.json.gz");
replay(LINEA_MAINNET, "296519.json.gz", false);
}

@Test
Expand Down Expand Up @@ -326,7 +326,7 @@ void test_5104810_5104819() {
// @Disabled
@Test
void test_5104820_5104829() {
replay(LINEA_MAINNET, "5104820-5104829.json.gz", false);
replay(LINEA_MAINNET, "5104820-5104829.json.gz");
}

// @Disabled
Expand All @@ -338,7 +338,7 @@ void test_5104830_5104839() {
// @Disabled
@Test
void test_5104840_5104849() {
replay(LINEA_MAINNET, "5104840-5104849.json.gz", false);
replay(LINEA_MAINNET, "5104840-5104849.json.gz");
}

// @Disabled
Expand Down Expand Up @@ -370,55 +370,55 @@ void test_5104880_5104883() {
// @Disabled
@Test
void test_5105646_5105649() {
replay(LINEA_MAINNET, "5105646-5105649.json.gz", false);
replay(LINEA_MAINNET, "5105646-5105649.json.gz");
}

// @Disabled
@Test
void test_5105650_5105659() {
replay(LINEA_MAINNET, "5105650-5105659.json.gz", false);
replay(LINEA_MAINNET, "5105650-5105659.json.gz");
}

// @Disabled
@Test
void test_5105660_5105669() {
replay(LINEA_MAINNET, "5105660-5105669.json.gz", false);
replay(LINEA_MAINNET, "5105660-5105669.json.gz");
}

// @Disabled
@Test
void test_5105670_5105679() {
replay(LINEA_MAINNET, "5105670-5105679.json.gz", false);
replay(LINEA_MAINNET, "5105670-5105679.json.gz");
}

// @Disabled
@Test
void test_5105680_5105689() {
replay(LINEA_MAINNET, "5105680-5105689.json.gz", false);
replay(LINEA_MAINNET, "5105680-5105689.json.gz");
}

// @Disabled
@Test
void test_5105690_5105699() {
replay(LINEA_MAINNET, "5105690-5105699.json.gz", false);
replay(LINEA_MAINNET, "5105690-5105699.json.gz");
}

// @Disabled
@Test
void test_5105700_5105709() {
replay(LINEA_MAINNET, "5105700-5105709.json.gz", false);
replay(LINEA_MAINNET, "5105700-5105709.json.gz");
}

// @Disabled
@Test
void test_5105710_5105719() {
replay(LINEA_MAINNET, "5105710-5105719.json.gz", false);
replay(LINEA_MAINNET, "5105710-5105719.json.gz");
}

// @Disabled
@Test
void test_5105720_5105728() {
replay(LINEA_MAINNET, "5105720-5105728.json.gz", false);
replay(LINEA_MAINNET, "5105720-5105728.json.gz");
}

// Leo's range split up 5106538-5106638
Expand All @@ -431,19 +431,19 @@ void test_5106538_5106539() {
// @Disabled
@Test
void test_5106540_5106549() {
replay(LINEA_MAINNET, "5106540-5106549.json.gz", false);
replay(LINEA_MAINNET, "5106540-5106549.json.gz");
}

// @Disabled
@Test
void test_5106550_5106559() {
replay(LINEA_MAINNET, "5106550-5106559.json.gz", false);
replay(LINEA_MAINNET, "5106550-5106559.json.gz");
}

// @Disabled
@Test
void test_5106560_5106569() {
replay(LINEA_MAINNET, "5106560-5106569.json.gz", false);
replay(LINEA_MAINNET, "5106560-5106569.json.gz");
}

// @Disabled
Expand Down Expand Up @@ -473,19 +473,19 @@ void test_5106600_5106609() {
// @Disabled
@Test
void test_5106610_5106619() {
replay(LINEA_MAINNET, "5106610-5106619.json.gz", false);
replay(LINEA_MAINNET, "5106610-5106619.json.gz");
}

// @Disabled
@Test
void test_5106620_5106629() {
replay(LINEA_MAINNET, "5106620-5106629.json.gz", false);
replay(LINEA_MAINNET, "5106620-5106629.json.gz");
}

// @Disabled
@Test
void test_5106630_5106638() {
replay(LINEA_MAINNET, "5106630-5106638.json.gz", false);
replay(LINEA_MAINNET, "5106630-5106638.json.gz");
}

// Leo's range split up 5118361-5118389
Expand All @@ -499,13 +499,13 @@ void test_5118361_5118369() {
// @Disabled
@Test
void test_5118370_5118379() {
replay(LINEA_MAINNET, "5118370-5118379.json.gz", false);
replay(LINEA_MAINNET, "5118370-5118379.json.gz");
}

// @Disabled
@Test
void test_5118380_5118389() {
replay(LINEA_MAINNET, "5118380-5118389.json.gz", false);
replay(LINEA_MAINNET, "5118380-5118389.json.gz");
}

// Florian's ranges
Expand Down Expand Up @@ -537,7 +537,7 @@ void test_7037321_7037321() {
// @Disabled
@Test
void test_7037237_7037243() {
replay(LINEA_MAINNET, "7037237-7037243.json.gz", false);
replay(LINEA_MAINNET, "7037237-7037243.json.gz");
}

// @Disabled
Expand Down Expand Up @@ -585,7 +585,7 @@ void returnOogxForCodeDepositCost() {

@Test
void modexpTriggeringNonAlignedFirstLimbSingleSourceMmuModexp() {
replay(LINEA_MAINNET, "3108622-3108633.json.gz", false);
replay(LINEA_MAINNET, "3108622-3108633.json.gz");
}

/**
Expand All @@ -594,6 +594,12 @@ void modexpTriggeringNonAlignedFirstLimbSingleSourceMmuModexp() {
*/
@Test
void mainnet1339346ContextRevertTwice() {
replay(LINEA_MAINNET, "1339346.json.gz", false);
replay(LINEA_MAINNET, "1339346.json.gz");
}

@Disabled("#1173")
@Test
void legacyTxWithoutChainID() {
replay(LINEA_SEPOLIA, "254251.sepolia.json.gz");
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 8be54ac

Please sign in to comment.