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

Casper FFG test net compatibility #1015

Open
wants to merge 74 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4f7b653
Merge branch 'develop' into research/casper
zilm13 Jan 22, 2018
7d62991
Merge branch 'develop' into research/casper
zilm13 Jan 31, 2018
c34ea0f
Casper init commit. Passive sync is ok, mining is ok, validator in de…
zilm13 Feb 22, 2018
0902660
Merge branch 'develop' into research/casper
zilm13 Feb 22, 2018
ebe5fb0
TransactionExecutor split to standard implementation and Casper version
zilm13 Feb 22, 2018
d736638
Fixing Spring circular references
zilm13 Feb 23, 2018
3f1b724
Fixing miner rejects casper votes
zilm13 Feb 23, 2018
726f4f7
Fixed Ethereum Harmony build dependency failing
zilm13 Feb 23, 2018
e2e3fd6
Init Casper with passed params instead of hexcode
zilm13 Feb 26, 2018
71dde8d
Added Casper Epoch test + minor fixes
zilm13 Feb 27, 2018
a50d280
Quick fix casper votes are dropped
zilm13 Feb 28, 2018
6b0f381
Fixed sync not done after miner start
zilm13 Feb 28, 2018
4369d4f
Added simple casper validator test, fixed voting in casper validator …
zilm13 Mar 1, 2018
a556ecc
Added logging of my validator stats
zilm13 Mar 1, 2018
492468e
Added validator logout test
zilm13 Mar 2, 2018
4818249
Fixed processed txs removal
zilm13 Mar 2, 2018
5287b22
Fixed basis test was started, but shouldn't
zilm13 Mar 2, 2018
b47e24c
Refactored null sender txs signing
zilm13 Mar 2, 2018
068152a
Started to detaching Casper in separate package: Config moved
zilm13 Mar 2, 2018
3a88e8b
Moved Blockchain and validators out of consensus strategy
zilm13 Mar 2, 2018
11fa1a7
Fixed frame encoding for chunked frames
zilm13 Mar 5, 2018
dbdbc28
Fxied type size counting
zilm13 Mar 5, 2018
a87b98f
Fixed dirty read coded size adjust
zilm13 Mar 5, 2018
26f5c6e
Fixed incorrect Transactions creation (with lead zeros)
zilm13 Mar 6, 2018
770b377
Fixed wrong place of chunked frame size adjust
zilm13 Mar 6, 2018
23e894c
Fixed tests
zilm13 Mar 6, 2018
d5c2650
Add publishing to jfrog
zilm13 Mar 6, 2018
f932df1
Trying another naming for publishing
zilm13 Mar 6, 2018
beccdb9
TransactionExecutor creation moved to CommonConfig. CasperBlockchain …
zilm13 Mar 7, 2018
abc8906
Net config moved to casper package
zilm13 Mar 7, 2018
6d23835
Moved switching to short sync on manual miner start to Harmony
zilm13 Mar 7, 2018
5c8634d
Completely removed ConsensusStrategy abstraction
zilm13 Mar 8, 2018
920747f
More cleanup to enclose casper in separate package
zilm13 Mar 8, 2018
0fb3a63
Temp patch for p2pv4 framing compatibility with p2pv5 snappy
zilm13 Mar 8, 2018
dbc1dcf
Validator start logging added
zilm13 Mar 9, 2018
97dba27
Fixed: casper votes should come after regular txs in mined block + va…
zilm13 Mar 9, 2018
b83b9cb
Fixing ethereumj w. ethereumj p2p
zilm13 Mar 10, 2018
281c60c
Moved dummy contracts to Casper genesis
zilm13 Mar 11, 2018
ce4bdf8
Cleanup of default config
zilm13 Mar 11, 2018
f101e4b
Correct constructor for creating RepositoryRoot without autowiring added
zilm13 Mar 11, 2018
dc652a3
Logic of casper validator start moved to casper validator
zilm13 Mar 11, 2018
c06a3b5
Casper vote checking moved to CasperFacade
zilm13 Mar 11, 2018
313223b
Fixed block was not always thrown away with new block mined when mini…
zilm13 Mar 12, 2018
16e4515
Removed state init abstraction
zilm13 Mar 12, 2018
2b1db0f
Added validators for transaction and transaction receipt in PendingState
zilm13 Mar 12, 2018
56f7d04
Revert "Added validators for transaction and transaction receipt in P…
zilm13 Mar 13, 2018
73fddc3
Decreased validator gas limit to make it easy passing in block with a…
zilm13 Mar 13, 2018
43b3f96
Fixed failure when no validator options configured
zilm13 Mar 13, 2018
1f0e5dc
Fixed: unsuccessful txs with 0 gas used were included in mined blocks
zilm13 Mar 13, 2018
0423bbf
Fixed wrong init in CasperValidatorService
zilm13 Mar 13, 2018
8ec6864
Make casper epoch switch free
zilm13 Mar 14, 2018
845c0bf
Revert "Make casper epoch switch free"
zilm13 Mar 14, 2018
c72cb9d
Don't subtract fee from null sender on succesful casper vote. Instead…
zilm13 Mar 14, 2018
2117fdc
Fixed makeInitTxs
zilm13 Mar 14, 2018
3a3e536
Logging of casper address added
zilm13 Mar 14, 2018
13fda70
Trying to fix github tests with delay after failed request
zilm13 Mar 14, 2018
0cc765d
Revert "Don't subtract fee from null sender on succesful casper vote.…
zilm13 Mar 14, 2018
3f39e57
Removed TransactionExecutorFactory
zilm13 Mar 14, 2018
bc829f6
Storing finalized checkpoints in separate source
zilm13 Mar 14, 2018
d7703cb
Fixed Casper test (finalizedBlocks storage was not set)
zilm13 Mar 18, 2018
2517cc0
Merge branch 'develop' into research/casper
zilm13 Mar 20, 2018
cce4815
Revert "Revert "Make casper epoch switch free""
zilm13 Mar 20, 2018
5e13b15
Revert "Revert "Don't subtract fee from null sender on succesful casp…
zilm13 Mar 20, 2018
9840b71
Testing that no gas was used for casper service txs and bad casper vo…
zilm13 Mar 20, 2018
d0cea52
Merge branch 'develop' into research/casper
zilm13 Mar 21, 2018
ad92db0
Merge branch 'develop' into research/casper
zilm13 Mar 21, 2018
33e6721
Merge branch 'develop' into research/casper
zilm13 Mar 22, 2018
feb3f91
CasperFacade: use apache.commons Pair instead of javafx.util Pair
mkalinin Apr 8, 2018
84a3254
Added transaction executor note for casper service txs
zilm13 Apr 9, 2018
6760e96
Bump Casper contract to commit #251a1a349fddd90b40febf9781ffc92e8c6a4a0e
zilm13 Apr 9, 2018
179888a
Temporary EIP-86 partial implementation
zilm13 Apr 10, 2018
e835c4a
Fixing Circle CI for Casper branch
zilm13 Apr 11, 2018
316c43d
Refactored tx validation
zilm13 Apr 11, 2018
29614b4
Testing chainId compatibility
zilm13 Apr 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Added validators for transaction and transaction receipt in P…
…endingState"

This reverts commit 2b1db0f.
  • Loading branch information
zilm13 committed Mar 13, 2018
commit 56f7d0440ed4ae764036fa34477d3c5907ee40fe
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
*/
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.Block;
import org.ethereum.core.Blockchain;
import org.ethereum.core.PendingState;
import org.ethereum.core.Repository;
import org.ethereum.core.Transaction;
import org.ethereum.core.TransactionExecutor;
Expand Down Expand Up @@ -79,6 +81,12 @@ public WorldManager worldManager() {
return new CasperWorldManager(systemProperties(), repository(), blockchain());
}

@Bean
@Override
public PendingState pendingState() {
return new CasperPendingStateImpl(ethereumListener);
}

@Bean
@Override
public BlockMiner blockMiner() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package org.ethereum.casper.config;

import org.apache.commons.lang3.tuple.Pair;
import org.ethereum.casper.config.net.CasperTestNetConfig;
import org.ethereum.config.BlockchainNetConfig;
import org.ethereum.config.SystemProperties;
import org.ethereum.core.genesis.GenesisConfig;
import org.ethereum.util.ByteUtil;
import org.ethereum.validator.BlockCustomHashRule;
import org.ethereum.validator.BlockHeaderValidator;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
import org.ethereum.db.ByteArrayWrapper;
import org.ethereum.util.ByteUtil;
import org.ethereum.util.RLP;
import org.ethereum.validator.transaction.ReceiptCasperVoteRule;
import org.ethereum.validator.transaction.ReceiptValidityRule;
import org.ethereum.validator.transaction.TransactionCasperVoteRule;
import org.ethereum.validator.transaction.TransactionFieldsRule;
import org.ethereum.validator.transaction.TransactionMineGasPriceRule;
import org.ethereum.validator.transaction.TransactionReceiptValidator;
import org.ethereum.validator.transaction.TransactionRule;
import org.ethereum.validator.transaction.TransactionValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.Arrays;
Expand All @@ -49,7 +41,6 @@

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -68,12 +59,6 @@ public class CasperBlockchain extends BlockchainImpl {
@Autowired
private CasperFacade casper;

@Autowired
private TransactionValidator transactionValidator;

@Autowired
private TransactionReceiptValidator receiptValidator;

private static final Logger logger = LoggerFactory.getLogger("blockchain");
private static final Logger stateLogger = LoggerFactory.getLogger("state");

Expand Down Expand Up @@ -379,22 +364,6 @@ coinbase, txTrack, blockStore, getProgramInvokeFactory(), block, listener, 0)
track.addBalance(casperAddress, track.getBalance(casperAddress).negate());
track.addBalance(casperAddress, BigInteger.valueOf(10).pow(25));
});
updateValidators(); // as casper contract is in place
}

private void updateValidators() {
// Update transaction validator as casper txs are applied
transactionValidator.reInit(
new ArrayList<TransactionRule>() {{
add(new TransactionFieldsRule());
add(new TransactionCasperVoteRule((CasperProperties) config, new TransactionMineGasPriceRule(config)));
}}
);

// Update transaction receipts validator
receiptValidator.reInit(Collections.singletonList(
new ReceiptCasperVoteRule((CasperProperties) config, new ReceiptValidityRule()))
);
}

/**
Expand Down Expand Up @@ -478,12 +447,4 @@ private BigInteger getPoWDifficulty(final Block block) {
public void setCasper(CasperFacade casper) {
this.casper = casper;
}

public void setTransactionValidator(TransactionValidator transactionValidator) {
this.transactionValidator = transactionValidator;
}

public void setReceiptValidator(TransactionReceiptValidator receiptValidator) {
this.receiptValidator = receiptValidator;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.core;

import org.ethereum.casper.config.CasperProperties;
import org.ethereum.core.PendingStateImpl;
import org.ethereum.core.Transaction;
import org.ethereum.core.TransactionReceipt;
import org.ethereum.listener.EthereumListener;
import org.ethereum.util.ByteUtil;

public class CasperPendingStateImpl extends PendingStateImpl {

public CasperPendingStateImpl(EthereumListener listener) {
super(listener);
}

@Override
protected boolean receiptIsValid(TransactionReceipt receipt) {
boolean isValid = super.receiptIsValid(receipt);
if (isValid) {
return true;
} else if (CasperFacade.isVote(receipt.getTransaction(), ((CasperProperties) config).getCasperAddress())) {
return receipt.isSuccessful();
}

return false;
}

@Override
protected String validate(Transaction tx) {
try {
tx.verify();
} catch (Exception e) {
return String.format("Invalid transaction: %s", e.getMessage());
}

if (CasperFacade.isVote(tx, ((CasperProperties) config).getCasperAddress())) {
return null; // Doesn't require more checks
}

if (config.getMineMinGasPrice().compareTo(ByteUtil.bytesToBigInteger(tx.getGasPrice())) > 0) {
return "Too low gas price for transaction: " + ByteUtil.bytesToBigInteger(tx.getGasPrice());
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.ethereum.core.*;
import org.ethereum.db.BlockStore;
import org.ethereum.mine.MinerIfc;
import org.ethereum.validator.block.BlockHeaderValidator;
import org.ethereum.validator.BlockHeaderValidator;
import org.ethereum.vm.DataWord;
import org.ethereum.vm.GasCost;
import org.ethereum.vm.OpCode;
Expand Down
53 changes: 12 additions & 41 deletions ethereumj-core/src/main/java/org/ethereum/config/CommonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,18 @@
import org.ethereum.manager.WorldManager;
import org.ethereum.mine.BlockMiner;
import org.ethereum.sync.FastSyncManager;
import org.ethereum.validator.block.BlockHashRule;
import org.ethereum.validator.block.BlockHeaderRule;
import org.ethereum.validator.block.BlockHeaderValidator;
import org.ethereum.validator.block.DependentBlockHeaderRule;
import org.ethereum.validator.block.DifficultyRule;
import org.ethereum.validator.block.ExtraDataRule;
import org.ethereum.validator.block.GasLimitRule;
import org.ethereum.validator.block.GasValueRule;
import org.ethereum.validator.block.ParentBlockHeaderValidator;
import org.ethereum.validator.block.ParentGasLimitRule;
import org.ethereum.validator.block.ParentNumberRule;
import org.ethereum.validator.block.ProofOfWorkRule;
import org.ethereum.validator.transaction.ReceiptValidityRule;
import org.ethereum.validator.transaction.TransactionFieldsRule;
import org.ethereum.validator.transaction.TransactionMineGasPriceRule;
import org.ethereum.validator.transaction.TransactionReceiptRule;
import org.ethereum.validator.transaction.TransactionReceiptValidator;
import org.ethereum.validator.transaction.TransactionRule;
import org.ethereum.validator.transaction.TransactionValidator;
import org.ethereum.validator.BlockHashRule;
import org.ethereum.validator.BlockHeaderRule;
import org.ethereum.validator.BlockHeaderValidator;
import org.ethereum.validator.DependentBlockHeaderRule;
import org.ethereum.validator.DifficultyRule;
import org.ethereum.validator.ExtraDataRule;
import org.ethereum.validator.GasLimitRule;
import org.ethereum.validator.GasValueRule;
import org.ethereum.validator.ParentBlockHeaderValidator;
import org.ethereum.validator.ParentGasLimitRule;
import org.ethereum.validator.ParentNumberRule;
import org.ethereum.validator.ProofOfWorkRule;
import org.ethereum.vm.DataWord;
import org.ethereum.vm.program.ProgramPrecompile;
import org.ethereum.vm.program.invoke.ProgramInvokeFactory;
Expand All @@ -59,7 +52,6 @@
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -287,27 +279,6 @@ public ParentBlockHeaderValidator parentHeaderValidator() {
return new ParentBlockHeaderValidator(rules);
}

@Bean
public TransactionValidator transactionValidator() {

List<TransactionRule> rules = new ArrayList<>(asList(
new TransactionFieldsRule(),
new TransactionMineGasPriceRule(systemProperties())
));

return new TransactionValidator(rules);
}

@Bean
public TransactionReceiptValidator transactionReceiptValidator() {

List<TransactionReceiptRule> rules = Collections.singletonList(
new ReceiptValidityRule()
);

return new TransactionReceiptValidator(rules);
}

@Bean
@Lazy
public PeerSource peerSource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.ethereum.net.rlpx.Node;
import org.ethereum.util.BuildInfo;
import org.ethereum.util.ByteUtil;
import org.ethereum.validator.block.BlockCustomHashRule;
import org.ethereum.validator.block.BlockHeaderValidator;
import org.ethereum.validator.BlockCustomHashRule;
import org.ethereum.validator.BlockHeaderValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.ethereum.db.BlockStore;
import org.ethereum.mine.EthashMiner;
import org.ethereum.mine.MinerIfc;
import org.ethereum.validator.block.BlockHeaderValidator;
import org.ethereum.validator.BlockHeaderValidator;
import org.ethereum.vm.DataWord;
import org.ethereum.vm.GasCost;
import org.ethereum.vm.OpCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
*/
package org.ethereum.config.blockchain;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.ethereum.config.BlockchainConfig;
import org.ethereum.core.BlockHeader;
import org.ethereum.core.Transaction;
import org.ethereum.validator.block.BlockHeaderRule;
import org.ethereum.validator.block.BlockHeaderValidator;
import org.ethereum.validator.block.ExtraDataPresenceRule;
import org.ethereum.validator.BlockHeaderRule;
import org.ethereum.validator.BlockHeaderValidator;
import org.ethereum.validator.ExtraDataPresenceRule;
import org.spongycastle.util.encoders.Hex;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;

/**
* Created by Stan Reshetnyk on 26.12.16.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.ethereum.db.BlockStore;
import org.ethereum.mine.MinerIfc;
import org.ethereum.util.Utils;
import org.ethereum.validator.block.BlockHeaderValidator;
import org.ethereum.validator.BlockHeaderValidator;
import org.ethereum.vm.DataWord;
import org.ethereum.vm.GasCost;
import org.ethereum.vm.OpCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@

import org.apache.commons.lang3.tuple.Pair;
import org.ethereum.config.BlockchainConfig;
import org.ethereum.validator.block.BlockCustomHashRule;
import org.ethereum.validator.block.BlockHeaderValidator;
import org.ethereum.validator.BlockCustomHashRule;
import org.ethereum.validator.BlockHeaderRule;
import org.ethereum.validator.BlockHeaderValidator;
import org.spongycastle.util.encoders.Hex;

import java.util.Arrays;
import java.util.List;

/**
* Created by Anton Nashatyrev on 21.11.2016.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.ethereum.listener.EthereumListenerAdapter;
import org.ethereum.manager.AdminInfo;
import org.ethereum.util.*;
import org.ethereum.validator.block.DependentBlockHeaderRule;
import org.ethereum.validator.block.ParentBlockHeaderValidator;
import org.ethereum.validator.DependentBlockHeaderRule;
import org.ethereum.validator.ParentBlockHeaderValidator;
import org.ethereum.vm.program.invoke.ProgramInvokeFactory;
import org.ethereum.vm.program.invoke.ProgramInvokeFactoryImpl;
import org.slf4j.Logger;
Expand Down
Loading