|
|
@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.privacy; |
|
|
|
|
|
|
|
|
|
|
|
import org.hyperledger.besu.ethereum.chain.Blockchain; |
|
|
|
import org.hyperledger.besu.ethereum.chain.Blockchain; |
|
|
|
import org.hyperledger.besu.ethereum.core.Account; |
|
|
|
import org.hyperledger.besu.ethereum.core.Account; |
|
|
|
|
|
|
|
import org.hyperledger.besu.ethereum.core.AccountState; |
|
|
|
import org.hyperledger.besu.ethereum.core.Address; |
|
|
|
import org.hyperledger.besu.ethereum.core.Address; |
|
|
|
import org.hyperledger.besu.ethereum.core.EvmAccount; |
|
|
|
import org.hyperledger.besu.ethereum.core.EvmAccount; |
|
|
|
import org.hyperledger.besu.ethereum.core.Gas; |
|
|
|
import org.hyperledger.besu.ethereum.core.Gas; |
|
|
@ -40,6 +41,7 @@ import org.hyperledger.besu.ethereum.worldstate.DefaultMutablePrivateWorldStateU |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayDeque; |
|
|
|
import java.util.ArrayDeque; |
|
|
|
import java.util.Deque; |
|
|
|
import java.util.Deque; |
|
|
|
|
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
@ -122,14 +124,30 @@ public class PrivateTransactionProcessor { |
|
|
|
previousNonce, |
|
|
|
previousNonce, |
|
|
|
sender.getNonce()); |
|
|
|
sender.getNonce()); |
|
|
|
|
|
|
|
|
|
|
|
final MessageFrame initialFrame; |
|
|
|
|
|
|
|
final Deque<MessageFrame> messageFrameStack = new ArrayDeque<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final WorldUpdater mutablePrivateWorldStateUpdater = |
|
|
|
final WorldUpdater mutablePrivateWorldStateUpdater = |
|
|
|
new DefaultMutablePrivateWorldStateUpdater(publicWorldState, privateWorldState); |
|
|
|
new DefaultMutablePrivateWorldStateUpdater(publicWorldState, privateWorldState); |
|
|
|
|
|
|
|
final Deque<MessageFrame> messageFrameStack = new ArrayDeque<>(); |
|
|
|
|
|
|
|
final MessageFrame.Builder commonMessageFrameBuilder = |
|
|
|
|
|
|
|
MessageFrame.builder() |
|
|
|
|
|
|
|
.messageFrameStack(messageFrameStack) |
|
|
|
|
|
|
|
.maxStackSize(maxStackSize) |
|
|
|
|
|
|
|
.returnStack(new ReturnStack()) |
|
|
|
|
|
|
|
.blockchain(blockchain) |
|
|
|
|
|
|
|
.worldState(mutablePrivateWorldStateUpdater) |
|
|
|
|
|
|
|
.initialGas(Gas.MAX_VALUE) |
|
|
|
|
|
|
|
.originator(senderAddress) |
|
|
|
|
|
|
|
.gasPrice(transaction.getGasPrice()) |
|
|
|
|
|
|
|
.sender(senderAddress) |
|
|
|
|
|
|
|
.value(transaction.getValue()) |
|
|
|
|
|
|
|
.apparentValue(transaction.getValue()) |
|
|
|
|
|
|
|
.blockHeader(blockHeader) |
|
|
|
|
|
|
|
.depth(0) |
|
|
|
|
|
|
|
.completer(__ -> {}) |
|
|
|
|
|
|
|
.miningBeneficiary(miningBeneficiary) |
|
|
|
|
|
|
|
.blockHashLookup(blockHashLookup) |
|
|
|
|
|
|
|
.transactionHash(pmtHash); |
|
|
|
|
|
|
|
|
|
|
|
final ReturnStack returnStack = new ReturnStack(); |
|
|
|
final MessageFrame initialFrame; |
|
|
|
|
|
|
|
|
|
|
|
if (transaction.isContractCreation()) { |
|
|
|
if (transaction.isContractCreation()) { |
|
|
|
final Address privateContractAddress = |
|
|
|
final Address privateContractAddress = |
|
|
|
Address.privateContractAddress(senderAddress, previousNonce, privacyGroupId); |
|
|
|
Address.privateContractAddress(senderAddress, previousNonce, privacyGroupId); |
|
|
@ -142,62 +160,26 @@ public class PrivateTransactionProcessor { |
|
|
|
privacyGroupId.toString()); |
|
|
|
privacyGroupId.toString()); |
|
|
|
|
|
|
|
|
|
|
|
initialFrame = |
|
|
|
initialFrame = |
|
|
|
MessageFrame.builder() |
|
|
|
commonMessageFrameBuilder |
|
|
|
.type(MessageFrame.Type.CONTRACT_CREATION) |
|
|
|
.type(MessageFrame.Type.CONTRACT_CREATION) |
|
|
|
.messageFrameStack(messageFrameStack) |
|
|
|
|
|
|
|
.returnStack(returnStack) |
|
|
|
|
|
|
|
.blockchain(blockchain) |
|
|
|
|
|
|
|
.worldState(mutablePrivateWorldStateUpdater) |
|
|
|
|
|
|
|
.address(privateContractAddress) |
|
|
|
.address(privateContractAddress) |
|
|
|
.originator(senderAddress) |
|
|
|
|
|
|
|
.contract(privateContractAddress) |
|
|
|
.contract(privateContractAddress) |
|
|
|
.contractAccountVersion(createContractAccountVersion) |
|
|
|
.contractAccountVersion(createContractAccountVersion) |
|
|
|
.initialGas(Gas.MAX_VALUE) |
|
|
|
|
|
|
|
.gasPrice(transaction.getGasPrice()) |
|
|
|
|
|
|
|
.inputData(Bytes.EMPTY) |
|
|
|
.inputData(Bytes.EMPTY) |
|
|
|
.sender(senderAddress) |
|
|
|
|
|
|
|
.value(transaction.getValue()) |
|
|
|
|
|
|
|
.apparentValue(transaction.getValue()) |
|
|
|
|
|
|
|
.code(new Code(transaction.getPayload())) |
|
|
|
.code(new Code(transaction.getPayload())) |
|
|
|
.blockHeader(blockHeader) |
|
|
|
|
|
|
|
.depth(0) |
|
|
|
|
|
|
|
.completer(c -> {}) |
|
|
|
|
|
|
|
.miningBeneficiary(miningBeneficiary) |
|
|
|
|
|
|
|
.blockHashLookup(blockHashLookup) |
|
|
|
|
|
|
|
.maxStackSize(maxStackSize) |
|
|
|
|
|
|
|
.transactionHash(pmtHash) |
|
|
|
|
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
final Address to = transaction.getTo().get(); |
|
|
|
final Address to = transaction.getTo().get(); |
|
|
|
final Account contract = privateWorldState.get(to); |
|
|
|
final Optional<Account> maybeContract = Optional.ofNullable(privateWorldState.get(to)); |
|
|
|
|
|
|
|
|
|
|
|
initialFrame = |
|
|
|
initialFrame = |
|
|
|
MessageFrame.builder() |
|
|
|
commonMessageFrameBuilder |
|
|
|
.type(MessageFrame.Type.MESSAGE_CALL) |
|
|
|
.type(MessageFrame.Type.MESSAGE_CALL) |
|
|
|
.messageFrameStack(messageFrameStack) |
|
|
|
|
|
|
|
.returnStack(returnStack) |
|
|
|
|
|
|
|
.blockchain(blockchain) |
|
|
|
|
|
|
|
.worldState(mutablePrivateWorldStateUpdater) |
|
|
|
|
|
|
|
.address(to) |
|
|
|
.address(to) |
|
|
|
.originator(senderAddress) |
|
|
|
|
|
|
|
.contract(to) |
|
|
|
.contract(to) |
|
|
|
.contractAccountVersion( |
|
|
|
.contractAccountVersion( |
|
|
|
contract != null ? contract.getVersion() : Account.DEFAULT_VERSION) |
|
|
|
maybeContract.map(AccountState::getVersion).orElse(Account.DEFAULT_VERSION)) |
|
|
|
.initialGas(Gas.MAX_VALUE) |
|
|
|
|
|
|
|
.gasPrice(transaction.getGasPrice()) |
|
|
|
|
|
|
|
.inputData(transaction.getPayload()) |
|
|
|
.inputData(transaction.getPayload()) |
|
|
|
.sender(senderAddress) |
|
|
|
.code(new Code(maybeContract.map(AccountState::getCode).orElse(Bytes.EMPTY))) |
|
|
|
.value(transaction.getValue()) |
|
|
|
|
|
|
|
.apparentValue(transaction.getValue()) |
|
|
|
|
|
|
|
.code(new Code(contract != null ? contract.getCode() : Bytes.EMPTY)) |
|
|
|
|
|
|
|
.blockHeader(blockHeader) |
|
|
|
|
|
|
|
.depth(0) |
|
|
|
|
|
|
|
.completer(c -> {}) |
|
|
|
|
|
|
|
.miningBeneficiary(miningBeneficiary) |
|
|
|
|
|
|
|
.blockHashLookup(blockHashLookup) |
|
|
|
|
|
|
|
.maxStackSize(maxStackSize) |
|
|
|
|
|
|
|
.transactionHash(pmtHash) |
|
|
|
|
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|