Skip to content

Commit 0c9b649

Browse files
authored
Merge pull request #743 from nervosnetwork/rc/v0.12.0
2 parents d5c7932 + 7e32188 commit 0c9b649

23 files changed

+314
-39
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ CKB_NET_MODE="mainnet"
3131
HOMEPAGE_BLOCK_RECORDS_COUNT="15"
3232
HOMEPAGE_TRANSACTIONS_RECORDS_COUNT="15"
3333
SUDT_CELL_TYPE_HASH="0x5e7a36a77e68eecc013dfa2fe6a23f3b6c344b04005808694ae6dd45eea4cfd5"
34+
SUDT1_CELL_TYPE_HASH=""

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
on:
2+
push:
3+
tags:
4+
- 'v*'
5+
6+
name: Create Release
7+
8+
jobs:
9+
release:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
outputs:
13+
output1: ${{ steps.create_release.outputs.upload_url }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
- name: Get current date
18+
id: current_date
19+
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
20+
- name: Create Release
21+
id: create_release
22+
uses: actions/create-release@v1
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
with:
26+
tag_name: ${{ github.ref }}
27+
release_name: ${{ github.ref }} (${{ steps.current_date.outputs.date }})
28+
body_path: ./RELEASENOTES.md
29+
draft: true
30+
prerelease: false

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# [v0.11.2](https://github.com/shaojunda/ckb-explorer/compare/v0.11.1...v0.11.2) (2020-08-30)
1+
# [v0.12.0](https://github.com/nervosnetwork/ckb-explorer/compare/v0.11.2...v0.12.0) (2020-11-10)
2+
3+
4+
### Features
5+
6+
* [#739](https://github.com/nervosnetwork/ckb-explorer/pull/739): support querying transactions in the transaction pool
7+
8+
# [v0.11.2](https://github.com/nervosnetwork/ckb-explorer/compare/v0.11.1...v0.11.2) (2020-08-30)
29

310
### Features
411

@@ -9,7 +16,7 @@
916
* [#721](https://github.com/nervosnetwork/ckb-explorer/pull/721): fix normal transactions counter
1017

1118

12-
# [v0.11.1](https://github.com/shaojunda/ckb-explorer/compare/v0.11.0...v0.11.1) (2020-08-12)
19+
# [v0.11.1](https://github.com/nervosnetwork/ckb-explorer/compare/v0.11.0...v0.11.1) (2020-08-12)
1320

1421
### Performance Improvements
1522

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ GIT
88

99
GIT
1010
remote: https://github.com/nervosnetwork/ckb-sdk-ruby.git
11-
revision: e1b2414561d8363b301f9480fab915e84f71b1c4
11+
revision: dfe4c30f3be49f89d2c8d88170a199cfa053d4fe
1212
branch: develop
1313
specs:
14-
ckb-sdk-ruby (0.35.0)
14+
ckb-sdk-ruby (0.37.0)
1515
bitcoin-secp256k1 (~> 0.5.2)
1616
net-http-persistent (~> 3.1.0)
1717
rbnacl (~> 7.1.1)
@@ -224,7 +224,7 @@ GEM
224224
pry-nav (0.3.0)
225225
pry (>= 0.9.10, < 0.13.0)
226226
public_suffix (3.1.0)
227-
puma (4.3.5)
227+
puma (4.3.6)
228228
nio4r (~> 2.0)
229229
raabro (1.1.6)
230230
rack (2.2.3)

RELEASENOTES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Adapted CKB Version
2+
[ckb 0.25.1](https://github.com/nervosnetwork/ckb/releases/tag/v0.25.1) and above
3+
4+
# [v0.12.0](https://github.com/nervosnetwork/ckb-explorer/compare/v0.11.2...v0.12.0) (2020-11-10)
5+
6+
### Features
7+
8+
* [#739](https://github.com/nervosnetwork/ckb-explorer/pull/739): support querying transactions in the transaction pool

app/controllers/api/v1/ckb_transactions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def index
2525
end
2626

2727
def show
28-
ckb_transaction = CkbTransaction.cached_find(params[:id])
28+
ckb_transaction = CkbTransaction.cached_find(params[:id]) || PoolTransactionEntry.find_by(tx_hash: params[:id])
2929

3030
raise Api::V1::Exceptions::CkbTransactionNotFoundError if ckb_transaction.blank?
3131

app/models/cellbase.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def cellbase_output_capacity_details
4141
target_block = block.target_block
4242
OpenStruct.new(primary: target_block.primary_reward, secondary: target_block.secondary_reward, proposal_reward: target_block.proposal_reward, tx_fee: target_block.commit_reward)
4343
else
44-
CkbSync::Api.instance.get_cellbase_output_capacity_details(block.block_hash)
44+
CkbSync::Api.instance.get_cellbase_output_capacity_details(block.block_hash) || OpenStruct.new(primary: 0, secondary: 0, proposal_reward: 0, tx_fee: 0)
4545
end
4646
end
4747
end

app/models/ckb_sync/node_data_processor.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def process_block(node_block)
3232
local_block.ckb_transactions_count = ckb_transactions.size
3333
local_block.live_cell_changes = ckb_transactions.sum(&:live_cell_changes)
3434
CkbTransaction.import!(ckb_transactions, recursive: true, batch_size: 3500, validate: false)
35+
update_pool_tx_status(ckb_transactions)
3536
input_capacities = ckb_transactions.reject(&:is_cellbase).pluck(:id).to_h { |id| [id, []] }
3637
update_tx_fee_related_data(local_block, input_capacities, udt_infos)
3738
calculate_tx_fee(local_block, ckb_transactions, input_capacities, outputs.group_by(&:ckb_transaction_id))
@@ -53,6 +54,10 @@ def process_block(node_block)
5354

5455
private
5556

57+
def update_pool_tx_status(ckb_transactions)
58+
PoolTransactionEntry.pool_transaction_pending.where(tx_hash: ckb_transactions.pluck(:tx_hash)).update_all(tx_status: "committed")
59+
end
60+
5661
def increase_records_count(ckb_transactions)
5762
block_counter = TableRecordCount.find_by(table_name: "blocks")
5863
block_counter.increment!(:count)
@@ -89,7 +94,7 @@ def update_udt_accounts(udt_infos, block_timestamp)
8994
if udt_account.present?
9095
udt_account.update!(amount: amount)
9196
else
92-
udt = Udt.find_or_create_by!(type_hash: type_hash, code_hash: ENV["SUDT_CELL_TYPE_HASH"], udt_type: "sudt")
97+
udt = Udt.find_or_create_by!(type_hash: type_hash, udt_type: "sudt")
9398
udt.update(block_timestamp: block_timestamp) if udt.block_timestamp.blank?
9499
if udt.issuer_address.blank?
95100
issuer_address = Address.where(lock_hash: udt_type_script.args).pick(:address_hash)
@@ -497,7 +502,7 @@ def build_cell_outputs(node_outputs, ckb_transaction, addresses, outputs_data, o
497502
if cell_output.udt?
498503
udt_infos << { type_script: output.type, address: address }
499504
tags << "udt"
500-
udt = Udt.find_or_create_by!(type_hash: output.type.compute_hash, code_hash: ENV["SUDT_CELL_TYPE_HASH"], udt_type: "sudt")
505+
udt = Udt.find_or_create_by!(type_hash: output.type.compute_hash, udt_type: "sudt")
501506
udt_ids << udt.id
502507
udt_address_ids << address.id
503508
end
@@ -540,7 +545,7 @@ def build_withdraw_dao_events(address_id, ckb_transaction_id, local_block, previ
540545
end
541546

542547
def cell_type(type_script, output_data)
543-
return "normal" unless [ENV["DAO_CODE_HASH"], ENV["DAO_TYPE_HASH"], ENV["SUDT_CELL_TYPE_HASH"]].include?(type_script&.code_hash)
548+
return "normal" unless [ENV["DAO_CODE_HASH"], ENV["DAO_TYPE_HASH"], ENV["SUDT_CELL_TYPE_HASH"], ENV["SUDT1_CELL_TYPE_HASH"]].include?(type_script&.code_hash)
544549

545550
case type_script&.code_hash
546551
when ENV["DAO_CODE_HASH"], ENV["DAO_TYPE_HASH"]
@@ -549,7 +554,7 @@ def cell_type(type_script, output_data)
549554
else
550555
"nervos_dao_withdrawing"
551556
end
552-
when ENV["SUDT_CELL_TYPE_HASH"]
557+
when ENV["SUDT_CELL_TYPE_HASH"], ENV["SUDT1_CELL_TYPE_HASH"]
553558
if CKB::Utils.hex_to_bin(output_data).bytesize >= CellOutput::MIN_SUDT_AMOUNT_BYTESIZE
554559
"udt"
555560
else
@@ -676,7 +681,7 @@ def update_ckb_transaction(consumed_tx, address_id, previous_cell_output, update
676681
consumed_tx.contained_address_ids << address_id
677682
if previous_cell_output.udt?
678683
consumed_tx.tags << "udt"
679-
consumed_tx.contained_udt_ids << Udt.find_or_create_by!(type_hash: previous_cell_output.type_hash, code_hash: ENV["SUDT_CELL_TYPE_HASH"], udt_type: "sudt").id
684+
consumed_tx.contained_udt_ids << Udt.find_or_create_by!(type_hash: previous_cell_output.type_hash, udt_type: "sudt").id
680685
consumed_tx.udt_address_ids << previous_cell_output.address_id
681686
end
682687
if previous_cell_output.nervos_dao_withdrawing?

app/models/ckb_transaction.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ class CkbTransaction < ApplicationRecord
33
paginates_per 10
44
max_paginates_per MAX_PAGINATES_PER
55

6+
enum tx_status: { pending: 0, proposed: 1, committed: 2 }, _prefix: :ckb_transaction
7+
68
belongs_to :block
79
has_many :account_books, dependent: :destroy
810
has_many :addresses, through: :account_books
@@ -62,6 +64,14 @@ def dao_transaction?
6264
inputs.where(cell_type: %w(nervos_dao_deposit nervos_dao_withdrawing)).exists? || outputs.where(cell_type: %w(nervos_dao_deposit nervos_dao_withdrawing)).exists?
6365
end
6466

67+
def tx_status
68+
"committed"
69+
end
70+
71+
def cell_info
72+
nil
73+
end
74+
6575
private
6676

6777
def normal_tx_display_outputs(previews)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
class PoolTransactionEntry < ApplicationRecord
2+
enum tx_status: { pending: 0, proposed: 1, committed: 2 }, _prefix: :pool_transaction
3+
4+
def is_cellbase
5+
false
6+
end
7+
8+
def income(address = nil)
9+
nil
10+
end
11+
12+
def display_outputs(previews: false)
13+
self.attributes["display_outputs"]
14+
end
15+
16+
def display_inputs(previews: false)
17+
self.attributes["display_inputs"]
18+
end
19+
20+
def proposal_short_id
21+
tx_hash[0...12]
22+
end
23+
end
24+
25+
# == Schema Information
26+
#
27+
# Table name: pool_transaction_entries
28+
#
29+
# id :bigint not null, primary key
30+
# cell_deps :jsonb
31+
# tx_hash :binary
32+
# header_deps :jsonb
33+
# inputs :jsonb
34+
# outputs :jsonb
35+
# outputs_data :jsonb
36+
# version :integer
37+
# witnesses :jsonb
38+
# transaction_fee :decimal(30, )
39+
# block_number :decimal(30, )
40+
# block_timestamp :decimal(30, )
41+
# cycles :decimal(30, )
42+
# tx_size :decimal(30, )
43+
# display_inputs :jsonb
44+
# display_outputs :jsonb
45+
# tx_status :integer default("pending")
46+
# created_at :datetime not null
47+
# updated_at :datetime not null
48+
#
49+
# Indexes
50+
#
51+
# index_pool_transaction_entries_on_tx_hash (tx_hash) UNIQUE
52+
#

0 commit comments

Comments
 (0)