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

Enable all EVM E2E suites to run with Ethereum Calls #4375

Merged
merged 30 commits into from Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8e6cfc1
enable eth tests in EndToEndTests
dimitar-dinev Nov 29, 2022
3234770
alter chain_id
dimitar-dinev Dec 2, 2022
580ae5f
feat: add eth tests in parallel and sequential itests
IvanKavaldzhiev Dec 6, 2022
beeb1c7
style: spotlessApply
IvanKavaldzhiev Dec 6, 2022
bb28047
Merge remote-tracking branch 'origin/develop' into check-eth-e2es
IvanKavaldzhiev Dec 6, 2022
52457b2
Merge remote-tracking branch 'origin/develop' into check-eth-e2es
IvanKavaldzhiev Dec 9, 2022
d9a63eb
Merge remote-tracking branch 'origin/develop' into check-eth-e2es
IvanKavaldzhiev Jan 4, 2023
d9838a7
nit: fix build
IvanKavaldzhiev Jan 4, 2023
71823a8
test: enable more E2E tests
IvanKavaldzhiev Jan 9, 2023
6a5cd07
Merge remote-tracking branch 'origin/develop' into check-eth-e2es
IvanKavaldzhiev Jan 9, 2023
2e09709
Merge branch 'develop' into check-eth-e2es
dimitar-dinev Jan 31, 2023
5fd4e13
run CI again
dimitar-dinev Jan 31, 2023
835bc84
test: enable contracts.precompile suites with Ethereum calls
dimitar-dinev Feb 3, 2023
ddd35bb
Merge branch 'develop' into check-eth-e2es
dimitar-dinev Feb 3, 2023
cd9ec76
fix: revert changes in EndToEndTests
dimitar-dinev Feb 3, 2023
8553ce0
fix: sonar smells
dimitar-dinev Feb 3, 2023
5084850
Merge branch 'develop' into check-eth-e2es
dimitar-dinev Feb 28, 2023
6c8fb62
Enable the rest of the Ethereum E2Es (#4879)
dimitar-dinev Feb 28, 2023
920f696
merge
dimitar-dinev Feb 28, 2023
26e220a
Merge remote-tracking branch 'origin/check-eth-e2es' into check-eth-e2es
dimitar-dinev Feb 28, 2023
10239fc
merge again
dimitar-dinev Feb 28, 2023
5917a3c
enable commented tests
dimitar-dinev Mar 1, 2023
f8f2017
Merge branch 'develop' into check-eth-e2es
dimitar-dinev Mar 1, 2023
f812f7b
fix sonar smells
dimitar-dinev Mar 1, 2023
a3e618e
Merge branch 'develop' into check-eth-e2es
dimitar-dinev Mar 15, 2023
81f2f92
remove old file
dimitar-dinev Mar 15, 2023
43c5c66
fix smell
dimitar-dinev Mar 15, 2023
d105b42
Merge branch 'develop' into check-eth-e2es
dimitar-dinev Mar 16, 2023
64f08f0
fix merge
dimitar-dinev Mar 16, 2023
d038d4f
remove unnecessary changes
dimitar-dinev Mar 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,7 +21,6 @@
import static com.hedera.node.app.service.mono.utils.EntityIdUtils.EVM_ADDRESS_SIZE;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_NEGATIVE_GAS;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_NEGATIVE_VALUE;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_ID;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CONTRACT_ID;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.MAX_GAS_LIMIT_EXCEEDED;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK;
Expand Down Expand Up @@ -126,7 +125,7 @@ public void doStateTransitionOperation(
&& properties.isLazyCreationEnabled()) {
// allow Ethereum transactions to lazy create a hollow account
// if `to` is non-existent and `value` is non-zero
validateTrue(op.getAmount() > 0, INVALID_ACCOUNT_ID);
validateTrue(op.getAmount() > 0, INVALID_CONTRACT_ID);
final var evmAddress = op.getContractID().getEvmAddress();
validateTrue(evmAddress.size() == EVM_ADDRESS_SIZE, INVALID_CONTRACT_ID);
receiver = new Account(evmAddress);
Expand Down
Expand Up @@ -21,7 +21,7 @@
import static com.hedera.test.utils.TxnUtils.assertFailsWith;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_NEGATIVE_GAS;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_NEGATIVE_VALUE;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_ID;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CONTRACT_ID;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.MAX_GAS_LIMIT_EXCEEDED;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand Down Expand Up @@ -331,7 +331,7 @@ void verifyEthLazyCreateThrowsWhenAmountIsZero() {
assertFailsWith(
() -> subject.doStateTransitionOperation(
accessor.getTxn(), senderAccount.getId(), relayerAccount.getId(), maxGas, biOfferedGasPrice),
INVALID_ACCOUNT_ID);
INVALID_CONTRACT_ID);
}

@Test
Expand Down
85 changes: 0 additions & 85 deletions hedera-node/test-clients/src/eet/java/EndToEndTests.java
Expand Up @@ -15,15 +15,6 @@
*/

import com.hedera.services.bdd.suites.autorenew.GracePeriodRestrictionsSuite;
import com.hedera.services.bdd.suites.contract.precompile.AssociatePrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.ContractBurnHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.ContractHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.ContractKeysHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.ContractMintHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.CreatePrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.CryptoTransferHTSSuite;
import com.hedera.services.bdd.suites.contract.precompile.DelegatePrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.DissociatePrecompileSuite;
import com.hedera.services.bdd.suites.fees.CongestionPricingSuite;
import com.hedera.services.bdd.suites.file.ExchangeRateControlSuite;
import com.hedera.services.bdd.suites.file.FileUpdateSuite;
Expand All @@ -44,7 +35,6 @@
import java.util.Collection;
import java.util.List;
import org.junit.jupiter.api.DynamicContainer;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Tag;
Expand Down Expand Up @@ -134,23 +124,6 @@ Collection<DynamicContainer> contractPrecompile() {
);
}

@Tag("contract")
@Tag("contract.precompile")
@Order(1)
@TestFactory
List<DynamicTest> contractPrecompileEth() {
return List.of(concurrentEthSpecsFrom(
AssociatePrecompileSuite::new,
ContractBurnHTSSuite::new,
ContractHTSSuite::new,
ContractKeysHTSSuite::new,
ContractMintHTSSuite::new,
CreatePrecompileSuite::new,
DissociatePrecompileSuite::new,
CryptoTransferHTSSuite::new,
DelegatePrecompileSuite::new));
}

@Tag("contract")
@Tag("contract.precompile")
@Tag("contract.precompile.part2")
Expand All @@ -177,17 +150,6 @@ Collection<DynamicContainer> contractOpenZeppelin() {
);
}

@Tag("contract")
@Tag("contract.openzeppelin.eth")
@TestFactory
Collection<DynamicContainer> contractOpenZeppelinEth() {
return List.of(
// extractSpecsFromSuiteForEth(ERC20ContractInteractions::new),
// extractSpecsFromSuiteForEth(ERC721ContractInteractions::new),
// extractSpecsFromSuiteForEth(ERC1155ContractInteractions::new)
);
}

@Tag("contract")
@Tag("contract.records")
@TestFactory
Expand All @@ -198,16 +160,6 @@ Collection<DynamicContainer> contractRecords() {
);
}

@Tag("contract")
@Tag("contract.records.eth")
@TestFactory
Collection<DynamicContainer> contractRecordsEth() {
return List.of(
// extractSpecsFromSuiteForEth(LogsSuite::new),
// extractSpecsFromSuiteForEth(RecordsSuite::new)
);
}

@Tag("contract")
@Tag("contract.opcodes")
@TestFactory
Expand All @@ -228,26 +180,6 @@ Collection<DynamicContainer> contractOpcodes() {
);
}

@Tag("contract")
@Tag("contract.opcodes.eth")
@TestFactory
Collection<DynamicContainer> contractOpcodesEth() {
return List.of(
// extractSpecsFromSuiteForEth(BalanceOperationSuite::new),
// extractSpecsFromSuiteForEth(CallCodeOperationSuite::new),
// extractSpecsFromSuiteForEth(CallOperationSuite::new),
// extractSpecsFromSuiteForEth(CreateOperationSuite::new),
// extractSpecsFromSuiteForEth(DelegateCallOperationSuite::new),
// extractSpecsFromSuiteForEth(ExtCodeCopyOperationSuite::new),
// extractSpecsFromSuiteForEth(ExtCodeHashOperationSuite::new),
// extractSpecsFromSuiteForEth(ExtCodeSizeOperationSuite::new),
// extractSpecsFromSuiteForEth(GlobalPropertiesSuite::new),
// extractSpecsFromSuiteForEth(StaticCallOperationSuite::new),
// extractSpecsFromSuiteForEth(SelfDestructSuite::new),
// extractSpecsFromSuiteForEth(SStoreSuite::new)
);
}

@Tag("contract")
@Tag("contract.hapi")
@TestFactory
Expand All @@ -265,23 +197,6 @@ Collection<DynamicContainer> contractHapi() {
});
}

@Tag("contract")
@Tag("contract.hapi.eth")
@TestFactory
Collection<DynamicContainer> contractHapiEth() {
return List.of(
new DynamicContainer[] {
// extractSpecsFromSuiteForEth(ContractCallLocalSuite::new),
// extractSpecsFromSuiteForEth(ContractCallSuite::new),
// extractSpecsFromSuiteForEth(ContractCreateSuite::new),
// extractSpecsFromSuiteForEth(ContractDeleteSuite::new),
// extractSpecsFromSuiteForEth(ContractGetBytecodeSuite::new),
// extractSpecsFromSuiteForEth(ContractGetInfoSuite::new),
// extractSpecsFromSuiteForEth(ContractMusicalChairsSuite::new),
// extractSpecsFromSuiteForEth(ContractUpdateSuite::new)
});
}

@Tag("crypto")
@TestFactory
Collection<DynamicContainer> crypto() {
Expand Down
Expand Up @@ -60,7 +60,8 @@ Collection<DynamicContainer> sequentialSpecsBySuite() {
@Order(2)
@TestFactory
List<DynamicTest> concurrentSpecs() {
return List.of(concurrentSpecsFrom(ConcurrentSuites.all()));
return List.of(
concurrentSpecsFrom(ConcurrentSuites.all()), concurrentEthSpecsFrom(ConcurrentSuites.ethereumSuites()));
}

@Tag("integration")
Expand Down
71 changes: 65 additions & 6 deletions hedera-node/test-clients/src/itest/java/ConcurrentSuites.java
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoUpdate;

import com.hedera.services.bdd.suites.HapiSuite;
import com.hedera.services.bdd.suites.consensus.ChunkingSuite;
import com.hedera.services.bdd.suites.consensus.SubmitMessageSuite;
Expand Down Expand Up @@ -65,7 +63,6 @@
import com.hedera.services.bdd.suites.contract.precompile.MixedHTSPrecompileTestsSuite;
import com.hedera.services.bdd.suites.contract.precompile.PauseUnpauseTokenAccountPrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.PrngPrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.RedirectPrecompileSuite;
import com.hedera.services.bdd.suites.contract.precompile.SigningReqsSuite;
import com.hedera.services.bdd.suites.contract.precompile.TokenAndTypeCheckSuite;
import com.hedera.services.bdd.suites.contract.precompile.TokenExpiryInfoSuite;
Expand Down Expand Up @@ -136,10 +133,8 @@ static Supplier<HapiSuite>[] all() {
CryptoTransferSuite::new,
CannotDeleteSystemEntitiesSuite::new,
CryptoUpdateSuite::new,
withAutoScheduling(CryptoUpdateSuite::new, Set.of(CryptoUpdate)),
SelfDestructSuite::new,
// contract.hapi
LogsSuite::new,
ContractCallLocalSuite::new,
ContractCallSuite::new,
ContractCreateSuite::new,
Expand Down Expand Up @@ -185,13 +180,13 @@ static Supplier<HapiSuite>[] all() {
MixedHTSPrecompileTestsSuite::new,
PauseUnpauseTokenAccountPrecompileSuite::new,
PrngPrecompileSuite::new,
RedirectPrecompileSuite::new,
TokenAndTypeCheckSuite::new,
TokenExpiryInfoSuite::new,
TokenInfoHTSSuite::new,
TokenUpdatePrecompileSuite::new,
WipeTokenAccountPrecompileSuite::new,
// contract.records
LogsSuite::new,
RecordsSuite::new,
// contract.ethereum
EthereumSuite::new,
Expand All @@ -217,4 +212,68 @@ private static Supplier<HapiSuite> withAutoScheduling(
return suite;
};
}

/*
All the EVM suites that should be executed with Ethereum calls to verify
Ethereum compatibility.
*/
@SuppressWarnings("unchecked")
static Supplier<HapiSuite>[] ethereumSuites() {
return (Supplier<HapiSuite>[]) new Supplier[] {
// contract.precompile
SigningReqsSuite::new,
ApproveAllowanceSuite::new,
AssociatePrecompileSuite::new,
ContractBurnHTSSuite::new,
ContractHTSSuite::new,
ContractKeysHTSSuite::new,
ContractMintHTSSuite::new,
CryptoTransferHTSSuite::new,
DefaultTokenStatusSuite::new,
DelegatePrecompileSuite::new,
DeleteTokenPrecompileSuite::new,
DissociatePrecompileSuite::new,
CreatePrecompileSuite::new,
ERCPrecompileSuite::new,
FreezeUnfreezeTokenPrecompileSuite::new,
GrantRevokeKycSuite::new,
LazyCreateThroughPrecompileSuite::new,
PauseUnpauseTokenAccountPrecompileSuite::new,
PrngPrecompileSuite::new,
TokenAndTypeCheckSuite::new,
TokenExpiryInfoSuite::new,
TokenInfoHTSSuite::new,
TokenUpdatePrecompileSuite::new,
WipeTokenAccountPrecompileSuite::new,
// contract opcodes
BalanceOperationSuite::new,
CallCodeOperationSuite::new,
CallOperationSuite::new,
CreateOperationSuite::new,
DelegateCallOperationSuite::new,
ExtCodeCopyOperationSuite::new,
ExtCodeHashOperationSuite::new,
ExtCodeSizeOperationSuite::new,
GlobalPropertiesSuite::new,
SelfDestructSuite::new,
SStoreSuite::new,
StaticCallOperationSuite::new,
// contract.hapi
ContractCallLocalSuite::new,
ContractCallSuite::new,
ContractCreateSuite::new,
ContractDeleteSuite::new,
ContractGetBytecodeSuite::new,
ContractGetInfoSuite::new,
ContractMusicalChairsSuite::new,
ContractUpdateSuite::new,
// contracts.openZeppelin
ERC20ContractInteractions::new,
ERC721ContractInteractions::new,
ERC1155ContractInteractions::new,
// contract.records
RecordsSuite::new,
LogsSuite::new,
};
}
}
Expand Up @@ -93,6 +93,9 @@ public static byte[] asAddress(final AccountID id) {
}

public static byte[] asAddress(final ContractID id) {
if (id.getEvmAddress().size() == 20) {
return id.getEvmAddress().toByteArray();
}
return asSolidityAddress((int) id.getShardNum(), id.getRealmNum(), id.getContractNum());
}

Expand Down
Expand Up @@ -2089,10 +2089,12 @@ private HapiSpec lpFarmSimulation() {
tokenAssociate(dev, sauce),
sourcing(
() -> contractCallWithFunctionAbi(farm, setSauceAbi, asHeadlongAddress(sauceAddr.get()))
.gas(gasToOffer)),
.gas(gasToOffer)
.refusingEthConversion()),
sourcing(
() -> contractCallWithFunctionAbi(farm, transferAbi, asHeadlongAddress(ownerAddr.get()))
.gas(gasToOffer)))
.gas(gasToOffer)
.refusingEthConversion()))
.when(
sourcing(() -> contractCallWithFunctionAbi(
farm,
Expand All @@ -2101,26 +2103,30 @@ private HapiSpec lpFarmSimulation() {
asHeadlongAddress(lpTokenAddr.get()))
.via("add")
.payingWith(OWNER)
.gas(gasToOffer)),
.gas(gasToOffer)
.refusingEthConversion()),
newKeyNamed("contractControl").shape(KeyShape.CONTRACT.signedWith(farm)),
tokenUpdate(sauce).supplyKey("contractControl"),
sourcing(() -> contractCallWithFunctionAbi(
farm, depositAbi, BigInteger.ZERO, BigInteger.valueOf(100_000))
.sending(ONE_HUNDRED_HBARS)
.payingWith(dev)
.gas(gasToOffer)),
.gas(gasToOffer)
.refusingEthConversion()),
sleepFor(1000),
sourcing(() -> contractCallWithFunctionAbi(
farm, depositAbi, BigInteger.ZERO, BigInteger.valueOf(100_000))
.sending(ONE_HUNDRED_HBARS)
.payingWith(dev)
.gas(gasToOffer)
.via("second")),
.via("second")
.refusingEthConversion()),
getTxnRecord("second").andAllChildRecords().logged())
.then(sourcing(() -> contractCallWithFunctionAbi(
farm, withdrawAbi, BigInteger.ZERO, BigInteger.valueOf(200_000))
.payingWith(dev)
.gas(gasToOffer)));
.gas(gasToOffer)
.refusingEthConversion()));
}

private HapiSpec consTimeManagementWorksWithRevertedInternalCreations() {
Expand Down
Expand Up @@ -154,6 +154,7 @@ private HapiSpec cannotSendValueToTokenAccount() {
sourcing((() -> contractCall(tokenMirrorAddr.get())
.sending(1L)
.payingWith(TOKEN_TREASURY)
.refusingEthConversion()
.via(externalViolation)
.hasKnownStatus(LOCAL_CALL_MODIFICATION_EXCEPTION))))
.then(
Expand Down