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
ba0a758d
Commit
ba0a758d
authored
Mar 03, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quad mem & log changes
parent
49da6a8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
common.go
vm/common.go
+4
-3
vm.go
vm/vm.go
+11
-7
No files found.
vm/common.go
View file @
ba0a758d
...
...
@@ -41,13 +41,14 @@ var (
GasStorageGet
=
big
.
NewInt
(
50
)
GasStorageAdd
=
big
.
NewInt
(
20000
)
GasStorageMod
=
big
.
NewInt
(
5000
)
GasLogBase
=
big
.
NewInt
(
2000
)
GasLogTopic
=
big
.
NewInt
(
2000
)
GasLogBase
=
big
.
NewInt
(
375
)
GasLogTopic
=
big
.
NewInt
(
375
)
GasLogByte
=
big
.
NewInt
(
8
)
GasCreate
=
big
.
NewInt
(
32000
)
GasCreateByte
=
big
.
NewInt
(
300
)
GasCall
=
big
.
NewInt
(
40
)
GasCallValueTransfer
=
big
.
NewInt
(
6700
)
GasCallValueTransfer
=
big
.
NewInt
(
9000
)
GasStipend
=
big
.
NewInt
(
2300
)
GasCallNewAccount
=
big
.
NewInt
(
25000
)
GasReturn
=
big
.
NewInt
(
0
)
GasStop
=
big
.
NewInt
(
0
)
...
...
vm/vm.go
View file @
ba0a758d
...
...
@@ -399,7 +399,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
stack
.
Push
(
ethutil
.
BigD
(
data
))
self
.
Printf
(
" =>
%x"
,
data
)
self
.
Printf
(
" =>
(%v) %x"
,
size
,
data
)
// 0x30 range
case
ADDRESS
:
stack
.
Push
(
ethutil
.
BigD
(
context
.
Address
()))
...
...
@@ -690,6 +690,10 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
// Get the arguments from the memory
args
:=
mem
.
Get
(
inOffset
.
Int64
(),
inSize
.
Int64
())
if
len
(
value
.
Bytes
())
>
0
{
gas
.
Add
(
gas
,
GasStipend
)
}
var
(
ret
[]
byte
err
error
...
...
@@ -938,7 +942,7 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
gas
.
Add
(
gas
,
GasCallNewAccount
)
}
if
len
(
stack
.
data
[
stack
.
Len
()
-
1
]
.
Bytes
())
>
0
{
if
len
(
stack
.
data
[
stack
.
Len
()
-
3
]
.
Bytes
())
>
0
{
gas
.
Add
(
gas
,
GasCallValueTransfer
)
}
}
...
...
@@ -951,7 +955,8 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
}
if
newMemSize
.
Cmp
(
ethutil
.
Big0
)
>
0
{
newMemSize
=
toWordSize
(
newMemSize
)
newMemSizeWords
:=
toWordSize
(
newMemSize
)
newMemSize
.
Mul
(
newMemSizeWords
,
u256
(
32
))
if
newMemSize
.
Cmp
(
u256
(
int64
(
mem
.
Len
())))
>
0
{
//memGasUsage := new(big.Int).Sub(newMemSize, u256(int64(mem.Len())))
...
...
@@ -959,20 +964,19 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
//memGasUsage.Div(memGasUsage, u256(32))
//Old: full_memory_gas_cost = W + floor(W*W / 1024), W = words in memory
pow
:=
new
(
big
.
Int
)
.
Exp
(
oldSize
,
ethutil
.
Big2
,
Zero
)
oldSize
:=
toWordSize
(
big
.
NewInt
(
int64
(
mem
.
Len
())))
pow
:=
new
(
big
.
Int
)
.
Exp
(
oldSize
,
ethutil
.
Big2
,
Zero
)
linCoef
:=
new
(
big
.
Int
)
.
Mul
(
oldSize
,
GasMemWord
)
quadCoef
:=
new
(
big
.
Int
)
.
Div
(
pow
,
GasQuadCoeffDenom
)
oldTotalFee
:=
new
(
big
.
Int
)
.
Add
(
linCoef
,
quadCoef
)
pow
.
Exp
(
newMemSize
,
ethutil
.
Big2
,
Zero
)
linCoef
=
new
(
big
.
Int
)
.
Mul
(
newMemSize
,
GasMemWord
)
pow
.
Exp
(
newMemSize
Words
,
ethutil
.
Big2
,
Zero
)
linCoef
=
new
(
big
.
Int
)
.
Mul
(
newMemSize
Words
,
GasMemWord
)
quadCoef
=
new
(
big
.
Int
)
.
Div
(
pow
,
GasQuadCoeffDenom
)
newTotalFee
:=
new
(
big
.
Int
)
.
Add
(
linCoef
,
quadCoef
)
gas
.
Add
(
gas
,
new
(
big
.
Int
)
.
Sub
(
newTotalFee
,
oldTotalFee
))
}
}
return
newMemSize
,
gas
...
...
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