-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Attempts to set the correct readonly values (#1607) * more readonly fixes (#1608) * Proper read only fix (#1610) * Working fix for read only * reset to main * feat: rf4 contract verification models (#1611) * feat: rf4 contract verification models * fix: linting issue * fix: rename source * refactor: contract discovery for rf4 (#1612) * feat: rf4 contract discovery part 2 (#1613) * refactor: contract discovery for rf4 * feat: discovery 3rd level contracts * fix: remove web of trust signal from TU model (#1614) --------- Co-authored-by: Reuven Gonzales <[email protected]>
- Loading branch information
Showing
11 changed files
with
397 additions
and
32 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
47 changes: 47 additions & 0 deletions
47
warehouse/dbt/models/marts/superchain/verification/rf4_agora_contract_discovery.sql
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,47 @@ | ||
with agora as ( | ||
select | ||
application_id, | ||
project_name, | ||
artifact as address, | ||
artifact_source as network, | ||
artifact_type, | ||
'agora_verification' as discovery_method | ||
from {{ source('static_data_sources', 'agora_rf4_artifacts_by_app') }} | ||
where artifact_type in ('CONTRACT', 'DEPLOYER') | ||
), | ||
|
||
discovered_contracts as ( | ||
select | ||
agora.application_id, | ||
agora.project_name, | ||
derived_contracts.contract_address as address, | ||
derived_contracts.network, | ||
--derived_contracts.factory_deployer_address, | ||
'CONTRACT' as artifact_type, | ||
'discovered_contract_from_agora_verified_deployer' as discovery_method | ||
from agora | ||
inner join {{ ref('int_derived_contracts') }} as derived_contracts | ||
on | ||
agora.address = derived_contracts.deployer_address | ||
and agora.network = derived_contracts.network | ||
where | ||
agora.address != derived_contracts.contract_address | ||
) | ||
|
||
select | ||
application_id, | ||
project_name, | ||
address, | ||
network, | ||
artifact_type, | ||
discovery_method | ||
from discovered_contracts | ||
union all | ||
select | ||
application_id, | ||
project_name, | ||
address, | ||
network, | ||
artifact_type, | ||
discovery_method | ||
from agora |
86 changes: 86 additions & 0 deletions
86
warehouse/dbt/models/marts/superchain/verification/rf4_contracts_by_app.sql
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,86 @@ | ||
{% set networks = ["optimism", "base", "frax", "metal", "mode", "zora"] %} | ||
|
||
{% set union_factory_queries = [] %} | ||
|
||
{% for network in networks %} | ||
|
||
{% set network_upper = network.upper() %} | ||
|
||
{% set factory_table = "stg_" ~ network ~ "__factories" %} | ||
{% set query %} | ||
select | ||
factory_address, | ||
contract_address, | ||
'{{ network_upper }}' as network | ||
from {{ ref(factory_table) }} | ||
{% endset %} | ||
{% do union_factory_queries.append(query) %} | ||
|
||
{% endfor %} | ||
|
||
{% set all_factories = union_factory_queries | join(' union all ') %} | ||
|
||
with factories as ( | ||
{{ all_factories }} | ||
), | ||
|
||
app_contracts as ( | ||
select | ||
application_id, | ||
project_name, | ||
address, | ||
network, | ||
artifact_type, | ||
discovery_method | ||
from {{ ref('rf4_oso_contract_discovery') }} | ||
where artifact_type = 'CONTRACT' | ||
union all | ||
select | ||
application_id, | ||
project_name, | ||
address, | ||
network, | ||
artifact_type, | ||
discovery_method | ||
from {{ ref('rf4_agora_contract_discovery') }} | ||
where artifact_type = 'CONTRACT' | ||
), | ||
|
||
discovered_contracts as ( | ||
select | ||
app_contracts.application_id, | ||
app_contracts.project_name, | ||
factories.contract_address as address, | ||
factories.network, | ||
'CONTRACT' as artifact_type, | ||
'discovered_contract_from_verified_factory' as discovery_method | ||
from factories | ||
left join app_contracts | ||
on | ||
factories.factory_address = app_contracts.address | ||
and factories.network = app_contracts.network | ||
), | ||
|
||
contracts as ( | ||
select | ||
application_id, | ||
address, | ||
network, | ||
discovery_method | ||
from discovered_contracts | ||
union all | ||
select | ||
application_id, | ||
address, | ||
network, | ||
discovery_method | ||
from app_contracts | ||
) | ||
|
||
select distinct | ||
application_id, | ||
address as contract_address, | ||
network, | ||
discovery_method | ||
from contracts | ||
where application_id is not null |
112 changes: 112 additions & 0 deletions
112
warehouse/dbt/models/marts/superchain/verification/rf4_oso_contract_discovery.sql
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,112 @@ | ||
with projects as ( | ||
select | ||
apps.application_id, | ||
apps.project_name, | ||
current_projects.blockchain | ||
from {{ source('static_data_sources', 'agora_rf4_applications') }} as apps | ||
left join | ||
{{ ref('stg_ossd__current_projects') }} as current_projects | ||
on apps.oso_project_name = current_projects.project_name | ||
), | ||
|
||
oso_blockchain_artifacts as ( | ||
select | ||
projects.application_id, | ||
projects.project_name, | ||
'oso_verification' as discovery_method, | ||
UPPER(tag) as artifact_type, | ||
UPPER(network) as network, | ||
LOWER(JSON_VALUE(blockchains.address)) as address | ||
from projects | ||
cross join | ||
UNNEST(JSON_QUERY_ARRAY(projects.blockchain)) as blockchains | ||
cross join | ||
UNNEST(JSON_VALUE_ARRAY(blockchains.networks)) as network | ||
cross join | ||
UNNEST(JSON_VALUE_ARRAY(blockchains.tags)) as tag | ||
where tag in ('contract', 'deployer') | ||
), | ||
|
||
networks as ( | ||
select * | ||
from UNNEST([ | ||
struct('OPTIMISM' as network), | ||
struct('BASE' as network), | ||
struct('FRAX' as network), | ||
struct('METAL' as network), | ||
struct('MODE' as network), | ||
struct('ZORA' as network) | ||
]) | ||
), | ||
|
||
oso_any_evm_deployers as ( | ||
select | ||
oso_blockchain_artifacts.application_id, | ||
oso_blockchain_artifacts.project_name, | ||
oso_blockchain_artifacts.artifact_type, | ||
networks.network, | ||
oso_blockchain_artifacts.address, | ||
oso_blockchain_artifacts.discovery_method | ||
from oso_blockchain_artifacts | ||
cross join networks | ||
where | ||
oso_blockchain_artifacts.artifact_type = 'DEPLOYER' | ||
and oso_blockchain_artifacts.network = 'ANY_EVM' | ||
), | ||
|
||
oso_other_addresses as ( | ||
select | ||
application_id, | ||
project_name, | ||
artifact_type, | ||
network, | ||
address, | ||
discovery_method | ||
from oso_blockchain_artifacts | ||
where | ||
network in (select network from networks) | ||
), | ||
|
||
oso_addresses as ( | ||
select * | ||
from oso_any_evm_deployers | ||
union all | ||
select * | ||
from oso_other_addresses | ||
), | ||
|
||
discovered_contracts as ( | ||
select | ||
oso_addresses.application_id, | ||
oso_addresses.project_name, | ||
derived_contracts.contract_address as address, | ||
derived_contracts.network, | ||
--derived_contracts.factory_deployer_address, | ||
'CONTRACT' as artifact_type, | ||
'discovered_contract_from_oso_verified_deployer' as discovery_method | ||
from oso_addresses | ||
inner join {{ ref('int_derived_contracts') }} as derived_contracts | ||
on | ||
oso_addresses.address = derived_contracts.deployer_address | ||
and oso_addresses.network = derived_contracts.network | ||
where | ||
oso_addresses.address != derived_contracts.contract_address | ||
) | ||
|
||
select | ||
application_id, | ||
project_name, | ||
address, | ||
network, | ||
artifact_type, | ||
discovery_method | ||
from discovered_contracts | ||
union all | ||
select | ||
application_id, | ||
project_name, | ||
address, | ||
network, | ||
artifact_type, | ||
discovery_method | ||
from oso_addresses |
Oops, something went wrong.