-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Casper FFG test net compatibility #1015
Open
zilm13
wants to merge
74
commits into
develop
Choose a base branch
from
research/casper
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
4f7b653
Merge branch 'develop' into research/casper
zilm13 7d62991
Merge branch 'develop' into research/casper
zilm13 c34ea0f
Casper init commit. Passive sync is ok, mining is ok, validator in de…
zilm13 0902660
Merge branch 'develop' into research/casper
zilm13 ebe5fb0
TransactionExecutor split to standard implementation and Casper version
zilm13 d736638
Fixing Spring circular references
zilm13 3f1b724
Fixing miner rejects casper votes
zilm13 726f4f7
Fixed Ethereum Harmony build dependency failing
zilm13 e2e3fd6
Init Casper with passed params instead of hexcode
zilm13 71dde8d
Added Casper Epoch test + minor fixes
zilm13 a50d280
Quick fix casper votes are dropped
zilm13 6b0f381
Fixed sync not done after miner start
zilm13 4369d4f
Added simple casper validator test, fixed voting in casper validator …
zilm13 a556ecc
Added logging of my validator stats
zilm13 492468e
Added validator logout test
zilm13 4818249
Fixed processed txs removal
zilm13 5287b22
Fixed basis test was started, but shouldn't
zilm13 b47e24c
Refactored null sender txs signing
zilm13 068152a
Started to detaching Casper in separate package: Config moved
zilm13 3a88e8b
Moved Blockchain and validators out of consensus strategy
zilm13 11fa1a7
Fixed frame encoding for chunked frames
zilm13 dbdbc28
Fxied type size counting
zilm13 a87b98f
Fixed dirty read coded size adjust
zilm13 26f5c6e
Fixed incorrect Transactions creation (with lead zeros)
zilm13 770b377
Fixed wrong place of chunked frame size adjust
zilm13 23e894c
Fixed tests
zilm13 d5c2650
Add publishing to jfrog
zilm13 f932df1
Trying another naming for publishing
zilm13 beccdb9
TransactionExecutor creation moved to CommonConfig. CasperBlockchain …
zilm13 abc8906
Net config moved to casper package
zilm13 6d23835
Moved switching to short sync on manual miner start to Harmony
zilm13 5c8634d
Completely removed ConsensusStrategy abstraction
zilm13 920747f
More cleanup to enclose casper in separate package
zilm13 0fb3a63
Temp patch for p2pv4 framing compatibility with p2pv5 snappy
zilm13 dbc1dcf
Validator start logging added
zilm13 97dba27
Fixed: casper votes should come after regular txs in mined block + va…
zilm13 b83b9cb
Fixing ethereumj w. ethereumj p2p
zilm13 281c60c
Moved dummy contracts to Casper genesis
zilm13 ce4bdf8
Cleanup of default config
zilm13 f101e4b
Correct constructor for creating RepositoryRoot without autowiring added
zilm13 dc652a3
Logic of casper validator start moved to casper validator
zilm13 c06a3b5
Casper vote checking moved to CasperFacade
zilm13 313223b
Fixed block was not always thrown away with new block mined when mini…
zilm13 16e4515
Removed state init abstraction
zilm13 2b1db0f
Added validators for transaction and transaction receipt in PendingState
zilm13 56f7d04
Revert "Added validators for transaction and transaction receipt in P…
zilm13 73fddc3
Decreased validator gas limit to make it easy passing in block with a…
zilm13 43b3f96
Fixed failure when no validator options configured
zilm13 1f0e5dc
Fixed: unsuccessful txs with 0 gas used were included in mined blocks
zilm13 0423bbf
Fixed wrong init in CasperValidatorService
zilm13 8ec6864
Make casper epoch switch free
zilm13 845c0bf
Revert "Make casper epoch switch free"
zilm13 c72cb9d
Don't subtract fee from null sender on succesful casper vote. Instead…
zilm13 2117fdc
Fixed makeInitTxs
zilm13 3a3e536
Logging of casper address added
zilm13 13fda70
Trying to fix github tests with delay after failed request
zilm13 0cc765d
Revert "Don't subtract fee from null sender on succesful casper vote.…
zilm13 3f39e57
Removed TransactionExecutorFactory
zilm13 bc829f6
Storing finalized checkpoints in separate source
zilm13 d7703cb
Fixed Casper test (finalizedBlocks storage was not set)
zilm13 2517cc0
Merge branch 'develop' into research/casper
zilm13 cce4815
Revert "Revert "Make casper epoch switch free""
zilm13 5e13b15
Revert "Revert "Don't subtract fee from null sender on succesful casp…
zilm13 9840b71
Testing that no gas was used for casper service txs and bad casper vo…
zilm13 d0cea52
Merge branch 'develop' into research/casper
zilm13 ad92db0
Merge branch 'develop' into research/casper
zilm13 33e6721
Merge branch 'develop' into research/casper
zilm13 feb3f91
CasperFacade: use apache.commons Pair instead of javafx.util Pair
mkalinin 84a3254
Added transaction executor note for casper service txs
zilm13 6760e96
Bump Casper contract to commit #251a1a349fddd90b40febf9781ffc92e8c6a4a0e
zilm13 179888a
Temporary EIP-86 partial implementation
zilm13 e835c4a
Fixing Circle CI for Casper branch
zilm13 316c43d
Refactored tx validation
zilm13 29614b4
Testing chainId compatibility
zilm13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
ethereumj-core/src/main/java/org/ethereum/casper/Start.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) [2016] [ <ether.camp> ] | ||
* This file is part of the ethereumJ library. | ||
* | ||
* The ethereumJ library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The ethereumJ library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.ethereum.casper; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.ethereum.casper.config.CasperConfig; | ||
import org.ethereum.cli.CLIInterface; | ||
import org.ethereum.config.SystemProperties; | ||
import org.ethereum.facade.Ethereum; | ||
import org.ethereum.facade.EthereumFactory; | ||
import org.ethereum.mine.Ethash; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
|
||
public class Start { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger("general"); | ||
|
||
public static void main(String args[]) throws IOException, URISyntaxException { | ||
logger.info("EthereumJ Casper edition"); | ||
CLIInterface.call(args); | ||
|
||
final SystemProperties config = SystemProperties.getDefault(); | ||
final boolean actionBlocksLoader = !config.blocksLoader().equals(""); | ||
final boolean actionGenerateDag = !StringUtils.isEmpty(System.getProperty("ethash.blockNumber")); | ||
|
||
if (actionBlocksLoader || actionGenerateDag) { | ||
config.setSyncEnabled(false); | ||
config.setDiscoveryEnabled(false); | ||
} | ||
|
||
if (actionGenerateDag) { | ||
new Ethash(config, Long.parseLong(System.getProperty("ethash.blockNumber"))).getFullDataset(); | ||
// DAG file has been created, lets exit | ||
System.exit(0); | ||
} else { | ||
Ethereum ethereum = EthereumFactory.createEthereum(new Class[] {CasperConfig.class}); | ||
|
||
if (actionBlocksLoader) { | ||
ethereum.getBlockLoader().loadBlocks(); | ||
} | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
ethereumj-core/src/main/java/org/ethereum/casper/config/CasperBeanConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) [2016] [ <ether.camp> ] | ||
* This file is part of the ethereumJ library. | ||
* | ||
* The ethereumJ library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The ethereumJ library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.ethereum.casper.config; | ||
|
||
import org.ethereum.casper.core.CasperPendingStateImpl; | ||
import org.ethereum.casper.manager.CasperWorldManager; | ||
import org.ethereum.casper.mine.CasperBlockMiner; | ||
import org.ethereum.config.CommonConfig; | ||
import org.ethereum.config.SystemProperties; | ||
import org.ethereum.core.Blockchain; | ||
import org.ethereum.core.PendingState; | ||
import org.ethereum.casper.core.CasperBlockchain; | ||
import org.ethereum.listener.CompositeEthereumListener; | ||
import org.ethereum.manager.WorldManager; | ||
import org.ethereum.mine.BlockMiner; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
@Configuration | ||
@EnableTransactionManagement | ||
public class CasperBeanConfig extends CommonConfig { | ||
|
||
@Override | ||
@Bean | ||
public Blockchain blockchain() { | ||
return new CasperBlockchain(systemProperties()); | ||
} | ||
|
||
@Bean | ||
@Override | ||
public WorldManager worldManager() { | ||
return new CasperWorldManager(systemProperties(), repository(), blockchain()); | ||
} | ||
|
||
@Bean | ||
@Override | ||
public PendingState pendingState() { | ||
return new CasperPendingStateImpl(ethereumListener); | ||
} | ||
|
||
@Bean | ||
@Override | ||
public BlockMiner blockMiner() { | ||
return new CasperBlockMiner(systemProperties(), (CompositeEthereumListener) ethereumListener, | ||
blockchain(), pendingState()); | ||
} | ||
|
||
@Bean | ||
@Override | ||
public SystemProperties systemProperties() { | ||
return CasperProperties.getDefault(); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
ethereumj-core/src/main/java/org/ethereum/casper/config/CasperConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (c) [2016] [ <ether.camp> ] | ||
* This file is part of the ethereumJ library. | ||
* | ||
* The ethereumJ library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The ethereumJ library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.ethereum.casper.config; | ||
|
||
import org.ethereum.config.CommonConfig; | ||
import org.ethereum.config.DefaultConfig; | ||
import org.ethereum.config.NoAutoscan; | ||
import org.ethereum.config.SystemProperties; | ||
import org.ethereum.datasource.Source; | ||
import org.ethereum.db.BlockStore; | ||
import org.ethereum.db.IndexedBlockStore; | ||
import org.ethereum.db.PruneManager; | ||
import org.ethereum.db.TransactionStore; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.FilterType; | ||
import org.springframework.context.annotation.Import; | ||
|
||
@Configuration | ||
@ComponentScan( | ||
basePackages = "org.ethereum", | ||
excludeFilters = {@ComponentScan.Filter(NoAutoscan.class), | ||
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = {CommonConfig.class, DefaultConfig.class})}, | ||
includeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = {CasperBeanConfig.class})} | ||
) | ||
@Import(CasperBeanConfig.class) | ||
public class CasperConfig { | ||
private static Logger logger = LoggerFactory.getLogger("general"); | ||
|
||
@Autowired | ||
ApplicationContext appCtx; | ||
|
||
@Autowired | ||
CasperBeanConfig beanConfig; | ||
|
||
@Autowired | ||
SystemProperties config; | ||
|
||
public CasperConfig() { | ||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.error("Uncaught exception", e)); | ||
} | ||
|
||
@Bean | ||
public BlockStore blockStore(){ | ||
beanConfig.fastSyncCleanUp(); | ||
IndexedBlockStore indexedBlockStore = new IndexedBlockStore(); | ||
Source<byte[], byte[]> block = beanConfig.cachedDbSource("block"); | ||
Source<byte[], byte[]> index = beanConfig.cachedDbSource("index"); | ||
indexedBlockStore.init(index, block); | ||
|
||
return indexedBlockStore; | ||
} | ||
|
||
@Bean(name = "finalizedBlocks") | ||
public Source<byte[], byte[]> finalizedBlockStore() { | ||
return beanConfig.cachedDbSource("finalized"); | ||
} | ||
|
||
@Bean | ||
public TransactionStore transactionStore() { | ||
beanConfig.fastSyncCleanUp(); | ||
return new TransactionStore(beanConfig.cachedDbSource("transactions")); | ||
} | ||
|
||
@Bean | ||
public PruneManager pruneManager() { | ||
if (config.databasePruneDepth() >= 0) { | ||
return new PruneManager((IndexedBlockStore) blockStore(), beanConfig.stateSource().getJournalSource(), | ||
beanConfig.stateSource().getNoJournalSource(), config.databasePruneDepth()); | ||
} else { | ||
return new PruneManager(null, null, null, -1); // dummy | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
ethereumj-core/src/main/java/org/ethereum/casper/config/CasperProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package org.ethereum.casper.config; | ||
|
||
import org.ethereum.config.SystemProperties; | ||
import org.ethereum.util.ByteUtil; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.ethereum.casper.config.net.CasperTestConfig.EPOCH_LENGTH; | ||
|
||
public class CasperProperties extends SystemProperties { | ||
|
||
private static CasperProperties CONFIG; | ||
|
||
private byte[] casperAddress = null; | ||
|
||
public static SystemProperties getDefault() { | ||
if (CONFIG == null) { | ||
CONFIG = new CasperProperties(); | ||
} | ||
return CONFIG; | ||
} | ||
|
||
public byte[] getCasperAddress() { | ||
return casperAddress; | ||
} | ||
|
||
public void setCasperAddress(byte[] casperAddress) { | ||
this.casperAddress = casperAddress; | ||
} | ||
|
||
public int getCasperEpochLength() { | ||
return EPOCH_LENGTH; | ||
} | ||
|
||
public byte[] getCasperValidatorPrivateKey() { | ||
String key = config.getString("casper.validator.privateKey"); | ||
if (key == null) return null; | ||
return ByteUtil.hexStringToBytes(key); | ||
} | ||
|
||
public long getCasperValidatorDeposit() { | ||
return config.getLong("casper.validator.deposit"); | ||
} | ||
|
||
public Boolean getCasperValidatorEnabled() { | ||
return config.getBoolean("casper.validator.enabled"); | ||
} | ||
|
||
public String getCasperAbi() { | ||
final String abiLocation = config.getString("casper.contractAbi"); | ||
return readFile(abiLocation); | ||
} | ||
|
||
public String getCasperBin() { | ||
final String binLocation = config.getString("casper.contractBin"); | ||
return readFile(binLocation); | ||
} | ||
|
||
private static String readFile(final String location) { | ||
try { | ||
InputStream is = SystemProperties.class.getResourceAsStream(location); | ||
|
||
if (is != null) { | ||
return readStream(is); | ||
} else { | ||
logger.error("File not found `{}`", location); | ||
throw new RuntimeException(String.format("File not found `%s`", location)); | ||
} | ||
} catch (Exception ex) { | ||
String errorMsg = String.format("Error while reading file from %s", location); | ||
logger.error(errorMsg, ex); | ||
throw new RuntimeException(errorMsg, ex); | ||
} | ||
} | ||
|
||
private static String readStream(InputStream input) throws IOException { | ||
try (BufferedReader buffer = new BufferedReader(new InputStreamReader(input))) { | ||
return buffer.lines().collect(Collectors.joining("\n")); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will
@Import(DefaultConfig.class)
work here instead of inheritance? If yes then it might also keep us from addingCasperConfig
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, will check. Expecting two beans of the same type by intuition.