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
1bce02ef
Commit
1bce02ef
authored
Nov 28, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Fixed merge
parents
8cf9ed0e
a3559c5e
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
76 additions
and
69 deletions
+76
-69
block_manager.go
chain/block_manager.go
+4
-3
chain_manager.go
chain/chain_manager.go
+0
-2
genesis.go
chain/genesis.go
+0
-2
state_transition.go
chain/state_transition.go
+15
-3
block.go
chain/types/block.go
+14
-22
main.go
cmd/ethereum/main.go
+2
-1
main.go
cmd/mist/main.go
+1
-1
install.sh
install.sh
+22
-19
miner.go
miner/miner.go
+1
-2
peer.go
peer.go
+1
-1
state.go
state/state.go
+16
-13
No files found.
chain/block_manager.go
View file @
1bce02ef
...
@@ -155,10 +155,11 @@ done:
...
@@ -155,10 +155,11 @@ done:
}
}
}
}
txGas
.
Sub
(
txGas
,
st
.
gas
)
// Update the state with pending changes
// Update the state with pending changes
state
.
Update
()
state
.
Update
(
txGas
)
txGas
.
Sub
(
txGas
,
st
.
gas
)
cumulative
:=
new
(
big
.
Int
)
.
Set
(
totalUsedGas
.
Add
(
totalUsedGas
,
txGas
))
cumulative
:=
new
(
big
.
Int
)
.
Set
(
totalUsedGas
.
Add
(
totalUsedGas
,
txGas
))
receipt
:=
types
.
NewReceipt
(
state
.
Root
(),
cumulative
)
receipt
:=
types
.
NewReceipt
(
state
.
Root
(),
cumulative
)
receipt
.
SetLogs
(
state
.
Logs
())
receipt
.
SetLogs
(
state
.
Logs
())
...
@@ -247,7 +248,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
...
@@ -247,7 +248,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
return
return
}
}
state
.
Update
()
state
.
Update
(
nil
)
if
!
block
.
State
()
.
Cmp
(
state
)
{
if
!
block
.
State
()
.
Cmp
(
state
)
{
err
=
fmt
.
Errorf
(
"invalid merkle root. received=%x got=%x"
,
block
.
Root
(),
state
.
Root
())
err
=
fmt
.
Errorf
(
"invalid merkle root. received=%x got=%x"
,
block
.
Root
(),
state
.
Root
())
...
...
chain/chain_manager.go
View file @
1bce02ef
...
@@ -112,8 +112,6 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block {
...
@@ -112,8 +112,6 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block {
nil
,
nil
,
""
)
""
)
block
.
MinGasPrice
=
big
.
NewInt
(
10000000000000
)
parent
:=
bc
.
CurrentBlock
parent
:=
bc
.
CurrentBlock
if
parent
!=
nil
{
if
parent
!=
nil
{
block
.
Difficulty
=
CalcDifficulty
(
block
,
parent
)
block
.
Difficulty
=
CalcDifficulty
(
block
,
parent
)
...
...
chain/genesis.go
View file @
1bce02ef
...
@@ -37,8 +37,6 @@ var GenesisHeader = []interface{}{
...
@@ -37,8 +37,6 @@ var GenesisHeader = []interface{}{
big
.
NewInt
(
131072
),
big
.
NewInt
(
131072
),
// Number
// Number
ethutil
.
Big0
,
ethutil
.
Big0
,
// Block minimum gas price
ethutil
.
Big0
,
// Block upper gas bound
// Block upper gas bound
big
.
NewInt
(
1000000
),
big
.
NewInt
(
1000000
),
// Block gas used
// Block gas used
...
...
chain/state_transition.go
View file @
1bce02ef
...
@@ -157,12 +157,24 @@ func (self *StateTransition) TransitionState() (err error) {
...
@@ -157,12 +157,24 @@ func (self *StateTransition) TransitionState() (err error) {
}
}
// Pay data gas
// Pay data gas
dataPrice
:=
big
.
NewInt
(
int64
(
len
(
self
.
data
)))
var
dgas
int64
dataPrice
.
Mul
(
dataPrice
,
vm
.
GasData
)
for
_
,
byt
:=
range
self
.
data
{
if
err
=
self
.
UseGas
(
dataPrice
);
err
!=
nil
{
if
byt
!=
0
{
dgas
+=
vm
.
GasData
.
Int64
()
}
else
{
dgas
+=
1
// This is 1/5. If GasData changes this fails
}
}
if
err
=
self
.
UseGas
(
big
.
NewInt
(
dgas
));
err
!=
nil
{
return
return
}
}
//dataPrice := big.NewInt(int64(len(self.data)))
//dataPrice.Mul(dataPrice, vm.GasData)
//if err = self.UseGas(dataPrice); err != nil {
// return
//}
if
sender
.
Balance
()
.
Cmp
(
self
.
value
)
<
0
{
if
sender
.
Balance
()
.
Cmp
(
self
.
value
)
<
0
{
return
fmt
.
Errorf
(
"Insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
sender
.
Balance
)
return
fmt
.
Errorf
(
"Insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
sender
.
Balance
)
}
}
...
...
chain/types/block.go
View file @
1bce02ef
...
@@ -84,8 +84,6 @@ type Block struct {
...
@@ -84,8 +84,6 @@ type Block struct {
Time
int64
Time
int64
// The block number
// The block number
Number
*
big
.
Int
Number
*
big
.
Int
// Minimum Gas Price
MinGasPrice
*
big
.
Int
// Gas limit
// Gas limit
GasLimit
*
big
.
Int
GasLimit
*
big
.
Int
// Gas used
// Gas used
...
@@ -132,7 +130,6 @@ func CreateBlock(root interface{},
...
@@ -132,7 +130,6 @@ func CreateBlock(root interface{},
Extra
:
extra
,
Extra
:
extra
,
UncleSha
:
nil
,
UncleSha
:
nil
,
GasUsed
:
new
(
big
.
Int
),
GasUsed
:
new
(
big
.
Int
),
MinGasPrice
:
new
(
big
.
Int
),
GasLimit
:
new
(
big
.
Int
),
GasLimit
:
new
(
big
.
Int
),
}
}
block
.
SetUncles
([]
*
Block
{})
block
.
SetUncles
([]
*
Block
{})
...
@@ -300,12 +297,11 @@ func (self *Block) setHeader(header *ethutil.Value) {
...
@@ -300,12 +297,11 @@ func (self *Block) setHeader(header *ethutil.Value) {
self
.
LogsBloom
=
header
.
Get
(
6
)
.
Bytes
()
self
.
LogsBloom
=
header
.
Get
(
6
)
.
Bytes
()
self
.
Difficulty
=
header
.
Get
(
7
)
.
BigInt
()
self
.
Difficulty
=
header
.
Get
(
7
)
.
BigInt
()
self
.
Number
=
header
.
Get
(
8
)
.
BigInt
()
self
.
Number
=
header
.
Get
(
8
)
.
BigInt
()
self
.
MinGasPrice
=
header
.
Get
(
9
)
.
BigInt
()
self
.
GasLimit
=
header
.
Get
(
9
)
.
BigInt
()
self
.
GasLimit
=
header
.
Get
(
10
)
.
BigInt
()
self
.
GasUsed
=
header
.
Get
(
10
)
.
BigInt
()
self
.
GasUsed
=
header
.
Get
(
11
)
.
BigInt
()
self
.
Time
=
int64
(
header
.
Get
(
11
)
.
BigInt
()
.
Uint64
())
self
.
Time
=
int64
(
header
.
Get
(
12
)
.
BigInt
()
.
Uint64
())
self
.
Extra
=
header
.
Get
(
12
)
.
Str
()
self
.
Extra
=
header
.
Get
(
13
)
.
Str
()
self
.
Nonce
=
header
.
Get
(
13
)
.
Bytes
()
self
.
Nonce
=
header
.
Get
(
14
)
.
Bytes
()
}
}
func
NewUncleBlockFromValue
(
header
*
ethutil
.
Value
)
*
Block
{
func
NewUncleBlockFromValue
(
header
*
ethutil
.
Value
)
*
Block
{
...
@@ -351,8 +347,6 @@ func (block *Block) miningHeader() []interface{} {
...
@@ -351,8 +347,6 @@ func (block *Block) miningHeader() []interface{} {
block
.
Difficulty
,
block
.
Difficulty
,
// The block number
// The block number
block
.
Number
,
block
.
Number
,
// Block minimum gas price
block
.
MinGasPrice
,
// Block upper gas bound
// Block upper gas bound
block
.
GasLimit
,
block
.
GasLimit
,
// Block gas used
// Block gas used
...
@@ -380,7 +374,6 @@ func (block *Block) String() string {
...
@@ -380,7 +374,6 @@ func (block *Block) String() string {
Bloom: %x
Bloom: %x
Difficulty: %v
Difficulty: %v
Number: %v
Number: %v
MinGas: %v
MaxLimit: %v
MaxLimit: %v
GasUsed: %v
GasUsed: %v
Time: %v
Time: %v
...
@@ -399,7 +392,6 @@ func (block *Block) String() string {
...
@@ -399,7 +392,6 @@ func (block *Block) String() string {
block
.
LogsBloom
,
block
.
LogsBloom
,
block
.
Difficulty
,
block
.
Difficulty
,
block
.
Number
,
block
.
Number
,
block
.
MinGasPrice
,
block
.
GasLimit
,
block
.
GasLimit
,
block
.
GasUsed
,
block
.
GasUsed
,
block
.
Time
,
block
.
Time
,
...
...
cmd/ethereum/main.go
View file @
1bce02ef
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"fmt"
"fmt"
"os"
"os"
"runtime"
"runtime"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
...
@@ -29,7 +30,7 @@ import (
...
@@ -29,7 +30,7 @@ import (
const
(
const
(
ClientIdentifier
=
"Ethereum(G)"
ClientIdentifier
=
"Ethereum(G)"
Version
=
"0.7.
5
"
Version
=
"0.7.
6
"
)
)
var
clilogger
=
logger
.
NewLogger
(
"CLI"
)
var
clilogger
=
logger
.
NewLogger
(
"CLI"
)
...
...
cmd/mist/main.go
View file @
1bce02ef
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
const
(
const
(
ClientIdentifier
=
"Mist"
ClientIdentifier
=
"Mist"
Version
=
"0.7.
5
"
Version
=
"0.7.
6
"
)
)
var
ethereum
*
eth
.
Ethereum
var
ethereum
*
eth
.
Ethereum
...
...
install.sh
View file @
1bce02ef
#!/bin/sh
#!/bin/sh
if
[
"
$1
"
==
""
]
;
then
if
[
"
$1
"
==
""
]
;
then
echo
"Usage
$0
executable branch
ethereum develop
"
echo
"Usage
$0
executable branch"
echo
"executable ethereum
or
mist"
echo
"executable ethereum
|
mist"
echo
"branch develop
or
master"
echo
"branch develop
|
master"
exit
exit
fi
fi
exe
=
$1
exe
=
$1
path
=
$exe
branch
=
$2
branch
=
$2
if
[
"
$branch
"
==
"develop"
]
;
then
path
=
"cmd/
$exe
"
fi
# Test if go is installed
# Test if go is installed
command
-v
go
>
/dev/null 2>&1
||
{
echo
>
&2
"Unable to find 'go'. This script requires go."
;
exit
1
;
}
command
-v
go
>
/dev/null 2>&1
||
{
echo
>
&2
"Unable to find 'go'. This script requires go."
;
exit
1
;
}
...
@@ -19,20 +24,23 @@ if [ "$GOPATH" == "" ]; then
...
@@ -19,20 +24,23 @@ if [ "$GOPATH" == "" ]; then
exit
exit
fi
fi
echo
"go get -u -d github.com/ethereum/go-ethereum/
$exe
"
echo
"changing branch to
$branch
"
go get
-v
-u
-d
github.com/ethereum/go-ethereum/
$exe
if
[
$?
!=
0
]
;
then
echo
"go get failed"
exit
fi
echo
"eth-go"
cd
$GOPATH
/src/github.com/ethereum/go-ethereum
cd
$GOPATH
/src/github.com/ethereum/go-ethereum
git checkout
$branch
git checkout
$branch
echo
"go-ethereum"
# installing package dependencies doesn't work for develop
cd
$GOPATH
/src/github.com/ethereum/go-ethereum/
$exe
# branch as go get always pulls from master head
git checkout
$branch
# so build will continue to fail, but this installs locally
# for people who git clone since go install will manage deps
#echo "go get -u -d github.com/ethereum/go-ethereum/$path"
#go get -v -u -d github.com/ethereum/go-ethereum/$path
#if [ $? != 0 ]; then
# echo "go get failed"
# exit
#fi
cd
$GOPATH
/src/github.com/ethereum/go-ethereum/
$path
if
[
"
$exe
"
==
"mist"
]
;
then
if
[
"
$exe
"
==
"mist"
]
;
then
echo
"Building Mist GUI. Assuming Qt is installed. If this step"
echo
"Building Mist GUI. Assuming Qt is installed. If this step"
...
@@ -42,9 +50,4 @@ else
...
@@ -42,9 +50,4 @@ else
fi
fi
go
install
go
install
if
[
$?
==
0
]
;
then
echo
"go install failed"
exit
fi
echo
"done. Please run
$exe
:-)"
echo
"done. Please run
$exe
:-)"
miner/miner.go
View file @
1bce02ef
...
@@ -179,7 +179,6 @@ func (self *Miner) mine() {
...
@@ -179,7 +179,6 @@ func (self *Miner) mine() {
chainMan
=
self
.
eth
.
ChainManager
()
chainMan
=
self
.
eth
.
ChainManager
()
block
=
chainMan
.
NewBlock
(
self
.
Coinbase
)
block
=
chainMan
.
NewBlock
(
self
.
Coinbase
)
)
)
block
.
MinGasPrice
=
self
.
MinAcceptedGasPrice
// Apply uncles
// Apply uncles
if
len
(
self
.
uncles
)
>
0
{
if
len
(
self
.
uncles
)
>
0
{
...
@@ -206,7 +205,7 @@ func (self *Miner) mine() {
...
@@ -206,7 +205,7 @@ func (self *Miner) mine() {
// Accumulate the rewards included for this block
// Accumulate the rewards included for this block
blockManager
.
AccumelateRewards
(
block
.
State
(),
block
,
parent
)
blockManager
.
AccumelateRewards
(
block
.
State
(),
block
,
parent
)
block
.
State
()
.
Update
()
block
.
State
()
.
Update
(
nil
)
minerlogger
.
Infof
(
"Mining on block. Includes %v transactions"
,
len
(
transactions
))
minerlogger
.
Infof
(
"Mining on block. Includes %v transactions"
,
len
(
transactions
))
...
...
peer.go
View file @
1bce02ef
...
@@ -24,7 +24,7 @@ const (
...
@@ -24,7 +24,7 @@ const (
// The size of the output buffer for writing messages
// The size of the output buffer for writing messages
outputBufferSize
=
50
outputBufferSize
=
50
// Current protocol version
// Current protocol version
ProtocolVersion
=
4
3
ProtocolVersion
=
4
5
// Current P2P version
// Current P2P version
P2PVersion
=
2
P2PVersion
=
2
// Ethereum network version
// Ethereum network version
...
...
state/state.go
View file @
1bce02ef
...
@@ -23,14 +23,14 @@ type State struct {
...
@@ -23,14 +23,14 @@ type State struct {
manifest
*
Manifest
manifest
*
Manifest
refund
map
[
string
]
*
big
.
Int
refund
map
[
string
]
[]
refund
logs
Logs
logs
Logs
}
}
// Create a new state from a given trie
// Create a new state from a given trie
func
New
(
trie
*
trie
.
Trie
)
*
State
{
func
New
(
trie
*
trie
.
Trie
)
*
State
{
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
]
*
big
.
Int
)}
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
]
[]
refund
)}
}
}
func
(
self
*
State
)
EmptyLogs
()
{
func
(
self
*
State
)
EmptyLogs
()
{
...
@@ -55,14 +55,12 @@ func (self *State) GetBalance(addr []byte) *big.Int {
...
@@ -55,14 +55,12 @@ func (self *State) GetBalance(addr []byte) *big.Int {
return
ethutil
.
Big0
return
ethutil
.
Big0
}
}
func
(
self
*
State
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
type
refund
struct
{
amount
:=
new
(
big
.
Int
)
.
Mul
(
gas
,
price
)
gas
,
price
*
big
.
Int
}
if
self
.
refund
[
string
(
addr
)]
==
nil
{
self
.
refund
[
string
(
addr
)]
=
new
(
big
.
Int
)
}
self
.
refund
[
string
(
addr
)]
.
Add
(
self
.
refund
[
string
(
addr
)],
amount
)
func
(
self
*
State
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
self
.
refund
[
string
(
addr
)]
=
append
(
self
.
refund
[
string
(
addr
)],
refund
{
gas
,
price
})
}
}
func
(
self
*
State
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
func
(
self
*
State
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
...
@@ -276,15 +274,20 @@ func (s *State) Sync() {
...
@@ -276,15 +274,20 @@ func (s *State) Sync() {
func
(
self
*
State
)
Empty
()
{
func
(
self
*
State
)
Empty
()
{
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
refund
=
make
(
map
[
string
]
*
big
.
Int
)
self
.
refund
=
make
(
map
[
string
]
[]
refund
)
}
}
func
(
self
*
State
)
Update
()
{
func
(
self
*
State
)
Update
(
gasUsed
*
big
.
Int
)
{
var
deleted
bool
var
deleted
bool
// Refund any gas that's left
// Refund any gas that's left
for
addr
,
amount
:=
range
self
.
refund
{
uhalf
:=
new
(
big
.
Int
)
.
Div
(
gasUsed
,
ethutil
.
Big2
)
self
.
GetStateObject
([]
byte
(
addr
))
.
AddBalance
(
amount
)
for
addr
,
refs
:=
range
self
.
refund
{
for
_
,
ref
:=
range
refs
{
refund
:=
ethutil
.
BigMin
(
uhalf
,
ref
.
gas
)
self
.
GetStateObject
([]
byte
(
addr
))
.
AddBalance
(
refund
.
Mul
(
refund
,
ref
.
price
))
}
}
}
for
_
,
stateObject
:=
range
self
.
stateObjects
{
for
_
,
stateObject
:=
range
self
.
stateObjects
{
...
...
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