Skip to content
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

Cleanup for latest go-ethereum merge #29

Open
wants to merge 2 commits into
base: aura-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/utils/flags.go
Expand Up @@ -33,8 +33,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/consensus/aura"
"github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
Expand Down Expand Up @@ -146,7 +146,7 @@ var (
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
}
GoerliFlag = cli.BoolFlag{
Name: "goerli",
Name: "goerli",
Usage: "Goerli network: pre-configured proof-of-authority test network",
}
DeveloperPeriodFlag = cli.IntFlag{
Expand Down
12 changes: 6 additions & 6 deletions consensus/aura/api.go
Expand Up @@ -17,17 +17,17 @@
package aura

import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/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/rpc"
)

// API is a user facing RPC API to allow controlling the signer and voting
// mechanisms of the proof-of-authority scheme.
type API struct {
chain consensus.ChainReader
aura *Aura
chain consensus.ChainReader
aura *Aura
}

// GetSnapshot retrieves the state snapshot at a given block.
Expand Down
7 changes: 3 additions & 4 deletions consensus/aura/aura.go
Expand Up @@ -190,7 +190,7 @@ func ecrecover(header *types.Header, sigcache *lru.ARCCache) (common.Address, er
// Ethereum testnet following the Ropsten attacks.
type Aura struct {
config *params.AuraConfig // Consensus engine configuration parameters
db ethdb.Database // Database to store and retrieve snapshot checkpoints
db ethdb.Database // Database to store and retrieve snapshot checkpoints

recents *lru.ARCCache // Snapshots for recent block to speed up reorgs
signatures *lru.ARCCache // Signatures of recent blocks to speed up mining
Expand Down Expand Up @@ -537,7 +537,7 @@ func (a *Aura) Prepare(chain consensus.ChainReader, header *types.Header) error
// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
// rewards given, and returns the final block.
func (a *Aura) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
state.AddBalance(a.signer, big.NewInt(5 * (10 ^ 18)))
state.AddBalance(a.signer, big.NewInt(5*(10^18)))
trustfarm-dev marked this conversation as resolved.
Show resolved Hide resolved
// No block rewards in PoA, so the state remains as is and uncles are dropped
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
header.UncleHash = types.CalcUncleHash(nil)
Expand Down Expand Up @@ -575,7 +575,6 @@ func (a *Aura) Seal(chain consensus.ChainReader, block *types.Block, results cha
signer, signFn := a.signer, a.signFn
a.lock.RUnlock()


// check if authorized to sign
step := uint64(time.Now().Unix()) % a.config.Period
turn := step % uint64(len(a.config.Authorities))
Expand Down Expand Up @@ -661,4 +660,4 @@ func (a *Aura) APIs(chain consensus.ChainReader) []rpc.API {
Service: &API{chain: chain, aura: a},
Public: false,
}}
}
}
19 changes: 9 additions & 10 deletions consensus/aura/snapshot.go
Expand Up @@ -17,15 +17,15 @@
package aura

import (
"bytes"
"encoding/json"
"sort"
"bytes"
"encoding/json"
"sort"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
lru "github.com/hashicorp/golang-lru"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
lru "github.com/hashicorp/golang-lru"
)

// Vote represents a single vote that an authorized signer made to modify the
Expand All @@ -47,7 +47,7 @@ type Tally struct {
// Snapshot is the state of the authorization voting at a given point in time.
type Snapshot struct {
config *params.AuraConfig // Consensus engine parameters to fine tune behavior
sigcache *lru.ARCCache // Cache of recent block signatures to speed up ecrecover
sigcache *lru.ARCCache // Cache of recent block signatures to speed up ecrecover

Number uint64 `json:"number"` // Block number where the snapshot was created
Hash common.Hash `json:"hash"` // Block hash where the snapshot was created
Expand Down Expand Up @@ -310,4 +310,3 @@ func (s *Snapshot) inturn(number uint64, signer common.Address) bool {
}
return (number % uint64(len(signers))) == uint64(offset)
}

3 changes: 1 addition & 2 deletions core/genesis.go
Expand Up @@ -235,7 +235,6 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
}
root := statedb.IntermediateRoot(false)


head := &types.Header{
Number: new(big.Int).SetUint64(g.Number),
Nonce: types.EncodeNonce(g.Nonce),
Expand All @@ -261,7 +260,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
if g.Difficulty == nil {
head.Difficulty = params.GenesisDifficulty
}
data,_ := rlp.EncodeToBytes(head)
data, _ := rlp.EncodeToBytes(head)
fmt.Printf("Genesis header rlp %v\n", common.Bytes2Hex(data))

statedb.Commit(false)
Expand Down
2 changes: 1 addition & 1 deletion core/genesis_alloc.go

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions core/types/block.go
Expand Up @@ -67,21 +67,21 @@ func (n *BlockNonce) UnmarshalText(input []byte) error {

//go:generate gencodec -type Header -field-override headerMarshaling -out gen_header_json.go
type AuraHeader struct {
ParentHash common.Hash `json:"parentHash" gencodec:"required"`
UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"`
Coinbase common.Address `json:"miner" gencodec:"required"`
Root common.Hash `json:"stateRoot" gencodec:"required"`
TxHash common.Hash `json:"transactionsRoot" gencodec:"required"`
ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"`
Bloom Bloom `json:"logsBloom" gencodec:"required"`
Difficulty *big.Int `json:"difficulty" gencodec:"required"`
Number *big.Int `json:"number" gencodec:"required"`
GasLimit uint64 `json:"gasLimit" gencodec:"required"`
GasUsed uint64 `json:"gasUsed" gencodec:"required"`
Time *big.Int `json:"timestamp" gencodec:"required"`
Extra []byte `json:"extraData" gencodec:"required"`
Signature1 []byte `json:"signature1,omitempty"`
Signature2 []byte `json:"signature2,omitempty"`
ParentHash common.Hash `json:"parentHash" gencodec:"required"`
UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"`
Coinbase common.Address `json:"miner" gencodec:"required"`
Root common.Hash `json:"stateRoot" gencodec:"required"`
TxHash common.Hash `json:"transactionsRoot" gencodec:"required"`
ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"`
Bloom Bloom `json:"logsBloom" gencodec:"required"`
Difficulty *big.Int `json:"difficulty" gencodec:"required"`
Number *big.Int `json:"number" gencodec:"required"`
GasLimit uint64 `json:"gasLimit" gencodec:"required"`
GasUsed uint64 `json:"gasUsed" gencodec:"required"`
Time *big.Int `json:"timestamp" gencodec:"required"`
Extra []byte `json:"extraData" gencodec:"required"`
Signature1 []byte `json:"signature1,omitempty"`
Signature2 []byte `json:"signature2,omitempty"`
}

// Header represents a block header in the Ethereum blockchain.
Expand Down
4 changes: 2 additions & 2 deletions eth/backend.go
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/aura"
"github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
Expand All @@ -49,7 +50,6 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/consensus/aura"
)

type LesServer interface {
Expand Down Expand Up @@ -222,7 +222,7 @@ func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainCo
if chainConfig.Clique != nil {
return clique.New(chainConfig.Clique, db)
} else if chainConfig.Aura != nil {
return aura.New(chainConfig.Aura, db)
return aura.New(chainConfig.Aura, db)
}
// Otherwise assume proof-of-work
switch config.PowMode {
Expand Down
2 changes: 1 addition & 1 deletion params/bootnodes.go
Expand Up @@ -62,4 +62,4 @@ var DiscoveryV5Bootnodes = []string{
"enode://0cc5f5ffb5d9098c8b8c62325f3797f56509bff942704687b6530992ac706e2cb946b90a34f1f19548cd3c7baccbcaea354531e5983c7d1bc0dee16ce4b6440b@40.118.3.223:30304",
"enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30306",
"enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30307",
}
}
2 changes: 1 addition & 1 deletion params/config.go
Expand Up @@ -172,7 +172,7 @@ type AuraConfig struct {
Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint
Authorities []common.Address `json:"authorities"` // list of addresses of authorities
Difficulty *big.Int `json:"difficulty"` // Constant block difficulty
Signatures Signatures `json:"signatures"`
Signatures Signatures `json:"signatures"`
}

// String implements the stringer interface, returning the consensus engine details.
Expand Down