Skip to content

Commit

Permalink
Update reserved counters with used in pool db during migration (#3352) (
Browse files Browse the repository at this point in the history
#3353)

* return used if reserved counters are 0

* refactor

* refactor
  • Loading branch information
ToniRamirezM authored Feb 22, 2024
1 parent 49e837a commit f8690e6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion db/migrations/pool/0013.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
-- +migrate Up
ALTER TABLE pool.transaction
ADD COLUMN reserved_zkcounters jsonb;
ADD COLUMN reserved_zkcounters jsonb DEFAULT '{}'::jsonb;

UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{GasUsed}', cast(cumulative_gas_used as text)::jsonb, true);
UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{KeccakHashes}', cast(used_keccak_hashes as text)::jsonb, true);
UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{PoseidonHashes}', cast(used_poseidon_hashes as text)::jsonb, true);
UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{PoseidonPaddings}', cast(used_poseidon_paddings as text)::jsonb, true);
UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{MemAligns}', cast(used_mem_aligns as text)::jsonb, true);
UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{Arithmetics}', cast(used_arithmetics as text)::jsonb, true);
UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{Binaries}', cast(used_binaries as text)::jsonb, true);
UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{Steps}', cast(used_steps as text)::jsonb, true);
UPDATE pool."transaction" set reserved_zkcounters = jsonb_set(reserved_zkcounters , '{Sha256Hashes_V2}', cast(used_sha256_hashes as text)::jsonb, true);

-- +migrate Down
ALTER TABLE pool.transaction
Expand Down

0 comments on commit f8690e6

Please sign in to comment.