Skip to content

Commit

Permalink
make all complete...
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed Sep 13, 2022
1 parent db5b5c9 commit b7668bd
Show file tree
Hide file tree
Showing 46 changed files with 172 additions and 147 deletions.
7 changes: 4 additions & 3 deletions cmd/evm/internal/t8ntool/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/consensus/eccpow"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -207,7 +208,7 @@ func (i *bbInput) sealEccpow(block *types.Block) (*types.Block, error) {
}

//!!true or false? // eccpow
engine = eccpow.New(eccpow.Config{}, nil, true)
engine := eccpow.New(eccpow.Config{}, nil, true)
defer engine.Close()
// Use a buffered chan for results.
// If the testmode is used, the sealer will return quickly, and complain
Expand Down Expand Up @@ -289,7 +290,7 @@ func readInput(ctx *cli.Context) (*bbInput, error) {
ommersStr = ctx.String(InputOmmersFlag.Name)
txsStr = ctx.String(InputTxsRlpFlag.Name)
cliqueStr = ctx.String(SealCliqueFlag.Name)
eccpowOn = ctx.String(SealEccpowFlag.Name)
eccpowOn = ctx.Bool(SealEccpowFlag.Name)
ethashOn = ctx.Bool(SealEthashFlag.Name)
ethashDir = ctx.String(SealEthashDirFlag.Name)
ethashMode = ctx.String(SealEthashModeFlag.Name)
Expand All @@ -298,7 +299,7 @@ func readInput(ctx *cli.Context) (*bbInput, error) {
if ethashOn && eccpowOn && cliqueStr != "" {
return nil, NewError(ErrorConfig, fmt.Errorf("ethash and clique, eccpow sealing specified, only one may be chosen"))
}
if eccpowOn {
if eccpowOn {
inputData.Eccpow = eccpowOn
}
if ethashOn {
Expand Down
2 changes: 1 addition & 1 deletion cmd/puppeth/wizard_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (w *wizard) makeGenesis() {
}
case choice == "3":
// In case of eccpow, we're pretty much done
genesis.Config.EccPoW = new(params.EccPoWConfig)
genesis.Config.Eccpow = new(params.EccpowConfig)
genesis.ExtraData = make([]byte, 32)

default:
Expand Down
2 changes: 1 addition & 1 deletion cmd/puppeth/wizard_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (w *wizard) deployNode(boot bool) {
return
}
}
} else if w.conf.Genesis.Config.EccPoW != nil {
} else if w.conf.Genesis.Config.Eccpow != nil {
// Ethash based miners only need an etherbase to mine against
fmt.Println()
if infos.etherbase == "" {
Expand Down
5 changes: 2 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/cryptoecc/ETH-ECC/consensus/eccpow"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/vm"
Expand Down Expand Up @@ -154,11 +153,11 @@ var (
Category: flags.EthCategory,
}
// EccPoW settings
LveFlag = cli.BoolFlag{
LveFlag = &cli.BoolFlag{
Name: "lve",
Usage: "LVE Network: Error-Correction Codes Proof-of-Work Main Network",
}
LvetestFlag = cli.BoolFlag{
LvetestFlag = &cli.BoolFlag{
Name: "lvetest",
Usage: "LVE test network: Error-Correction Codes Proof-of-Work Test Network",
}
Expand Down
4 changes: 2 additions & 2 deletions consensus/eccpow/LDPCDecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/binary"
"math"

"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/crypto"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
)

//OptimizedDecoding return hashVector, outputWord, LRrtl
Expand Down
2 changes: 1 addition & 1 deletion consensus/eccpow/LDPCDecoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"testing"

"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/ethereum/go-ethereum/core/types"
)

func TestNonceDecoding(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion consensus/eccpow/LDPCDifficulty.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"math"
"math/big"

"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/ethereum/go-ethereum/core/types"
)

/*
Expand Down
2 changes: 1 addition & 1 deletion consensus/eccpow/LDPCDifficulty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/ethereum/go-ethereum/core/types"
)

func TestTablePrint(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion consensus/eccpow/LDPC_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"math/big"
"math/rand"

"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/ethereum/go-ethereum/core/types"
)

//Parameters for matrix and seed
Expand Down
16 changes: 7 additions & 9 deletions consensus/eccpow/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ import (
"math/big"
"math/rand"

//"reflect"

"sync"
"time"

"github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/consensus"
"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/metrics"
"github.com/cryptoecc/ETH-ECC/rpc"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/rpc"
)

type ECC struct {
Expand Down Expand Up @@ -454,7 +452,7 @@ func (ecc *ECC) Hashrate() float64 {
}

// APIs implements consensus.Engine, returning the user facing RPC APIs.
func (ecc *ECC) APIs(chain consensus.ChainReader) []rpc.API {
func (ecc *ECC) APIs(chain consensus.ChainHeaderReader) []rpc.API {
// In order to ensure backward compatibility, we exposes ecc RPC APIs
// to both eth and ecc namespaces.
return []rpc.API{
Expand Down
6 changes: 3 additions & 3 deletions consensus/eccpow/algorithm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"reflect"
"testing"

"github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
)

func TestRandomSeed(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions consensus/eccpow/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package eccpow
import (
"errors"

"github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
)

var erreccStopped = errors.New("ecc stopped")
Expand Down
61 changes: 37 additions & 24 deletions consensus/eccpow/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ import (
"runtime"
"time"

"github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/consensus"
"github.com/cryptoecc/ETH-ECC/consensus/misc"
"github.com/cryptoecc/ETH-ECC/core/state"
"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/params"
"github.com/cryptoecc/ETH-ECC/rlp"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
mapset "github.com/deckarep/golang-set"
"golang.org/x/crypto/sha3"
)
Expand Down Expand Up @@ -81,7 +82,7 @@ func (ecc *ECC) Author(header *types.Header) (common.Address, error) {

// VerifyHeader checks whether a header conforms to the consensus rules of the
// stock Ethereum ecc engine.
func (ecc *ECC) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error {
func (ecc *ECC) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error {
// If we're running a full engine faking, accept any input as valid
if ecc.config.PowMode == ModeFullFake {
return nil
Expand All @@ -102,7 +103,7 @@ func (ecc *ECC) VerifyHeader(chain consensus.ChainReader, header *types.Header,
// VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers
// concurrently. The method returns a quit channel to abort the operations and
// a results channel to retrieve the async verifications.
func (ecc *ECC) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error) {
func (ecc *ECC) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error) {
// If we're running a full engine faking, accept any input as valid
if ecc.config.PowMode == ModeFullFake || len(headers) == 0 {
abort, results := make(chan struct{}), make(chan error, len(headers))
Expand Down Expand Up @@ -163,7 +164,7 @@ func (ecc *ECC) VerifyHeaders(chain consensus.ChainReader, headers []*types.Head
return abort, errorsOut
}

func (ecc *ECC) verifyHeaderWorker(chain consensus.ChainReader, headers []*types.Header, seals []bool, index int) error {
func (ecc *ECC) verifyHeaderWorker(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool, index int) error {
var parent *types.Header
if index == 0 {
parent = chain.GetHeader(headers[0].ParentHash, headers[0].Number.Uint64()-1)
Expand All @@ -190,20 +191,32 @@ func (ecc *ECC) VerifyUncles(chain consensus.ChainReader, block *types.Block) er
if len(block.Uncles()) > maxUncles {
return errTooManyUncles
}
if len(block.Uncles()) == 0 {
return nil
}
// Gather the set of past uncles and ancestors
uncles, ancestors := mapset.NewSet(), make(map[common.Hash]*types.Header)

number, parent := block.NumberU64()-1, block.ParentHash()

for i := 0; i < 7; i++ {
ancestor := chain.GetBlock(parent, number)
if ancestor == nil {
ancestorHeader := chain.GetHeader(parent, number)
if ancestorHeader == nil {
break
}
ancestors[ancestor.Hash()] = ancestor.Header()
for _, uncle := range ancestor.Uncles() {
uncles.Add(uncle.Hash())
ancestors[parent] = ancestorHeader
// If the ancestor doesn't have any uncles, we don't have to iterate them
if ancestorHeader.UncleHash != types.EmptyUncleHash {
// Need to add those uncles to the banned list too
ancestor := chain.GetBlock(parent, number)
if ancestor == nil {
break
}
for _, uncle := range ancestor.Uncles() {
uncles.Add(uncle.Hash())
}
}
parent, number = ancestor.ParentHash(), number-1
parent, number = ancestorHeader.ParentHash, number-1
}
ancestors[block.Hash()] = block.Header()
uncles.Add(block.Hash())
Expand Down Expand Up @@ -234,7 +247,7 @@ func (ecc *ECC) VerifyUncles(chain consensus.ChainReader, block *types.Block) er
// verifyHeader checks whether a header conforms to the consensus rules of the
// stock Ethereum ecc engine.
// See YP section 4.3.4. "Block Header Validity"
func (ecc *ECC) verifyHeader(chain consensus.ChainReader, header, parent *types.Header, uncle bool, seal bool) error {
func (ecc *ECC) verifyHeader(chain consensus.ChainHeaderReader, header, parent *types.Header, uncle bool, seal bool) error {
// Ensure that the header's extra-data section is of a reasonable size
if uint64(len(header.Extra)) > params.MaximumExtraDataSize {
return fmt.Errorf("extra-data too long: %d > %d", len(header.Extra), params.MaximumExtraDataSize)
Expand Down Expand Up @@ -298,7 +311,7 @@ func (ecc *ECC) verifyHeader(chain consensus.ChainReader, header, parent *types.
// CalcDifficulty is the difficulty adjustment algorithm. It returns
// the difficulty that a new block should have when created at time
// given the parent block's time and difficulty.
func (ecc *ECC) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int {
func (ecc *ECC) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int {
return CalcDifficulty(chain.Config(), time, parent)
}

Expand Down Expand Up @@ -487,14 +500,14 @@ func calcDifficultyFrontier(time uint64, parent *types.Header) *big.Int {

// VerifySeal implements consensus.Engine, checking whether the given block satisfies
// the PoW difficulty requirements.
func (ecc *ECC) VerifySeal(chain consensus.ChainReader, header *types.Header) error {
func (ecc *ECC) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error {
return ecc.verifySeal(chain, header, false)
}

// verifySeal checks whether a block satisfies the PoW difficulty requirements,
// either using the usual ecc cache for it, or alternatively using a full DAG
// to make remote mining fast.
func (ecc *ECC) verifySeal(chain consensus.ChainReader, header *types.Header, fulldag bool) error {
func (ecc *ECC) verifySeal(chain consensus.ChainHeaderReader, header *types.Header, fulldag bool) error {
// If we're running a fake PoW, accept any seal as valid
if ecc.config.PowMode == ModeFake || ecc.config.PowMode == ModeFullFake {
time.Sleep(ecc.fakeDelay)
Expand Down Expand Up @@ -548,7 +561,7 @@ func (ecc *ECC) verifySeal(chain consensus.ChainReader, header *types.Header, fu

// Prepare implements consensus.Engine, initializing the difficulty field of a
// header to conform to the ecc protocol. The changes are done inline.
func (ecc *ECC) Prepare(chain consensus.ChainReader, header *types.Header) error {
func (ecc *ECC) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error {
parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1)
if parent == nil {
return consensus.ErrUnknownAncestor
Expand All @@ -559,19 +572,19 @@ func (ecc *ECC) Prepare(chain consensus.ChainReader, header *types.Header) error

// Finalize implements consensus.Engine, accumulating the block and uncle rewards,
// setting the final state and assembling the block.
func (ecc *ECC) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) {
func (ecc *ECC) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) {
// Accumulate any block and uncle rewards and commit the final state root
accumulateRewards(chain.Config(), state, header, uncles)
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
}

func (ecc *ECC) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
func (ecc *ECC) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
// Accumulate any block and uncle rewards and commit the final state root
accumulateRewards(chain.Config(), state, header, uncles)
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))

// Header seems complete, assemble into a block and return
return types.NewBlock(header, txs, uncles, receipts), nil
return types.NewBlock(header, txs, uncles, receipts, trie.NewStackTrie(nil)), nil
}

// SealHash returns the hash of a block prior to it being sealed.
Expand Down
8 changes: 4 additions & 4 deletions consensus/eccpow/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"path/filepath"
"testing"

"github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/math"
"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/params"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
)

type diffTest struct {
Expand Down
12 changes: 6 additions & 6 deletions consensus/eccpow/sealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
"sync"
"time"

"github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/consensus"
"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
)

const (
Expand All @@ -49,7 +49,7 @@ var (

// Seal implements consensus.Engine, attempting to find a nonce that satisfies
// the block's difficulty requirements.
func (ecc *ECC) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
func (ecc *ECC) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
// If we're running a fake PoW, simply return a 0 nonce immediately
if ecc.config.PowMode == ModeFake || ecc.config.PowMode == ModeFullFake {
header := block.Header()
Expand Down
4 changes: 2 additions & 2 deletions consensus/eccpow/sealer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"testing"
"time"

"github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/core/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)

// Tests whether remote HTTP servers are correctly notified of new work.
Expand Down
2 changes: 1 addition & 1 deletion dashboard/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package dashboard
import (
"syscall"

"github.com/cryptoecc/ETH-ECC/log"
"github.com/ethereum/go-ethereum/log"
)

// getProcessCPUTime retrieves the process' CPU time since program startup.
Expand Down
Loading

0 comments on commit b7668bd

Please sign in to comment.