Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0114eca
core/state: abort commit if errors have occurred (#484)
wanwiset25 Mar 11, 2024
2fcd6f4
add pull request trigger test (#488)
liam-lai Mar 11, 2024
4616d59
internal/ethapi: support block number or hash on state-related method…
gzliudan Mar 7, 2024
f340875
eth: check err before return in function StateAndHeaderByNumber
gzliudan Mar 12, 2024
b2a767e
eth: let function HeaderByNumber return error when header is nil
gzliudan Mar 12, 2024
106af4d
Merge pull request #486 from gzliudan/EIP-1898
gzliudan Mar 12, 2024
8edb76f
Revert "core/state: abort commit if errors have occurred (#484)" (#489)
wanwiset25 Mar 13, 2024
69b4383
eth/filters, ethereum: EIP-234 add blockHash param for eth_getLogs
reductionista May 12, 2018
4938ba7
Merge pull request #490 from gzliudan/eip234
gzliudan Mar 14, 2024
28480b1
remove 1s waiting time in miner
wang-gerui Mar 14, 2024
bbab326
after we use time.Ticker it didn't allow to have 0 time duration (#493)
liam-lai Mar 15, 2024
04cf52b
Merge pull request #492 from XinFinOrg/xdc-05
wgr523 Mar 15, 2024
7197172
eth/filter: check nil pointer when unsubscribe (#16682)
gzliudan Mar 14, 2024
19b84ff
eth/filters: make filterLogs func more readable (#16920)
nujeh Jun 14, 2018
a4b557b
accounts, eth, les: blockhash based filtering on all code paths (#16734)
gzliudan Mar 14, 2024
40ee6f8
eth/filters: improve error message for invalid filter topics (#17234)
macalinao Jul 24, 2018
43f038d
eth/filters: simplify switches (#17267)
gzliudan Mar 14, 2024
65b4815
eth/filters: fix the block range assignment for log filter (#17284)
rjl493456442 Jul 31, 2018
7cffa1d
eth/filters: replace fmt.Println with b.Log in tests (#19670)
gzliudan Mar 13, 2024
4d8effe
Merge pull request #491 from gzliudan/filter
gzliudan Mar 18, 2024
42c57c6
Ci improvement (#496)
liam-lai Mar 18, 2024
e5317a0
bump to 2.2.0 (#500)
liam-lai Mar 20, 2024
816dce9
drop peer if received bad block data which does not include the valid…
wjrjerome Mar 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- '*'
Expand Down Expand Up @@ -84,10 +86,13 @@ jobs:
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build and Push Docker images
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
docker pull xinfinorg/devnet:latest
docker tag xinfinorg/devnet:latest xinfinorg/devnet:previous
docker rmi xinfinorg/devnet:latest
docker build -t xinfinorg/devnet:latest -f cicd/Dockerfile .
docker tag xinfinorg/devnet:latest xinfinorg/devnet:dev-upgrade-${git_hash}
docker push xinfinorg/devnet:dev-upgrade-${git_hash}
docker push xinfinorg/devnet:latest
docker push xinfinorg/devnet:previous

Expand All @@ -103,9 +108,10 @@ jobs:
- uses: actions/checkout@v4
- name: Terraform Apply
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
cd cicd/devnet/terraform
terraform init ${{ env.tf_init_cli_options }}
terraform apply ${{ env.tf_apply_cli_options }}
terraform apply -var "docker_tag=dev-upgrade-${git_hash}" ${{ env.tf_apply_cli_options }}
sleep 5
source .env
for ((i=$us_east_2_start;i<$us_east_2_end;i++)); do
Expand All @@ -120,7 +126,6 @@ jobs:
echo "Force deploy xdc-$i"
aws ecs update-service --region ap-southeast-2 --cluster devnet-xdcnode-cluster --service ecs-service-xdc$i --force-new-deployment --no-cli-pager | head -n 10;
done
aws ecs update-service --region ap-southeast-1 --cluster devnet-xdcnode-cluster --service ecs-service-rpc1 --force-new-deployment --no-cli-pager | head -n 10;

rpcnode_terraform_apply:
runs-on: ubuntu-latest
Expand All @@ -137,6 +142,20 @@ jobs:
terraform init ${{ env.tf_init_cli_options }}
terraform apply ${{ env.tf_apply_cli_options }}

devnet_dev-upgrade_node:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
needs: rpcnode_terraform_apply
environment: devnet
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v4
- name: ECS Update
run: |
aws ecs update-service --region ap-southeast-1 --cluster devnet-xdcnode-cluster --service ecs-service-rpc1 --force-new-deployment --no-cli-pager | head -n 10;

testnet_dev-upgrade_node:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
Expand Down
32 changes: 21 additions & 11 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,18 +415,24 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
//
// TODO(karalabe): Deprecate when the subscription one can return past data too.
func (b *SimulatedBackend) FilterLogs(ctx context.Context, query XDPoSChain.FilterQuery) ([]types.Log, error) {
// Initialize unset filter boundaried to run from genesis to chain head
from := int64(0)
if query.FromBlock != nil {
from = query.FromBlock.Int64()
}
to := int64(-1)
if query.ToBlock != nil {
to = query.ToBlock.Int64()
var filter *filters.Filter
if query.BlockHash != nil {
// Block filter requested, construct a single-shot filter
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain}, *query.BlockHash, query.Addresses, query.Topics)
} else {
// Initialize unset filter boundaried to run from genesis to chain head
from := int64(0)
if query.FromBlock != nil {
from = query.FromBlock.Int64()
}
to := int64(-1)
if query.ToBlock != nil {
to = query.ToBlock.Int64()
}
// Construct the range filter
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
}
// Construct and execute the filter
filter := filters.New(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)

// Run the filter and return all the logs
logs, err := filter.Logs(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -527,6 +533,10 @@ func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumb
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
}

func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
return fb.bc.GetHeaderByHash(hash), nil
}

func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
return core.GetBlockReceipts(fb.db, hash, core.GetBlockNumber(fb.db, hash)), nil
}
Expand Down
2 changes: 1 addition & 1 deletion cicd/devnet/terraform/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
log_level=3
log_level=2

# Ohio
us_east_2_start=0
Expand Down
23 changes: 3 additions & 20 deletions cicd/devnet/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module "us-east-2" {
devnetNodeKeys = local.devnetNodeKeys["us-east-2"]
logLevel = local.logLevel
devnet_xdc_ecs_tasks_execution_role_arn = aws_iam_role.devnet_xdc_ecs_tasks_execution_role.arn
docker_tag = var.docker_tag
providers = {
aws = aws.us-east-2
}
Expand All @@ -39,6 +40,7 @@ module "eu-west-1" {
devnetNodeKeys = local.devnetNodeKeys["eu-west-1"]
logLevel = local.logLevel
devnet_xdc_ecs_tasks_execution_role_arn = aws_iam_role.devnet_xdc_ecs_tasks_execution_role.arn
docker_tag = var.docker_tag
providers = {
aws = aws.eu-west-1
}
Expand All @@ -55,27 +57,8 @@ module "ap-southeast-2" {
devnetNodeKeys = local.devnetNodeKeys["ap-southeast-2"]
logLevel = local.logLevel
devnet_xdc_ecs_tasks_execution_role_arn = aws_iam_role.devnet_xdc_ecs_tasks_execution_role.arn
docker_tag = var.docker_tag
providers = {
aws = aws.ap-southeast-2
}
}

# WARNING: APSE-1 will only be used to host rpc node
# Workaround to avoid conflicts with existing ecs cluster in existing regions
provider "aws" {
alias = "ap-southeast-1"
region = "ap-southeast-1"
}

module "ap-southeast-1-rpc" {
source = "./module/region"
region = "ap-southeast-1"
devnetNodeKeys = local.rpcNodeKeys
enableFixedIp = true
logLevel = local.logLevel
devnet_xdc_ecs_tasks_execution_role_arn = aws_iam_role.devnet_xdc_ecs_tasks_execution_role.arn

providers = {
aws = aws.ap-southeast-1
}
}
2 changes: 1 addition & 1 deletion cicd/devnet/terraform/module/region/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data template_file devnet_container_definition {

vars = {
image_environment = "${lookup(each.value, "imageEnvironment", "devnet")}"
image_tag = "${lookup(each.value, "imageTag", "latest")}"
image_tag = "${lookup(each.value, "imageTag", var.docker_tag)}"
node_name = "${each.key}"
private_key = "${each.value.pk}"
cloudwatch_group = "tf-${each.key}"
Expand Down
8 changes: 7 additions & 1 deletion cicd/devnet/terraform/module/region/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ variable "enableFixedIp" {
description = "a flag to indicate whether fixed ip should be associated to the nodes. This is used for RPC node"
type = bool
default = false
}
}

variable docker_tag {
type = string
default = "latest"
description = "description"
}
6 changes: 3 additions & 3 deletions cicd/devnet/terraform/s3.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Bucket need to be created first. If first time run terraform init, need to comment out the below section
terraform {
backend "s3" {
bucket = "tf-devnet-bucket" // This name need to be updated to be the same as local.s3BucketName. We can't use variable here.
key = "tf/terraform_new.tfstate"
bucket = "tf-xinfin-bucket" // This name need to be updated to be the same as local.s3BucketName. We can't use variable here.
key = "tf/terraform_devnet.tfstate"
region = "us-east-1"
encrypt = true
}
}

data "aws_s3_object" "devnet_xdc_node_config" {
bucket = local.s3BucketName
bucket = "tf-xinfin-bucket"
key = "node-config.json"
}
10 changes: 6 additions & 4 deletions cicd/devnet/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
variable docker_tag {
type = string
default = "latest"
description = "description"
}

locals {
/**
Load the nodes data from s3
Expand Down Expand Up @@ -39,8 +45,4 @@ locals {
for r in local.regions :
r.name => { for i in local.keyNames[r.name]: i => local.predefinedNodesConfig[i] }
}

rpcNodeKeys = { "rpc1": local.predefinedNodesConfig["rpc1"]} // we hardcode the rpc to a single node for now

s3BucketName = "tf-devnet-bucket"
}
19 changes: 19 additions & 0 deletions cicd/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ provider "aws" {
region = "ap-southeast-1"
}

module "devnet-rpc" {
source = "./module/region"
region = "ap-southeast-1"
nodeKeys = local.rpcDevnetNodeKeys
enableFixedIp = true
logLevel = local.logLevel
xdc_ecs_tasks_execution_role_arn = aws_iam_role.xdc_ecs_tasks_execution_role.arn

cpu = 1024
memory = 4096

network = "devnet"
vpc_cidr = "10.0.0.0/16"
subnet_cidr = "10.0.0.0/20"
providers = {
aws = aws.ap-southeast-1
}
}

module "testnet-rpc" {
source = "./module/region"
region = "ap-southeast-1"
Expand Down
2 changes: 1 addition & 1 deletion cicd/terraform/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
terraform {
backend "s3" {
bucket = "tf-xinfin-bucket"
key = "tf/terraform.tfstate"
key = "tf/terraform_rpc.tfstate"
region = "us-east-1"
encrypt = true
}
Expand Down
1 change: 1 addition & 0 deletions cicd/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ locals {
# r.name => { for i in local.keyNames[r.name]: i => local.predefinedNodesConfig[i] }
# }

rpcDevnetNodeKeys = { "devnet-rpc1": local.predefinedNodesConfig["devnet-rpc1"]} // we hardcode the rpc to a single node for now
rpcTestnetNodeKeys = { "testnet-rpc1": local.predefinedNodesConfig["testnet-rpc1"]} // we hardcode the rpc to a single node for now
rpcMainnetNodeKeys = { "mainnet-rpc1": local.predefinedNodesConfig["mainnet-rpc1"]} // we hardcode the rpc to a single node for now
}
3 changes: 2 additions & 1 deletion consensus/XDPoS/engines/engine_v2/verifyHeader.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
}

if len(header.Validator) == 0 {
return consensus.ErrNoValidatorSignature
// This should never happen, if it does, then it means the peer is sending us invalid data.
return consensus.ErrNoValidatorSignatureV2
}

if fullVerify {
Expand Down
2 changes: 2 additions & 0 deletions consensus/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ var (

ErrNoValidatorSignature = errors.New("no validator in header")

ErrNoValidatorSignatureV2 = errors.New("no validator in v2 header")

ErrNotReadyToPropose = errors.New("not ready to propose, QC is not ready")

ErrNotReadyToMine = errors.New("Not ready to mine, it's not your turn")
Expand Down
2 changes: 1 addition & 1 deletion consensus/tests/engine_v2_tests/verify_header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestShouldVerifyBlock(t *testing.T) {
noValidatorBlock := blockchain.GetBlockByNumber(902).Header()
noValidatorBlock.Validator = []byte{}
err = adaptor.VerifyHeader(blockchain, noValidatorBlock, true)
assert.Equal(t, consensus.ErrNoValidatorSignature, err)
assert.Equal(t, consensus.ErrNoValidatorSignatureV2, err)

blockFromFuture := blockchain.GetBlockByNumber(902).Header()
blockFromFuture.Time = big.NewInt(time.Now().Unix() + 10000)
Expand Down
5 changes: 5 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,11 @@ func (bc *BlockChain) HasHeader(hash common.Hash, number uint64) bool {
return bc.hc.HasHeader(hash, number)
}

// GetCanonicalHash returns the canonical hash for a given block number
func (bc *BlockChain) GetCanonicalHash(number uint64) common.Hash {
return bc.hc.GetCanonicalHash(number)
}

// GetBlockHashesFromHash retrieves a number of block hashes starting at a given
// hash, fetching towards the genesis block.
func (bc *BlockChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash {
Expand Down
7 changes: 6 additions & 1 deletion core/headerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/XinFinOrg/XDPoSChain/ethdb"
"github.com/XinFinOrg/XDPoSChain/log"
"github.com/XinFinOrg/XDPoSChain/params"
"github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru"
)

const (
Expand Down Expand Up @@ -382,6 +382,11 @@ func (hc *HeaderChain) GetHeaderByNumber(number uint64) *types.Header {
return hc.GetHeader(hash, number)
}

func (hc *HeaderChain) GetCanonicalHash(number uint64) common.Hash {
// TODO: return rawdb.ReadCanonicalHash(hc.chainDb, number)
return GetCanonicalHash(hc.chainDb, number)
}

// CurrentHeader retrieves the current head header of the canonical chain. The
// header is retrieved from the HeaderChain's internal cache.
func (hc *HeaderChain) CurrentHeader() *types.Header {
Expand Down
Loading