aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2020-08-03 17:16:53 -0400
committerDeterminant <[email protected]>2020-08-03 17:16:53 -0400
commitc73ba009031126e16da6999468851b33f93e8005 (patch)
tree961111c84794cf3807946d073bcef36ec8ba6025 /core
parent746a107e2a7bb1f66049240d320e29d0a0536eae (diff)
allow using extra binary data in a block for state transition
Diffstat (limited to 'core')
-rw-r--r--core/state_processor.go3
-rw-r--r--core/types/block.go48
2 files changed, 33 insertions, 18 deletions
diff --git a/core/state_processor.go b/core/state_processor.go
index 6cc646a..ab8759a 100644
--- a/core/state_processor.go
+++ b/core/state_processor.go
@@ -75,6 +75,9 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
receipts = append(receipts, receipt)
allLogs = append(allLogs, receipt.Logs...)
}
+ if err := p.engine.ExtraStateChange(block, statedb); err != nil {
+ return nil, nil, 0, err
+ }
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles())
diff --git a/core/types/block.go b/core/types/block.go
index fcbd8ab..6fa710a 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -150,6 +150,7 @@ type Block struct {
header *Header
uncles []*Header
transactions Transactions
+ version uint32
extdata []byte
// caches
@@ -187,11 +188,11 @@ type extblock struct {
}
type myextblock struct {
- Header *Header
- Txs []*Transaction
- Uncles []*Header
- VersionNumber uint32
- ExtData []byte
+ Header *Header
+ Txs []*Transaction
+ Uncles []*Header
+ Version uint32
+ ExtData []byte `rlp:"nil"`
}
// [deprecated by eth/63]
@@ -291,10 +292,22 @@ func (b *Block) DecodeRLP(s *rlp.Stream) error {
return nil
}
-func (b *Block) RawExtraData() []byte {
+func (b *Block) SetExtraData(data []byte) {
+ b.extdata = data
+}
+
+func (b *Block) ExtraData() []byte {
return b.extdata
}
+func (b *Block) SetVersion(ver uint32) {
+ b.version = ver
+}
+
+func (b *Block) Version() uint32 {
+ return b.version
+}
+
// EncodeRLPEth serializes b into the Ethereum RLP block format.
func (b *Block) EncodeRLPEth(w io.Writer) error {
return rlp.Encode(w, extblock{
@@ -304,25 +317,24 @@ func (b *Block) EncodeRLPEth(w io.Writer) error {
})
}
-func (b *Block) EncodeRLPTest(w io.Writer, ver uint32, data []byte) error {
+func (b *Block) EncodeRLPTest(w io.Writer, ver uint32) error {
return rlp.Encode(w, myextblock{
- Header: b.header,
- Txs: b.transactions,
- Uncles: b.uncles,
- VersionNumber: ver,
- ExtData: data,
+ Header: b.header,
+ Txs: b.transactions,
+ Uncles: b.uncles,
+ Version: ver,
+ ExtData: b.extdata,
})
}
// EncodeRLP serializes b into an extended format.
func (b *Block) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, myextblock{
- Header: b.header,
- Txs: b.transactions,
- Uncles: b.uncles,
- VersionNumber: 0,
- // TODO: add actual extra data for the current version
- ExtData: []byte{},
+ Header: b.header,
+ Txs: b.transactions,
+ Uncles: b.uncles,
+ Version: b.version,
+ ExtData: b.extdata,
})
}