Skip to content

Commit

Permalink
Merge pull request ethereum#135 from olumuyiwadad/new_EVM_Upgrade
Browse files Browse the repository at this point in the history
Merge branch 'forking-incident-fix'  @hash-laboratories-au
  • Loading branch information
AnilChinchawale authored Oct 7, 2021
2 parents e1daa99 + 2b326de commit a0046ff
Show file tree
Hide file tree
Showing 24 changed files with 1,102 additions and 141 deletions.
139 changes: 90 additions & 49 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,80 @@ jobs:

- stage: Lint
sudo: false
go: '1.12.x'
go: '1.14.x'
git:
submodules: false
script:
- go run build/ci.go lint

- stage: Build and test
go: '1.12.x'
script:
- sudo modprobe fuse
- sudo chmod 666 /dev/fuse
- sudo chown root:$USER /etc/fuse.conf
- go run build/ci.go install
- while sleep 540; do echo "[ still running ]"; done &
- go run build/ci.go test -coverage
- kill %1
after_success:
- bash <(curl -s https://codecov.io/bash)

- go: '1.11.x'
script:
- sudo modprobe fuse
- sudo chmod 666 /dev/fuse
- sudo chown root:$USER /etc/fuse.conf
- go run build/ci.go install
- while sleep 540; do echo "[ still running ]"; done &
- go run build/ci.go test -coverage
- kill %1

- stage: Tests
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: A-B tests
script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[a-b].*")
- script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/c[a-m].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: C-[a-m] tests
- script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/c[n-o].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: C-[n-o] tests
- script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/c[p-z].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: C-[p-z] tests
- script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[d-i].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: D-I tests
- script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[j-n].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: J-N tests
- script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[o-r].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: O-R tests
- script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/s.*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: S tests
- script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[t-z].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: T-Z tests
- stage: Github release
go: '1.12.x'
go: '1.14.x'
script:
- GOARCH=amd64 GOOS=linux go build -o ./build/bin/XDC-linux-amd64 -v ./cmd/XDC
- GOARCH=amd64 GOOS=linux go build -o ./build/bin/XDC-linux-amd64 ./cmd/XDC
deploy:
provider: releases
api_key: $GITHUB_TOKEN
Expand All @@ -61,46 +102,46 @@ jobs:
- docker
install: skip
before_script:
- docker build -t XDPoSChain/XDPoSChain .
- docker build -t XDPoSChain/node -f Dockerfile.node .
- docker build -t XinFinOrg/XDPoSChain .
- docker build -t XinFinOrg/node -f Dockerfile.node .
script:
- echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker tag XDPoSChain/XDPoSChain XDPoSChain/XDPoSChain:latest
- docker push XDPoSChain/XDPoSChain:latest
- docker tag XDPoSChain/XDPoSChain XDPoSChain/XDPoSChain:$TRAVIS_BUILD_ID
- docker push XDPoSChain/XDPoSChain:$TRAVIS_BUILD_ID
- docker tag XDPoSChain/node XDPoSChain/node:latest
- docker push XDPoSChain/node:latest
- docker tag XDPoSChain/node XDPoSChain/node:$TRAVIS_BUILD_ID
- docker push XDPoSChain/node:$TRAVIS_BUILD_ID
- docker tag XinFinOrg/XDPoSChain XinFinOrg/XDPoSChain:latest
- docker push XinFinOrg/XDPoSChain:latest
- docker tag XinFinOrg/XDPoSChain XinFinOrg/XDPoSChain:$TRAVIS_BUILD_ID
- docker push XinFinOrg/XDPoSChain:$TRAVIS_BUILD_ID
- docker tag XinFinOrg/node XinFinOrg/node:latest
- docker push XinFinOrg/node:latest
- docker tag XinFinOrg/node XinFinOrg/node:$TRAVIS_BUILD_ID
- docker push XinFinOrg/node:$TRAVIS_BUILD_ID

- stage: Build and push image (tagged)
services:
- docker
install: skip
before_script:
- docker build -t XDPoSChain/XDPoSChain .
- docker build -t XDPoSChain/XDPoSChain -f Dockerfile.node .
- docker build -t XinFinOrg/XDPoSChain .
- docker build -t XinFinOrg/XDPoSChain -f Dockerfile.node .
script:
- echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker tag XDPoSChain/XDPoSChain XDPoSChain/XDPoSChain:latest
- docker push XDPoSChain/XDPoSChain:latest
- docker tag XDPoSChain/XDPoSChain XDPoSChain/XDPoSChain:$TRAVIS_TAG
- docker push XDPoSChain/XDPoSChain:$TRAVIS_TAG
- docker tag XDPoSChain/XDPoSChain XDPoSChain/node:latest
- docker push XDPoSChain/node:latest
- docker tag XDPoSChain/node XDPoSChain/node:$TRAVIS_TAG
- docker push XDPoSChain/node:$TRAVIS_TAG
- docker tag XinFinOrg/XDPoSChain XinFinOrg/XDPoSChain:latest
- docker push XinFinOrg/XDPoSChain:latest
- docker tag XinFinOrg/XDPoSChain XinFinOrg/XDPoSChain:$TRAVIS_TAG
- docker push XinFinOrg/XDPoSChain:$TRAVIS_TAG
- docker tag XinFinOrg/XDPoSChain XinFinOrg/node:latest
- docker push XinFinOrg/node:latest
- docker tag XinFinOrg/node XinFinOrg/node:$TRAVIS_TAG
- docker push XinFinOrg/node:$TRAVIS_TAG

stages:
- name: Lint
- name: Build and test
- name: Github release
if: type != pull_request AND branch =~ ^v AND tag IS present AND repo = XDPoSChain/XDPoSChain
if: type != pull_request AND branch =~ ^v AND tag IS present AND repo = XinFinOrg/XDPoSChain
- name: Build and push image
if: type != pull_request AND branch = master AND tag IS blank AND repo = XDPoSChain/XDPoSChain
if: type != pull_request AND branch = master AND tag IS blank AND repo = XinFinOrg/XDPoSChain
- name: Build and push image (tagged)
if: type != pull_request AND branch =~ ^v AND tag IS present AND repo = XDPoSChain/XDPoSChain
if: type != pull_request AND branch =~ ^v AND tag IS present AND repo = XinFinOrg/XDPoSChain

notifications:
slack:
Expand Down
43 changes: 38 additions & 5 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ import (
"context"
"errors"
"fmt"
"github.com/XinFinOrg/XDPoSChain/consensus"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
"math/big"
"sync"
"time"

"github.com/XinFinOrg/XDPoSChain/consensus"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"

"github.com/XinFinOrg/XDPoSChain"
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/common/math"
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS"
"github.com/XinFinOrg/XDPoSChain/consensus/ethash"
"github.com/XinFinOrg/XDPoSChain/core"
"github.com/XinFinOrg/XDPoSChain/core/bloombits"
Expand Down Expand Up @@ -64,6 +66,31 @@ type SimulatedBackend struct {
config *params.ChainConfig
}

// XDC simulated backend for testing purpose.
func NewXDCSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
// database := ethdb.NewMemDatabase()
database := rawdb.NewMemoryDatabase()

genesis := core.Genesis{
GasLimit: gasLimit, // need this big, support initial smart contract
Config: params.TestXDPoSMockChainConfig,
Alloc: alloc,
ExtraData: append(make([]byte, 32), make([]byte, 65)...),
}
genesis.MustCommit(database)
blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, XDPoS.NewFaker(database), vm.Config{})

backend := &SimulatedBackend{
database: database,
blockchain: blockchain,
config: genesis.Config,
events: filters.NewEventSystem(new(event.TypeMux), &filterBackend{database, blockchain}, false),
}
blockchain.Client = backend
backend.rollback()
return backend
}

// NewSimulatedBackend creates a new binding backend using a simulated blockchain
// for testing purposes.
func NewSimulatedBackend(alloc core.GenesisAlloc) *SimulatedBackend {
Expand Down Expand Up @@ -103,7 +130,7 @@ func (b *SimulatedBackend) Rollback() {
}

func (b *SimulatedBackend) rollback() {
blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), ethash.NewFaker(), b.database, 1, func(int, *core.BlockGen) {})
blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), b.blockchain.Engine(), b.database, 1, func(int, *core.BlockGen) {})
statedb, _ := b.blockchain.State()

b.pendingBlock = blocks[0]
Expand Down Expand Up @@ -359,7 +386,8 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
panic(fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce))
}

blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), b.blockchain.Engine(), b.database, 1, func(number int, block *core.BlockGen) {
// blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), b.blockchain.Engine(), b.database, 1, func(number int, block *core.BlockGen) {
for _, tx := range b.pendingBlock.Transactions() {
block.AddTxWithChain(b.blockchain, tx)
}
Expand Down Expand Up @@ -438,7 +466,8 @@ func (b *SimulatedBackend) SubscribeFilterLogs(ctx context.Context, query XDPoSC
func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
b.mu.Lock()
defer b.mu.Unlock()
blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), b.blockchain.Engine(), b.database, 1, func(number int, block *core.BlockGen) {
// blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), b.blockchain.Engine(), b.database, 1, func(number int, block *core.BlockGen) {
for _, tx := range b.pendingBlock.Transactions() {
block.AddTx(tx)
}
Expand All @@ -452,6 +481,10 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
return nil
}

func (b *SimulatedBackend) GetBlockChain() *core.BlockChain {
return b.blockchain
}

// callmsg implements core.Message to allow passing it as a transaction simulator.
type callmsg struct {
XDPoSChain.CallMsg
Expand Down
22 changes: 11 additions & 11 deletions accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy an interaction tester contract and call a transaction on it
_, _, interactor, err := DeployInteractor(auth, sim, "Deploy string")
Expand Down Expand Up @@ -270,7 +270,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy a tuple tester contract and execute a structured call on it
_, _, getter, err := DeployGetter(auth, sim)
Expand Down Expand Up @@ -302,7 +302,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy a tuple tester contract and execute a structured call on it
_, _, tupler, err := DeployTupler(auth, sim)
Expand Down Expand Up @@ -344,7 +344,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy a slice tester contract and execute a n array call on it
_, _, slicer, err := DeploySlicer(auth, sim)
Expand Down Expand Up @@ -378,7 +378,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy a default method invoker contract and execute its default method
_, _, defaulter, err := DeployDefaulter(auth, sim)
Expand Down Expand Up @@ -411,7 +411,7 @@ var bindTests = []struct {
`[{"constant":true,"inputs":[],"name":"String","outputs":[{"name":"","type":"string"}],"type":"function"}]`,
`
// Create a simulator and wrap a non-deployed contract
sim := backends.NewSimulatedBackend(nil)
sim := backends.NewXDCSimulatedBackend(nil, uint64(10000000000))
nonexistent, err := NewNonExistent(common.Address{}, sim)
if err != nil {
Expand Down Expand Up @@ -447,7 +447,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy a funky gas pattern contract
_, _, limiter, err := DeployFunkyGasPattern(auth, sim)
Expand Down Expand Up @@ -482,7 +482,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy a sender tester contract and execute a structured call on it
_, _, callfrom, err := DeployCallFrom(auth, sim)
Expand Down Expand Up @@ -542,7 +542,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy a underscorer tester contract and execute a structured call on it
_, _, underscorer, err := DeployUnderscorer(auth, sim)
Expand Down Expand Up @@ -612,7 +612,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
// Deploy an eventer contract
_, _, eventer, err := DeployEventer(auth, sim)
Expand Down Expand Up @@ -761,7 +761,7 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}})
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
//deploy the test contract
_, _, testContract, err := DeployDeeplyNestedArray(auth, sim)
Expand Down
8 changes: 5 additions & 3 deletions accounts/abi/bind/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ var waitDeployedTests = map[string]struct {

func TestWaitDeployed(t *testing.T) {
for name, test := range waitDeployedTests {
backend := backends.NewSimulatedBackend(core.GenesisAlloc{
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
})
backend := backends.NewXDCSimulatedBackend(
core.GenesisAlloc{
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
}, 10000000,
)

// Create the transaction.
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, big.NewInt(1), common.FromHex(test.code))
Expand Down
6 changes: 3 additions & 3 deletions accounts/keystore/testdata/keystore/README
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ The passphrase that unlocks them is "foobar".
The "good" key files which are supposed to be loadable are:

- File: UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
Address: 0x7ef5a6135f1fd6a02593eedc869c6d41d934aef8
Address: xdc7ef5a6135f1fd6a02593eedc869c6d41d934aef8
- File: aaa
Address: 0xf466859ead1932d743d622cb74fc058882e8648a
Address: xdcf466859ead1932d743d622cb74fc058882e8648a
- File: zzz
Address: 0x289d485d9771714cce91d3393d764e1311907acc
Address: xdc289d485d9771714cce91d3393d764e1311907acc

The other files (including this README) are broken in various ways
and should not be picked up by package accounts:
Expand Down
Loading

0 comments on commit a0046ff

Please sign in to comment.