Skip to content

Commit

Permalink
Merge branch 'develop' into p2p-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
dCanyon authored Jan 25, 2019
2 parents 9da40b1 + 225477d commit 21ed79a
Show file tree
Hide file tree
Showing 20 changed files with 2,667 additions and 161 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ swarm:
all:
build/env.sh go run build/ci.go install

puppeth:
build/env.sh go run build/ci.go install ./cmd/puppeth
@echo "Done building."
@echo "Run \"$(GOBIN)/puppeth\" to launch puppeth."

android:
build/env.sh go run build/ci.go aar --local
@echo "Done building."
Expand Down
7 changes: 6 additions & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import (
"github.com/Onther-Tech/plasma-evm/core/state"
"github.com/Onther-Tech/plasma-evm/core/types"
"github.com/Onther-Tech/plasma-evm/core/vm"
"github.com/Onther-Tech/plasma-evm/pls/filters"
"github.com/Onther-Tech/plasma-evm/ethdb"
"github.com/Onther-Tech/plasma-evm/event"
"github.com/Onther-Tech/plasma-evm/params"
"github.com/Onther-Tech/plasma-evm/pls/filters"
"github.com/Onther-Tech/plasma-evm/rpc"
)

Expand Down Expand Up @@ -158,6 +158,11 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
return val[:], nil
}

// CurrentBlock returns current block number.
func (b *SimulatedBackend) CurrentBlock() *big.Int {
return b.blockchain.CurrentBlock().Number()
}

// TransactionReceipt returns the receipt of a transaction.
func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
receipt, _, _, _ := rawdb.ReadReceipt(b.database, txHash)
Expand Down
13 changes: 12 additions & 1 deletion cmd/puppeth/wizard_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ func (w *wizard) makeGenesis() {
case choice == "1":
// In case of ethash, we're pretty much done
genesis.Config.Ethash = new(params.EthashConfig)
genesis.ExtraData = make([]byte, 32)
genesis.ExtraData = make([]byte, 20)
genesis.Difficulty = big.NewInt(1)

// Query for the rootchain contract
fmt.Println()
fmt.Println("What is the rootchain contract address?")
var rootchain []common.Address
if address := w.readAddress(); address != nil {
rootchain = append(rootchain, *address)
}
copy(genesis.ExtraData[:common.AddressLength], rootchain[0][:])

case choice == "" || choice == "2":
// In the case of clique, configure the consensus parameters
Expand Down Expand Up @@ -127,6 +137,7 @@ func (w *wizard) makeGenesis() {
genesis.Alloc[common.BigToAddress(big.NewInt(i))] = core.GenesisAccount{Balance: big.NewInt(1)}
}
}

// Query the user for some custom extras
fmt.Println()
fmt.Println("Specify your chain/network ID if you want an explicit one (default = random)")
Expand Down
10 changes: 7 additions & 3 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"runtime"
"time"

mapset "github.com/deckarep/golang-set"
"github.com/Onther-Tech/plasma-evm/common"
"github.com/Onther-Tech/plasma-evm/common/math"
"github.com/Onther-Tech/plasma-evm/consensus"
Expand All @@ -34,6 +33,7 @@ import (
"github.com/Onther-Tech/plasma-evm/crypto/sha3"
"github.com/Onther-Tech/plasma-evm/params"
"github.com/Onther-Tech/plasma-evm/rlp"
mapset "github.com/deckarep/golang-set"
)

// Ethash proof-of-work protocol constants.
Expand Down Expand Up @@ -254,12 +254,13 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
if header.Time.Cmp(parent.Time) <= 0 {
return errZeroBlockTime
}
// Verify the block's difficulty based in it's timestamp and parent's difficulty
// Verify the block's fork number by difficulty
expected := ethash.CalcDifficulty(chain, header.Time.Uint64(), parent)

if expected.Cmp(header.Difficulty) != 0 {
if expected.Cmp(header.Difficulty) != 0 && new(big.Int).Sub(header.Difficulty, expected).Cmp(big.NewInt(1)) != 0 {
return fmt.Errorf("invalid difficulty: have %v, want %v", header.Difficulty, expected)
}

// Verify that the gas limit is <= 2^63-1
cap := uint64(0x7fffffffffffffff)
if header.GasLimit > cap {
Expand Down Expand Up @@ -304,6 +305,9 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
// the difficulty that a new block should have when created at time
// given the parent block's time and difficulty.
func (ethash *Ethash) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int {
if ethash.config.PowMode == ModeFake || ethash.config.PowMode == ModeFullFake {
return new(big.Int).Set(parent.Difficulty)
}
return CalcDifficulty(chain.Config(), time, parent)
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/plasma/plasma-evm-cotracts
90 changes: 84 additions & 6 deletions contracts/plasma/rootchain/rootchain.go

Large diffs are not rendered by default.

Loading

0 comments on commit 21ed79a

Please sign in to comment.