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
b7bb2d85
Commit
b7bb2d85
authored
Mar 15, 2016
by
Leif Jurvetson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: various typos
parent
e189fb83
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
39 additions
and
39 deletions
+39
-39
block_validator.go
core/block_validator.go
+3
-3
blockchain_test.go
core/blockchain_test.go
+4
-4
chain_makers.go
core/chain_makers.go
+2
-2
managed_state.go
core/state/managed_state.go
+1
-1
state_test.go
core/state/state_test.go
+1
-1
state_processor.go
core/state_processor.go
+1
-1
tx_pool.go
core/tx_pool.go
+3
-3
tx_pool_test.go
core/tx_pool_test.go
+1
-1
types.go
core/types.go
+1
-1
block.go
core/types/block.go
+1
-1
transaction.go
core/types/transaction.go
+2
-2
asm.go
core/vm/asm.go
+1
-1
doc.go
core/vm/doc.go
+1
-1
environment.go
core/vm/environment.go
+3
-3
jit.go
core/vm/jit.go
+3
-3
jit_test.go
core/vm/jit_test.go
+1
-1
jit_util.go
core/vm/jit_util.go
+1
-1
runtime.go
core/vm/runtime/runtime.go
+1
-1
vm.go
core/vm/vm.go
+4
-4
vm_jit.go
core/vm/vm_jit.go
+3
-3
vm_env.go
core/vm_env.go
+1
-1
No files found.
core/block_validator.go
View file @
b7bb2d85
...
...
@@ -58,7 +58,7 @@ func NewBlockValidator(blockchain *BlockChain, pow pow.PoW) *BlockValidator {
// the block header's transaction and uncle roots.
//
// ValidateBlock does not validate the header's pow. The pow work validated
// sep
erately so we can process them in para
lel.
// sep
arately so we can process them in paral
lel.
//
// ValidateBlock also validates and makes sure that any previous state (or present)
// state that might or might not be present is checked to make sure that fast
...
...
@@ -106,7 +106,7 @@ func (v *BlockValidator) ValidateBlock(block *types.Block) error {
// ValidateState validates the various changes that happen after a state
// transition, such as amount of used gas, the receipt roots and the state root
// itself. ValidateState returns a database batch if the validation was a succes
// itself. ValidateState returns a database batch if the validation was a succes
s
// otherwise nil and an error is returned.
func
(
v
*
BlockValidator
)
ValidateState
(
block
,
parent
*
types
.
Block
,
statedb
*
state
.
StateDB
,
receipts
types
.
Receipts
,
usedGas
*
big
.
Int
)
(
err
error
)
{
header
:=
block
.
Header
()
...
...
@@ -297,7 +297,7 @@ func calcDifficultyHomestead(time, parentTime uint64, parentNumber, parentDiff *
periodCount
:=
new
(
big
.
Int
)
.
Add
(
parentNumber
,
common
.
Big1
)
periodCount
.
Div
(
periodCount
,
ExpDiffPeriod
)
// the exponential factor, commonly refered to as "the bomb"
// the exponential factor, commonly refer
r
ed to as "the bomb"
// diff = diff + 2^(periodCount - 2)
if
periodCount
.
Cmp
(
common
.
Big1
)
>
0
{
y
.
Sub
(
periodCount
,
common
.
Big2
)
...
...
core/blockchain_test.go
View file @
b7bb2d85
...
...
@@ -578,7 +578,7 @@ func testBadHashes(t *testing.T, full bool) {
}
}
// Tests that bad hashes are detected on boot, and the chan rolled back to a
// Tests that bad hashes are detected on boot, and the cha
i
n rolled back to a
// good state prior to the bad hash.
func
TestReorgBadHeaderHashes
(
t
*
testing
.
T
)
{
testReorgBadHashes
(
t
,
false
)
}
func
TestReorgBadBlockHashes
(
t
*
testing
.
T
)
{
testReorgBadHashes
(
t
,
true
)
}
...
...
@@ -589,7 +589,7 @@ func testReorgBadHashes(t *testing.T, full bool) {
genesis
,
_
:=
WriteTestNetGenesisBlock
(
db
)
bc
:=
chm
(
genesis
,
db
)
// Create a chain, import and ban aferwards
// Create a chain, import and ban af
t
erwards
headers
:=
makeHeaderChainWithDiff
(
genesis
,
[]
int
{
1
,
2
,
3
,
4
},
10
)
blocks
:=
makeBlockChainWithDiff
(
genesis
,
[]
int
{
1
,
2
,
3
,
4
},
10
)
...
...
@@ -889,7 +889,7 @@ func TestChainTxReorgs(t *testing.T) {
var
pastDrop
,
freshDrop
*
types
.
Transaction
// Create three transactions that will be added in the forked chain:
// - pastAdd: transaction added before the reorganiztion is detected
// - pastAdd: transaction added before the reorganiz
a
tion is detected
// - freshAdd: transaction added at the exact block the reorg is detected
// - futureAdd: transaction added after the reorg has already finished
var
pastAdd
,
freshAdd
,
futureAdd
*
types
.
Transaction
...
...
@@ -1086,7 +1086,7 @@ done:
// make sure no more events are fired
select
{
case
e
:=
<-
subs
.
Chan
()
:
t
.
Errorf
(
"unex
ectp
ed event fired: %v"
,
e
)
t
.
Errorf
(
"unex
pect
ed event fired: %v"
,
e
)
case
<-
time
.
After
(
250
*
time
.
Millisecond
)
:
}
...
...
core/chain_makers.go
View file @
b7bb2d85
...
...
@@ -108,7 +108,7 @@ func (b *BlockGen) Number() *big.Int {
// backing transaction.
//
// AddUncheckedReceipts will cause consensus failures when used during real
// chain processing. This is best used in conjuction with raw block insertion.
// chain processing. This is best used in conju
n
ction with raw block insertion.
func
(
b
*
BlockGen
)
AddUncheckedReceipt
(
receipt
*
types
.
Receipt
)
{
b
.
receipts
=
append
(
b
.
receipts
,
receipt
)
}
...
...
@@ -215,7 +215,7 @@ func makeHeader(parent *types.Block, state *state.StateDB) *types.Header {
// chain. Depending on the full flag, if creates either a full block chain or a
// header only chain.
func
newCanonical
(
n
int
,
full
bool
)
(
ethdb
.
Database
,
*
BlockChain
,
error
)
{
// Create te new chain database
// Create t
h
e new chain database
db
,
_
:=
ethdb
.
NewMemDatabase
()
evmux
:=
&
event
.
TypeMux
{}
...
...
core/state/managed_state.go
View file @
b7bb2d85
...
...
@@ -82,7 +82,7 @@ func (ms *ManagedState) NewNonce(addr common.Address) uint64 {
return
uint64
(
len
(
account
.
nonces
)
-
1
)
+
account
.
nstart
}
// GetNonce returns the canonical nonce for the managed or unmanged account
// GetNonce returns the canonical nonce for the managed or unman
a
ged account
func
(
ms
*
ManagedState
)
GetNonce
(
addr
common
.
Address
)
uint64
{
ms
.
mu
.
RLock
()
defer
ms
.
mu
.
RUnlock
()
...
...
core/state/state_test.go
View file @
b7bb2d85
...
...
@@ -102,7 +102,7 @@ func (s *StateSuite) TestSnapshot(c *checker.C) {
data1
:=
common
.
BytesToHash
([]
byte
{
42
})
data2
:=
common
.
BytesToHash
([]
byte
{
43
})
// set inital state object value
// set init
i
al state object value
s
.
state
.
SetState
(
stateobjaddr
,
storageaddr
,
data1
)
// get snapshot of current state
snapshot
:=
s
.
state
.
Copy
()
...
...
core/state_processor.go
View file @
b7bb2d85
...
...
@@ -55,7 +55,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB) (ty
return
receipts
,
allLogs
,
totalUsedGas
,
err
}
// ApplyTransaction attemps to apply a transaction to the given state database
// ApplyTransaction attemp
t
s to apply a transaction to the given state database
// and uses the input parameters for its environment.
//
// ApplyTransactions returns the generated receipts and vm logs during the
...
...
core/tx_pool.go
View file @
b7bb2d85
...
...
@@ -60,8 +60,8 @@ type stateFn func() (*state.StateDB, error)
// current state) and future transactions. Transactions move between those
// two states over time as they are received and processed.
type
TxPool
struct
{
quit
chan
bool
// Quiting channel
currentState
stateFn
// The state function which will allow us to do some pre check
e
s
quit
chan
bool
// Quit
t
ing channel
currentState
stateFn
// The state function which will allow us to do some pre checks
pendingState
*
state
.
ManagedState
gasLimit
func
()
*
big
.
Int
// The current gas limit function callback
minGasPrice
*
big
.
Int
...
...
@@ -357,7 +357,7 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) {
}
}
// check and validate the queue
ue
// check and validate the queue
self
.
checkQueue
()
}
...
...
core/tx_pool_test.go
View file @
b7bb2d85
...
...
@@ -331,7 +331,7 @@ func TestTransactionDropping(t *testing.T) {
// Tests that if a transaction is dropped from the current pending pool (e.g. out
// of fund), all consecutive (still valid, but not executable) transactions are
// postponed back into the future queue to prevent broadcating them.
// postponed back into the future queue to prevent broadca
s
ting them.
func
TestTransactionPostponing
(
t
*
testing
.
T
)
{
// Create a test account and fund it
pool
,
key
:=
setupTxPool
()
...
...
core/types.go
View file @
b7bb2d85
...
...
@@ -39,7 +39,7 @@ import (
// if it failed to do so.
//
// ValidateState validates the given statedb and optionally the receipts and
// gas used. The implement
o
r should decide what to do with the given input.
// gas used. The implement
e
r should decide what to do with the given input.
type
Validator
interface
{
HeaderValidator
ValidateBlock
(
block
*
types
.
Block
)
error
...
...
core/types/block.go
View file @
b7bb2d85
...
...
@@ -34,7 +34,7 @@ import (
)
// A BlockNonce is a 64-bit hash which proves (combined with the
// mix-hash) that a suffcient amount of computation has been carried
// mix-hash) that a suff
i
cient amount of computation has been carried
// out on a block.
type
BlockNonce
[
8
]
byte
...
...
core/types/transaction.go
View file @
b7bb2d85
...
...
@@ -158,7 +158,7 @@ func (tx *Transaction) Size() common.StorageSize {
}
// From returns the address derived from the signature (V, R, S) using secp256k1
// eliptic curve and an error if it failed deriving or upon an incorrect
// el
l
iptic curve and an error if it failed deriving or upon an incorrect
// signature.
//
// From Uses the homestead consensus rules to determine whether the signature is
...
...
@@ -176,7 +176,7 @@ func (tx *Transaction) From() (common.Address, error) {
}
// FromFrontier returns the address derived from the signature (V, R, S) using
// secp256k1 eliptic curve and an error if it failed deriving or upon an
// secp256k1 el
l
iptic curve and an error if it failed deriving or upon an
// incorrect signature.
//
// FromFrantier uses the frontier consensus rules to determine whether the
...
...
core/vm/asm.go
View file @
b7bb2d85
...
...
@@ -23,7 +23,7 @@ import (
"github.com/ethereum/go-ethereum/common"
)
// Dis
sassemble dis
sassembles the byte code and returns the string
// Dis
assemble di
sassembles the byte code and returns the string
// representation (human readable opcodes).
func
Disassemble
(
script
[]
byte
)
(
asm
[]
string
)
{
pc
:=
new
(
big
.
Int
)
...
...
core/vm/doc.go
View file @
b7bb2d85
...
...
@@ -20,7 +20,7 @@ Package vm implements the Ethereum Virtual Machine.
The vm package implements two EVMs, a byte code VM and a JIT VM. The BC
(Byte Code) VM loops over a set of bytes and executes them according to the set
of rules defined in the Ethereum yellow paper. When the BC VM is invoked it
invokes the JIT VM in a sep
e
rate goroutine and compiles the byte code in JIT
invokes the JIT VM in a sep
a
rate goroutine and compiles the byte code in JIT
instructions.
The JIT VM, when invoked, loops around a set of pre-defined instructions until
...
...
core/vm/environment.go
View file @
b7bb2d85
...
...
@@ -34,9 +34,9 @@ type Environment interface {
MakeSnapshot
()
Database
// Set database to previous snapshot
SetSnapshot
(
Database
)
// Address of the original invoker (first occur
a
nce of the VM invoker)
// Address of the original invoker (first occur
re
nce of the VM invoker)
Origin
()
common
.
Address
// The block number this VM is invoke
n
on
// The block number this VM is invoke
d
on
BlockNumber
()
*
big
.
Int
// The n'th hash ago from this block number
GetHash
(
uint64
)
common
.
Hash
...
...
@@ -101,7 +101,7 @@ type Database interface {
IsDeleted
(
common
.
Address
)
bool
}
// StructLog is emit
ed to the Environment each cycle and lists information about the cu
rent internal state
// StructLog is emit
ted to the Environment each cycle and lists information about the cur
rent internal state
// prior to the execution of the statement.
type
StructLog
struct
{
Pc
uint64
...
...
core/vm/jit.go
View file @
b7bb2d85
...
...
@@ -300,7 +300,7 @@ func CompileProgram(program *Program) (err error) {
return
nil
}
// RunProgram runs the program given the enviroment and contract and returns an
// RunProgram runs the program given the enviro
n
ment and contract and returns an
// error if the execution failed (non-consensus)
func
RunProgram
(
program
*
Program
,
env
Environment
,
contract
*
Contract
,
input
[]
byte
)
([]
byte
,
error
)
{
return
runProgram
(
program
,
0
,
NewMemory
(),
newstack
(),
env
,
contract
,
input
)
...
...
@@ -346,7 +346,7 @@ func runProgram(program *Program, pcstart uint64, mem *Memory, stack *stack, env
return
nil
,
nil
}
// validDest checks if the given d
i
stination is a valid one given the
// validDest checks if the given d
e
stination is a valid one given the
// destination table of the program
func
validDest
(
dests
map
[
uint64
]
struct
{},
dest
*
big
.
Int
)
bool
{
// PC cannot go beyond len(code) and certainly can't be bigger than 64bits.
...
...
@@ -416,7 +416,7 @@ func jitCalculateGasAndSize(env Environment, contract *Contract, instr instructi
// This checks for 3 scenario's and calculates gas accordingly
// 1. From a zero-value address to a non-zero value (NEW VALUE)
// 2. From a non-zero value address to a zero-value address (DELETE)
// 3. From a n
e
n-zero to a non-zero (CHANGE)
// 3. From a n
o
n-zero to a non-zero (CHANGE)
if
common
.
EmptyHash
(
val
)
&&
!
common
.
EmptyHash
(
common
.
BigToHash
(
y
))
{
g
=
params
.
SstoreSetGas
}
else
if
!
common
.
EmptyHash
(
val
)
&&
common
.
EmptyHash
(
common
.
BigToHash
(
y
))
{
...
...
core/vm/jit_test.go
View file @
b7bb2d85
...
...
@@ -77,7 +77,7 @@ func TestCompiling(t *testing.T) {
}
if
len
(
prog
.
instructions
)
!=
1
{
t
.
Error
(
"exected 1 compiled instruction, got"
,
len
(
prog
.
instructions
))
t
.
Error
(
"ex
p
ected 1 compiled instruction, got"
,
len
(
prog
.
instructions
))
}
}
...
...
core/vm/jit_util.go
View file @
b7bb2d85
...
...
@@ -41,7 +41,7 @@ func Parse(code []byte) (opcodes []OpCode) {
// MatchFn searcher for match in the given input and calls matcheFn if it finds
// an appropriate match. matcherFn yields the starting position in the input.
// MatchFn will continue to search for a match until it reache
r
the end of the
// MatchFn will continue to search for a match until it reache
s
the end of the
// buffer or if matcherFn return false.
func
MatchFn
(
input
,
match
[]
OpCode
,
matcherFn
func
(
int
)
bool
)
{
// short circuit if either input or match is empty or if the match is
...
...
core/vm/runtime/runtime.go
View file @
b7bb2d85
...
...
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
)
// Config is a basic type specifing certain configuration flags for running
// Config is a basic type specif
y
ing certain configuration flags for running
// the EVM.
type
Config
struct
{
Difficulty
*
big
.
Int
...
...
core/vm/vm.go
View file @
b7bb2d85
...
...
@@ -63,7 +63,7 @@ func (self *Vm) Run(contract *Contract, input []byte) (ret []byte, err error) {
)
if
EnableJit
{
// If the JIT is enabled check the status of the JIT program,
// if it doesn't exist compile a new program in a sep
e
rate
// if it doesn't exist compile a new program in a sep
a
rate
// goroutine or wait for compilation to finish if the JIT is
// forced.
switch
GetProgramStatus
(
codehash
)
{
...
...
@@ -80,7 +80,7 @@ func (self *Vm) Run(contract *Contract, input []byte) (ret []byte, err error) {
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"error compiling program"
,
err
)
}
else
{
// create and compile the program. Compilation
// is done in a sep
e
rate goroutine
// is done in a sep
a
rate goroutine
program
=
NewProgram
(
contract
.
Code
)
go
func
()
{
err
:=
CompileProgram
(
program
)
...
...
@@ -103,7 +103,7 @@ func (self *Vm) Run(contract *Contract, input []byte) (ret []byte, err error) {
stack
=
newstack
()
// local stack
statedb
=
self
.
env
.
Db
()
// current state
// For optimisation reason we're using uint64 as the program counter.
// It's theoretically possible to go above 2^64. The YP defines the PC to be uint256. Pratically much less so feasible.
// It's theoretically possible to go above 2^64. The YP defines the PC to be uint256. Pra
c
tically much less so feasible.
pc
=
uint64
(
0
)
// program counter
// jump evaluates and checks whether the given jump destination is a valid one
...
...
@@ -271,7 +271,7 @@ func calculateGasAndSize(env Environment, contract *Contract, caller ContractRef
// This checks for 3 scenario's and calculates gas accordingly
// 1. From a zero-value address to a non-zero value (NEW VALUE)
// 2. From a non-zero value address to a zero-value address (DELETE)
// 3. From a n
e
n-zero to a non-zero (CHANGE)
// 3. From a n
o
n-zero to a non-zero (CHANGE)
if
common
.
EmptyHash
(
val
)
&&
!
common
.
EmptyHash
(
common
.
BigToHash
(
y
))
{
// 0 => non 0
g
=
params
.
SstoreSetGas
...
...
core/vm/vm_jit.go
View file @
b7bb2d85
...
...
@@ -138,7 +138,7 @@ func llvm2big(m *i256) *big.Int {
}
// llvm2bytesRef creates a []byte slice that references byte buffer on LLVM side (as of that not controller by GC)
// User must
a
sure that referenced memory is available to Go until the data is copied or not needed any more
// User must
en
sure that referenced memory is available to Go until the data is copied or not needed any more
func llvm2bytesRef(data *byte, length uint64) []byte {
if length == 0 {
return nil
...
...
@@ -171,7 +171,7 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
// TODO: Move it to Env.Call() or sth
if Precompiled[string(me.Address())] != nil {
// if it's address of precopiled contract
// if it's address of preco
m
piled contract
// fallback to standard VM
stdVm := New(self.env)
return stdVm.Run(me, caller, code, value, gas, price, callData)
...
...
@@ -348,7 +348,7 @@ func env_create(_vm unsafe.Pointer, _gas *int64, _value unsafe.Pointer, initData
gas := big.NewInt(*_gas)
ret, suberr, ref := vm.env.Create(vm.me, nil, initData, gas, vm.price, value)
if suberr == nil {
dataGas := big.NewInt(int64(len(ret))) // TODO: N
to
the best design. env.Create can do it, it has the reference to gas counter
dataGas := big.NewInt(int64(len(ret))) // TODO: N
ot
the best design. env.Create can do it, it has the reference to gas counter
dataGas.Mul(dataGas, params.CreateDataGas)
gas.Sub(gas, dataGas)
*result = hash2llvm(ref.Address())
...
...
core/vm_env.go
View file @
b7bb2d85
...
...
@@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
)
// GetHashFn returns a function for which the VM env can query block hashes thr
u
// GetHashFn returns a function for which the VM env can query block hashes thr
ough
// up to the limit defined by the Yellow Paper and uses the given block chain
// to query for information.
func
GetHashFn
(
ref
common
.
Hash
,
chain
*
BlockChain
)
func
(
n
uint64
)
common
.
Hash
{
...
...
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