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
a0523578
Commit
a0523578
authored
Dec 01, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed EXP gas
parent
a22056db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
22 deletions
+11
-22
big.go
ethutil/big.go
+3
-3
gh_test.go
tests/vm/gh_test.go
+1
-13
vm_debug.go
vm/vm_debug.go
+7
-6
No files found.
ethutil/big.go
View file @
a0523578
...
@@ -62,14 +62,14 @@ func S256(x *big.Int) *big.Int {
...
@@ -62,14 +62,14 @@ func S256(x *big.Int) *big.Int {
}
}
}
}
func
FirstBitSet
(
v
*
big
.
Int
)
*
big
.
I
nt
{
func
FirstBitSet
(
v
*
big
.
Int
)
i
nt
{
for
i
:=
0
;
i
<
v
.
BitLen
();
i
++
{
for
i
:=
0
;
i
<
v
.
BitLen
();
i
++
{
if
v
.
Bit
(
i
)
>
0
{
if
v
.
Bit
(
i
)
>
0
{
return
big
.
NewInt
(
int64
(
i
))
return
i
}
}
}
}
return
big
.
NewInt
(
int64
(
v
.
BitLen
())
)
return
v
.
BitLen
(
)
}
}
// Big to bytes
// Big to bytes
...
...
tests/vm/gh_test.go
View file @
a0523578
...
@@ -2,7 +2,6 @@ package vm
...
@@ -2,7 +2,6 @@ package vm
import
(
import
(
"bytes"
"bytes"
"fmt"
"testing"
"testing"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
...
@@ -45,7 +44,6 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -45,7 +44,6 @@ func RunVmTest(p string, t *testing.T) {
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
fmt
.
Println
(
name
)
state
:=
state
.
New
(
helper
.
NewTrie
())
state
:=
state
.
New
(
helper
.
NewTrie
())
for
addr
,
account
:=
range
test
.
Pre
{
for
addr
,
account
:=
range
test
.
Pre
{
obj
:=
StateObjectFromAccount
(
addr
,
account
)
obj
:=
StateObjectFromAccount
(
addr
,
account
)
...
@@ -85,20 +83,10 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -85,20 +83,10 @@ func RunVmTest(p string, t *testing.T) {
// I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail.
// I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail.
func
TestVMArithmetic
(
t
*
testing
.
T
)
{
func
TestVMArithmetic
(
t
*
testing
.
T
)
{
//helper.Logger.SetLogLevel(5)
const
fn
=
"../files/vmtests/vmArithmeticTest.json"
const
fn
=
"../files/vmtests/vmArithmeticTest.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
/*
deleted?
func TestVMSystemOperation(t *testing.T) {
helper.Logger.SetLogLevel(5)
const fn = "../files/vmtests/vmSystemOperationsTest.json"
RunVmTest(fn, t)
}
*/
func
TestBitwiseLogicOperation
(
t
*
testing
.
T
)
{
func
TestBitwiseLogicOperation
(
t
*
testing
.
T
)
{
const
fn
=
"../files/vmtests/vmBitwiseLogicOperationTest.json"
const
fn
=
"../files/vmtests/vmBitwiseLogicOperationTest.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
...
@@ -126,7 +114,7 @@ func TestPushDupSwap(t *testing.T) {
...
@@ -126,7 +114,7 @@ func TestPushDupSwap(t *testing.T) {
}
}
func
TestVMSha3
(
t
*
testing
.
T
)
{
func
TestVMSha3
(
t
*
testing
.
T
)
{
helper
.
Logger
.
SetLogLevel
(
5
)
//
helper.Logger.SetLogLevel(5)
const
fn
=
"../files/vmtests/vmSha3Test.json"
const
fn
=
"../files/vmtests/vmSha3Test.json"
RunVmTest
(
fn
,
t
)
RunVmTest
(
fn
,
t
)
}
}
...
...
vm/vm_debug.go
View file @
a0523578
...
@@ -172,12 +172,13 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
...
@@ -172,12 +172,13 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
case
EXP
:
case
EXP
:
require
(
2
)
require
(
2
)
expGas
:=
ethutil
.
FirstBitSet
(
stack
.
data
[
stack
.
Len
()
-
2
])
exp
:=
new
(
big
.
Int
)
.
Set
(
stack
.
data
[
stack
.
Len
()
-
2
])
expGas
.
Div
(
expGas
,
u256
(
8
))
nbytes
:=
0
expGas
.
Sub
(
u256
(
32
),
expGas
)
for
exp
.
Cmp
(
ethutil
.
Big0
)
>
0
{
expGas
.
Add
(
expGas
,
u256
(
1
))
nbytes
+=
1
exp
.
Rsh
(
exp
,
8
)
gas
.
Set
(
expGas
)
}
gas
.
Set
(
big
.
NewInt
(
int64
(
nbytes
+
1
)))
// Gas only
// Gas only
case
STOP
:
case
STOP
:
gas
.
Set
(
ethutil
.
Big0
)
gas
.
Set
(
ethutil
.
Big0
)
...
...
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