diff --git a/.github/workflows/publish.yaml b/.github/workflows/on-pr-publish.yaml similarity index 73% rename from .github/workflows/publish.yaml rename to .github/workflows/on-pr-publish.yaml index 610f8afbff82..51fec9b5abd1 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/on-pr-publish.yaml @@ -1,13 +1,35 @@ -name: Publish geth to release +name: Test, Build, and/or Publish on: release: types: [published] + pull_request: + jobs: + pre_job: + # continue-on-error: true # Uncomment once integration is finished + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@v4 + with: + # All of these options are optional, so you can remove them if you are happy with the defaults + concurrent_skipping: "never" + skip_after_successful_duplicate: "true" + do_not_skip: '["workflow_dispatch", "schedule"]' run-tests: uses: ./.github/workflows/tests.yml + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + needs: pre_job build: name: Run docker build and publish needs: run-tests + if: | + always() && + (needs.run-tests.result == 'success' || needs.run-tests.result == 'skipped') && + github.event_name == 'release' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -25,6 +47,10 @@ jobs: push_to_registries: name: Publish assets to Release runs-on: ubuntu-latest + if: | + always() && + (needs.build.result == 'success') && + github.event_name == 'release' needs: build steps: - name: Get the version diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml deleted file mode 100644 index 2b05dcda5f8f..000000000000 --- a/.github/workflows/on-pr.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: Build and test - -on: [pull_request] - -jobs: - run-tests: - uses: ./.github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 41f63f235738..31f8a8946771 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,7 +5,7 @@ on: env: stack-orchestrator-ref: ${{ github.event.inputs.stack-orchestrator-ref || '382aca8e42bc5e33f301f77cdd2e09cc80602fc3'}} - ipld-eth-db-ref: ${{ github.event.inputs.ipld-ethcl-db-ref || '65b7bee7a6757c1fc527c8bfdc4f99ab915fcf36' }} + ipld-eth-db-ref: ${{ github.event.inputs.ipld-ethcl-db-ref || '67c32e9d4d12b786eb4135d82392cb708f96b1c9' }} GOPATH: /tmp/go jobs: diff --git a/statediff/indexer/database/file/config.go b/statediff/indexer/database/file/config.go index a075e896b3d7..57c20fe8bd1b 100644 --- a/statediff/indexer/database/file/config.go +++ b/statediff/indexer/database/file/config.go @@ -41,7 +41,7 @@ var TestConfig = Config{ GenesisBlock: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", NetworkID: "1", ChainID: 1, - ID: "mockNodeID", + ID: "1", ClientName: "go-ethereum", }, } diff --git a/statediff/indexer/database/file/writer.go b/statediff/indexer/database/file/writer.go index 3c11b5eea135..2e84250e551c 100644 --- a/statediff/indexer/database/file/writer.go +++ b/statediff/indexer/database/file/writer.go @@ -197,8 +197,10 @@ func (sqw *SQLWriter) upsertIPLDRaw(blockNumber string, codec, mh uint64, raw [] } func (sqw *SQLWriter) upsertHeaderCID(header models.HeaderModel) { + nodeId := fmt.Sprintf("{%s}", header.NodeID) + // {'1'} stmt := fmt.Sprintf(headerInsert, header.BlockNumber, header.BlockHash, header.ParentHash, header.CID, - header.TotalDifficulty, header.NodeID, header.Reward, header.StateRoot, header.TxRoot, + header.TotalDifficulty, nodeId, header.Reward, header.StateRoot, header.TxRoot, header.RctRoot, header.UncleRoot, header.Bloom, header.Timestamp, header.MhKey, 1, header.Coinbase) sqw.stmts <- []byte(stmt) indexerMetrics.blocks.Inc(1) diff --git a/statediff/indexer/database/sql/postgres/database.go b/statediff/indexer/database/sql/postgres/database.go index 35a9cbc82400..76bdc730f184 100644 --- a/statediff/indexer/database/sql/postgres/database.go +++ b/statediff/indexer/database/sql/postgres/database.go @@ -40,7 +40,7 @@ type DB struct { func (db *DB) InsertHeaderStm() string { return `INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) - ON CONFLICT (block_hash, block_number) DO UPDATE SET (parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) = ($3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, eth.header_cids.times_validated + 1, $16)` + ON CONFLICT (block_hash, block_number) DO UPDATE SET (parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) = ($3, $4, $5, ARRAY(SELECT DISTINCT unnest(array_cat(eth.header_cids.node_id, $6))), $7, $8, $9, $10, $11, $12, $13, $14, eth.header_cids.times_validated + 1, $16)` } // InsertUncleStm satisfies the sql.Statements interface diff --git a/statediff/indexer/database/sql/writer.go b/statediff/indexer/database/sql/writer.go index c6c37855653e..bcec19ad5e6e 100644 --- a/statediff/indexer/database/sql/writer.go +++ b/statediff/indexer/database/sql/writer.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/statediff/indexer/models" + "github.com/lib/pq" ) var ( @@ -47,11 +48,12 @@ func (w *Writer) Close() error { /* INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) -ON CONFLICT (block_hash, block_number) DO UPDATE SET (block_number, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) = ($1, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, eth.header_cids.times_validated + 1, $16) +ON CONFLICT (block_hash, block_number) DO UPDATE SET (block_number, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) = ($1, $3, $4, $5, ARRAY(SELECT DISTINCT unnest(array_cat(eth.header_cids.node_id, $6))), $7, $8, $9, $10, $11, $12, $13, $14, eth.header_cids.times_validated + 1, $16) */ func (w *Writer) upsertHeaderCID(tx Tx, header models.HeaderModel) error { + nodeIds := []string{w.db.NodeID()} _, err := tx.Exec(w.db.Context(), w.db.InsertHeaderStm(), - header.BlockNumber, header.BlockHash, header.ParentHash, header.CID, header.TotalDifficulty, w.db.NodeID(), + header.BlockNumber, header.BlockHash, header.ParentHash, header.CID, header.TotalDifficulty, pq.Array(nodeIds), header.Reward, header.StateRoot, header.TxRoot, header.RctRoot, header.UncleRoot, header.Bloom, header.Timestamp, header.MhKey, 1, header.Coinbase) if err != nil {