Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
EIP 196, 197, 198 (#24)
Browse files Browse the repository at this point in the history
* implement bn256 precompiles

* implement bigModExp

* add comments and test

* run precompile tests

* skip failing tests for now

* add distinction between atlantis and pre-atlantis precompiles

* refactor precompiles to separate pre and post atlantis

* implement bn256 precompiles

* implement bigModExp

* add comments and test

* run precompile tests

* skip failing tests for now

* add distinction between atlantis and pre-atlantis precompiles

* refactor precompiles to separate pre and post atlantis

* fix ecrecover edge case

* implement bn256 precompiles

* implement bigModExp

* add comments and test

* run precompile tests

* skip failing tests for now

* add distinction between atlantis and pre-atlantis precompiles

* refactor precompiles to separate pre and post atlantis

* implement bn256 precompiles

* implement bigModExp

* add comments and test

* run precompile tests

* fix ecrecover edge case

* update go.mod

* remove skip for previously failing tests

* attempt to fix go.mod

* attempt to fix go.mod

* fix go.mod termiu version
  • Loading branch information
noot authored May 30, 2019
1 parent db1d4a1 commit 5aff51c
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 55 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ coverage.txt
.vscode

accounts/testdata/keystore/accounts.db
*sublime-project
*sublime-workspace
16 changes: 16 additions & 0 deletions common/integer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package common

const (
MaxInt8 = 1<<7 - 1
MinInt8 = -1 << 7
MaxInt16 = 1<<15 - 1
MinInt16 = -1 << 15
MaxInt32 = 1<<31 - 1
MinInt32 = -1 << 31
MaxInt64 = 1<<63 - 1
MinInt64 = -1 << 63
MaxUint8 = 1<<8 - 1
MaxUint16 = 1<<16 - 1
MaxUint32 = 1<<32 - 1
MaxUint64 = 1<<64 - 1
)
20 changes: 10 additions & 10 deletions core/assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (f *File) Close() error {
}

// Readdir implements http.File.Readdir
func (f *File) Readdir(count int) ([]os.FileInfo, error) {
func (f *File) Readdir(_ int) ([]os.FileInfo, error) {
return nil, os.ErrNotExist
}

Expand Down Expand Up @@ -123,7 +123,7 @@ func (f *FileInfo) IsDir() bool {
}

// Readdir implements os.FileInfo.Readdir
func (f *FileInfo) Readdir(count int) ([]os.FileInfo, error) {
func (f *FileInfo) Readdir(_ int) ([]os.FileInfo, error) {
return f.files, nil
}

Expand Down Expand Up @@ -435,7 +435,7 @@ func init() {
fi: FileInfo{
name: "mainnet.json",
size: 3503,
modTime: time.Unix(0, 1525956628000000000),
modTime: time.Unix(0, 1553983028384120351),
isDir: false,
},
}, "/core/config/mainnet_bootnodes.json": File{
Expand Down Expand Up @@ -587,7 +587,7 @@ func init() {
fi: FileInfo{
name: "mainnet_bootnodes.json",
size: 1715,
modTime: time.Unix(0, 1525956628000000000),
modTime: time.Unix(0, 1553983028384120351),
isDir: false,
},
}, "/core/config/mainnet_genesis.json": File{
Expand Down Expand Up @@ -623,7 +623,7 @@ func init() {
fi: FileInfo{
name: "mainnet_genesis.json",
size: 313,
modTime: time.Unix(0, 1527228759000000000),
modTime: time.Unix(0, 1553983028384120351),
isDir: false,
},
}, "/core/config/mainnet_genesis_alloc.csv": File{
Expand Down Expand Up @@ -50741,7 +50741,7 @@ func init() {
fi: FileInfo{
name: "mainnet_genesis_alloc.csv",
size: 601300,
modTime: time.Unix(0, 1525956628000000000),
modTime: time.Unix(0, 1553983028392120353),
isDir: false,
},
}, "/core/config/morden.json": File{
Expand Down Expand Up @@ -51057,7 +51057,7 @@ func init() {
fi: FileInfo{
name: "morden.json",
size: 3682,
modTime: time.Unix(0, 1525956628000000000),
modTime: time.Unix(0, 1553983028392120353),
isDir: false,
},
}, "/core/config/morden_bootnodes.json": File{
Expand Down Expand Up @@ -51279,7 +51279,7 @@ func init() {
fi: FileInfo{
name: "morden_bootnodes.json",
size: 2552,
modTime: time.Unix(0, 1527231057000000000),
modTime: time.Unix(0, 1553983028392120353),
isDir: false,
},
}, "/core/config/morden_genesis.json": File{
Expand Down Expand Up @@ -51319,7 +51319,7 @@ func init() {
fi: FileInfo{
name: "morden_genesis.json",
size: 364,
modTime: time.Unix(0, 1525956628000000000),
modTime: time.Unix(0, 1553983028392120353),
isDir: false,
},
}, "/core/config/morden_genesis_alloc.csv": File{
Expand Down Expand Up @@ -51353,7 +51353,7 @@ func init() {
fi: FileInfo{
name: "morden_genesis_alloc.csv",
size: 295,
modTime: time.Unix(0, 1525956628000000000),
modTime: time.Unix(0, 1553983028392120353),
isDir: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion core/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A
} else {
if !env.Db().Exist(*address) {
//no account may change state from non-existent to existent-but-empty. Refund sender.
if vm.Precompiled[(*address).Str()] == nil && env.RuleSet().IsAtlantis(env.BlockNumber()) && value.BitLen() == 0 {
if vm.PrecompiledAtlantis[(*address).Str()] == nil && env.RuleSet().IsAtlantis(env.BlockNumber()) && value.BitLen() == 0 {
caller.ReturnGas(gas, gasPrice)
return nil, common.Address{}, nil
}
Expand Down
9 changes: 9 additions & 0 deletions core/vm/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,12 @@ func useGas(gas, amount *big.Int) bool {
gas.Sub(gas, amount)
return true
}

func allZero(b []byte) bool {
for _, byte := range b {
if byte != 0 {
return false
}
}
return true
}
Loading

0 comments on commit 5aff51c

Please sign in to comment.