Skip to content

Commit

Permalink
Update readme and fix ci (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx authored Sep 23, 2024
1 parent ca38a3a commit cc369cf
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 27 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,23 @@ du -hsc /erigon/snapshots/*
4.1T /erigon/snapshots
```

```
# bsc-mainnet - archive - Sep 2024
du -hsc /erigon/*
327M /erigon/parlia
5.1G /erigon/chaindata
4.2T /erigon/snapshots
4.2T total
du -hsc /erigon/snapshots/*
332G /erigon-data/snapshots/accessor
562G /erigon-data/snapshots/domain
882G /erigon-data/snapshots/history
1.3T /erigon-data/snapshots/idx
4.4T /erigon/snapshots
```

### E3 other perf trics

- `--sync.loop.block.limit=10_000 --batchSize=2g` - likely will help for sync speed.
Expand Down
5 changes: 4 additions & 1 deletion cmd/state/exec3/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining bool) {
rules := txTask.Rules
var err error
header := txTask.Header
lastBlockTime := header.Time - rw.chainConfig.Parlia.Period
var lastBlockTime uint64
if rw.isPoSA {
lastBlockTime = header.Time - rw.chainConfig.Parlia.Period
}
//fmt.Printf("txNum=%d blockNum=%d history=%t\n", txTask.TxNum, txTask.BlockNum, txTask.HistoryExecution)

switch {
Expand Down
5 changes: 3 additions & 2 deletions consensus/aura/auraabi/gen_block_reward.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 30 additions & 2 deletions consensus/misc/eip4844.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ func FakeExponential(factor, denom *uint256.Int, excessBlobGas uint64) (*uint256

// VerifyPresenceOfCancunHeaderFields checks that the fields introduced in Cancun (EIP-4844, EIP-4788) are present.
func VerifyPresenceOfCancunHeaderFields(header *types.Header) error {
if header.BlobGasUsed == nil {
return errors.New("header is missing blobGasUsed")
}
if header.ExcessBlobGas == nil {
return errors.New("header is missing excessBlobGas")
}
if header.ParentBeaconBlockRoot == nil {
return errors.New("header is missing parentBeaconBlockRoot")
}
return nil
}

// VerifyBscPresenceOfCancunHeaderFields checks that the fields introduced in Cancun (EIP-4844, EIP-4788) are present.
func VerifyBscPresenceOfCancunHeaderFields(header *types.Header) error {
if header.BlobGasUsed == nil {
return errors.New("header is missing blobGasUsed")
}
Expand All @@ -95,6 +109,20 @@ func VerifyPresenceOfCancunHeaderFields(header *types.Header) error {

// VerifyAbsenceOfCancunHeaderFields checks that the header doesn't have any fields added in Cancun (EIP-4844, EIP-4788).
func VerifyAbsenceOfCancunHeaderFields(header *types.Header) error {
if header.BlobGasUsed != nil {
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
}
if header.ExcessBlobGas != nil {
return fmt.Errorf("invalid excessBlobGas before fork: have %v, expected 'nil'", header.ExcessBlobGas)
}
if header.ParentBeaconBlockRoot != nil {
return fmt.Errorf("invalid parentBeaconBlockRoot before fork: have %v, expected 'nil'", header.ParentBeaconBlockRoot)
}
return nil
}

// VerifyBscAbsenceOfCancunHeaderFields checks that the header doesn't have any fields added in Cancun (EIP-4844, EIP-4788).
func VerifyBscAbsenceOfCancunHeaderFields(header *types.Header) error {
if header.BlobGasUsed != nil {
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
}
Expand All @@ -113,10 +141,10 @@ func VerifyAbsenceOfCancunHeaderFields(header *types.Header) error {
// VerifyPresenceOfBohrHeaderFields checks that the fields introduced in Cancun (EIP-4844, EIP-4788) are present.
func VerifyPresenceOfBohrHeaderFields(header *types.Header) error {
if header.BlobGasUsed == nil {
return fmt.Errorf("header is missing blobGasUsed")
return errors.New("header is missing blobGasUsed")
}
if header.ExcessBlobGas == nil {
return fmt.Errorf("header is missing excessBlobGas")
return errors.New("header is missing excessBlobGas")
}
if header.ParentBeaconBlockRoot == nil || *header.ParentBeaconBlockRoot != (libcommon.Hash{}) {
return fmt.Errorf("invalid parentBeaconRoot, have %#x, expected zero hash", header.ParentBeaconBlockRoot)
Expand Down
4 changes: 2 additions & 2 deletions consensus/parlia/feynmanfork.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package parlia

import (
"container/heap"
"fmt"
"errors"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/kv/rawdbv3"
"math/big"
Expand Down Expand Up @@ -163,7 +163,7 @@ func (p *Parlia) getValidatorElectionInfo(header *types.Header, ibs *state.Intra
return nil, err
}
if totalLength.Int64() != int64(len(validators)) || totalLength.Int64() != int64(len(votingPowers)) || totalLength.Int64() != int64(len(voteAddrs)) {
return nil, fmt.Errorf("validator length not match")
return nil, errors.New("validator length not match")
}

validatorItems := make([]ValidatorItem, len(validators))
Expand Down
12 changes: 6 additions & 6 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func (p *Parlia) verifyVoteAttestation(chain consensus.ChainHeaderReader, header

// The valid voted validators should be no less than 2/3 validators.
if len(votedAddrs) < math.CeilDiv(len(snap.Validators)*2, 3) {
return fmt.Errorf("invalid attestation, not enough validators voted")
return errors.New("invalid attestation, not enough validators voted")
}

// Verify the aggregated signature.
Expand All @@ -503,7 +503,7 @@ func (p *Parlia) verifyVoteAttestation(chain consensus.ChainHeaderReader, header
return fmt.Errorf("BLS signature converts failed: %v", err)
}
if !aggSig.FastAggregateVerify(votedAddrs, attestation.Data.Hash()) {
return fmt.Errorf("invalid attestation, signature verify failed")
return errors.New("invalid attestation, signature verify failed")
}

return nil
Expand Down Expand Up @@ -583,7 +583,7 @@ func (p *Parlia) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
// Verify the existence / non-existence of excessBlobGas
cancun := chain.Config().IsCancun(header.Number.Uint64(), header.Time)
if !cancun {
if err := misc.VerifyAbsenceOfCancunHeaderFields(header); err != nil {
if err := misc.VerifyBscAbsenceOfCancunHeaderFields(header); err != nil {
return err
}
} else {
Expand All @@ -593,7 +593,7 @@ func (p *Parlia) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
return err
}
} else {
if err := misc.VerifyPresenceOfCancunHeaderFields(header); err != nil {
if err := misc.VerifyBscPresenceOfCancunHeaderFields(header); err != nil {
return err
}
}
Expand Down Expand Up @@ -1491,10 +1491,10 @@ func (p *Parlia) applyTransaction(from libcommon.Address, to libcommon.Address,
expectedTx := types.Transaction(types.NewTransaction(actualTx.GetNonce(), to, value, math.MaxUint64/2, u256.Num0, data))
expectedHash := expectedTx.SigningHash(p.chainConfig.ChainID)
if len(*systemTxs) == 0 {
return false, fmt.Errorf("supposed to get a actual transaction, but get none")
return false, errors.New("supposed to get a actual transaction, but get none")
}
if actualTx == nil {
return false, fmt.Errorf("supposed to get a actual transaction, but get nil")
return false, errors.New("supposed to get a actual transaction, but get nil")
}
actualHash := actualTx.SigningHash(p.chainConfig.ChainID)
if !bytes.Equal(actualHash.Bytes(), expectedHash.Bytes()) {
Expand Down
13 changes: 7 additions & 6 deletions core/vm/contracts_lightclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vm

import (
"encoding/binary"
"errors"
"fmt"
"github.com/tendermint/tendermint/crypto/secp256k1"
"net/url"
Expand Down Expand Up @@ -67,7 +68,7 @@ func (c *tmHeaderValidate) Run(input []byte) (result []byte, err error) {
}()

if uint64(len(input)) <= precompileContractInputMetaDataLength {
return nil, fmt.Errorf("invalid input")
return nil, errors.New("invalid input")
}

payloadLength := binary.BigEndian.Uint64(input[precompileContractInputMetaDataLength-uint64TypeLength : precompileContractInputMetaDataLength])
Expand Down Expand Up @@ -131,7 +132,7 @@ func (c *tmHeaderValidateNano) RequiredGas(input []byte) uint64 {
}

func (c *tmHeaderValidateNano) Run(input []byte) (result []byte, err error) {
return nil, fmt.Errorf("suspend")
return nil, errors.New("suspend")
}

type iavlMerkleProofValidateNano struct{}
Expand All @@ -141,7 +142,7 @@ func (c *iavlMerkleProofValidateNano) RequiredGas(_ []byte) uint64 {
}

func (c *iavlMerkleProofValidateNano) Run(_ []byte) (result []byte, err error) {
return nil, fmt.Errorf("suspend")
return nil, errors.New("suspend")
}

// ------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -250,7 +251,7 @@ func (c *basicIavlMerkleProofValidate) Run(input []byte) (result []byte, err err

valid := kvmp.Validate()
if !valid {
return nil, fmt.Errorf("invalid merkle proof")
return nil, errors.New("invalid merkle proof")
}

return successfulMerkleResult(), nil
Expand Down Expand Up @@ -418,7 +419,7 @@ const (
// | 33 bytes | 64 bytes | 32 bytes |
func (c *secp256k1SignatureRecover) Run(input []byte) (result []byte, err error) {
if len(input) != int(secp256k1PubKeyLength)+int(secp256k1SignatureLength)+int(secp256k1SignatureMsgHashLength) {
return nil, fmt.Errorf("invalid input")
return nil, errors.New("invalid input")
}

return c.runTMSecp256k1Signature(
Expand All @@ -432,7 +433,7 @@ func (c *secp256k1SignatureRecover) runTMSecp256k1Signature(pubkey, signatureStr
tmPubKey := secp256k1.PubKeySecp256k1(pubkey)
ok := tmPubKey.VerifyBytesWithMsgHash(msgHash, signatureStr)
if !ok {
return nil, fmt.Errorf("invalid signature")
return nil, errors.New("invalid signature")
}
return tmPubKey.Address().Bytes(), nil
}
7 changes: 4 additions & 3 deletions core/vm/lightclient/iavl/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package iavl

import (
"bytes"
"errors"
"fmt"

"github.com/tendermint/go-amino"
Expand All @@ -11,13 +12,13 @@ import (

var (
// ErrInvalidProof is returned by Verify when a proof cannot be validated.
ErrInvalidProof = fmt.Errorf("invalid proof")
ErrInvalidProof = errors.New("invalid proof")

// ErrInvalidInputs is returned when the inputs passed to the function are invalid.
ErrInvalidInputs = fmt.Errorf("invalid inputs")
ErrInvalidInputs = errors.New("invalid inputs")

// ErrInvalidRoot is returned when the root passed in does not match the proof's.
ErrInvalidRoot = fmt.Errorf("invalid root")
ErrInvalidRoot = errors.New("invalid root")
)

//----------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions core/vm/lightclient/v2/lightclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package v2
import (
"bytes"
"encoding/binary"
"errors"
"fmt"

"github.com/cometbft/cometbft/crypto/ed25519"
Expand Down Expand Up @@ -49,7 +50,7 @@ func (cs ConsensusState) EncodeConsensusState() ([]byte, error) {

pos := uint64(0)
if uint64(len(cs.ChainID)) > chainIDLength {
return nil, fmt.Errorf("chainID length should be no more than 32")
return nil, errors.New("chainID length should be no more than 32")
}
copy(encodingBytes[pos:pos+chainIDLength], cs.ChainID)
pos += chainIDLength
Expand All @@ -64,7 +65,7 @@ func (cs ConsensusState) EncodeConsensusState() ([]byte, error) {
validator := cs.ValidatorSet.Validators[index]
pubkey, ok := validator.PubKey.(ed25519.PubKey)
if !ok {
return nil, fmt.Errorf("invalid pubkey type")
return nil, errors.New("invalid pubkey type")
}

copy(encodingBytes[pos:pos+validatorPubkeyLength], pubkey[:])
Expand Down Expand Up @@ -195,7 +196,7 @@ func DecodeConsensusState(input []byte) (ConsensusState, error) {
// 32 bytes | | |
func DecodeLightBlockValidationInput(input []byte) (*ConsensusState, *types.LightBlock, error) {
if uint64(len(input)) <= consensusStateLengthBytesLength {
return nil, nil, fmt.Errorf("invalid input")
return nil, nil, errors.New("invalid input")
}

csLen := binary.BigEndian.Uint64(input[consensusStateLengthBytesLength-uint64TypeLength : consensusStateLengthBytesLength])
Expand Down
2 changes: 1 addition & 1 deletion eth/protocols/eth/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,6 @@ func TestNewBlockPacket_EncodeDecode(t *testing.T) {
var actual NewBlockPacket
err = rlp.DecodeBytes(enc, &actual)
require.NoError(t, err)
require.Equal(t, item.msg, actual)
require.DeepEqual(t, item.msg, actual)
}
}
2 changes: 1 addition & 1 deletion turbo/stages/headerdownload/header_algos.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ func (hd *HeaderDownload) ProcessHeader(sh ChainSegmentHeader, newBlock bool, pe
func (hd *HeaderDownload) ProcessHeaders(csHeaders []ChainSegmentHeader, newBlock bool, peerID [64]byte) bool {
requestMore := false
for _, sh := range csHeaders {
if sh.Number > uint64(hd.loopBlockLimit)+hd.highestInDb {
if hd.loopBlockLimit != 0 && sh.Number > uint64(hd.loopBlockLimit)+hd.highestInDb {
continue
}
// Lock is acquired for every invocation of ProcessHeader
Expand Down

0 comments on commit cc369cf

Please sign in to comment.