mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-08 21:38:15 -05:00
Sepolia: Fix for deposit contract log decoding (#8383)
* Sepolia: Fix for deposit contract log decoding Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * add tests Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> Co-authored-by: Daniel Lehrner <daniel.lehrner@consensys.net>
This commit is contained in:
@@ -19,6 +19,8 @@ import org.hyperledger.besu.datatypes.RequestType;
|
||||
import org.hyperledger.besu.ethereum.core.Request;
|
||||
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
|
||||
import org.hyperledger.besu.ethereum.core.encoding.DepositLogDecoder;
|
||||
import org.hyperledger.besu.evm.log.Log;
|
||||
import org.hyperledger.besu.evm.log.LogTopic;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -27,6 +29,10 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import org.apache.tuweni.bytes.Bytes;
|
||||
|
||||
public class DepositRequestProcessor implements RequestProcessor {
|
||||
private static final LogTopic DEPOSIT_EVENT_TOPIC =
|
||||
LogTopic.wrap(
|
||||
Bytes.fromHexString(
|
||||
"0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"));
|
||||
|
||||
private final Optional<Address> depositContractAddress;
|
||||
|
||||
@@ -49,8 +55,14 @@ public class DepositRequestProcessor implements RequestProcessor {
|
||||
address ->
|
||||
transactionReceipts.stream()
|
||||
.flatMap(receipt -> receipt.getLogsList().stream())
|
||||
.filter(log -> address.equals(log.getLogger()))
|
||||
.filter(log -> isDepositEvent(address, log))
|
||||
.map(DepositLogDecoder::decodeFromLog)
|
||||
.reduce(Bytes::concatenate));
|
||||
}
|
||||
|
||||
private boolean isDepositEvent(final Address depositContractAddress, final Log log) {
|
||||
return depositContractAddress.equals(log.getLogger())
|
||||
&& !log.getTopics().isEmpty()
|
||||
&& log.getTopics().getFirst().equals(DEPOSIT_EVENT_TOPIC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,25 @@ class DepositLogDecoderTest {
|
||||
|
||||
assertThat(requestData).isEqualTo(expectedDepositRequestData);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldDecodeSepoliaDepositFromLog() {
|
||||
final Address logger = Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa");
|
||||
final List<LogTopic> topics =
|
||||
List.of(
|
||||
LogTopic.fromHexString(
|
||||
"0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"));
|
||||
final Bytes data =
|
||||
Bytes.fromHexString(
|
||||
"0x00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000800000c3d5d53aa01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
final Log log = new Log(logger, data, topics);
|
||||
final Bytes requestData = DepositLogDecoder.decodeFromLog(log);
|
||||
|
||||
final Bytes expectedDepositRequestData =
|
||||
Bytes.fromHexString(
|
||||
"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000c3d5d53aa010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000");
|
||||
|
||||
assertThat(requestData).isEqualTo(expectedDepositRequestData);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user