Skip to content

Commit

Permalink
add info related to tx validity (hyperledger#7773)
Browse files Browse the repository at this point in the history
* add info related to tx validity

Signed-off-by: FlorianHuc <[email protected]>

---------

Signed-off-by: FlorianHuc <[email protected]>
Co-authored-by: Sally MacFarlane <[email protected]>
  • Loading branch information
FlorianHuc and macfarla authored Oct 15, 2024
1 parent 0f4e0d4 commit e720d8f
Show file tree
Hide file tree
Showing 4 changed files with 354 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.hyperledger.besu.evm.log.LogsBloomFilter;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.List;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -224,14 +225,14 @@ public ParsedExtraData parseExtraData(final BlockHeader header) {
"expectExceptionHomestead",
"expectExceptionALL",
"hasBigInt",
"rlp_decoded",
"transactionSequence"
"rlp_decoded"
})
public static class CandidateBlock {

private final Bytes rlp;

private final Boolean valid;
private final List<TransactionSequence> transactionSequence;

@JsonCreator
public CandidateBlock(
Expand All @@ -242,31 +243,38 @@ public CandidateBlock(
@JsonProperty("withdrawals") final Object withdrawals,
@JsonProperty("depositRequests") final Object depositRequests,
@JsonProperty("withdrawalRequests") final Object withdrawalRequests,
@JsonProperty("consolidationRequests") final Object consolidationRequests) {
boolean blockVaid = true;
@JsonProperty("consolidationRequests") final Object consolidationRequests,
@JsonProperty("transactionSequence") final List<TransactionSequence> transactionSequence) {
boolean blockValid = true;
// The BLOCK__WrongCharAtRLP_0 test has an invalid character in its rlp string.
Bytes rlpAttempt = null;
try {
rlpAttempt = Bytes.fromHexString(rlp);
} catch (final IllegalArgumentException e) {
blockVaid = false;
blockValid = false;
}
this.rlp = rlpAttempt;

if (blockHeader == null
&& transactions == null
&& uncleHeaders == null
&& withdrawals == null) {
blockVaid = false;
blockValid = false;
}

this.valid = blockVaid;
this.valid = blockValid;
this.transactionSequence = transactionSequence;
}

public boolean isValid() {
return valid;
}

public boolean areAllTransactionsValid() {
return transactionSequence == null
|| transactionSequence.stream().filter(t -> !t.valid()).count() == 0;
}

public boolean isExecutable() {
return rlp != null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.referencetests;

import com.fasterxml.jackson.annotation.JsonProperty;

public record TransactionSequence(
@JsonProperty("exception") String exception,
@JsonProperty("rawBytes") String rawBytes,
@JsonProperty("valid") boolean valid) {}
Loading

0 comments on commit e720d8f

Please sign in to comment.