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
20ee1ae6
Commit
20ee1ae6
authored
Jul 21, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored CALLDATALOAD to use big int
* Added BigMin
parent
eab0b2a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
18 deletions
+27
-18
vm.go
ethchain/vm.go
+9
-5
big.go
ethutil/big.go
+11
-8
common.go
ethutil/common.go
+7
-5
No files found.
ethchain/vm.go
View file @
20ee1ae6
...
...
@@ -503,13 +503,17 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
vm
.
Printf
(
" => %v"
,
vm
.
vars
.
Value
)
case
CALLDATALOAD
:
require
(
1
)
offset
:=
stack
.
Pop
()
.
Int64
()
var
(
offset
=
stack
.
Pop
()
data
=
make
([]
byte
,
32
)
lenData
=
big
.
NewInt
(
int64
(
len
(
closure
.
Args
)))
)
data
:=
make
([]
byte
,
32
)
if
big
.
NewInt
(
int64
(
len
(
closure
.
Args
)))
.
Cmp
(
big
.
NewInt
(
offset
))
>=
0
{
l
:=
int64
(
math
.
Min
(
float64
(
offset
+
32
),
float64
(
len
(
closure
.
Args
)))
)
if
lenData
.
Cmp
(
offset
)
>=
0
{
length
:=
new
(
big
.
Int
)
.
Add
(
offset
,
ethutil
.
Big32
)
l
ength
=
ethutil
.
BigMin
(
length
,
lenData
)
copy
(
data
,
closure
.
Args
[
offset
:
l
])
copy
(
data
,
closure
.
Args
[
offset
.
Int64
()
:
length
.
Int64
()
])
}
vm
.
Printf
(
" => 0x%x"
,
data
)
...
...
ethutil/big.go
View file @
20ee1ae6
...
...
@@ -4,14 +4,6 @@ import (
"math/big"
)
var
BigInt0
*
big
.
Int
=
big
.
NewInt
(
0
)
// True
var
BigTrue
*
big
.
Int
=
big
.
NewInt
(
1
)
// False
var
BigFalse
*
big
.
Int
=
big
.
NewInt
(
0
)
// Big pow
//
// Returns the power of two big integers
...
...
@@ -73,3 +65,14 @@ func BigMax(x, y *big.Int) *big.Int {
return
x
}
// Big min
//
// Returns the minimum size big integer
func
BigMin
(
x
,
y
*
big
.
Int
)
*
big
.
Int
{
if
x
.
Cmp
(
y
)
>=
0
{
return
y
}
return
x
}
ethutil/common.go
View file @
20ee1ae6
...
...
@@ -58,9 +58,11 @@ func CurrencyToString(num *big.Int) string {
// Common big integers often used
var
(
Big1
=
big
.
NewInt
(
1
)
Big2
=
big
.
NewInt
(
2
)
Big0
=
big
.
NewInt
(
0
)
Big32
=
big
.
NewInt
(
32
)
Big256
=
big
.
NewInt
(
0xff
)
Big1
=
big
.
NewInt
(
1
)
Big2
=
big
.
NewInt
(
2
)
Big0
=
big
.
NewInt
(
0
)
BigTrue
=
Big1
BigFalse
=
Big0
Big32
=
big
.
NewInt
(
32
)
Big256
=
big
.
NewInt
(
0xff
)
)
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