Skip to content

Commit

Permalink
feat: allow the foundry deterministic deployemnt contract transaction…
Browse files Browse the repository at this point in the history
… to succeed

Signed-off-by: lukelee-sl <[email protected]>
  • Loading branch information
lukelee-sl committed Apr 10, 2024
1 parent b1d3a00 commit 7ee416e
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.jcajce.provider.digest.Keccak;

Expand Down Expand Up @@ -60,6 +61,16 @@ public record EthTxData(
static final BigInteger LEGACY_V_BYTE_SIGNATURE_0 = BigInteger.valueOf(27);
static final BigInteger LEGACY_V_BYTE_SIGNATURE_1 = BigInteger.valueOf(28);

static final byte[] FOUNDRY_DETERMINISTIC_DEPLOYER_TRANSACTION;

static {
try {
FOUNDRY_DETERMINISTIC_DEPLOYER_TRANSACTION = Hex.decodeHex("0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222");
} catch (DecoderException e) {
throw new IllegalStateException("FOUNDRY_DETERMINISTIC_DEPLOYER_TRANSACTION could not be decoded", e);
}
}

public static EthTxData populateEthTxData(byte[] data) {
try {
var decoder = RLPDecoder.RLP_STRICT.sequenceIterator(data);
Expand Down Expand Up @@ -193,8 +204,13 @@ public long getAmount() {
}

public BigInteger getMaxGasAsBigInteger() {
long multiple = 1L;
if (Arrays.equals(rawTx, FOUNDRY_DETERMINISTIC_DEPLOYER_TRANSACTION)) {
multiple = 100L;
}
return switch (type) {
case LEGACY_ETHEREUM, EIP2930 -> new BigInteger(1, gasPrice);
case LEGACY_ETHEREUM -> new BigInteger(1, gasPrice).multiply(BigInteger.valueOf(multiple));
case EIP2930 -> new BigInteger(1, gasPrice);
case EIP1559 -> new BigInteger(1, maxGas);
};
}
Expand Down

0 comments on commit 7ee416e

Please sign in to comment.