Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker workflow updates #195

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
71 changes: 52 additions & 19 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,65 @@
name: docker-image-ci
name: docker-image

on:
push:
branches:
- "main"
- "main"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
- "develop"
branches:
- "main"
- "develop"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read
packages: write

jobs:
push-image:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
if: ${{ !env.ACT }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}

- uses: actions/checkout@v2
- name: Build & Publish the Docker image
if: ${{ !env.ACT }}
run: |
docker build . --file Dockerfile --tag ghcr.io/covalenthq/bsp-geth:latest
docker push ghcr.io/covalenthq/bsp-geth:latest
- name: Log in to the Container registry
if: ${{ !env.ACT }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v2
- name: Extract metadata for the Docker image
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
push: ${{ env.ACT && 'false' || 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create release
uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.2.1
if: startsWith(github.ref, 'refs/tags/v')
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
draft: false
prerelease: false

# - name: Start containers
# run: docker-compose -f "docker-compose.yml" up --build --remove-orphans --force-recreate --exit-code-from agent
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/gcr-image.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/tag-release.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ logs/
coverage.out
coverage.txt
tests/spec-tests/
bin/
1 change: 1 addition & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ if one is set. Otherwise it prints the genesis from the datadir.`,
utils.BlockReplicationTargetsFlag,
utils.ReplicaEnableSpecimenFlag,
utils.ReplicaEnableResultFlag,
utils.ReplicaEnableBlobFlag,
}, utils.DatabaseFlags),
Description: `
The import command imports blocks from an RLP-encoded form. The form can be one file
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ var (
utils.BlockReplicationTargetsFlag,
utils.ReplicaEnableResultFlag,
utils.ReplicaEnableSpecimenFlag,
utils.ReplicaEnableBlobFlag,
}, utils.NetworkFlags, utils.DatabaseFlags)

rpcFlags = []cli.Flag{
Expand Down
9 changes: 8 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,10 @@ var (
Name: "replica.result",
Usage: "Enables export of fields that comprise a block-result",
}
ReplicaEnableBlobFlag = &cli.BoolFlag{
Name: "replica.blob",
Usage: "Enables export of fields that comprise a block-blob",
}
BatchRequestLimit = &cli.IntFlag{
Name: "rpc.batch-request-limit",
Usage: "Maximum number of requests in a batch",
Expand Down Expand Up @@ -2188,8 +2192,11 @@ func setBlockReplicationTargets(ctx *cli.Context, cfg *eth.Config) {
if ctx.Bool(ReplicaEnableResultFlag.Name) {
cfg.ReplicaEnableResult = true
}
if ctx.Bool(ReplicaEnableBlobFlag.Name) {
cfg.ReplicaEnableBlob = true
}
} else {
Fatalf("--replication.targets flag is invalid without --replica.specimen and/or --replica.result")
Fatalf("--replication.targets flag is invalid without --replica.specimen and/or --replica.result, ONLY ADD --replica.blob with both replica.specimen AND replica.result flags for complete unified state capture)")
}
}

Expand Down
101 changes: 61 additions & 40 deletions core/block_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,23 @@ type BlockReplicationEvent struct {
}

func (bc *BlockChain) createBlockReplica(block *types.Block, replicaConfig *ReplicaConfig, chainConfig *params.ChainConfig, stateSpecimen *types.StateSpecimen) error {
//block replica
exportBlockReplica, err := bc.createReplica(block, replicaConfig, chainConfig, stateSpecimen)

// blobs
var blobTxSidecars []*types.BlobTxSidecar
if replicaConfig.EnableBlob {
for sidecarData := range types.BlobTxSidecarChan {
if sidecarData.BlockNumber.Uint64() == block.NumberU64() {
log.Info("Consuming BlobTxSidecar Match From Chain Sync Channel", "Block Number:", sidecarData.BlockNumber.Uint64())
blobTxSidecars = append(blobTxSidecars, sidecarData.Blobs)
} else {
log.Info("Failing BlobTxSidecar Match from Chain Sync Channel", "Block Number:", sidecarData.BlockNumber.Uint64())
}
log.Info("BlobTxSidecar Header", "Block Number:", sidecarData.BlockNumber.Uint64())
log.Info("Chain Sync Sidecar Channel", "Length:", len(types.BlobTxSidecarChan))
}
}
//block replica with blobs
exportBlockReplica, err := bc.createReplica(block, replicaConfig, chainConfig, stateSpecimen, blobTxSidecars)
if err != nil {
return err
}
Expand Down Expand Up @@ -50,7 +65,7 @@ func (bc *BlockChain) createBlockReplica(block *types.Block, replicaConfig *Repl
}
}

func (bc *BlockChain) createReplica(block *types.Block, replicaConfig *ReplicaConfig, chainConfig *params.ChainConfig, stateSpecimen *types.StateSpecimen) (*types.ExportBlockReplica, error) {
func (bc *BlockChain) createReplica(block *types.Block, replicaConfig *ReplicaConfig, chainConfig *params.ChainConfig, stateSpecimen *types.StateSpecimen, blobSpecimen []*types.BlobTxSidecar) (*types.ExportBlockReplica, error) {
bHash := block.Hash()
bNum := block.NumberU64()

Expand Down Expand Up @@ -117,55 +132,58 @@ func (bc *BlockChain) createReplica(block *types.Block, replicaConfig *ReplicaCo
uncles := block.Uncles()

//block replica export
if replicaConfig.EnableSpecimen && replicaConfig.EnableResult {
if replicaConfig.EnableSpecimen && replicaConfig.EnableResult && replicaConfig.EnableBlob {
exportBlockReplica := &types.ExportBlockReplica{
Type: "block-replica",
NetworkId: chainConfig.ChainID.Uint64(),
Hash: bHash,
TotalDiff: td,
Header: header,
Transactions: txsRlp,
Uncles: uncles,
Receipts: receiptsRlp,
Senders: senders,
State: stateSpecimen,
Withdrawals: withdrawalsRlp,
Type: "block-replica",
NetworkId: chainConfig.ChainID.Uint64(),
Hash: bHash,
TotalDiff: td,
Header: header,
Transactions: txsRlp,
Uncles: uncles,
Receipts: receiptsRlp,
Senders: senders,
State: stateSpecimen,
Withdrawals: withdrawalsRlp,
BlobTxSidecars: blobSpecimen,
}
log.Debug("Exporting full block-replica")
log.Debug("Exporting full block-replica with blob-specimen")
return exportBlockReplica, nil
} else if replicaConfig.EnableSpecimen && !replicaConfig.EnableResult {
exportBlockReplica := &types.ExportBlockReplica{
Type: "block-specimen",
NetworkId: chainConfig.ChainID.Uint64(),
Hash: bHash,
TotalDiff: td,
Header: header,
Transactions: txsRlp,
Uncles: uncles,
Receipts: []*types.ReceiptExportRLP{},
Senders: senders,
State: stateSpecimen,
Withdrawals: withdrawalsRlp,
Type: "block-specimen",
NetworkId: chainConfig.ChainID.Uint64(),
Hash: bHash,
TotalDiff: td,
Header: header,
Transactions: txsRlp,
Uncles: uncles,
Receipts: []*types.ReceiptExportRLP{},
Senders: senders,
State: stateSpecimen,
Withdrawals: withdrawalsRlp,
BlobTxSidecars: []*types.BlobTxSidecar{},
}
log.Debug("Exporting block-specimen only")
log.Debug("Exporting block-specimen only (no blob specimens)")
return exportBlockReplica, nil
} else if !replicaConfig.EnableSpecimen && replicaConfig.EnableResult {
exportBlockReplica := &types.ExportBlockReplica{
Type: "block-result",
NetworkId: chainConfig.ChainID.Uint64(),
Hash: bHash,
TotalDiff: td,
Header: header,
Transactions: txsRlp,
Uncles: uncles,
Receipts: receiptsRlp,
Senders: senders,
State: &types.StateSpecimen{},
Type: "block-result",
NetworkId: chainConfig.ChainID.Uint64(),
Hash: bHash,
TotalDiff: td,
Header: header,
Transactions: txsRlp,
Uncles: uncles,
Receipts: receiptsRlp,
Senders: senders,
State: &types.StateSpecimen{},
BlobTxSidecars: []*types.BlobTxSidecar{},
}
log.Debug("Exporting block-result only")
log.Debug("Exporting block-result only (no blob specimens)")
return exportBlockReplica, nil
} else {
return nil, fmt.Errorf("--replication.targets flag is invalid without --replica.specimen and/or --replica.result")
return nil, fmt.Errorf("--replication.targets flag is invalid without --replica.specimen and/or --replica.result, ADD --replica.blob with both replica.specimen AND replica.result flags for complete unified state capture aka block-replica)")
}
}

Expand All @@ -181,5 +199,8 @@ func (bc *BlockChain) SetBlockReplicaExports(replicaConfig *ReplicaConfig) bool
if replicaConfig.EnableSpecimen {
bc.ReplicaConfig.EnableSpecimen = true
}
if replicaConfig.EnableBlob {
bc.ReplicaConfig.EnableBlob = true
}
return true
}
14 changes: 11 additions & 3 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ type BlockChain struct {
type ReplicaConfig struct {
EnableSpecimen bool
EnableResult bool
EnableBlob bool
HistoricalBlocksSynced *uint32
}

Expand Down Expand Up @@ -315,6 +316,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
ReplicaConfig: &ReplicaConfig{
EnableSpecimen: false,
EnableResult: false,
EnableBlob: false,
HistoricalBlocksSynced: new(uint32), // Always set 0 for historical mode at start
},
}
Expand Down Expand Up @@ -1851,7 +1853,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)

if !setHead {
// Export Block Specimen
bc.createBlockReplica(block, bc.ReplicaConfig, bc.chainConfig, statedb.TakeStateSpecimen())
if bc.ReplicaConfig.EnableSpecimen || bc.ReplicaConfig.EnableResult {
bc.createBlockReplica(block, bc.ReplicaConfig, bc.chainConfig, statedb.TakeStateSpecimen())
}
// After merge we expect few side chains. Simply count
// all blocks the CL gives us for GC processing time
bc.gcproc += proctime
Expand All @@ -1865,7 +1869,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
"elapsed", common.PrettyDuration(time.Since(start)),
"root", block.Root())
// Handle creation of block specimen for canonical blocks
bc.createBlockReplica(block, bc.ReplicaConfig, bc.chainConfig, statedb.TakeStateSpecimen())
if bc.ReplicaConfig.EnableSpecimen || bc.ReplicaConfig.EnableResult {
bc.createBlockReplica(block, bc.ReplicaConfig, bc.chainConfig, statedb.TakeStateSpecimen())
}
lastCanon = block

// Only count canonical blocks for GC processing time
Expand All @@ -1887,7 +1893,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
"txs", len(block.Transactions()), "gas", block.GasUsed(), "uncles", len(block.Uncles()),
"root", block.Root())
// Is impossible but keeping in line to be nice to our future selves we add this for now
bc.createBlockReplica(block, bc.ReplicaConfig, bc.chainConfig, statedb.TakeStateSpecimen())
if bc.ReplicaConfig.EnableSpecimen || bc.ReplicaConfig.EnableResult {
bc.createBlockReplica(block, bc.ReplicaConfig, bc.chainConfig, statedb.TakeStateSpecimen())
}
}
}

Expand Down
Loading