-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add v1.4.1 singletons L1 singleton 0x41675C099F32341bf84BFc5382aF534df5C7461a L2 singleton 0x29fcB43b46531BcA003ddC8FCB67FFE91900C76 * Change goerli test * Declare new Safe models for zkevm * Implement Safe models for zkevm * Update crosschain models with zkevm data Models updated are: - safe_native_transfers.all.sql -> Added safe_zkevm_matic_transfers - safe_safes_all.sql -> Added safe_zkevm_safes - safe_transactions_all.sql -> safe_zkevm_transactions * Bugfix: Joining correctly on celo transactions for safe_celo_transactions spell * Fix project start for safe_polygon_matic_transfers.sql * rename correctly Safe zkevm transactions spell * Add zkevm base source * Implement correctly base source # Conflicts: # sources/_base_sources/zkevm_base_sources.yml * Fix zkevm schema * Trigger run again * Remove singletons spell * Add singletons spell * add decoded source tables * Fix duplicate anchor * Update sources/safe/zkevm/safe_zkevm_sources.yml Co-authored-by: Huang Geyang <Sukebeta@outlook.com> * Adapt test * Update models/safe/zkevm/safe_zkevm_matic_transfers.sql Co-authored-by: Huang Geyang <Sukebeta@outlook.com> * Update models/safe/zkevm/safe_zkevm_matic_transfers.sql Co-authored-by: Huang Geyang <Sukebeta@outlook.com> * Add schema to zkevm Safe data models * Adapt pot_hook section * Use same incremental interval in union * Set project start date * Add unique combo of columns test * remove unique_key column on zkevm_transactions * Revert "remove unique_key column on zkevm_transactions" This reverts commit 5e44197. * Delelete unique key on safe_zkevm_transacions * Update models/safe/zkevm/safe_zkevm_matic_transfers.sql Co-authored-by: Huang Geyang <Sukebeta@outlook.com> * Add increment join Following suggestion of Hosuke * Address merge conflicts * Address one more merge conflict * Address one more merge conflict * Quickfix: Change block_time incremental join * Update models/safe/zkevm/safe_zkevm_transactions.sql Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> * Update models/safe/zkevm/safe_zkevm_transactions.sql Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> * Address feedback of jeff * Move unique combo test to safe txs spell * Update models/safe/zkevm/safe_zkevm_schema.yml Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --------- Co-authored-by: Huang Geyang <Sukebeta@outlook.com> Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com>
- Loading branch information
1 parent
2efee82
commit 64b3cbc
Showing
13 changed files
with
444 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
schema = 'safe_zkevm', | ||
alias = 'matic_transfers', | ||
partition_by = ['block_month'], | ||
unique_key = ['block_date', 'address', 'tx_hash', 'trace_address'], | ||
on_schema_change='fail', | ||
file_format ='delta', | ||
incremental_strategy='merge', | ||
post_hook = '{{ expose_spells( | ||
blockchains = \'["zkevm"]\', | ||
spell_type = "project", | ||
spell_name = "safe", | ||
contributors = \'["danielpartida"]\') }}' | ||
) | ||
}} | ||
|
||
{% set project_start_date = '2023-09-01' %} | ||
|
||
select | ||
t.*, | ||
p.price * t.amount_raw / 1e18 AS amount_usd | ||
|
||
from ( | ||
select | ||
'zkevm' as blockchain, | ||
'MATIC' as symbol, | ||
s.address, | ||
try_cast(date_trunc('day', et.block_time) as date) as block_date, | ||
CAST(date_trunc('month', et.block_time) as DATE) as block_month, | ||
et.block_time, | ||
-CAST(et.value AS INT256) as amount_raw, | ||
et.tx_hash, | ||
array_join(et.trace_address, ',') as trace_address | ||
from {{ source('zkevm', 'traces') }} et | ||
join {{ ref('safe_zkevm_safes') }} s on et."from" = s.address | ||
and et."from" != et.to -- exclude calls to self to guarantee unique key property | ||
and et.success = true | ||
and (lower(et.call_type) not in ('delegatecall', 'callcode', 'staticcall') or et.call_type is null) | ||
and et.value > UINT256 '0' -- et.value is uint256 type | ||
{% if not is_incremental() %} | ||
where et.block_time > TIMESTAMP '{{project_start_date}}' -- for initial query optimisation | ||
{% endif %} | ||
{% if is_incremental() %} | ||
-- to prevent potential counterfactual safe deployment issues we take a bigger interval | ||
where et.block_time > date_trunc('day', now() - interval '10' day) | ||
{% endif %} | ||
|
||
union all | ||
|
||
select | ||
'zkevm' as blockchain, | ||
'MATIC' as symbol, | ||
s.address, | ||
try_cast(date_trunc('day', et.block_time) as date) as block_date, | ||
CAST(date_trunc('month', et.block_time) as DATE) as block_month, | ||
et.block_time, | ||
CAST(et.value AS INT256) as amount_raw, | ||
et.tx_hash, | ||
array_join(et.trace_address, ',') as trace_address | ||
from {{ source('zkevm', 'traces') }} et | ||
join {{ ref('safe_zkevm_safes') }} s on et.to = s.address | ||
and et."from" != et.to -- exclude calls to self to guarantee unique key property | ||
and et.success = true | ||
and (lower(et.call_type) not in ('delegatecall', 'callcode', 'staticcall') or et.call_type is null) | ||
and et.value > UINT256 '0' -- et.value is uint256 type | ||
{% if not is_incremental() %} | ||
where et.block_time > TIMESTAMP '{{project_start_date}}' -- for initial query optimisation | ||
{% endif %} | ||
{% if is_incremental() %} | ||
-- to prevent potential counterfactual safe deployment issues we take a bigger interval | ||
where et.block_time > date_trunc('day', now() - interval '10' day) | ||
{% endif %} | ||
) t | ||
|
||
left join {{ source('prices', 'usd') }} p on p.blockchain is null | ||
{% if is_incremental() %} | ||
and {{ incremental_predicate('p.minute') }} | ||
{% endif %} | ||
and p.symbol = t.symbol | ||
and p.minute = date_trunc('minute', t.block_time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
schema = 'safe_zkevm', | ||
alias= 'safes', | ||
partition_by = ['block_month'], | ||
unique_key = ['block_date', 'address'], | ||
on_schema_change='fail', | ||
file_format ='delta', | ||
incremental_strategy='merge', | ||
post_hook = '{{ expose_spells( | ||
blockchains = \'["zkevm"]\', | ||
spell_type = "project", | ||
spell_name = "safe", | ||
contributors = \'["danielpartida"]\') }}' | ||
) | ||
}} | ||
|
||
select | ||
'zkevm' as blockchain, | ||
et."from" as address, | ||
case | ||
when et.to = 0xd9db270c1b5e3bd161e8c8503c55ceabee709552 then '1.3.0' | ||
when et.to = 0x3e5c63644e683549055b9be8653de26e0b4cd36e then '1.3.0L2' | ||
when et.to = 0x41675C099F32341bf84BFc5382aF534df5C7461a then '1.4.1' | ||
when et.to = 0x29fcB43b46531BcA003ddC8FCB67FFE91900C762 then '1.4.1L2' | ||
else 'unknown' | ||
end as creation_version, | ||
try_cast(date_trunc('day', et.block_time) as date) as block_date, | ||
CAST(date_trunc('month', et.block_time) as DATE) as block_month, | ||
et.block_time as creation_time, | ||
et.tx_hash | ||
from {{ source('zkevm', 'traces') }} et | ||
join {{ ref('safe_zkevm_singletons') }} s | ||
on et.to = s.address | ||
where et.success = true | ||
and et.call_type = 'delegatecall' -- delegatecall to singleton is Safe (proxy) address | ||
and bytearray_substring(et.input, 1, 4) in ( | ||
0x0ec78d9e, -- setup method v0.1.0 | ||
0xa97ab18a, -- setup method v1.0.0 | ||
0xb63e800d -- setup method v1.1.0, v1.1.1, v1.2.0, v1.3.0, v1.3.0L2, v1.4.1, v.1.4.1L2 | ||
) | ||
and et.gas_used > 10000 -- to ensure the setup call was successful. excludes e.g. setup calls with missing params that fallback | ||
{% if not is_incremental() %} | ||
and et.block_time > TIMESTAMP '2023-09-01' -- for initial query optimisation | ||
{% endif %} | ||
{% if is_incremental() %} | ||
and et.block_time > date_trunc('day', now() - interval '7' day) | ||
{% endif %} |
Oops, something went wrong.