Skip to content

Commit

Permalink
Update contracts and ABIs for preprod and testnet (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary authored Nov 22, 2024
2 parents e73b099 + af5385d commit 280f000
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 227 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
REPOSITORY: ${{ github.event.repository.name }}
run: |
VERSION=$(cat .release_version)
if [[ $GITHUB_REF == refs/heads/master ]]; then
if [[ $GITHUB_REF == refs/heads/master || $GITHUB_REF == refs/tags/* ]]; then
docker buildx build --platform "linux/amd64,linux/arm64" -t $REGISTRY/$REPOSITORY:$VERSION -t $REGISTRY/$REPOSITORY:latest --push .
else
docker buildx build --platform "linux/amd64" -t $REGISTRY/$REPOSITORY:$VERSION --push .
Expand Down
37 changes: 37 additions & 0 deletions pkg/contractStore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Generating contracts from BlockLake

```sql
-- base query
with all_contracts as (
select
contract_address,
proxy_contract_address,
block_number
from proxy_contracts
where contract_address in (
-- core contracts for network (e.g. mainnet, testnet, preprod)
'0xacc1fb458a1317e886db376fc8141540537e68fe',
'0x30770d7e3e71112d7a6b7259542d1f680a70e315',
'0xdfb5f6ce42aaa7830e94ecfccad411bef4d4d5b6',
'0xa44151489861fe9e3055d95adc98fbd462b948e7',
'0x055733000064333caddbc92763c58bf0192ffebf'
)
),
distinct_contracts as (
select distinct contract_address from all_contracts
union all
select distinct proxy_contract_address from all_contracts
)


-- proxy contracts
select
contract_address,
contract_abi,
bytecode_hash
from contracts
where contract_address in (select contract_address from distinct_contracts)

-- implementation contracts
select * from all_contracts
```
344 changes: 170 additions & 174 deletions pkg/contractStore/coreContracts/preprod.json

Large diffs are not rendered by default.

87 changes: 41 additions & 46 deletions pkg/contractStore/coreContracts/testnet.json

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions pkg/contractStore/postgresContractStore/postgresContractStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,9 @@ func (s *PostgresContractStore) InitializeCoreContracts() error {
if res.Error != nil {
return xerrors.Errorf("Failed to fetch contracts: %w", res.Error)
}
if len(contracts) > 0 {
s.Logger.Sugar().Debugw("Core contracts already initialized")
return nil
}

for _, contract := range coreContracts.CoreContracts {
_, _, err := s.FindOrCreateContract(
_, found, err := s.FindOrCreateContract(
contract.ContractAddress,
contract.ContractAbi,
true,
Expand All @@ -242,21 +238,37 @@ func (s *PostgresContractStore) InitializeCoreContracts() error {
if err != nil {
return xerrors.Errorf("Failed to create core contract: %w", err)
}
if found {
s.Logger.Sugar().Infow("Contract already exists", zap.String("contractAddress", contract.ContractAddress))
continue
}

_, err = s.SetContractCheckedForProxy(contract.ContractAddress)
if err != nil {
return xerrors.Errorf("Failed to create core contract: %w", err)
}
s.Logger.Sugar().Infow("Created core contract", zap.String("contractAddress", contract.ContractAddress))
}
for _, proxy := range coreContracts.ProxyContracts {
_, _, err := s.FindOrCreateProxyContract(
_, found, err := s.FindOrCreateProxyContract(
uint64(proxy.BlockNumber),
proxy.ContractAddress,
proxy.ProxyContractAddress,
)
if err != nil {
return xerrors.Errorf("Failed to create core proxy contract: %w", err)
}
if found {
s.Logger.Sugar().Infow("Proxy contract already exists",
zap.String("contractAddress", proxy.ContractAddress),
zap.String("proxyContractAddress", proxy.ContractAddress),
)
continue
}
s.Logger.Sugar().Infow("Created proxy contract",
zap.String("contractAddress", proxy.ContractAddress),
zap.String("proxyContractAddress", proxy.ContractAddress),
)
}
return nil
}

0 comments on commit 280f000

Please sign in to comment.