good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
eec89168
Commit
eec89168
authored
Aug 7, 2020
by
ptsayli@gmail.com
Browse files
Options
Downloads
Patches
Plain Diff
chg: move state sync event from block to header
parent
1fd375ea
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
consensus/bor/bor.go
+7
-2
7 additions, 2 deletions
consensus/bor/bor.go
core/types/block.go
+28
-29
28 additions, 29 deletions
core/types/block.go
with
35 additions
and
31 deletions
consensus/bor/bor.go
+
7
−
2
View file @
eec89168
...
@@ -655,6 +655,8 @@ func (c *Bor) Prepare(chain consensus.ChainReader, header *types.Header) error {
...
@@ -655,6 +655,8 @@ func (c *Bor) Prepare(chain consensus.ChainReader, header *types.Header) error {
// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
// rewards given.
// rewards given.
func
(
c
*
Bor
)
Finalize
(
chain
consensus
.
ChainReader
,
header
*
types
.
Header
,
state
*
state
.
StateDB
,
txs
[]
*
types
.
Transaction
,
uncles
[]
*
types
.
Header
)
{
func
(
c
*
Bor
)
Finalize
(
chain
consensus
.
ChainReader
,
header
*
types
.
Header
,
state
*
state
.
StateDB
,
txs
[]
*
types
.
Transaction
,
uncles
[]
*
types
.
Header
)
{
stateSyncData
:=
[]
*
types
.
StateData
{}
var
err
error
headerNumber
:=
header
.
Number
.
Uint64
()
headerNumber
:=
header
.
Number
.
Uint64
()
if
headerNumber
%
c
.
config
.
Sprint
==
0
{
if
headerNumber
%
c
.
config
.
Sprint
==
0
{
cx
:=
chainContext
{
Chain
:
chain
,
Bor
:
c
}
cx
:=
chainContext
{
Chain
:
chain
,
Bor
:
c
}
...
@@ -666,7 +668,7 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
...
@@ -666,7 +668,7 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
if
!
c
.
WithoutHeimdall
{
if
!
c
.
WithoutHeimdall
{
// commit statees
// commit statees
_
,
err
:
=
c
.
CommitStates
(
state
,
header
,
cx
)
stateSyncData
,
err
=
c
.
CommitStates
(
state
,
header
,
cx
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"Error while committing states"
,
"error"
,
err
)
log
.
Error
(
"Error while committing states"
,
"error"
,
err
)
return
return
...
@@ -677,6 +679,8 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
...
@@ -677,6 +679,8 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
// No block rewards in PoA, so the state remains as is and uncles are dropped
// 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
.
Root
=
state
.
IntermediateRoot
(
chain
.
Config
()
.
IsEIP158
(
header
.
Number
))
header
.
UncleHash
=
types
.
CalcUncleHash
(
nil
)
header
.
UncleHash
=
types
.
CalcUncleHash
(
nil
)
header
.
SetStateSync
(
stateSyncData
)
}
}
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
...
@@ -707,10 +711,11 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Hea
...
@@ -707,10 +711,11 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Hea
// No block rewards in PoA, so the state remains as is and uncles are dropped
// 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
.
Root
=
state
.
IntermediateRoot
(
chain
.
Config
()
.
IsEIP158
(
header
.
Number
))
header
.
UncleHash
=
types
.
CalcUncleHash
(
nil
)
header
.
UncleHash
=
types
.
CalcUncleHash
(
nil
)
header
.
SetStateSync
(
stateSyncData
)
// Assemble block
// Assemble block
block
:=
types
.
NewBlock
(
header
,
txs
,
nil
,
receipts
)
block
:=
types
.
NewBlock
(
header
,
txs
,
nil
,
receipts
)
block
.
SetStateSync
(
stateSyncData
)
// return the final block for sealing
// return the final block for sealing
return
block
,
nil
return
block
,
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
core/types/block.go
+
28
−
29
View file @
eec89168
...
@@ -85,6 +85,7 @@ type Header struct {
...
@@ -85,6 +85,7 @@ type Header struct {
Extra
[]
byte
`json:"extraData" gencodec:"required"`
Extra
[]
byte
`json:"extraData" gencodec:"required"`
MixDigest
common
.
Hash
`json:"mixHash"`
MixDigest
common
.
Hash
`json:"mixHash"`
Nonce
BlockNonce
`json:"nonce"`
Nonce
BlockNonce
`json:"nonce"`
stateSyncData
[]
*
StateData
}
}
// field type overrides for gencodec
// field type overrides for gencodec
...
@@ -112,6 +113,11 @@ func (h *Header) Size() common.StorageSize {
...
@@ -112,6 +113,11 @@ func (h *Header) Size() common.StorageSize {
return
headerSize
+
common
.
StorageSize
(
len
(
h
.
Extra
)
+
(
h
.
Difficulty
.
BitLen
()
+
h
.
Number
.
BitLen
())
/
8
)
return
headerSize
+
common
.
StorageSize
(
len
(
h
.
Extra
)
+
(
h
.
Difficulty
.
BitLen
()
+
h
.
Number
.
BitLen
())
/
8
)
}
}
// SetStateSync set sync data in block
func
(
b
*
Header
)
SetStateSync
(
stateData
[]
*
StateData
)
{
b
.
stateSyncData
=
stateData
}
// SanityCheck checks a few basic things -- these checks are way beyond what
// SanityCheck checks a few basic things -- these checks are way beyond what
// any 'sane' production values should hold, and can mainly be used to prevent
// any 'sane' production values should hold, and can mainly be used to prevent
// that the unbounded fields are stuffed with junk data to add processing
// that the unbounded fields are stuffed with junk data to add processing
...
@@ -159,7 +165,6 @@ type Block struct {
...
@@ -159,7 +165,6 @@ type Block struct {
header
*
Header
header
*
Header
uncles
[]
*
Header
uncles
[]
*
Header
transactions
Transactions
transactions
Transactions
stateSyncData
[]
*
StateData
// caches
// caches
hash
atomic
.
Value
hash
atomic
.
Value
size
atomic
.
Value
size
atomic
.
Value
...
@@ -266,11 +271,6 @@ func CopyHeader(h *Header) *Header {
...
@@ -266,11 +271,6 @@ func CopyHeader(h *Header) *Header {
return
&
cpy
return
&
cpy
}
}
// SetStateSync set sync data in block
func
(
b
*
Block
)
SetStateSync
(
stateData
[]
*
StateData
)
{
b
.
stateSyncData
=
stateData
}
// DecodeRLP decodes the Ethereum
// DecodeRLP decodes the Ethereum
func
(
b
*
Block
)
DecodeRLP
(
s
*
rlp
.
Stream
)
error
{
func
(
b
*
Block
)
DecodeRLP
(
s
*
rlp
.
Stream
)
error
{
var
eb
extblock
var
eb
extblock
...
@@ -321,7 +321,7 @@ func (b *Block) GasLimit() uint64 { return b.header.GasLimit }
...
@@ -321,7 +321,7 @@ func (b *Block) GasLimit() uint64 { return b.header.GasLimit }
func
(
b
*
Block
)
GasUsed
()
uint64
{
return
b
.
header
.
GasUsed
}
func
(
b
*
Block
)
GasUsed
()
uint64
{
return
b
.
header
.
GasUsed
}
func
(
b
*
Block
)
Difficulty
()
*
big
.
Int
{
return
new
(
big
.
Int
)
.
Set
(
b
.
header
.
Difficulty
)
}
func
(
b
*
Block
)
Difficulty
()
*
big
.
Int
{
return
new
(
big
.
Int
)
.
Set
(
b
.
header
.
Difficulty
)
}
func
(
b
*
Block
)
Time
()
uint64
{
return
b
.
header
.
Time
}
func
(
b
*
Block
)
Time
()
uint64
{
return
b
.
header
.
Time
}
func
(
b
*
Block
)
StateSyncData
()
[]
*
StateData
{
return
b
.
stateSyncData
}
func
(
b
*
Block
)
StateSyncData
()
[]
*
StateData
{
return
b
.
header
.
stateSyncData
}
func
(
b
*
Block
)
NumberU64
()
uint64
{
return
b
.
header
.
Number
.
Uint64
()
}
func
(
b
*
Block
)
NumberU64
()
uint64
{
return
b
.
header
.
Number
.
Uint64
()
}
func
(
b
*
Block
)
MixDigest
()
common
.
Hash
{
return
b
.
header
.
MixDigest
}
func
(
b
*
Block
)
MixDigest
()
common
.
Hash
{
return
b
.
header
.
MixDigest
}
...
@@ -381,7 +381,6 @@ func (b *Block) WithSeal(header *Header) *Block {
...
@@ -381,7 +381,6 @@ func (b *Block) WithSeal(header *Header) *Block {
header
:
&
cpy
,
header
:
&
cpy
,
transactions
:
b
.
transactions
,
transactions
:
b
.
transactions
,
uncles
:
b
.
uncles
,
uncles
:
b
.
uncles
,
stateSyncData
:
b
.
stateSyncData
,
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment