diff --git a/model/actors/miner/feedebt.go b/model/actors/miner/feedebt.go index b4e2008a2..5fb251add 100644 --- a/model/actors/miner/feedebt.go +++ b/model/actors/miner/feedebt.go @@ -13,7 +13,7 @@ type MinerFeeDebt struct { MinerID string `pg:",pk,notnull"` StateRoot string `pg:",pk,notnull"` - FeeDebt string `pg:"type:numeric,notnull"` + FeeDebt string `pg:",notnull"` } func (m *MinerFeeDebt) Persist(ctx context.Context, s model.StorageBatch) error { diff --git a/model/actors/miner/lockedfunds.go b/model/actors/miner/lockedfunds.go index 2ea72aba7..63254df5e 100644 --- a/model/actors/miner/lockedfunds.go +++ b/model/actors/miner/lockedfunds.go @@ -13,9 +13,9 @@ type MinerLockedFund struct { MinerID string `pg:",pk,notnull"` StateRoot string `pg:",pk,notnull"` - LockedFunds string `pg:"type:numeric,notnull"` - InitialPledge string `pg:"type:numeric,notnull"` - PreCommitDeposits string `pg:"type:numeric,notnull"` + LockedFunds string `pg:",notnull"` + InitialPledge string `pg:",notnull"` + PreCommitDeposits string `pg:",notnull"` } func (m *MinerLockedFund) Persist(ctx context.Context, s model.StorageBatch) error { diff --git a/model/actors/miner/precommit.go b/model/actors/miner/precommit.go index 7dc4cceeb..e0c14819f 100644 --- a/model/actors/miner/precommit.go +++ b/model/actors/miner/precommit.go @@ -20,10 +20,10 @@ type MinerPreCommitInfo struct { SealRandEpoch int64 `pg:",use_zero"` ExpirationEpoch int64 `pg:",use_zero"` - PreCommitDeposit string `pg:"type:numeric,notnull"` + PreCommitDeposit string `pg:",notnull"` PreCommitEpoch int64 `pg:",use_zero"` - DealWeight string `pg:"type:numeric,notnull"` - VerifiedDealWeight string `pg:"type:numeric,notnull"` + DealWeight string `pg:",notnull"` + VerifiedDealWeight string `pg:",notnull"` IsReplaceCapacity bool ReplaceSectorDeadline uint64 `pg:",use_zero"` diff --git a/model/actors/miner/sector.go b/model/actors/miner/sector.go index ac2a5245b..75e084c71 100644 --- a/model/actors/miner/sector.go +++ b/model/actors/miner/sector.go @@ -21,12 +21,12 @@ type MinerSectorInfo struct { ActivationEpoch int64 `pg:",use_zero"` ExpirationEpoch int64 `pg:",use_zero"` - DealWeight string `pg:"type:numeric,notnull"` - VerifiedDealWeight string `pg:"type:numeric,notnull"` + DealWeight string `pg:",notnull"` + VerifiedDealWeight string `pg:",notnull"` - InitialPledge string `pg:"type:numeric,notnull"` - ExpectedDayReward string `pg:"type:numeric,notnull"` - ExpectedStoragePledge string `pg:"type:numeric,notnull"` + InitialPledge string `pg:",notnull"` + ExpectedDayReward string `pg:",notnull"` + ExpectedStoragePledge string `pg:",notnull"` } func (msi *MinerSectorInfo) Persist(ctx context.Context, s model.StorageBatch) error { diff --git a/model/actors/power/chainpower.go b/model/actors/power/chainpower.go index a4fb6e7e1..4cf9cb9a0 100644 --- a/model/actors/power/chainpower.go +++ b/model/actors/power/chainpower.go @@ -14,16 +14,16 @@ type ChainPower struct { Height int64 `pg:",pk,notnull,use_zero"` StateRoot string `pg:",pk"` - TotalRawBytesPower string `pg:"type:numeric,notnull"` - TotalQABytesPower string `pg:"type:numeric,notnull"` + TotalRawBytesPower string `pg:",notnull"` + TotalQABytesPower string `pg:",notnull"` - TotalRawBytesCommitted string `pg:"type:numeric,notnull"` - TotalQABytesCommitted string `pg:"type:numeric,notnull"` + TotalRawBytesCommitted string `pg:",notnull"` + TotalQABytesCommitted string `pg:",notnull"` - TotalPledgeCollateral string `pg:"type:numeric,notnull"` + TotalPledgeCollateral string `pg:",notnull"` - QASmoothedPositionEstimate string `pg:"type:numeric,notnull"` - QASmoothedVelocityEstimate string `pg:"type:numeric,notnull"` + QASmoothedPositionEstimate string `pg:",notnull"` + QASmoothedVelocityEstimate string `pg:",notnull"` MinerCount uint64 `pg:",use_zero"` ParticipatingMinerCount uint64 `pg:",use_zero"` diff --git a/model/actors/power/claimedpower.go b/model/actors/power/claimedpower.go index eb464022c..983c94d0e 100644 --- a/model/actors/power/claimedpower.go +++ b/model/actors/power/claimedpower.go @@ -12,8 +12,8 @@ type PowerActorClaim struct { Height int64 `pg:",pk,notnull,use_zero"` MinerID string `pg:",pk,notnull"` StateRoot string `pg:",pk,notnull"` - RawBytePower string `pg:"type:numeric,notnull"` - QualityAdjPower string `pg:"type:numeric,notnull"` + RawBytePower string `pg:",notnull"` + QualityAdjPower string `pg:",notnull"` } func (p *PowerActorClaim) Persist(ctx context.Context, s model.StorageBatch) error { diff --git a/model/actors/reward/chainreward.go b/model/actors/reward/chainreward.go index 31c921452..f8e08ffb5 100644 --- a/model/actors/reward/chainreward.go +++ b/model/actors/reward/chainreward.go @@ -12,15 +12,15 @@ import ( type ChainReward struct { Height int64 `pg:",pk,notnull,use_zero"` StateRoot string `pg:",pk,notnull"` - CumSumBaseline string `pg:"type:numeric,notnull"` - CumSumRealized string `pg:"type:numeric,notnull"` - EffectiveBaselinePower string `pg:"type:numeric,notnull"` - NewBaselinePower string `pg:"type:numeric,notnull"` - NewRewardSmoothedPositionEstimate string `pg:"type:numeric,notnull"` - NewRewardSmoothedVelocityEstimate string `pg:"type:numeric,notnull"` - TotalMinedReward string `pg:"type:numeric,notnull"` - - NewReward string `pg:"type:numeric,use_zero"` + CumSumBaseline string `pg:",notnull"` + CumSumRealized string `pg:",notnull"` + EffectiveBaselinePower string `pg:",notnull"` + NewBaselinePower string `pg:",notnull"` + NewRewardSmoothedPositionEstimate string `pg:",notnull"` + NewRewardSmoothedVelocityEstimate string `pg:",notnull"` + TotalMinedReward string `pg:",notnull"` + + NewReward string `pg:",use_zero"` EffectiveNetworkTime int64 `pg:",use_zero"` } diff --git a/model/derived/gasoutputs.go b/model/derived/gasoutputs.go index 50a09a663..41685b315 100644 --- a/model/derived/gasoutputs.go +++ b/model/derived/gasoutputs.go @@ -17,9 +17,9 @@ type GasOutputs struct { StateRoot string `pg:",pk,notnull"` From string `pg:",notnull"` To string `pg:",notnull"` - Value string `pg:"type:numeric,notnull"` - GasFeeCap string `pg:"type:numeric,notnull"` - GasPremium string `pg:"type:numeric,notnull"` + Value string `pg:",notnull"` + GasFeeCap string `pg:",notnull"` + GasPremium string `pg:",notnull"` GasLimit int64 `pg:",use_zero,notnull"` SizeBytes int `pg:",use_zero,notnull"` Nonce uint64 `pg:",use_zero,notnull"` @@ -27,12 +27,12 @@ type GasOutputs struct { ActorName string `pg:",notnull"` ExitCode int64 `pg:",use_zero,notnull"` GasUsed int64 `pg:",use_zero,notnull"` - ParentBaseFee string `pg:"type:numeric,notnull"` - BaseFeeBurn string `pg:"type:numeric,notnull"` - OverEstimationBurn string `pg:"type:numeric,notnull"` - MinerPenalty string `pg:"type:numeric,notnull"` - MinerTip string `pg:"type:numeric,notnull"` - Refund string `pg:"type:numeric,notnull"` + ParentBaseFee string `pg:",notnull"` + BaseFeeBurn string `pg:",notnull"` + OverEstimationBurn string `pg:",notnull"` + MinerPenalty string `pg:",notnull"` + MinerTip string `pg:",notnull"` + Refund string `pg:",notnull"` GasRefund int64 `pg:",use_zero,notnull"` GasBurned int64 `pg:",use_zero,notnull"` } diff --git a/model/messages/gaseconomy.go b/model/messages/gaseconomy.go index 32fd9b083..f08937d61 100644 --- a/model/messages/gaseconomy.go +++ b/model/messages/gaseconomy.go @@ -11,11 +11,11 @@ type MessageGasEconomy struct { Height int64 `pg:",pk,notnull,use_zero"` StateRoot string `pg:",pk,notnull"` - BaseFee float64 `pg:"type:numeric,use_zero"` + BaseFee float64 `pg:",use_zero"` BaseFeeChangeLog float64 `pg:",use_zero"` - GasLimitTotal int64 `pg:"type:numeric,use_zero"` - GasLimitUniqueTotal int64 `pg:"type:numeric,use_zero"` + GasLimitTotal int64 `pg:",use_zero"` + GasLimitUniqueTotal int64 `pg:",use_zero"` GasFillRatio float64 `pg:",use_zero"` GasCapacityRatio float64 `pg:",use_zero"` diff --git a/model/messages/message.go b/model/messages/message.go index 63489760d..ad7676ef6 100644 --- a/model/messages/message.go +++ b/model/messages/message.go @@ -18,9 +18,9 @@ type Message struct { From string `pg:",notnull"` To string `pg:",notnull"` - Value string `pg:"type:numeric,notnull"` - GasFeeCap string `pg:"type:numeric,notnull"` - GasPremium string `pg:"type:numeric,notnull"` + Value string `pg:",notnull"` + GasFeeCap string `pg:",notnull"` + GasPremium string `pg:",notnull"` GasLimit int64 `pg:",use_zero"` SizeBytes int `pg:",use_zero"` diff --git a/storage/migrations/27_use_numberic_types.go b/storage/migrations/27_use_numberic_types.go deleted file mode 100644 index ffe0f6952..000000000 --- a/storage/migrations/27_use_numberic_types.go +++ /dev/null @@ -1,178 +0,0 @@ -package migrations - -import "github.com/go-pg/migrations/v8" - -// Schema version 27 converts string types containing numbers to numeric types. - -func init() { - up := batch(` - ALTER TABLE public.derived_gas_outputs ALTER COLUMN value TYPE numeric USING (value::numeric); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN gas_fee_cap TYPE numeric USING (gas_fee_cap::numeric); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN gas_premium TYPE numeric USING (gas_premium::numeric); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN parent_base_fee TYPE numeric USING (parent_base_fee::numeric); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN base_fee_burn TYPE numeric USING (base_fee_burn::numeric); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN over_estimation_burn TYPE numeric USING (over_estimation_burn::numeric); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN miner_penalty TYPE numeric USING (miner_penalty::numeric); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN miner_tip TYPE numeric USING (miner_tip::numeric); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN refund TYPE numeric USING (refund::numeric); - - ALTER TABLE public.messages ALTER COLUMN value TYPE numeric USING (value::numeric); - ALTER TABLE public.messages ALTER COLUMN gas_fee_cap TYPE numeric USING (gas_fee_cap::numeric); - ALTER TABLE public.messages ALTER COLUMN gas_premium TYPE numeric USING (gas_premium::numeric); - - ALTER TABLE public.miner_locked_funds ALTER COLUMN locked_funds TYPE numeric USING (locked_funds::numeric); - ALTER TABLE public.miner_locked_funds ALTER COLUMN initial_pledge TYPE numeric USING (initial_pledge::numeric); - ALTER TABLE public.miner_locked_funds ALTER COLUMN pre_commit_deposits TYPE numeric USING (pre_commit_deposits::numeric); - - ALTER TABLE public.miner_fee_debts ALTER COLUMN fee_debt TYPE numeric USING (fee_debt::numeric); - - ALTER TABLE public.miner_pre_commit_infos ALTER COLUMN pre_commit_deposit TYPE numeric USING (pre_commit_deposit::numeric); - ALTER TABLE public.miner_pre_commit_infos ALTER COLUMN deal_weight TYPE numeric USING (deal_weight::numeric); - ALTER TABLE public.miner_pre_commit_infos ALTER COLUMN verified_deal_weight TYPE numeric USING (verified_deal_weight::numeric); - - ALTER TABLE public.miner_sector_infos ALTER COLUMN deal_weight TYPE numeric USING (deal_weight::numeric); - ALTER TABLE public.miner_sector_infos ALTER COLUMN verified_deal_weight TYPE numeric USING (verified_deal_weight::numeric); - ALTER TABLE public.miner_sector_infos ALTER COLUMN initial_pledge TYPE numeric USING (initial_pledge::numeric); - ALTER TABLE public.miner_sector_infos ALTER COLUMN expected_day_reward TYPE numeric USING (expected_day_reward::numeric); - ALTER TABLE public.miner_sector_infos ALTER COLUMN expected_storage_pledge TYPE numeric USING (expected_storage_pledge::numeric); - - ALTER TABLE public.chain_powers ALTER COLUMN total_pledge_collateral TYPE numeric USING (total_pledge_collateral::numeric); - ALTER TABLE public.chain_powers ALTER COLUMN total_raw_bytes_power TYPE numeric USING (total_raw_bytes_power::numeric); - ALTER TABLE public.chain_powers ALTER COLUMN total_raw_bytes_committed TYPE numeric USING (total_raw_bytes_committed::numeric); - ALTER TABLE public.chain_powers ALTER COLUMN total_qa_bytes_power TYPE numeric USING (total_qa_bytes_power::numeric); - ALTER TABLE public.chain_powers ALTER COLUMN total_qa_bytes_committed TYPE numeric USING (total_qa_bytes_committed::numeric); - ALTER TABLE public.chain_powers ALTER COLUMN qa_smoothed_position_estimate TYPE numeric USING (qa_smoothed_position_estimate::numeric); - ALTER TABLE public.chain_powers ALTER COLUMN qa_smoothed_velocity_estimate TYPE numeric USING (qa_smoothed_velocity_estimate::numeric); - - ALTER TABLE public.chain_rewards ALTER COLUMN effective_baseline_power TYPE numeric USING (effective_baseline_power::numeric); - ALTER TABLE public.chain_rewards ALTER COLUMN cum_sum_baseline TYPE numeric USING (cum_sum_baseline::numeric); - ALTER TABLE public.chain_rewards ALTER COLUMN cum_sum_realized TYPE numeric USING (cum_sum_realized::numeric); - ALTER TABLE public.chain_rewards ALTER COLUMN new_baseline_power TYPE numeric USING (new_baseline_power::numeric); - ALTER TABLE public.chain_rewards ALTER COLUMN new_reward_smoothed_position_estimate TYPE numeric USING (new_reward_smoothed_position_estimate::numeric); - ALTER TABLE public.chain_rewards ALTER COLUMN new_reward_smoothed_velocity_estimate TYPE numeric USING (new_reward_smoothed_velocity_estimate::numeric); - ALTER TABLE public.chain_rewards ALTER COLUMN total_mined_reward TYPE numeric USING (total_mined_reward::numeric); - ALTER TABLE public.chain_rewards ALTER COLUMN new_reward TYPE numeric USING (new_reward::numeric); - - ALTER TABLE public.message_gas_economy ALTER COLUMN base_fee TYPE numeric USING (base_fee::numeric); - ALTER TABLE public.message_gas_economy ALTER COLUMN gas_limit_total TYPE numeric USING (base_fee::numeric); - ALTER TABLE public.message_gas_economy ALTER COLUMN gas_limit_unique_total TYPE numeric USING (base_fee::numeric); - - -- cannot modify column type if a view depends on it. - DROP VIEW IF EXISTS chain_visualizer_chain_data_view; - - ALTER TABLE public.power_actor_claims ALTER COLUMN raw_byte_power TYPE numeric USING (raw_byte_power::numeric); - ALTER TABLE public.power_actor_claims ALTER COLUMN quality_adj_power TYPE numeric USING (quality_adj_power::numeric); - - CREATE VIEW chain_visualizer_chain_data_view AS - SELECT - main_block.cid AS block, - bp.parent AS parent, - main_block.miner, - main_block.height, - main_block.parent_weight AS parentweight, - main_block.timestamp, - main_block.parent_state_root AS parentstateroot, - parent_block.timestamp AS parenttimestamp, - parent_block.height AS parentheight, - -- was miner_power.raw_bytes_power (plural bytes) - pac.raw_byte_power AS parentpower, - -- was blocks_synced.synced_at - main_block.timestamp AS syncedtimestamp, - (SELECT COUNT(*) FROM block_messages WHERE block_messages.block = main_block.cid) AS messages - FROM - block_headers main_block - LEFT JOIN - block_parents bp ON bp.block = main_block.cid - LEFT JOIN - block_headers parent_block ON parent_block.cid = bp.parent - LEFT JOIN - -- was miner_power (singular) - power_actor_claims pac ON main_block.parent_state_root = pac.state_root - ; -`) - down := batch(` - ALTER TABLE public.derived_gas_outputs ALTER COLUMN value TYPE text USING (value::text); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN gas_fee_cap TYPE text USING (gas_fee_cap::text); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN gas_premium TYPE text USING (gas_premium::text); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN parent_base_fee TYPE text USING (parent_base_fee::text); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN base_fee_burn TYPE text USING (base_fee_burn::text); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN over_estimation_burn TYPE text USING (over_estimation_burn::text); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN miner_penalty TYPE text USING (miner_penalty::text); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN miner_tip TYPE text USING (miner_tip::text); - ALTER TABLE public.derived_gas_outputs ALTER COLUMN refund TYPE text USING (refund::text); - - ALTER TABLE public.messages ALTER COLUMN value TYPE text USING (value::text); - ALTER TABLE public.messages ALTER COLUMN gas_fee_cap TYPE text USING (gas_fee_cap::text); - ALTER TABLE public.messages ALTER COLUMN gas_premium TYPE text USING (gas_premium::text); - - ALTER TABLE public.miner_locked_funds ALTER COLUMN locked_funds TYPE text USING (locked_funds::text); - ALTER TABLE public.miner_locked_funds ALTER COLUMN initial_pledge TYPE text USING (initial_pledge::text); - ALTER TABLE public.miner_locked_funds ALTER COLUMN pre_commit_deposits TYPE text USING (pre_commit_deposits::text); - - ALTER TABLE public.miner_fee_debts ALTER COLUMN fee_debt TYPE text USING (fee_debt::text); - - ALTER TABLE public.miner_pre_commit_infos ALTER COLUMN pre_commit_deposit TYPE text USING (pre_commit_deposit::text); - ALTER TABLE public.miner_pre_commit_infos ALTER COLUMN deal_weight TYPE text USING (deal_weight::text); - ALTER TABLE public.miner_pre_commit_infos ALTER COLUMN verified_deal_weight TYPE text USING (verified_deal_weight::text); - - ALTER TABLE public.miner_sector_infos ALTER COLUMN deal_weight TYPE text USING (deal_weight::text); - ALTER TABLE public.miner_sector_infos ALTER COLUMN verified_deal_weight TYPE text USING (verified_deal_weight::text); - ALTER TABLE public.miner_sector_infos ALTER COLUMN initial_pledge TYPE text USING (initial_pledge::text); - ALTER TABLE public.miner_sector_infos ALTER COLUMN expected_day_reward TYPE text USING (expected_day_reward::text); - ALTER TABLE public.miner_sector_infos ALTER COLUMN expected_storage_pledge TYPE text USING (expected_storage_pledge::text); - - ALTER TABLE public.chain_powers ALTER COLUMN total_pledge_collateral TYPE text USING (total_pledge_collateral::text); - ALTER TABLE public.chain_powers ALTER COLUMN total_raw_bytes_power TYPE text USING (total_raw_bytes_power::text); - ALTER TABLE public.chain_powers ALTER COLUMN total_raw_bytes_committed TYPE text USING (total_raw_bytes_committed::text); - ALTER TABLE public.chain_powers ALTER COLUMN total_qa_bytes_power TYPE text USING (total_qa_bytes_power::text); - ALTER TABLE public.chain_powers ALTER COLUMN total_qa_bytes_committed TYPE text USING (total_qa_bytes_committed::text); - - ALTER TABLE public.chain_rewards ALTER COLUMN effective_baseline_power TYPE text USING (effective_baseline_power::text); - ALTER TABLE public.chain_rewards ALTER COLUMN cum_sum_baseline TYPE text USING (cum_sum_baseline::text); - ALTER TABLE public.chain_rewards ALTER COLUMN cum_sum_realized TYPE text USING (cum_sum_realized::text); - ALTER TABLE public.chain_rewards ALTER COLUMN new_baseline_power TYPE text USING (new_baseline_power::text); - ALTER TABLE public.chain_rewards ALTER COLUMN new_reward_smoothed_position_estimate TYPE text USING (new_reward_smoothed_position_estimate::text); - ALTER TABLE public.chain_rewards ALTER COLUMN new_reward_smoothed_velocity_estimate TYPE text USING (new_reward_smoothed_velocity_estimate::text); - ALTER TABLE public.chain_rewards ALTER COLUMN total_mined_reward TYPE text USING (total_mined_reward::text); - ALTER TABLE public.chain_rewards ALTER COLUMN new_reward TYPE text USING (new_reward::text); - - ALTER TABLE public.message_gas_economy ALTER COLUMN base_fee TYPE float USING (base_fee::float); - ALTER TABLE public.message_gas_economy ALTER COLUMN gas_limit_total TYPE text USING (base_fee::text); - ALTER TABLE public.message_gas_economy ALTER COLUMN gas_limit_unique_total TYPE text USING (base_fee::text); - - -- cannot modify column type if a view depends on it. - DROP VIEW IF EXISTS chain_visualizer_chain_data_view; - - ALTER TABLE public.power_actor_claims ALTER COLUMN raw_byte_power TYPE text USING (raw_byte_power::text); - ALTER TABLE public.power_actor_claims ALTER COLUMN quality_adj_power TYPE text USING (quality_adj_power::text); - - CREATE VIEW chain_visualizer_chain_data_view AS - SELECT - main_block.cid AS block, - bp.parent AS parent, - main_block.miner, - main_block.height, - main_block.parent_weight AS parentweight, - main_block.timestamp, - main_block.parent_state_root AS parentstateroot, - parent_block.timestamp AS parenttimestamp, - parent_block.height AS parentheight, - -- was miner_power.raw_bytes_power (plural bytes) - pac.raw_byte_power AS parentpower, - -- was blocks_synced.synced_at - main_block.timestamp AS syncedtimestamp, - (SELECT COUNT(*) FROM block_messages WHERE block_messages.block = main_block.cid) AS messages - FROM - block_headers main_block - LEFT JOIN - block_parents bp ON bp.block = main_block.cid - LEFT JOIN - block_headers parent_block ON parent_block.cid = bp.parent - LEFT JOIN - -- was miner_power (singular) - power_actor_claims pac ON main_block.parent_state_root = pac.state_root - ; -`) - - migrations.MustRegisterTx(up, down) -}