Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
99481a24
Commit
99481a24
authored
Dec 02, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for known block err and ignore
parent
9f7a8ea5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
80 deletions
+37
-80
block_manager.go
chain/block_manager.go
+18
-12
chain_manager.go
chain/chain_manager.go
+5
-65
error.go
chain/error.go
+13
-0
gh_test.go
tests/vm/gh_test.go
+0
-2
address.go
vm/address.go
+1
-1
No files found.
chain/block_manager.go
View file @
99481a24
...
@@ -185,6 +185,7 @@ func (sm *BlockManager) Process(block *Block) (td *big.Int, msgs state.Messages,
...
@@ -185,6 +185,7 @@ func (sm *BlockManager) Process(block *Block) (td *big.Int, msgs state.Messages,
defer
sm
.
mutex
.
Unlock
()
defer
sm
.
mutex
.
Unlock
()
if
sm
.
bc
.
HasBlock
(
block
.
Hash
())
{
if
sm
.
bc
.
HasBlock
(
block
.
Hash
())
{
fmt
.
Println
(
"already having this block"
)
return
nil
,
nil
,
nil
return
nil
,
nil
,
nil
}
}
...
@@ -211,7 +212,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
...
@@ -211,7 +212,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
fmt
.
Printf
(
"## %x %x ##
\n
"
,
block
.
Hash
(),
block
.
Number
)
fmt
.
Printf
(
"## %x %x ##
\n
"
,
block
.
Hash
(),
block
.
Number
)
}
}
receipts
,
err
:
=
sm
.
ApplyDiff
(
state
,
parent
,
block
)
_
,
err
=
sm
.
ApplyDiff
(
state
,
parent
,
block
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -222,11 +223,13 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
...
@@ -222,11 +223,13 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
return
return
}
}
/*
receiptSha := DeriveSha(receipts)
receiptSha := DeriveSha(receipts)
if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
err = fmt.Errorf("validating receipt root. received=%x got=%x", block.ReceiptSha, receiptSha)
err = fmt.Errorf("validating receipt root. received=%x got=%x", block.ReceiptSha, receiptSha)
return
return
}
}
*/
// Block validation
// Block validation
if
err
=
sm
.
ValidateBlock
(
block
,
parent
);
err
!=
nil
{
if
err
=
sm
.
ValidateBlock
(
block
,
parent
);
err
!=
nil
{
...
@@ -239,12 +242,14 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
...
@@ -239,12 +242,14 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
return
return
}
}
/*
block.receipts = receipts // although this isn't necessary it be in the future
block.receipts = receipts // although this isn't necessary it be in the future
rbloom := CreateBloom(receipts)
rbloom := CreateBloom(receipts)
if bytes.Compare(rbloom, block.LogsBloom) != 0 {
if bytes.Compare(rbloom, block.LogsBloom) != 0 {
err = fmt.Errorf("unable to replicate block's bloom=%x", rbloom)
err = fmt.Errorf("unable to replicate block's bloom=%x", rbloom)
return
return
}
}
*/
state
.
Update
(
ethutil
.
Big0
)
state
.
Update
(
ethutil
.
Big0
)
...
@@ -266,6 +271,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
...
@@ -266,6 +271,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
sm
.
transState
=
state
.
Copy
()
sm
.
transState
=
state
.
Copy
()
sm
.
eth
.
TxPool
()
.
RemoveSet
(
block
.
Transactions
())
sm
.
eth
.
TxPool
()
.
RemoveSet
(
block
.
Transactions
())
fmt
.
Println
(
"TD"
,
td
)
return
td
,
messages
,
nil
return
td
,
messages
,
nil
}
else
{
}
else
{
...
...
chain/chain_manager.go
View file @
99481a24
...
@@ -326,9 +326,14 @@ func (self *ChainManager) InsertChain(chain Blocks) error {
...
@@ -326,9 +326,14 @@ func (self *ChainManager) InsertChain(chain Blocks) error {
for
_
,
block
:=
range
chain
{
for
_
,
block
:=
range
chain
{
td
,
messages
,
err
:=
self
.
Ethereum
.
BlockManager
()
.
Process
(
block
)
td
,
messages
,
err
:=
self
.
Ethereum
.
BlockManager
()
.
Process
(
block
)
if
err
!=
nil
{
if
err
!=
nil
{
if
IsKnownBlockErr
(
err
)
{
continue
}
return
err
return
err
}
}
fmt
.
Println
(
td
,
messages
,
err
)
self
.
add
(
block
)
self
.
add
(
block
)
self
.
SetTotalDifficulty
(
td
)
self
.
SetTotalDifficulty
(
td
)
self
.
Ethereum
.
EventMux
()
.
Post
(
NewBlockEvent
{
block
})
self
.
Ethereum
.
EventMux
()
.
Post
(
NewBlockEvent
{
block
})
...
@@ -337,68 +342,3 @@ func (self *ChainManager) InsertChain(chain Blocks) error {
...
@@ -337,68 +342,3 @@ func (self *ChainManager) InsertChain(chain Blocks) error {
return
nil
return
nil
}
}
/*
// This function assumes you've done your checking. No checking is done at this stage anymore
func (self *ChainManager) InsertChain(chain *BlockChain) {
for e := chain.Front(); e != nil; e = e.Next() {
link := e.Value.(*link)
self.add(link.block)
self.SetTotalDifficulty(link.td)
self.Ethereum.EventMux().Post(NewBlockEvent{link.block})
self.Ethereum.EventMux().Post(link.messages)
}
b, e := chain.Front(), chain.Back()
if b != nil && e != nil {
front, back := b.Value.(*link).block, e.Value.(*link).block
chainlogger.Infof("Imported %d blocks. #%v (%x) / %#v (%x)", chain.Len(), front.Number, front.Hash()[0:4], back.Number, back.Hash()[0:4])
}
}
*/
/*
func (self *ChainManager) TestChain(chain *BlockChain) (td *big.Int, err error) {
self.workingChain = chain
defer func() { self.workingChain = nil }()
for e := chain.Front(); e != nil; e = e.Next() {
var (
l = e.Value.(*link)
block = l.block
parent = self.GetBlock(block.PrevHash)
)
//fmt.Println("parent", parent)
//fmt.Println("current", block)
if parent == nil {
err = fmt.Errorf("incoming chain broken on hash %x\n", block.PrevHash[0:4])
return
}
var messages state.Messages
td, messages, err = self.Ethereum.BlockManager().ProcessWithParent(block, parent)
if err != nil {
chainlogger.Infoln(err)
chainlogger.Debugf("Block #%v failed (%x...)\n", block.Number, block.Hash()[0:4])
chainlogger.Debugln(block)
err = fmt.Errorf("incoming chain failed %v\n", err)
return
}
l.td = td
l.messages = messages
}
if td.Cmp(self.TD) <= 0 {
err = &TDError{td, self.TD}
return
}
self.workingChain = nil
return
}
*/
chain/error.go
View file @
99481a24
...
@@ -126,3 +126,16 @@ func IsTDError(e error) bool {
...
@@ -126,3 +126,16 @@ func IsTDError(e error) bool {
_
,
ok
:=
e
.
(
*
TDError
)
_
,
ok
:=
e
.
(
*
TDError
)
return
ok
return
ok
}
}
type
KnownBlockError
struct
{
number
uint64
hash
[]
byte
}
func
(
self
*
KnownBlockError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"block %d already known (%x)"
,
self
.
number
,
self
.
hash
[
0
:
4
])
}
func
IsKnownBlockErr
(
e
error
)
bool
{
_
,
ok
:=
e
.
(
*
KnownBlockError
)
return
ok
}
tests/vm/gh_test.go
View file @
99481a24
...
@@ -142,7 +142,6 @@ func TestEnvironmentalInfo(t *testing.T) {
...
@@ -142,7 +142,6 @@ func TestEnvironmentalInfo(t *testing.T) {
}
}
func
TestFlowOperation
(
t
*
testing
.
T
)
{
func
TestFlowOperation
(
t
*
testing
.
T
)
{
//helper.Logger.SetLogLevel(5)
const
fn
=
"../files/vmtests/vmIOandFlowOperationsTest.json"
const
fn
=
"../files/vmtests/vmIOandFlowOperationsTest.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
...
@@ -153,7 +152,6 @@ func TestPushDupSwap(t *testing.T) {
...
@@ -153,7 +152,6 @@ func TestPushDupSwap(t *testing.T) {
}
}
func
TestVMSha3
(
t
*
testing
.
T
)
{
func
TestVMSha3
(
t
*
testing
.
T
)
{
//helper.Logger.SetLogLevel(5)
const
fn
=
"../files/vmtests/vmSha3Test.json"
const
fn
=
"../files/vmtests/vmSha3Test.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
...
...
vm/address.go
View file @
99481a24
...
@@ -42,5 +42,5 @@ func ecrecoverFunc(in []byte) []byte {
...
@@ -42,5 +42,5 @@ func ecrecoverFunc(in []byte) []byte {
v
:=
ethutil
.
BigD
(
in
[
32
:
64
])
.
Bytes
()[
0
]
-
27
v
:=
ethutil
.
BigD
(
in
[
32
:
64
])
.
Bytes
()[
0
]
-
27
sig
:=
append
(
in
[
64
:
],
v
)
sig
:=
append
(
in
[
64
:
],
v
)
return
crypto
.
Sha3
(
crypto
.
Ecrecover
(
append
(
hash
,
sig
...
))[
1
:
]
)
return
ethutil
.
LeftPadBytes
(
crypto
.
Sha3
(
crypto
.
Ecrecover
(
append
(
hash
,
sig
...
))[
1
:
])[
12
:
],
32
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment