Skip to content

Commit

Permalink
Merge branch 'develop' into 09689-improve-error-message-file-not-found
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-swirlds-labs authored Dec 21, 2023
2 parents 8025932 + 1061cc9 commit 353a39e
Show file tree
Hide file tree
Showing 64 changed files with 1,497 additions and 941 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.hedera.node.config.VersionedConfiguration;
import com.hedera.node.config.converter.BytesConverter;
import com.hedera.node.config.converter.LongPairConverter;
import com.hedera.node.config.converter.ProfileConverter;
import com.hedera.node.config.converter.SemanticVersionConverter;
import com.hedera.node.config.data.FilesConfig;
import com.hedera.node.config.data.HederaConfig;
Expand Down Expand Up @@ -60,7 +59,6 @@ public BootstrapConfigProviderImpl() {
.withConfigDataType(LedgerConfig.class)
.withConverter(new BytesConverter())
.withConverter(new SemanticVersionConverter())
.withConverter(new ProfileConverter())
.withConverter(new LongPairConverter());

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@
import com.hedera.node.config.ConfigProvider;
import com.hedera.node.config.VersionedConfigImpl;
import com.hedera.node.config.VersionedConfiguration;
import com.hedera.node.config.converter.*;
import com.hedera.node.config.converter.AccountIDConverter;
import com.hedera.node.config.converter.BytesConverter;
import com.hedera.node.config.converter.CongestionMultipliersConverter;
import com.hedera.node.config.converter.ContractIDConverter;
import com.hedera.node.config.converter.EntityScaleFactorsConverter;
import com.hedera.node.config.converter.FileIDConverter;
import com.hedera.node.config.converter.FunctionalitySetConverter;
import com.hedera.node.config.converter.KeyValuePairConverter;
import com.hedera.node.config.converter.KnownBlockValuesConverter;
import com.hedera.node.config.converter.LegacyContractIdActivationsConverter;
import com.hedera.node.config.converter.LongPairConverter;
import com.hedera.node.config.converter.PermissionedAccountsRangeConverter;
import com.hedera.node.config.converter.ScaleFactorConverter;
import com.hedera.node.config.converter.SemanticVersionConverter;
import com.hedera.node.config.data.AccountsConfig;
import com.hedera.node.config.data.ApiPermissionConfig;
import com.hedera.node.config.data.AutoCreationConfig;
Expand Down Expand Up @@ -177,24 +190,18 @@ private ConfigurationBuilder createConfigurationBuilder() {
.withConfigDataType(VersionConfig.class)
.withConverter(new CongestionMultipliersConverter())
.withConverter(new EntityScaleFactorsConverter())
.withConverter(new EntityTypeConverter())
.withConverter(new KnownBlockValuesConverter())
.withConverter(new LegacyContractIdActivationsConverter())
.withConverter(new MapAccessTypeConverter())
.withConverter(new RecomputeTypeConverter())
.withConverter(new ScaleFactorConverter())
.withConverter(new AccountIDConverter())
.withConverter(new ContractIDConverter())
.withConverter(new FileIDConverter())
.withConverter(new HederaFunctionalityConverter())
.withConverter(new PermissionedAccountsRangeConverter())
.withConverter(new SidecarTypeConverter())
.withConverter(new SemanticVersionConverter())
.withConverter(new LongPairConverter())
.withConverter(new KeyValuePairConverter())
.withConverter(new FunctionalitySetConverter())
.withConverter(new BytesConverter())
.withConverter(new ProfileConverter())
.withValidator(new EmulatesMapValidator());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.IntSupplier;
import org.apache.commons.lang3.tuple.Pair;
Expand Down Expand Up @@ -512,9 +513,11 @@ private long getGasLimitForContractTx(
return switch (function) {
case CONTRACT_CREATE -> txn.contractCreateInstance().gas();
case CONTRACT_CALL -> txn.contractCall().gas();
case ETHEREUM_TRANSACTION -> EthTxData.populateEthTxData(
txn.ethereumTransaction().ethereumData().toByteArray())
.gasLimit();
case ETHEREUM_TRANSACTION -> Optional.of(
txn.ethereumTransactionOrThrow().ethereumData().toByteArray())
.map(EthTxData::populateEthTxData)
.map(EthTxData::gasLimit)
.orElse(0L);
default -> 0L;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void checkSolvency(
return;
}

final var totalFee = fees.totalFee();
final var totalFee = ingestCheck ? fees.totalWithoutServiceFee() : fees.totalFee();
final var availableBalance = account.tinybarBalance();
final var offeredFee = txBody.transactionFee();
final ResponseCodeEnum insufficientFeeResponseCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1128,4 +1128,9 @@ private TransactionBody inProgressBody() {
throw new IllegalStateException("Record being built for unparseable transaction", e);
}
}

public EthereumTransactionRecordBuilder feeChargedToPayer(@NonNull long amount) {
transactionRecordBuilder.transactionFee(transactionFee + amount);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,26 @@
import static com.hedera.node.app.spi.HapiUtils.isHollow;
import static com.hedera.node.app.spi.workflows.PreCheckException.validateTruePreCheck;
import static com.swirlds.platform.system.status.PlatformStatus.ACTIVE;
import static java.util.Collections.emptyList;
import static java.util.Objects.requireNonNull;

import com.hedera.hapi.node.base.AccountID;
import com.hedera.hapi.node.base.HederaFunctionality;
import com.hedera.hapi.node.base.SignaturePair;
import com.hedera.hapi.node.base.Transaction;
import com.hedera.hapi.node.state.token.Account;
import com.hedera.node.app.annotations.NodeSelfId;
import com.hedera.node.app.fees.FeeContextImpl;
import com.hedera.node.app.fees.FeeManager;
import com.hedera.node.app.info.CurrentPlatformStatus;
import com.hedera.node.app.service.evm.utils.EthSigsUtils;
import com.hedera.node.app.signature.DefaultKeyVerifier;
import com.hedera.node.app.signature.ExpandedSignaturePair;
import com.hedera.node.app.signature.SignatureExpander;
import com.hedera.node.app.signature.SignatureVerifier;
import com.hedera.node.app.spi.authorization.Authorizer;
import com.hedera.node.app.spi.fees.FeeContext;
import com.hedera.node.app.spi.signatures.SignatureVerification;
import com.hedera.node.app.spi.workflows.PreCheckException;
import com.hedera.node.app.state.DeduplicationCache;
import com.hedera.node.app.state.HederaState;
Expand All @@ -55,6 +59,8 @@
import com.hedera.node.app.workflows.dispatcher.ReadableStoreFactory;
import com.hedera.node.app.workflows.dispatcher.TransactionDispatcher;
import com.hedera.node.config.data.HederaConfig;
import com.hedera.node.config.data.LazyCreationConfig;
import com.hedera.pbj.runtime.io.buffer.Bytes;
import com.swirlds.config.api.Configuration;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.time.Instant;
Expand Down Expand Up @@ -229,16 +235,32 @@ private void verifyPayerSignature(
signatureExpander.expand(sigPairs, expandedSigs);
if (!isHollow(payer)) {
signatureExpander.expand(payerKey, sigPairs, expandedSigs);
} else {
// If the payer is hollow, then we need to expand the signature for the payer
final var originals = txInfo.signatureMap().sigPairOrElse(emptyList()).stream()
.filter(SignaturePair::hasEcdsaSecp256k1)
.filter(pair -> Bytes.wrap(EthSigsUtils.recoverAddressFromPubKey(
pair.pubKeyPrefix().toByteArray()))
.equals(payer.alias()))
.findFirst();
validateTruePreCheck(originals.isPresent(), INVALID_SIGNATURE);
validateTruePreCheck(
configuration.getConfigData(LazyCreationConfig.class).enabled(), INVALID_SIGNATURE);
signatureExpander.expand(List.of(originals.get()), expandedSigs);
}

// Verify the signatures
final var results = signatureVerifier.verify(txInfo.signedBytes(), expandedSigs);
final var verifier = new DefaultKeyVerifier(sigPairs.size(), hederaConfig, results);
final var payerKeyVerification = verifier.verificationFor(payerKey);

// This can happen if the signature map was missing a signature for the payer account.
if (payerKeyVerification.failed()) {
throw new PreCheckException(INVALID_SIGNATURE);
}
// Verify the signatures
final var results = signatureVerifier.verify(txInfo.signedBytes(), expandedSigs);
final var verifier = new DefaultKeyVerifier(sigPairs.size(), hederaConfig, results);
final SignatureVerification payerKeyVerification;
if (!isHollow(payer)) {
payerKeyVerification = verifier.verificationFor(payerKey);
} else {
payerKeyVerification = verifier.verificationFor(payer.alias());
}
// This can happen if the signature map was missing a signature for the payer account.
if (payerKeyVerification.failed()) {
throw new PreCheckException(INVALID_SIGNATURE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.hedera.node.config.VersionedConfigImpl;
import com.hedera.node.config.converter.BytesConverter;
import com.hedera.node.config.converter.LongPairConverter;
import com.hedera.node.config.converter.ProfileConverter;
import com.hedera.node.config.data.FilesConfig;
import com.hedera.node.config.data.HederaConfig;
import com.hedera.node.config.data.LedgerConfig;
Expand Down Expand Up @@ -103,7 +102,6 @@ void setUp() {
final var config = new TestConfigBuilder(false)
.withConverter(new BytesConverter())
.withConverter(new LongPairConverter())
.withConverter(new ProfileConverter())
.withConfigDataType(FilesConfig.class)
.withConfigDataType(HederaConfig.class)
.withConfigDataType(LedgerConfig.class)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 353a39e

Please sign in to comment.