Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ jobs:
GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d')
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth -a ./cmd/geth

- name: Temporary replace BLS for Windows
if: matrix.os == 'windows-latest'
shell: cmd
run: go mod edit -replace=github.com/herumi/bls-eth-go-binary=github.com/herumi/bls-eth-go-binary@v0.0.0-20210917013441-d37c07cfda4e && go mod tidy

- name: Build Binary for ${{matrix.os}}
if: matrix.os != 'ubuntu-latest'
run: |
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ jobs:
GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d')
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth -a ./cmd/geth

# ==============================
- name: Temporary replace BLS for Windows
if: matrix.os == 'windows-latest'
shell: cmd
run: go mod edit -replace=github.com/herumi/bls-eth-go-binary=github.com/herumi/bls-eth-go-binary@v0.0.0-20210917013441-d37c07cfda4e && go mod tidy

- name: Build Binary for ${{matrix.os}}
if: matrix.os != 'ubuntu-latest'
run: |
Expand Down
1 change: 0 additions & 1 deletion accounts/keystore/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//go:build (darwin && !ios && cgo) || freebsd || (linux && !arm64) || netbsd || solaris
// +build darwin,!ios,cgo freebsd linux,!arm64 netbsd solaris

package keystore

Expand Down
1 change: 0 additions & 1 deletion accounts/keystore/watch_fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//go:build (darwin && !cgo) || ios || (linux && arm64) || windows || (!darwin && !freebsd && !linux && !netbsd && !solaris)
// +build darwin,!cgo ios linux,arm64 windows !darwin,!freebsd,!linux,!netbsd,!solaris

// This is the fallback implementation of directory watching.
// It is used on unsupported platforms.
Expand Down
24 changes: 15 additions & 9 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var (
utils.OverrideMaxwell,
utils.OverrideFermi,
utils.OverrideOsaka,
utils.OverrideMendel,
utils.OverrideVerkle,
// utils.MultiDataBaseFlag,
}, utils.DatabaseFlags),
Expand Down Expand Up @@ -349,6 +350,10 @@ func initGenesis(ctx *cli.Context) error {
v := ctx.Uint64(utils.OverrideOsaka.Name)
overrides.OverrideOsaka = &v
}
if ctx.IsSet(utils.OverrideMendel.Name) {
v := ctx.Uint64(utils.OverrideMendel.Name)
overrides.OverrideMendel = &v
}
if ctx.IsSet(utils.OverrideVerkle.Name) {
v := ctx.Uint64(utils.OverrideVerkle.Name)
overrides.OverrideVerkle = &v
Expand Down Expand Up @@ -451,7 +456,7 @@ func createPorts(ipStr string, port int, size int) []int {
}

// Create config for node i in the cluster
func createNodeConfig(baseConfig gethConfig, ip string, port int, enodes []*enode.Node, index int, staticConnect bool) gethConfig {
func createNodeConfig(baseConfig gethConfig, prefix string, ip string, port int, enodes []*enode.Node, index int) gethConfig {
baseConfig.Node.HTTPHost = ip
baseConfig.Node.P2P.ListenAddr = fmt.Sprintf(":%d", port)
connectEnodes := make([]*enode.Node, 0, len(enodes)-1)
Expand All @@ -462,9 +467,10 @@ func createNodeConfig(baseConfig gethConfig, ip string, port int, enodes []*enod
connectEnodes = append(connectEnodes, enodes[j])
}
// Set the P2P connections between this node and the other nodes
if staticConnect {
baseConfig.Node.P2P.StaticNodes = connectEnodes
} else {
baseConfig.Node.P2P.StaticNodes = connectEnodes
if prefix == "fullnode" {
// Fullnodes may reside in different regions than the `enodes`.
// StaticNodes cannot connect to them directly, but can still discover them.
baseConfig.Node.P2P.BootstrapNodes = connectEnodes
}
return baseConfig
Expand Down Expand Up @@ -539,7 +545,7 @@ func initNetwork(ctx *cli.Context) error {
connectOneExtraEnodes = true
}

configs, enodes, accounts, err := createConfigs(config, initDir, "node", ips, ports, sentryEnodes, connectOneExtraEnodes, true)
configs, enodes, accounts, err := createConfigs(config, initDir, "node", ips, ports, sentryEnodes, connectOneExtraEnodes)
if err != nil {
utils.Fatalf("Failed to create node configs: %v", err)
}
Expand Down Expand Up @@ -620,7 +626,7 @@ func createSentryNodeConfigs(ctx *cli.Context, baseConfig gethConfig, initDir st
if err != nil {
utils.Fatalf("Failed to parse ports: %v", err)
}
configs, enodes, _, err := createConfigs(baseConfig, initDir, "sentry", ips, ports, nil, false, true)
configs, enodes, _, err := createConfigs(baseConfig, initDir, "sentry", ips, ports, nil, false)
if err != nil {
utils.Fatalf("Failed to create config: %v", err)
}
Expand All @@ -643,7 +649,7 @@ func createAndSaveFullNodeConfigs(ctx *cli.Context, inGenesisFile *os.File, base
utils.Fatalf("Failed to parse ports: %v", err)
}

configs, enodes, _, err := createConfigs(baseConfig, initDir, "fullnode", ips, ports, extraEnodes, false, false)
configs, enodes, _, err := createConfigs(baseConfig, initDir, "fullnode", ips, ports, extraEnodes, false)
if err != nil {
utils.Fatalf("Failed to create config: %v", err)
}
Expand All @@ -658,7 +664,7 @@ func createAndSaveFullNodeConfigs(ctx *cli.Context, inGenesisFile *os.File, base
return configs, enodes, nil
}

func createConfigs(base gethConfig, initDir string, prefix string, ips []string, ports []int, extraEnodes []*enode.Node, connectOneExtraEnodes bool, staticConnect bool) ([]gethConfig, []*enode.Node, [][]common.Address, error) {
func createConfigs(base gethConfig, initDir string, prefix string, ips []string, ports []int, extraEnodes []*enode.Node, connectOneExtraEnodes bool) ([]gethConfig, []*enode.Node, [][]common.Address, error) {
if len(ips) != len(ports) {
return nil, nil, nil, errors.New("mismatch of size and length of ports")
}
Expand Down Expand Up @@ -689,7 +695,7 @@ func createConfigs(base gethConfig, initDir string, prefix string, ips []string,
allEnodes = []*enode.Node{enodes[i], extraEnodes[i]}
index = 0
}
configs[i] = createNodeConfig(base, ips[i], ports[i], allEnodes, index, staticConnect)
configs[i] = createNodeConfig(base, prefix, ips[i], ports[i], allEnodes, index)
}
return configs, enodes, accounts, nil
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
v := ctx.Uint64(utils.OverrideOsaka.Name)
cfg.Eth.OverrideOsaka = &v
}
if ctx.IsSet(utils.OverrideMendel.Name) {
v := ctx.Uint64(utils.OverrideMendel.Name)
cfg.Eth.OverrideMendel = &v
}
if ctx.IsSet(utils.OverrideVerkle.Name) {
v := ctx.Uint64(utils.OverrideVerkle.Name)
cfg.Eth.OverrideVerkle = &v
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var (
utils.OverrideMaxwell,
utils.OverrideFermi,
utils.OverrideOsaka,
utils.OverrideMendel,
utils.OverrideVerkle,
utils.OverrideFullImmutabilityThreshold,
utils.OverrideMinBlocksForBlobRequests,
Expand Down
53 changes: 48 additions & 5 deletions cmd/jsutils/getchainstatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,53 @@ async function getBinaryVersion() {
let turnLength = program.turnLength;
for (let i = 0; i < program.num; i++) {
let blockData = await provider.getBlock(blockNum - i * turnLength);
// 1.get Geth client version
let major = ethers.toNumber(ethers.dataSlice(blockData.extraData, 2, 3));
let minor = ethers.toNumber(ethers.dataSlice(blockData.extraData, 3, 4));
let patch = ethers.toNumber(ethers.dataSlice(blockData.extraData, 4, 5));

let major = 0, minor = 0, patch = 0;
let commitID = "";

try {
major = ethers.toNumber(ethers.dataSlice(blockData.extraData, 2, 3));
minor = ethers.toNumber(ethers.dataSlice(blockData.extraData, 3, 4));
patch = ethers.toNumber(ethers.dataSlice(blockData.extraData, 4, 5));

// Check version: >= 1.6.4 uses new format with commitID
const isNewFormat = major > 1 || (major === 1 && minor > 6) || (major === 1 && minor === 6 && patch >= 4);

if (isNewFormat) {
const extraVanity = 28;
let vanityBytes = ethers.getBytes(ethers.dataSlice(blockData.extraData, 0, extraVanity));

let rlpLength = vanityBytes.length;
if (vanityBytes[0] >= 0xC0 && vanityBytes[0] <= 0xF7) {
rlpLength = (vanityBytes[0] - 0xC0) + 1;
}

const rlpData = ethers.dataSlice(blockData.extraData, 0, rlpLength);
const decoded = ethers.decodeRlp(rlpData);

if (Array.isArray(decoded) && decoded.length >= 2) {
const secondElemHex = decoded[1];
let secondElemStr = "";
try {
secondElemStr = ethers.toUtf8String(secondElemHex);
} catch (e) {
secondElemStr = secondElemHex;
}

if (secondElemStr.length > 0 && secondElemStr !== "geth") {
commitID = secondElemStr.startsWith("0x") ? secondElemStr.substring(2) : secondElemStr;
}
}
}
} catch (e) {
console.log("Parsing failed:", e.message);
}

// Format version string
let versionStr = major + "." + minor + "." + patch;
if (commitID && commitID.length > 0) {
versionStr = versionStr + "-" + commitID;
}

// 2.get minimum txGasPrice based on the last non-zero-gasprice transaction
let lastGasPrice = 0;
Expand All @@ -332,7 +375,7 @@ async function getBinaryVersion() {
break;
}
var moniker = await getValidatorMoniker(blockData.miner, blockNum);
console.log(blockNum - i * turnLength, blockData.miner, "version =", major + "." + minor + "." + patch, " MinGasPrice = " + lastGasPrice, moniker);
console.log(blockNum - i * turnLength, blockData.miner, "version =", versionStr, " MinGasPrice = " + lastGasPrice, moniker);
}
}

Expand Down
1 change: 0 additions & 1 deletion cmd/utils/diskusage.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.

//go:build !windows && !openbsd && !wasip1
// +build !windows,!openbsd,!wasip1

package utils

Expand Down
1 change: 0 additions & 1 deletion cmd/utils/diskusage_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.

//go:build openbsd
// +build openbsd

package utils

Expand Down
5 changes: 5 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ var (
Usage: "Manually specify the Osaka fork timestamp, overriding the bundled setting",
Category: flags.EthCategory,
}
OverrideMendel = &cli.Uint64Flag{
Name: "override.mendel",
Usage: "Manually specify the Mendel fork timestamp, overriding the bundled setting",
Category: flags.EthCategory,
}
OverrideVerkle = &cli.Uint64Flag{
Name: "override.verkle",
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",
Expand Down
1 change: 0 additions & 1 deletion common/fdlimit/fdlimit_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//go:build freebsd || dragonfly
// +build freebsd dragonfly

package fdlimit

Expand Down
1 change: 0 additions & 1 deletion common/fdlimit/fdlimit_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//go:build linux || netbsd || openbsd || solaris
// +build linux netbsd openbsd solaris

package fdlimit

Expand Down
2 changes: 1 addition & 1 deletion consensus/misc/eip4844/eip4844.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func CalcExcessBlobGas(config *params.ChainConfig, parent *types.Header, headTim
func CalcBlobFee(config *params.ChainConfig, header *types.Header) *big.Int {
var frac uint64
switch config.LatestFork(header.Time) {
case forks.Osaka:
case forks.Mendel, forks.Osaka:
frac = config.BlobScheduleConfig.Osaka.UpdateFraction
case forks.Fermi, forks.Maxwell, forks.Lorentz, forks.Prague:
frac = config.BlobScheduleConfig.Prague.UpdateFraction
Expand Down
18 changes: 18 additions & 0 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ var (
validVotesfromSelfCounter = metrics.NewRegisteredCounter("parlia/VerifyVote/self", nil)
doubleSignCounter = metrics.NewRegisteredCounter("parlia/doublesign", nil)
intentionalDelayMiningCounter = metrics.NewRegisteredCounter("parlia/intentionalDelayMining", nil)
attestationVoteCountGauge = metrics.NewRegisteredGauge("parlia/attestation/voteCount", nil)

systemContracts = map[common.Address]bool{
common.HexToAddress(systemcontracts.ValidatorContract): true,
Expand Down Expand Up @@ -1698,6 +1699,23 @@ func (p *Parlia) Delay(chain consensus.ChainReader, header *types.Header, leftOv
return &delay
}

// AssembleSignature assemble the signature for block header
func (p *Parlia) AssembleSignature(block *types.Block) (*types.Block, error) {
header := block.Header()
// Don't hold the val fields for the entire sealing procedure
p.lock.RLock()
val, signFn := p.val, p.signFn
p.lock.RUnlock()
sig, err := signFn(accounts.Account{Address: val}, accounts.MimetypeParlia, ParliaRLP(header, p.chainConfig.ChainID))
if err != nil {
log.Error("Sign for the block header failed when sealing", "err", err)
return nil, err
}
copy(header.Extra[len(header.Extra)-extraSeal:], sig)
block = block.WithSeal(header)
return block, nil
}

// Seal implements consensus.Engine, attempting to create a sealed block using
// the local signing credentials.
func (p *Parlia) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
Expand Down
5 changes: 5 additions & 0 deletions consensus/parlia/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/willf/bitset"
)

// Snapshot is the state of the validatorSet at a given point.
Expand Down Expand Up @@ -219,6 +220,10 @@ func (s *Snapshot) updateAttestation(header *types.Header, chainConfig *params.C
}
}

// Update vote count metric after validation passed
voteCount := bitset.From([]uint64{uint64(attestation.VoteAddressSet)}).Count()
attestationVoteCountGauge.Update(int64(voteCount))

// Update attestation
// Two scenarios for s.Attestation being nil:
// 1) The first attestation is assembled.
Expand Down
10 changes: 5 additions & 5 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1997,18 +1997,18 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.

// WriteBlockAndSetHead writes the given block and all associated state to the database,
// and applies the block as the new chain head.
func (bc *BlockChain) WriteBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, sealedBlockSender *event.TypeMux) (status WriteStatus, err error) {
func (bc *BlockChain) WriteBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, sealedBlockSender *event.TypeMux, delayBroadcast bool) (status WriteStatus, err error) {
if !bc.chainmu.TryLock() {
return NonStatTy, errChainStopped
}
defer bc.chainmu.Unlock()

return bc.writeBlockAndSetHead(block, receipts, logs, state, sealedBlockSender)
return bc.writeBlockAndSetHead(block, receipts, logs, state, sealedBlockSender, delayBroadcast)
}

// writeBlockAndSetHead is the internal implementation of WriteBlockAndSetHead.
// This function expects the chain mutex to be held.
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, sealedBlockSender *event.TypeMux) (status WriteStatus, err error) {
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, sealedBlockSender *event.TypeMux, delayBroadcast bool) (status WriteStatus, err error) {
currentBlock := bc.CurrentBlock()
reorg, err := bc.forker.ReorgNeededWithFastFinality(currentBlock, block.Header())
if err != nil {
Expand All @@ -2017,7 +2017,7 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
if reorg {
bc.highestVerifiedBlock.Store(types.CopyHeader(block.Header()))
bc.highestVerifiedBlockFeed.Send(HighestVerifiedBlockEvent{Header: block.Header()})
if sealedBlockSender != nil {
if sealedBlockSender != nil && !delayBroadcast {
// If the local DB is corrupted, writeBlockWithState may fail.
// It's fine — other nodes will persist the block.
//
Expand Down Expand Up @@ -2628,7 +2628,7 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
// Don't set the head, only insert the block
err = bc.writeBlockWithState(block, res.Receipts, statedb)
} else {
status, err = bc.writeBlockAndSetHead(block, res.Receipts, res.Logs, statedb, nil)
status, err = bc.writeBlockAndSetHead(block, res.Receipts, res.Logs, statedb, nil, false)
}
if err != nil {
return nil, err
Expand Down
4 changes: 4 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ type ChainOverrides struct {
OverrideMaxwell *uint64
OverrideFermi *uint64
OverrideOsaka *uint64
OverrideMendel *uint64
OverrideVerkle *uint64
}

Expand Down Expand Up @@ -304,6 +305,9 @@ func (o *ChainOverrides) apply(cfg *params.ChainConfig) error {
if o.OverrideOsaka != nil {
cfg.OsakaTime = o.OverrideOsaka
}
if o.OverrideMendel != nil {
cfg.MendelTime = o.OverrideMendel
}
if o.OverrideVerkle != nil {
cfg.VerkleTime = o.OverrideVerkle
}
Expand Down
1 change: 0 additions & 1 deletion core/mkalloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//go:build none
// +build none

/*
The mkalloc tool creates the genesis allocation constants in genesis_alloc.go
Expand Down
2 changes: 1 addition & 1 deletion core/state_prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (p *statePrefetcher) Prefetch(transactions types.Transactions, header *type

// Iterate over and process the individual transactions
for i, tx := range transactions {
stateCpy := statedb.CopyDoPrefetch() // closure
stateCpy := statedb.CopyDoPrefetch()
workers.Go(func() error {
// If block precaching was interrupted, abort
if interrupt != nil && interrupt.Load() {
Expand Down
Loading
Loading