Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
zilm13 committed Jun 26, 2018
2 parents 4430b41 + bbf5472 commit 9be3604
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 84 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Welcome to ethereumj

[![Slack Status](http://harmony-slack-ether-camp.herokuapp.com/badge.svg)](http://ether.camp)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/ethereumj?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/ethereum/ethereumj.svg?branch=master)](https://travis-ci.org/ethereum/ethereumj)
[![Coverage Status](https://coveralls.io/repos/ethereum/ethereumj/badge.png?branch=master)](https://coveralls.io/r/ethereum/ethereumj?branch=master)
Expand All @@ -19,7 +18,7 @@ We keep EthereumJ as thin as possible. For [JSON-RPC](https://github.com/ethereu
<dependency>
<groupId>org.ethereum</groupId>
<artifactId>ethereumj-core</artifactId>
<version>1.6.3-RELEASE</version>
<version>1.8.1-RELEASE</version>
</dependency>
```

Expand All @@ -31,7 +30,7 @@ We keep EthereumJ as thin as possible. For [JSON-RPC](https://github.com/ethereu
jcenter()
maven { url "https://dl.bintray.com/ethereum/maven/" }
}
compile "org.ethereum:ethereumj-core:1.6.+"
compile "org.ethereum:ethereumj-core:1.8.+"
```

As a starting point for your own project take a look at https://github.com/ether-camp/ethereumj.starter
Expand Down Expand Up @@ -64,6 +63,27 @@ java -jar ethereumj-core/build/libs/ethereumj-core-*-all.jar
./gradlew run -PmainClass=org.ethereum.samples.TransactionBomb
```

##### For snapshot builds:
Please, note, snapshots are not stable and are currently in development! If you still want to try it:

- Add https://oss.jfrog.org/libs-snapshot/ as a repository to your build script
- Add a dependency on `org.ethereum:ethereumj-core:${VERSION}`, where `${VERSION}` is of the form `1.9.0-SNAPSHOT`.

Example:

<repository>
<id>jfrog-snapshots</id>
<name>oss.jfrog.org</name>
<url>https://oss.jfrog.org/libs-snapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<!-- ... -->
<dependency>
<groupId>org.ethereum</groupId>
<artifactId>ethereumj-core</artifactId>
<version>1.9.0-SNAPSHOT</version>
</dependency>

##### Importing project to IntelliJ IDEA:
```
> git clone https://github.com/ethereum/ethereumj
Expand Down
62 changes: 0 additions & 62 deletions ethereumj-core/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,11 @@ private boolean isValid(Repository repo, Block block) {

for (Transaction tx : txs) {
byte[] txSender = tx.getSender();
if (txSender == null) {
logger.warn("Invalid transaction: sender in tx with rlp={} is null." +
"Not valid until EIP-86", ByteUtil.toHexString(tx.getEncoded()));
return false;
}
ByteArrayWrapper key = new ByteArrayWrapper(txSender);
BigInteger expectedNonce = curNonce.get(key);
if (expectedNonce == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.ethereum.facade.EthereumFactory;
import org.ethereum.listener.EthereumListenerAdapter;
import org.ethereum.util.ByteUtil;
import org.ethereum.util.blockchain.EtherUtil;
import org.spongycastle.util.encoders.Hex;
import org.springframework.context.annotation.Bean;

Expand Down Expand Up @@ -84,7 +85,7 @@ private TransactionReceipt sendTxAndWait(byte[] receiveAddress, byte[] data) thr
ByteUtil.longToBytesNoLeadZeroes(ethereum.getGasPrice()),
ByteUtil.longToBytesNoLeadZeroes(200000),
receiveAddress,
ByteUtil.bigIntegerToBytes(BigInteger.valueOf(1)), // 1_000_000_000 gwei, 1_000_000_000_000L szabo, 1_000_000_000_000_000L finney, 1_000_000_000_000_000_000L ether
ByteUtil.bigIntegerToBytes(EtherUtil.convert(1, EtherUtil.Unit.WEI)), // Use EtherUtil.convert for easy value unit conversion
data,
ethereum.getChainIdForNextBlock());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ public void main() {

syncSecure();

listener.onSyncDone(EthereumListener.SyncState.SECURE);
fireSyncDone(SECURE);
case COMPLETE:
if (origSyncStage == COMPLETE) {
logger.info("FastSync: SECURE sync was completed prior to this run, proceeding with next stage...");
Expand All @@ -735,7 +735,7 @@ public void main() {

syncBlocksReceipts();

listener.onSyncDone(EthereumListener.SyncState.COMPLETE);
fireSyncDone(COMPLETE);
}
logger.info("FastSync: Full sync done.");
} catch (InterruptedException ex) {
Expand All @@ -751,6 +751,14 @@ public void main() {
}
}

private void fireSyncDone(EthereumListener.SyncState state) {
// prevent early state notification when sync is not yet done
syncManager.setSyncDoneType(state);
if (syncManager.isSyncDone()) {
listener.onSyncDone(state);
}
}

public boolean isFastSyncInProgress() {
return fastSyncInProgress;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,14 @@ void initRegularSync(EthereumListener.SyncState syncDoneType) {
} catch (Exception e) {
logger.error("Unexpected", e);
}
}, 0, 10, TimeUnit.SECONDS);
}, 0, 2, TimeUnit.SECONDS);
}
}

void setSyncDoneType(EthereumListener.SyncState syncDoneType) {
this.syncDoneType = syncDoneType;
}

public SyncStatus getSyncStatus() {
if (config.isFastSyncEnabled()) {
SyncStatus syncStatus = fastSyncManager.getSyncState();
Expand Down
8 changes: 4 additions & 4 deletions ethereumj-core/src/main/java/org/ethereum/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private long calcMemGas(GasCost gasCosts, long oldMemSize, BigInteger newMemSize
long gasCost = 0;

// Avoid overflows
if (newMemSize.compareTo(MAX_MEM_SIZE) == 1) {
if (newMemSize.compareTo(MAX_MEM_SIZE) > 0) {
throw Program.Exception.gasOverflow(newMemSize, MAX_MEM_SIZE);
}

Expand Down Expand Up @@ -790,7 +790,7 @@ else if (oldValue != null && newValue.isZero()) {
if (logger.isInfoEnabled())
hint = "data: " + toHexString(msgData);

program.memorySave(memOffsetData.intValueSafe(), msgData);
program.memorySave(memOffsetData.intValueSafe(), lengthData.intValueSafe(), msgData);
program.step();
}
break;
Expand Down Expand Up @@ -818,7 +818,7 @@ else if (oldValue != null && newValue.isZero()) {
if (logger.isInfoEnabled())
hint = "data: " + toHexString(msgData);

program.memorySave(memOffsetData.intValueSafe(), msgData);
program.memorySave(memOffsetData.intValueSafe(), lengthData.intValueSafe(), msgData);
program.step();
}
break;
Expand Down Expand Up @@ -870,7 +870,7 @@ else if (oldValue != null && newValue.isZero()) {
if (logger.isInfoEnabled())
hint = "code: " + toHexString(codeCopy);

program.memorySave(memOffset, codeCopy);
program.memorySave(memOffset, lengthData, codeCopy);
program.step();
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public byte[] read(int address, int size) {
}

public void write(int address, byte[] data, int dataSize, boolean limited) {
if (dataSize <= 0) return;

if (data.length < dataSize)
dataSize = data.length;
Expand Down Expand Up @@ -107,7 +108,7 @@ public void write(int address, byte[] data, int dataSize, boolean limited) {

public void extendAndWrite(int address, int allocSize, byte[] data) {
extend(address, allocSize);
write(address, data, data.length, false);
write(address, data, allocSize, false);
}

public void extend(int address, int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ public void callToPrecompiledAddress(MessageCall msg, PrecompiledContract contra
track.rollback();
}

this.memorySave(msg.getOutDataOffs().intValue(), out.getRight());
this.memorySave(msg.getOutDataOffs().intValue(), msg.getOutDataSize().intValueSafe(), out.getRight());
}
}

Expand Down
2 changes: 1 addition & 1 deletion ethereumj-core/src/main/resources/version.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versionNumber='1.8.0'
versionNumber='1.9.0'
// Remove org.ethereum.db.migrate.MigrateHeaderSourceTotalDiff with databaseVersion > 6
databaseVersion=6
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,11 @@ public void testAllocateMemoryUnrounded7() {
assertEquals(32, program.getMemSize());
}

@Ignore
@Test
public void testInitialInsert() {


// todo: fix the array out of bound here
public void testEmptyInsert() {
int offset = 32;
int size = 00;
program.memorySave(32, 0, new byte[0]);
assertEquals(32, program.getMemSize());
int size = 0;
program.memorySave(offset, size, new byte[] {0x01});
assertEquals(0, program.getMemSize());
}
}

0 comments on commit 9be3604

Please sign in to comment.