Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
ff9a8682
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ff9a8682
编写于
8月 24, 2017
作者:
P
Péter Szilágyi
提交者:
Felix Lange
8月 24, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core/state: revert metro suicide map addition (#15024)
上级
20b818d2
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
28 addition
and
49 deletion
+28
-49
core/state/journal.go
core/state/journal.go
+0
-5
core/state/statedb.go
core/state/statedb.go
+27
-42
core/state_processor.go
core/state_processor.go
+1
-1
tests/block_test.go
tests/block_test.go
+0
-1
未找到文件。
core/state/journal.go
浏览文件 @
ff9a8682
...
...
@@ -91,11 +91,6 @@ func (ch suicideChange) undo(s *StateDB) {
if
obj
!=
nil
{
obj
.
suicided
=
ch
.
prev
obj
.
setBalance
(
ch
.
prevbalance
)
// if the object wasn't suicided before, remove
// it from the list of destructed objects as well.
if
!
obj
.
suicided
{
delete
(
s
.
stateObjectsDestructed
,
*
ch
.
account
)
}
}
}
...
...
core/state/statedb.go
浏览文件 @
ff9a8682
...
...
@@ -48,7 +48,6 @@ type StateDB struct {
// This map holds 'live' objects, which will get modified while processing a state transition.
stateObjects
map
[
common
.
Address
]
*
stateObject
stateObjectsDirty
map
[
common
.
Address
]
struct
{}
stateObjectsDestructed
map
[
common
.
Address
]
struct
{}
// DB error.
// State objects are used by the consensus core and VM which are
...
...
@@ -87,7 +86,6 @@ func New(root common.Hash, db Database) (*StateDB, error) {
trie
:
tr
,
stateObjects
:
make
(
map
[
common
.
Address
]
*
stateObject
),
stateObjectsDirty
:
make
(
map
[
common
.
Address
]
struct
{}),
stateObjectsDestructed
:
make
(
map
[
common
.
Address
]
struct
{}),
refund
:
new
(
big
.
Int
),
logs
:
make
(
map
[
common
.
Hash
][]
*
types
.
Log
),
preimages
:
make
(
map
[
common
.
Hash
][]
byte
),
...
...
@@ -115,7 +113,6 @@ func (self *StateDB) Reset(root common.Hash) error {
self
.
trie
=
tr
self
.
stateObjects
=
make
(
map
[
common
.
Address
]
*
stateObject
)
self
.
stateObjectsDirty
=
make
(
map
[
common
.
Address
]
struct
{})
self
.
stateObjectsDestructed
=
make
(
map
[
common
.
Address
]
struct
{})
self
.
thash
=
common
.
Hash
{}
self
.
bhash
=
common
.
Hash
{}
self
.
txIndex
=
0
...
...
@@ -323,7 +320,6 @@ func (self *StateDB) Suicide(addr common.Address) bool {
})
stateObject
.
markSuicided
()
stateObject
.
data
.
Balance
=
new
(
big
.
Int
)
self
.
stateObjectsDestructed
[
addr
]
=
struct
{}{}
return
true
}
...
...
@@ -460,7 +456,6 @@ func (self *StateDB) Copy() *StateDB {
trie
:
self
.
trie
,
stateObjects
:
make
(
map
[
common
.
Address
]
*
stateObject
,
len
(
self
.
stateObjectsDirty
)),
stateObjectsDirty
:
make
(
map
[
common
.
Address
]
struct
{},
len
(
self
.
stateObjectsDirty
)),
stateObjectsDestructed
:
make
(
map
[
common
.
Address
]
struct
{},
len
(
self
.
stateObjectsDestructed
)),
refund
:
new
(
big
.
Int
)
.
Set
(
self
.
refund
),
logs
:
make
(
map
[
common
.
Hash
][]
*
types
.
Log
,
len
(
self
.
logs
)),
logSize
:
self
.
logSize
,
...
...
@@ -470,9 +465,6 @@ func (self *StateDB) Copy() *StateDB {
for
addr
:=
range
self
.
stateObjectsDirty
{
state
.
stateObjects
[
addr
]
=
self
.
stateObjects
[
addr
]
.
deepCopy
(
state
,
state
.
MarkStateObjectDirty
)
state
.
stateObjectsDirty
[
addr
]
=
struct
{}{}
if
self
.
stateObjects
[
addr
]
.
suicided
{
state
.
stateObjectsDestructed
[
addr
]
=
struct
{}{}
}
}
for
hash
,
logs
:=
range
self
.
logs
{
state
.
logs
[
hash
]
=
make
([]
*
types
.
Log
,
len
(
logs
))
...
...
@@ -520,10 +512,9 @@ func (self *StateDB) GetRefund() *big.Int {
return
self
.
refund
}
// IntermediateRoot computes the current root hash of the state trie.
// It is called in between transactions to get the root hash that
// goes into transaction receipts.
func
(
s
*
StateDB
)
IntermediateRoot
(
deleteEmptyObjects
bool
)
common
.
Hash
{
// Finalise finalises the state by removing the self destructed objects
// and clears the journal as well as the refunds.
func
(
s
*
StateDB
)
Finalise
(
deleteEmptyObjects
bool
)
{
for
addr
:=
range
s
.
stateObjectsDirty
{
stateObject
:=
s
.
stateObjects
[
addr
]
if
stateObject
.
suicided
||
(
deleteEmptyObjects
&&
stateObject
.
empty
())
{
...
...
@@ -535,6 +526,13 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
}
// Invalidate journal because reverting across transactions is not allowed.
s
.
clearJournalAndRefund
()
}
// IntermediateRoot computes the current root hash of the state trie.
// It is called in between transactions to get the root hash that
// goes into transaction receipts.
func
(
s
*
StateDB
)
IntermediateRoot
(
deleteEmptyObjects
bool
)
common
.
Hash
{
s
.
Finalise
(
deleteEmptyObjects
)
return
s
.
trie
.
Hash
()
}
...
...
@@ -546,19 +544,6 @@ func (self *StateDB) Prepare(thash, bhash common.Hash, ti int) {
self
.
txIndex
=
ti
}
// Finalise finalises the state by removing the self destructed objects
// in the current stateObjectsDestructed buffer and clears the journal
// as well as the refunds.
//
// Please note that Finalise is used by EIP#98 and is used instead of
// IntermediateRoot.
func
(
s
*
StateDB
)
Finalise
()
{
for
addr
:=
range
s
.
stateObjectsDestructed
{
s
.
deleteStateObject
(
s
.
stateObjects
[
addr
])
}
s
.
clearJournalAndRefund
()
}
// DeleteSuicides flags the suicided objects for deletion so that it
// won't be referenced again when called / queried up on.
//
...
...
core/state_processor.go
浏览文件 @
ff9a8682
...
...
@@ -106,7 +106,7 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common
// Update the state with pending changes
var
root
[]
byte
if
config
.
IsMetropolis
(
header
.
Number
)
{
statedb
.
Finalise
()
statedb
.
Finalise
(
true
)
}
else
{
root
=
statedb
.
IntermediateRoot
(
config
.
IsEIP158
(
header
.
Number
))
.
Bytes
()
}
...
...
tests/block_test.go
浏览文件 @
ff9a8682
...
...
@@ -37,7 +37,6 @@ func TestBlockchain(t *testing.T) {
// Still failing tests
bt
.
skipLoad
(
`^bcWalletTest.*_Byzantium$`
)
bt
.
skipLoad
(
`^bcStateTests/suicideCoinbase.json.*_Byzantium$`
)
bt
.
walk
(
t
,
blockTestDir
,
func
(
t
*
testing
.
T
,
name
string
,
test
*
BlockTest
)
{
if
err
:=
bt
.
checkFailure
(
t
,
name
,
test
.
Run
());
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录