use of com.hedera.services.store.contracts.HederaStackedWorldStateUpdater in project hedera-services by hashgraph.
the class HederaCreate2Operation method targetContractAddress.
@Override
protected Address targetContractAddress(final MessageFrame frame) {
final var sourceAddressOrAlias = frame.getRecipientAddress();
final var offset = clampedToLong(frame.getStackItem(1));
final var length = clampedToLong(frame.getStackItem(2));
final var updater = (HederaStackedWorldStateUpdater) frame.getWorldUpdater();
final var source = updater.priorityAddress(sourceAddressOrAlias);
final Bytes32 salt = UInt256.fromBytes(frame.getStackItem(3));
final var initCode = frame.readMutableMemory(offset, length);
final var hash = keccak256(Bytes.concatenate(PREFIX, source, salt, keccak256(initCode)));
final var alias = Address.wrap(hash.slice(12, 20));
final Address address = updater.newAliasedContractAddress(sourceAddressOrAlias, alias);
frame.warmUpAddress(address);
frame.warmUpAddress(alias);
return alias;
}
use of com.hedera.services.store.contracts.HederaStackedWorldStateUpdater in project hedera-services by hashgraph.
the class HederaLogOperation method execute.
@Override
public OperationResult execute(final MessageFrame frame, final EVM evm) {
final long dataLocation = clampedToLong(frame.popStackItem());
final long numBytes = clampedToLong(frame.popStackItem());
final Gas cost = gasCalculator().logOperationGasCost(frame, dataLocation, numBytes, numTopics);
final Optional<Gas> optionalCost = Optional.of(cost);
if (frame.isStatic()) {
return new OperationResult(optionalCost, Optional.of(ExceptionalHaltReason.ILLEGAL_STATE_CHANGE));
} else if (frame.getRemainingGas().compareTo(cost) < 0) {
return new OperationResult(optionalCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS));
}
final var addressOrAlias = frame.getRecipientAddress();
final var updater = (HederaStackedWorldStateUpdater) frame.getWorldUpdater();
final var aliases = updater.aliases();
var address = aliases.resolveForEvm(addressOrAlias);
if (!aliases.isMirror(address)) {
address = UNRESOLVABLE_ADDRESS_STANDIN;
log.warn("Could not resolve logger address {}", addressOrAlias);
}
final Bytes data = frame.readMemory(dataLocation, numBytes);
final ImmutableList.Builder<LogTopic> builder = ImmutableList.builderWithExpectedSize(numTopics);
for (int i = 0; i < numTopics; i++) {
builder.add(LogTopic.create(leftPad(frame.popStackItem())));
}
frame.addLog(new Log(address, data, builder.build()));
return new OperationResult(optionalCost, Optional.empty());
}
Aggregations