Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added implementation support for movePrecompileToAddress #8086

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
*/
package org.hyperledger.besu.datatypes;

import org.hyperledger.besu.datatypes.parameters.UnsignedLongParameter;

import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.hyperledger.besu.datatypes.parameters.UnsignedLongParameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.Objects;
import java.util.Optional;

/** Account Override parameter class */
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(builder = AccountOverride.Builder.class)
Expand All @@ -36,16 +35,20 @@ public class AccountOverride {
private final Optional<Long> nonce;
private final Optional<String> code;
private final Optional<Map<String, String>> stateDiff;
private final Optional<String> movePrecompileToAddress;

private AccountOverride(
final Optional<Wei> balance,
final Optional<Long> nonce,
final Optional<String> code,
final Optional<Map<String, String>> stateDiff) {
final Optional<Map<String, String>> stateDiff,
final Optional<String> movePrecompileToAddress
) {
this.balance = balance;
this.nonce = nonce;
this.code = code;
this.stateDiff = stateDiff;
this.movePrecompileToAddress = movePrecompileToAddress;
}

/**
Expand Down Expand Up @@ -84,13 +87,23 @@ public Optional<Map<String, String>> getStateDiff() {
return stateDiff;
}

/**
* Gets the movePrecompileToAddress override
*
* @return the movePrecompileToAddress if present
*/
public Optional<String> getMovePrecompileToAddress() {
return movePrecompileToAddress;
}

/** Builder class for Account overrides */
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Builder {
private Optional<Wei> balance = Optional.empty();
private Optional<Long> nonce = Optional.empty();
private Optional<String> code = Optional.empty();
private Optional<Map<String, String>> stateDiff = Optional.empty();
private Optional<String> movePrecompileToAddress = Optional.empty();

/** Default constructor. */
public Builder() {}
Expand All @@ -106,6 +119,17 @@ public Builder withBalance(final Wei balance) {
return this;
}

/**
* Sets the movePrecompileToAddress override
*
* @param movePrecompileToAddress the address
* @return the builder
*/
public Builder withMovePrecompileToAddress(final String movePrecompileToAddress) {
this.movePrecompileToAddress = Optional.ofNullable(movePrecompileToAddress);
return this;
}

/**
* Sets the nonce override
*
Expand Down Expand Up @@ -145,7 +169,7 @@ public Builder withStateDiff(final Map<String, String> stateDiff) {
* @return account override
*/
public AccountOverride build() {
return new AccountOverride(balance, nonce, code, stateDiff);
return new AccountOverride(balance, nonce, code, stateDiff, movePrecompileToAddress);
}
}

Expand Down Expand Up @@ -176,25 +200,28 @@ public boolean equals(final Object o) {
return balance.equals(accountOverride.balance)
&& nonce.equals(accountOverride.nonce)
&& code.equals(accountOverride.code)
&& stateDiff.equals(accountOverride.stateDiff);
&& stateDiff.equals(accountOverride.stateDiff)
&& movePrecompileToAddress.equals(accountOverride.movePrecompileToAddress);
}

@Override
public int hashCode() {
return Objects.hash(balance, nonce, code, stateDiff);
return Objects.hash(balance, nonce, code, stateDiff, movePrecompileToAddress);
}

@Override
public String toString() {
return "AccountOverride{"
+ "balance="
+ balance
+ ", nonce="
+ nonce
+ ", code="
+ code
+ ", stateDiff="
+ stateDiff
+ '}';
+ "balance="
+ balance
+ ", nonce="
+ nonce
+ ", code="
+ code
+ ", stateDiff="
+ stateDiff
+ ", movePrecompileToAddress="
+ movePrecompileToAddress
+ '}';
}
}