Skip to content
Open

wip #2077

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
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**/.git
.git
!.git/HEAD
!.git/refs/heads
**/*_test.go
Expand Down
3 changes: 3 additions & 0 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ func TestHeaderByHash(t *testing.T) {
}
}

//here test header hash


func TestHeaderByNumber(t *testing.T) {
t.Parallel()
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
Expand Down
2 changes: 1 addition & 1 deletion cicd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.25-alpine AS builder

RUN apk add make build-base linux-headers
RUN apk add make build-base linux-headers git

COPY . /builder

Expand Down
82 changes: 80 additions & 2 deletions consensus/XDPoS/XDPoS.go

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions consensus/XDPoS/engines/engine_v2/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,12 @@ func (x *XDPoS_v2) Prepare(chain consensus.ChainReader, header *types.Header) er
if parent == nil {
return consensus.ErrUnknownAncestor
}
// Ensure gas settings are bounded
if err := misc.VerifyGaslimit(parent.GasLimit, header.GasLimit); err != nil {
// Ensure gas limit is consistent with parent
err = misc.VerifyGaslimit(parent.GasLimit, header.GasLimit)
if err != nil && parent.Number.Uint64() != 0 { // skip genesis block
return err
}

if header.GasUsed > header.GasLimit {
return fmt.Errorf("gas used exceeded gaslimit, gas used: %d, gas limit: %d", header.GasUsed, header.GasLimit)
}
Expand Down Expand Up @@ -453,10 +455,12 @@ func (x *XDPoS_v2) Finalize(chain consensus.ChainReader, header *types.Header, s
if parentHeader == nil {
return nil, consensus.ErrUnknownAncestor
}
// Ensure gas settings are bounded
if err := misc.VerifyGaslimit(parentHeader.GasLimit, header.GasLimit); err != nil {
// Ensure gas limit is consistent with parent
err = misc.VerifyGaslimit(parentHeader.GasLimit, header.GasLimit)
if err != nil && parentHeader.Number.Uint64() != 0 { // skip genesis block
return nil, err
}

if header.GasUsed > header.GasLimit {
return nil, fmt.Errorf("gas used exceeded gaslimit, gas used: %d, gas limit: %d", header.GasUsed, header.GasLimit)
}
Expand Down
14 changes: 14 additions & 0 deletions consensus/XDPoS/engines/engine_v2_subnet/difficulty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package engine_v2_subnet

import (
"math/big"

"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/consensus"
"github.com/XinFinOrg/XDPoSChain/core/types"
)

// TODO: what should be new difficulty
func (x *XDPoS_v2) calcDifficulty(chain consensus.ChainReader, parent *types.Header, signer common.Address) *big.Int {
return big.NewInt(1)
}
Loading
Loading