Skip to content

Commit

Permalink
fix:fix style
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Kai <281165273grape@gmail.com>
  • Loading branch information
GrapeBaBa committed May 4, 2024
1 parent c1ab33a commit 4f223d9
Show file tree
Hide file tree
Showing 11 changed files with 1,052 additions and 10 deletions.
4 changes: 2 additions & 2 deletions hildr-batcher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

group = 'io.optimism'
version = '0.2.5'
group = 'me.grapebaba'
version = '0.4.0'

repositories {
// Use Maven Central for resolving dependencies.
Expand Down
2 changes: 1 addition & 1 deletion hildr-node/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

group 'me.grapebaba'
version '0.2.5'
version '0.4.0'

repositories {
// Use Maven Central for resolving dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public ExecutionPayload toExecutionPayload(String parentBeaconBlockRoot) {
* From execution payload.
*
* @param block the L2 block
* @param config the chain config
* @return the execution payload
*/
public static ExecutionPayload fromL2Block(OpEthBlock.Block block, Config.ChainConfig config) {
Expand Down
2 changes: 2 additions & 0 deletions hildr-node/src/main/java/io/optimism/runner/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public void challengeSync() {
* Full sync.
*
* @throws InterruptedException the interrupted exception
* @throws ExecutionException the execution exception
*/
public void fullSync() throws InterruptedException, ExecutionException {
LOGGER.info("starting full sync");
Expand Down Expand Up @@ -284,6 +285,7 @@ private static void addTrustedPeerToL2Engine(Web3j l2Provider) throws Interrupte
* snap sync.
*
* @throws InterruptedException the interrupted exception
* @throws ExecutionException the execution exception
*/
public void executionLayerSync() throws InterruptedException, ExecutionException {
LOGGER.info("execution layer sync");
Expand Down
4 changes: 2 additions & 2 deletions hildr-utilities/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ plugins {
id "net.ltgt.errorprone" version "3.1.0"
}

group = 'io.optimism'
version = '0.2.5'
group = 'me.grapebaba'
version = '0.4.0'

repositories {
// Use Maven Central for resolving dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,54 @@ public class BeaconSignedBlockHeader {

private String signature;

/**
* Instantiates a new Beacon signed block header.
*/
public BeaconSignedBlockHeader() {}

/**
* Instantiates a new Beacon signed block header.
*
* @param message the message
* @param signature the signature
*/
public BeaconSignedBlockHeader(BeaconBlockHeader message, String signature) {
this.message = message;
this.signature = signature;
}

/**
* Gets message.
*
* @return the message
*/
public BeaconBlockHeader getMessage() {
return message;
}

/**
* Sets message.
*
* @param message the message
*/
public void setMessage(BeaconBlockHeader message) {
this.message = message;
}

/**
* Gets signature.
*
* @return the signature
*/
public String getSignature() {
return signature;
}

/**
* Sets signature.
*
* @param signature the signature
*/
public void setSignature(String signature) {
this.signature = signature;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,27 @@ public class SpecConfig {

/**
* The SpecConfig constructor.
*
* @return the seconds per slot
*/
public BigInteger getSecondsPerSlot() {
return new BigInteger(secondsPerSlot);
}

/**
* The SpecConfig constructor.
*
* @param secondsPerSlot the seconds per slot
*/
public void setSecondsPerSlot(String secondsPerSlot) {
this.secondsPerSlot = secondsPerSlot;
}

/**
* The SpecConfig constructor.
*/
public SpecConfig() {}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
43 changes: 39 additions & 4 deletions hildr-utilities/src/main/java/io/optimism/type/enums/TxType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@

import org.hyperledger.besu.datatypes.TransactionType;

/**
* The enum Tx type.
*/
public enum TxType {
/**
* Legacy tx type.
*/
LEGACY(0x00, "0x0", TransactionType.FRONTIER),
/** Access list transaction type. */
/**
* Access list transaction type.
*/
ACCESS_LIST(0x01, "0x1", TransactionType.ACCESS_LIST),
/** Eip1559 transaction type. */
/**
* Eip1559 transaction type.
*/
EIP1559(0x02, "0x2", TransactionType.EIP1559),
/** Blob transaction type. */
/**
* Blob transaction type.
*/
BLOB(0x03, "0x3", TransactionType.BLOB),
/** Optimism Deposit transaction type. */
/**
* Optimism Deposit transaction type.
*/
OPTIMISM_DEPOSIT(0x7e, "0x7e", null);

private final int typeValue;
Expand All @@ -23,18 +37,39 @@ public enum TxType {
this.besuType = txBesuType;
}

/**
* Is boolean.
*
* @param type the type
* @return the boolean
*/
public boolean is(final String type) {
return this.typeHexString.equalsIgnoreCase(type);
}

/**
* Gets value.
*
* @return the value
*/
public int getValue() {
return this.typeValue;
}

/**
* Gets string.
*
* @return the string
*/
public String getString() {
return this.typeHexString;
}

/**
* Gets besu type.
*
* @return the besu type
*/
public TransactionType getBesuType() {
return besuType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,31 @@
import org.web3j.protocol.core.methods.response.EthBlock;
import org.web3j.utils.Numeric;

/**
* The type Tx encoder.
*/
public class TxEncoder {

private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
Suppliers.memoize(SignatureAlgorithmFactory::getInstance);

/**
* The constant REPLAY_UNPROTECTED_V_BASE.
*/
public static final BigInteger REPLAY_UNPROTECTED_V_BASE = BigInteger.valueOf(27);
/**
* The constant REPLAY_UNPROTECTED_V_BASE_PLUS_1.
*/
public static final BigInteger REPLAY_UNPROTECTED_V_BASE_PLUS_1 = BigInteger.valueOf(28);

/**
* The constant REPLAY_PROTECTED_V_BASE.
*/
public static final BigInteger REPLAY_PROTECTED_V_BASE = BigInteger.valueOf(35);

/**
* The constant REPLAY_PROTECTED_V_MIN.
*/
// The v signature parameter starts at 36 because 1 is the first valid chainId so:
// chainId > 1 implies that 2 * chainId + V_BASE > 36.
public static final BigInteger REPLAY_PROTECTED_V_MIN = BigInteger.valueOf(36);
Expand All @@ -44,6 +59,17 @@ public class TxEncoder {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

/**
* Instantiates a new Tx encoder.
*/
public TxEncoder() {}

/**
* Encode byte [ ].
*
* @param tx the tx
* @return the byte [ ]
*/
public static byte[] encode(EthBlock.TransactionObject tx) {
if (TxType.OPTIMISM_DEPOSIT.is(tx.getType())) {
throw new IllegalArgumentException("this method not support deposit transaction");
Expand All @@ -52,6 +78,13 @@ public static byte[] encode(EthBlock.TransactionObject tx) {
.toArray();
}

/**
* To deposit tx deposit transaction.
*
* @param tx the tx
* @param isSystemTx the is system tx
* @return the deposit transaction
*/
public static DepositTransaction toDepositTx(OpEthBlock.TransactionObject tx, boolean isSystemTx) {
return new DepositTransaction(
tx.getSourceHash(),
Expand All @@ -64,6 +97,13 @@ public static DepositTransaction toDepositTx(OpEthBlock.TransactionObject tx, bo
tx.getInput());
}

/**
* Encode deposit tx byte [ ].
*
* @param tx the tx
* @param isSystemTx the is system tx
* @return the byte [ ]
*/
public static byte[] encodeDepositTx(OpEthBlock.TransactionObject tx, boolean isSystemTx) {
DepositTransaction depositTx = new DepositTransaction(
tx.getSourceHash(),
Expand All @@ -77,6 +117,12 @@ public static byte[] encodeDepositTx(OpEthBlock.TransactionObject tx, boolean is
return depositTx.encode();
}

/**
* Web 3 j tx to besu tx transaction.
*
* @param tx the tx
* @return the transaction
*/
public static Transaction web3jTxToBesuTx(EthBlock.TransactionObject tx) {
if (TxType.LEGACY.is(tx.getType())) {
return toLegacyTx(tx);
Expand Down
Loading

0 comments on commit 4f223d9

Please sign in to comment.