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

Swap EthereumJ with Besu #2208

Merged
merged 111 commits into from Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
126f16b
Bump maven-gpg-plugin from 1.6 to 3.0.1 (#378)
dependabot[bot] Aug 16, 2021
9cf38ba
Bump os-maven-plugin from 1.6.0 to 1.7.0 (#379)
dependabot[bot] Aug 16, 2021
93b0dc5
Bump maven-release-plugin from 3.0.0-M1 to 3.0.0-M4 (#380)
dependabot[bot] Aug 16, 2021
214185a
Bump snakeyaml from 1.26 to 1.29 (#382)
dependabot[bot] Aug 16, 2021
4d3b30a
Bump ubuntu from 20.10 to 21.10 (#410)
dependabot[bot] Aug 16, 2021
68b089c
Bump jackson-databind from 2.11.2 to 2.12.4 (#411)
dependabot[bot] Aug 16, 2021
15e7567
Bump maven-dependency-plugin from 3.1.1 to 3.2.0 (#412)
dependabot[bot] Aug 16, 2021
52e10cf
Bump maven-antrun-plugin from 1.8 to 3.0.0 (#413)
dependabot[bot] Aug 16, 2021
bf4ff52
Merge remote-tracking branch 'origin/master'
failfmi Aug 18, 2021
1f33e13
Bump swirlds.version from 0.17.1 to 0.17.3 (#422)
dependabot[bot] Aug 23, 2021
0d70199
Bump mockito.version from 3.11.2 to 3.12.1 (#423)
dependabot[bot] Aug 23, 2021
9693606
Bump netty-bom from 4.1.66.Final to 4.1.67.Final (#424)
dependabot[bot] Aug 23, 2021
49de0c8
Bump grpc-bom from 1.39.0 to 1.40.0 (#425)
dependabot[bot] Aug 23, 2021
8e56723
Bump mockito.version from 3.12.1 to 3.12.4 (#435)
dependabot[bot] Aug 30, 2021
40b7a66
Bump swirlds.version from 0.17.3 to 0.17.4 (#436)
dependabot[bot] Aug 30, 2021
1e6fdb5
Bump grpc-bom from 1.40.0 to 1.40.1 (#437)
dependabot[bot] Aug 30, 2021
e05a741
Bump jackson-databind from 2.12.4 to 2.12.5 (#438)
dependabot[bot] Aug 30, 2021
d10397b
Merge remote-tracking branch 'origin/master'
failfmi Aug 31, 2021
d707931
Merge branch 'hashgraph:master' into master
Daniel-K-Ivanov Sep 3, 2021
446870c
Bump dagger from 2.37 to 2.38.1 (#450)
dependabot[bot] Sep 7, 2021
52a9567
Merge branch 'hashgraph:master' into master
Daniel-K-Ivanov Sep 10, 2021
e870de0
Initial swap of EthereumJ for Hyperledger Besu
stoqnkpL Sep 7, 2021
8679ade
Fix imports after besu packages refactor
stoqnkpL Sep 9, 2021
8de122a
Refactor BesuAdapter and ContractCallTransitionLogic
stoqnkpL Sep 10, 2021
c780671
Added google-maven repository for dagger dependencies resolution
stoqnkpL Sep 10, 2021
cec6031
Added getEvmAddress method to Account
stoqnkpL Sep 10, 2021
780d599
Merged AccountTest and AccountStoreTest from crypto-create branch
stoqnkpL Sep 10, 2021
9370476
Latest changes on BesuAdapter
stoqnkpL Sep 13, 2021
9531c06
Add getAccount to HederaWorldUpdater.updater
stoqnkpL Sep 13, 2021
0a1aa05
Introduce `CreateEvmProcessor` and `CallEvmProcessor` (#486)
Daniel-K-Ivanov Sep 15, 2021
421bbff
annotate code changes
Daniel-K-Ivanov Sep 15, 2021
fa65a4a
Copied EthJ storage models to Hedera (#488)
stoqnkpL Sep 15, 2021
6d05b8e
Ref/update hedera world (#493)
Daniel-K-Ivanov Sep 16, 2021
74a764f
Merge branch 'hedera-master' into feature/ethereumj-besu-swap
Daniel-K-Ivanov Sep 16, 2021
eae28af
merge(master): merge from hedera master
Daniel-K-Ivanov Sep 16, 2021
5029390
Feat/use old impl of world state (#497)
Daniel-K-Ivanov Sep 17, 2021
ef5ba7d
fix: remove unnecessary changes
Daniel-K-Ivanov Sep 17, 2021
2634e3f
fix(build)
Daniel-K-Ivanov Sep 17, 2021
e88b480
fix(reclaim): count provisional Ids when allocating new contractId
Daniel-K-Ivanov Sep 17, 2021
fff81c2
refactor: remove unnecessary file changes
Daniel-K-Ivanov Sep 17, 2021
6883c4e
remove dependency on Besu Core
shemnon Sep 18, 2021
d2751f0
Custom Build EVM
shemnon Sep 18, 2021
cdd8c0d
cleanup
shemnon Sep 18, 2021
e7b4bd4
successful runthrough
shemnon Sep 18, 2021
054fd3a
Removed copied classes from ethJ (#499)
stoqnkpL Sep 20, 2021
fbc6595
refactor: remove unnecessary file changes
Daniel-K-Ivanov Sep 20, 2021
493a8e8
fix(license+java-doc): Add license and java doc to util file
Daniel-K-Ivanov Sep 20, 2021
4b50561
Fix NPE when retrieving null value from contract storage
stoqnkpL Sep 21, 2021
a550184
fix(deployment-bugs): Revert with insufficient gas once gas is consum…
Daniel-K-Ivanov Sep 21, 2021
23c5d6c
clear storage implementation in HederaWorldState (#512)
stoqnkpL Sep 24, 2021
f8592c8
Feature: Transaction Record Externalisation (#519)
Daniel-K-Ivanov Sep 25, 2021
816a02e
e2e: call opcode contract test (#518)
stoqnkpL Sep 25, 2021
aa31583
Feature/global opcodes (#516)
iamrusko Sep 25, 2021
30184ee
Revert Account model and Store changes (#530)
Daniel-K-Ivanov Sep 27, 2021
a5f56e6
feat: besu ContractCallLocal (#525)
failfmi Sep 28, 2021
0297263
Merge branch 'hedera-master' into feature/ethereumj-besu-swap
Daniel-K-Ivanov Sep 28, 2021
0ce911a
resolve(conflicts): Resolve conflicts from Hedera master
Daniel-K-Ivanov Sep 28, 2021
7824f2b
Feat: Hedera Custom Create Operation + SelfDestructs (#529)
stoqnkpL Sep 29, 2021
e59babc
feat(evm-opcodes): revert when accessing a non-existing account (#541)
failfmi Sep 30, 2021
6347cf9
#526: Added unit tests for Call and Create Transition Logics (#534)
iamrusko Sep 30, 2021
ffcc6e2
Log Gas Calculations (#540)
shemnon Sep 30, 2021
becdb05
test: from call/callLocal/createEvmTxProcessor (#544)
iamrusko Oct 4, 2021
c541d93
Update Besu Version (#558)
shemnon Oct 4, 2021
ba92cf3
Fix Copy-paste error (#559)
shemnon Oct 5, 2021
bdcae8d
Refactored HederaWorldState to persist objects through ServicesReposi…
stoqnkpL Oct 5, 2021
bc513c9
feat(contracts): signature verification on recipients that require it…
failfmi Oct 5, 2021
fb9e446
NPE in EVM Opcodes that require the usage of an expiry (#561)
stoqnkpL Oct 5, 2021
29be559
Merge branch 'hedera-master' into feature/ethereumj-besu-swap
Daniel-K-Ivanov Oct 5, 2021
83f5bac
merge(hedera-master): Fix import path from hedera-master
Daniel-K-Ivanov Oct 5, 2021
4a61b17
Added TransactionProcessingTest (#564)
iamrusko Oct 5, 2021
5533fb5
Gas calculator for 0.19.0 (#547)
shemnon Oct 5, 2021
a10edd4
license: add missing
failfmi Oct 5, 2021
e0459bd
Inject operations and GasCalculator (#565)
shemnon Oct 5, 2021
d7cbc2b
Unit tests for `*Call` operations (#557)
joan41868 Oct 6, 2021
b5f625e
Unit Tests: Coverage Increase (#560)
georgiyazovaliiski Oct 6, 2021
65d843c
Added GasCalculatorHedera_0_18 tests (#571)
iamrusko Oct 7, 2021
a75da40
Unit tests for *ExtCode operations (#563)
alshapi Oct 7, 2021
1ecc0a7
Remove Legacy EthereumJ Code (#575)
Daniel-K-Ivanov Oct 7, 2021
73bf119
fix(contract-processor): correct response codes upon fail before exec…
failfmi Oct 7, 2021
77db80f
Return ResponseCode INSUFFICIENT_GAS when exceptional halt reason is …
stoqnkpL Oct 7, 2021
5caca34
Revise SStore gas price (#573)
shemnon Oct 7, 2021
630e412
Fix breakes found in perf tests (#574)
shemnon Oct 7, 2021
09ca192
Return Status ERROR_DECODING_BYTESTRING when trying to create contrac…
stoqnkpL Oct 7, 2021
95e3955
Docs: Add JavaDocs to new classes/interfaces/methods (#579)
Daniel-K-Ivanov Oct 7, 2021
1891159
fix(unit-test): Fix failing unit test
Daniel-K-Ivanov Oct 7, 2021
fd8283d
Re-order maven repositories
shemnon Oct 7, 2021
e9aaa11
besu swap sonar fixes (#580)
shemnon Oct 7, 2021
4871206
merge master
shemnon Oct 8, 2021
92fc6ea
javadoc
shemnon Oct 8, 2021
89ac2a2
public test classes
shemnon Oct 8, 2021
0efb8c0
Fix NewOpInConstructorSuite
shemnon Oct 8, 2021
d63693a
Check for out of gas in SStore
shemnon Oct 8, 2021
022d2a5
Unit tests for code coverage increase (#566)
CordonaCodeCraft Oct 8, 2021
1523d60
Refactored E2E tests related to Contracts (#572)
stoqnkpL Oct 8, 2021
ac4afb9
fix(code-smell): Remove public modifier
Daniel-K-Ivanov Oct 8, 2021
07118e6
Coverage: Additional Unit Tests for ci-enabled-2208 (#582)
georgiyazovaliiski Oct 10, 2021
6ef3cbb
test(contracts): additional coverage (#583)
failfmi Oct 10, 2021
c0e88e3
Enforce Storage Limit (#581)
shemnon Oct 11, 2021
d69d159
Merge branch 'hedera-master' into feature/ethereumj-besu-swap
Daniel-K-Ivanov Oct 11, 2021
645d1d6
Feature: Resolve TODOs (#592)
Daniel-K-Ivanov Oct 11, 2021
34d5b98
E2E tests refactoring (#593)
stoqnkpL Oct 11, 2021
9ba77bb
e2e(contract-call-local): insufficientfee set payer different than de…
failfmi Oct 12, 2021
4e2750e
Merge branch 'hedera-master' into feature/ethereumj-besu-swap
Daniel-K-Ivanov Oct 12, 2021
16c6868
Feat/sbh refunds (#595)
stoqnkpL Oct 12, 2021
27c2ee0
Refactor(contracts): extract duplicate code in operations (#596)
failfmi Oct 12, 2021
8eb1880
test: npe mocks (#597)
failfmi Oct 12, 2021
5571235
refactor(contracts): gas calculators (#598)
failfmi Oct 12, 2021
c31e9a7
style: unnecessary constants
failfmi Oct 12, 2021
4962802
check: suppress unused
failfmi Oct 12, 2021
be7b762
delete(file): Remove empty file
Daniel-K-Ivanov Oct 12, 2021
fa75cb9
pom cleanup
shemnon Oct 12, 2021
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
31 changes: 31 additions & 0 deletions hedera-node/pom.xml
Expand Up @@ -26,6 +26,9 @@
<ant-contrib.version>1.0b3</ant-contrib.version>
<ant-nodeps.version>1.8.1</ant-nodeps.version>
<jackson.version>2.11.2</jackson.version>
<besu.version>21.10.0-RC1</besu.version>
<tuweni.version>2.0.0</tuweni.version>
<besu-native.version>0.3.0</besu-native.version>
</properties>

<build>
Expand Down Expand Up @@ -292,6 +295,26 @@
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tuweni</groupId>
<artifactId>tuweni-units</artifactId>
<version>${tuweni.version}</version>
</dependency>
<dependency>
<groupId>org.hyperledger.besu</groupId>
<artifactId>bls12-381</artifactId>
<version>${besu-native.version}</version>
</dependency>
<dependency>
<groupId>org.hyperledger.besu</groupId>
<artifactId>evm</artifactId>
<version>${besu.version}</version>
</dependency>
<dependency>
<groupId>org.hyperledger.besu</groupId>
<artifactId>besu-datatypes</artifactId>
<version>${besu.version}</version>
</dependency>
</dependencies>

<repositories>
Expand All @@ -310,6 +333,14 @@
<id>local-repo-for-swirlds-sdk</id>
<url>file:${project.basedir}/localSwirldsSDK</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>besu</id>
<name>Hyperledger Besu</name>
<url>https://hyperledger.jfrog.io/artifactory/besu-maven</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
Expand Down
Expand Up @@ -210,6 +210,7 @@ public Set<String> allPropertyNames() {
"contracts.defaultLifetime",
"contracts.localCall.estRetBytes",
"contracts.maxGas",
"contracts.chainId",
"contracts.maxStorageKb",
"files.maxSizeKb",
"fees.minCongestionPeriod",
Expand Down Expand Up @@ -391,6 +392,7 @@ public static Function<String, Object> transformFor(String prop) {
entry("contracts.maxStorageKb", AS_INT),
entry("contracts.defaultLifetime", AS_LONG),
entry("contracts.maxGas", AS_INT),
entry("contracts.chainId", AS_INT),
entry("rates.intradayChangeLimitPercent", AS_INT),
entry("rates.midnightCheckInterval", AS_LONG),
entry("scheduling.whitelist", AS_FUNCTIONS),
Expand Down
Expand Up @@ -64,6 +64,7 @@ public class GlobalDynamicProperties {
private long minTxnDuration;
private int minValidityBuffer;
private int maxGas;
private int chainId;
private long defaultContractLifetime;
private int feesTokenTransferUsageMultiplier;
private boolean autoRenewEnabled;
Expand Down Expand Up @@ -128,6 +129,7 @@ public void reload() {
minTxnDuration = properties.getLongProperty("hedera.transaction.minValidDuration");
minValidityBuffer = properties.getIntProperty("hedera.transaction.minValidityBufferSecs");
maxGas = properties.getIntProperty("contracts.maxGas");
chainId = properties.getIntProperty("contracts.chainId");
defaultContractLifetime = properties.getLongProperty("contracts.defaultLifetime");
feesTokenTransferUsageMultiplier = properties.getIntProperty("fees.tokenTransferUsageMultiplier");
autoRenewEnabled = properties.getBooleanProperty("autorenew.isEnabled");
Expand Down Expand Up @@ -252,6 +254,10 @@ public int maxGas() {
return maxGas;
}

public int getChainId() {
return chainId;
}

public long defaultContractLifetime() {
return defaultContractLifetime;
}
Expand Down
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -24,8 +24,8 @@
import com.hedera.services.context.properties.GlobalDynamicProperties;
import com.hedera.services.contracts.annotations.BytecodeSource;
import com.hedera.services.contracts.annotations.StorageSource;
import com.hedera.services.contracts.execution.SoliditySigsVerifier;
import com.hedera.services.contracts.execution.TxnAwareSoliditySigsVerifier;
import com.hedera.services.contracts.sources.SoliditySigsVerifier;
import com.hedera.services.contracts.sources.TxnAwareSoliditySigsVerifier;
import com.hedera.services.contracts.persistence.BlobStoragePersistence;
import com.hedera.services.contracts.sources.BlobStorageSource;
import com.hedera.services.contracts.sources.LedgerAccountsSource;
Expand All @@ -38,17 +38,33 @@
import com.hedera.services.sigs.verification.SyncVerifier;
import com.hedera.services.state.merkle.MerkleAccount;
import com.hedera.services.state.submerkle.EntityId;
import com.hedera.services.utils.EntityNum;
import com.hedera.services.contracts.gascalculator.GasCalculatorHederaV19;
import com.hedera.services.contracts.operation.HederaBalanceOperation;
import com.hedera.services.contracts.operation.HederaCallCodeOperation;
import com.hedera.services.contracts.operation.HederaCallOperation;
import com.hedera.services.contracts.operation.HederaCreateOperation;
import com.hedera.services.contracts.operation.HederaDelegateCallOperation;
import com.hedera.services.contracts.operation.HederaExtCodeCopyOperation;
import com.hedera.services.contracts.operation.HederaExtCodeHashOperation;
import com.hedera.services.contracts.operation.HederaExtCodeSizeOperation;
import com.hedera.services.contracts.operation.HederaSStoreOperation;
import com.hedera.services.contracts.operation.HederaSelfDestructOperation;
import com.hedera.services.contracts.operation.HederaStaticCallOperation;
import com.hedera.services.txns.validation.OptionValidator;
import com.hedera.services.utils.EntityNum;
import com.hederahashgraph.api.proto.java.AccountID;
import com.swirlds.merkle.map.MerkleMap;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoSet;
import org.ethereum.core.AccountState;
import org.ethereum.datasource.Source;
import org.ethereum.datasource.StoragePersistence;
import org.ethereum.db.ServicesRepositoryRoot;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.hyperledger.besu.evm.operation.InvalidOperation;
import org.hyperledger.besu.evm.operation.Operation;

import javax.inject.Singleton;
import java.util.Map;
Expand Down Expand Up @@ -151,4 +167,70 @@ public static Map<byte[], byte[]> provideStorageSource(Map<String, byte[]> blobS
public static Map<EntityId, Long> provideEntityExpiries(Map<String, byte[]> blobStore) {
return entityExpiryMapFrom(blobStore);
}

@Provides
@Singleton
@IntoSet
public static Operation provideCreate2Operation(GasCalculator gasCalculator) {
return new InvalidOperation(0xF5, gasCalculator);
}

@Binds
@Singleton
public abstract GasCalculator bindHederaGasCalculatorV19(GasCalculatorHederaV19 gasCalculator);

@Binds
@Singleton
@IntoSet
public abstract Operation bindBalanceOperation(HederaBalanceOperation balance);

@Binds
@Singleton
@IntoSet
public abstract Operation bindCallCodeOperation(HederaCallCodeOperation callCode);

@Binds
@Singleton
@IntoSet
public abstract Operation bindCallOperation(HederaCallOperation call);

@Binds
@Singleton
@IntoSet
public abstract Operation bindCreateOperation(HederaCreateOperation create);

@Binds
@Singleton
@IntoSet
public abstract Operation bindDelegateCallOperation(HederaDelegateCallOperation delegateCall);

@Binds
@Singleton
@IntoSet
public abstract Operation bindExtCodeCopyOperation(HederaExtCodeCopyOperation extCodeCopy);

@Binds
@Singleton
@IntoSet
public abstract Operation bindExtCodeHashOperation(HederaExtCodeHashOperation extCodeHash);

@Binds
@Singleton
@IntoSet
public abstract Operation bindExtCodeSizeOperation(HederaExtCodeSizeOperation extCodeSize);

@Binds
@Singleton
@IntoSet
public abstract Operation bindSelfDestructOperation(HederaSelfDestructOperation selfDestruct);

@Binds
@Singleton
@IntoSet
public abstract Operation bindSStoreOperation(HederaSStoreOperation sstore);

@Binds
@Singleton
@IntoSet
public abstract Operation bindStaticCallOperation(HederaStaticCallOperation staticCall);
}
@@ -0,0 +1,97 @@
package com.hedera.services.contracts.execution;

/*
* -
* ‌
* Hedera Services Node
* ​
* Copyright (C) 2018 - 2021 Hedera Hashgraph, LLC
* ​
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ‍
*
*/

import com.hedera.services.context.properties.GlobalDynamicProperties;
import com.hedera.services.fees.HbarCentExchange;
import com.hedera.services.fees.calculation.UsagePricesProvider;
import com.hedera.services.store.contracts.HederaWorldState;
import com.hedera.services.store.models.Account;
import com.hederahashgraph.api.proto.java.HederaFunctionality;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.hyperledger.besu.evm.operation.Operation;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.time.Instant;
import java.util.Optional;
import java.util.Set;

@Singleton
public class CallEvmTxProcessor extends EvmTxProcessor {

@Inject
public CallEvmTxProcessor(
HederaWorldState worldState,
HbarCentExchange exchange,
UsagePricesProvider usagePrices,
GlobalDynamicProperties dynamicProperties,
GasCalculator gasCalculator,
Set<Operation> hederaOperations) {
super(worldState, exchange, usagePrices, dynamicProperties, gasCalculator, hederaOperations);
}

public TransactionProcessingResult execute(
final Account sender,
final Address receiver,
final long providedGasLimit,
final long value,
final Bytes callData,
final Instant consensusTime
) {
final long gasPrice = gasPriceTinyBarsGiven(consensusTime);

return super.execute(sender,
receiver,
gasPrice,
providedGasLimit,
value,
callData,
false,
consensusTime,
false,
Optional.empty());
}

@Override
protected HederaFunctionality getFunctionType() {
return HederaFunctionality.ContractCall;
}

@Override
protected MessageFrame buildInitialFrame(MessageFrame.Builder baseInitialFrame, HederaWorldState.Updater updater, Address to, Bytes payload) {
Bytes code = updater.get(to).getCode();
return baseInitialFrame
.type(MessageFrame.Type.MESSAGE_CALL)
.address(to)
.contract(to)
.inputData(payload)
.code(new Code(code, Hash.hash(code)))
.build();
}
}