Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaubennassar committed Jul 30, 2024
2 parents 69d9139 + 3d61577 commit b90342f
Show file tree
Hide file tree
Showing 6 changed files with 795 additions and 6 deletions.
55 changes: 52 additions & 3 deletions dataavailability/datacommittee/datacommittee_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package datacommittee

import (
"errors"
"fmt"
"math/big"
"testing"

smcparis "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana-paris/polygondatacommittee"
"github.com/0xPolygon/cdk-contracts-tooling/contracts/banana/polygondatacommittee"
"github.com/0xPolygon/cdk/log"
erc1967proxy "github.com/0xPolygon/cdk/test/contracts/erc1967proxy"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand All @@ -16,7 +20,7 @@ import (
)

func TestUpdateDataCommitteeEvent(t *testing.T) {
t.Skip("This test is not working because the simulated backend doesnt accept PUSH0, check: https://github.com/ethereum/go-ethereum/issues/28144#issuecomment-2247124776")
//t.Skip("This test is not working because the simulated backend doesnt accept PUSH0, check: https://github.com/ethereum/go-ethereum/issues/28144#issuecomment-2247124776")
// Set up testing environment
dac, ethBackend, auth, da := newTestingEnv(t)

Expand Down Expand Up @@ -109,16 +113,22 @@ func newSimulatedDacman(t *testing.T, auth *bind.TransactOpts) (
client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))

// DAC Setup
_, _, da, err = polygondatacommittee.DeployPolygondatacommittee(auth, client.Client())
addr, _, _, err := smcparis.DeployPolygondatacommittee(auth, client.Client())
if err != nil {
return &Backend{}, nil, nil, err
}
client.Commit()
_, err = da.Initialize(auth)
proxyAddr, err := deployDACProxy(auth, client.Client(), addr)
if err != nil {
return &Backend{}, nil, nil, err
}

client.Commit()
da, err = polygondatacommittee.NewPolygondatacommittee(proxyAddr, client.Client())
if err != nil {
return &Backend{}, nil, nil, err
}

_, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{})
if err != nil {
return &Backend{}, nil, nil, err
Expand All @@ -130,3 +140,42 @@ func newSimulatedDacman(t *testing.T, auth *bind.TransactOpts) (
}
return c, client, da, nil
}

func deployDACProxy(auth *bind.TransactOpts, client bind.ContractBackend, dacImpl common.Address) (common.Address, error) {
// Deploy proxy
dacABI, err := polygondatacommittee.PolygondatacommitteeMetaData.GetAbi()
if err != nil {
return common.Address{}, err
}
if dacABI == nil {
return common.Address{}, errors.New("GetABI returned nil")
}
initializeCallData, err := dacABI.Pack("initialize")
if err != nil {
return common.Address{}, err
}
proxyAddr, err := deployProxy(
auth,
client,
dacImpl,
initializeCallData,
)
if err != nil {
return common.Address{}, err
}
fmt.Println("DAC proxy deployed at", proxyAddr)
return proxyAddr, nil
}

func deployProxy(auth *bind.TransactOpts,
client bind.ContractBackend,
implementationAddr common.Address,
initializeParams []byte) (common.Address, error) {
addr, _, _, err := erc1967proxy.DeployErc1967proxy(
auth,
client,
implementationAddr,
initializeParams,
)
return addr, err
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/0xPolygon/cdk
go 1.22.4

require (
github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240726101945-d05a885ae884
github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240726125827-301fa4c59245
github.com/0xPolygon/cdk-data-availability v0.0.8
github.com/0xPolygon/cdk-rpc v0.0.0-20240419104226-c0a62ba0f49d
github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-RC4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240726101945-d05a885ae884 h1:oXUct6UWuGs15WyCEKipY0Kc0BsCnMzniAz0EIFoPxs=
github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240726101945-d05a885ae884/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU=
github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240726125827-301fa4c59245 h1:BBmVd50JQID9UyUR3vWFMKr2pMHD3mrqjpuB9DDepBw=
github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240726125827-301fa4c59245/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU=
github.com/0xPolygon/cdk-data-availability v0.0.8 h1:bMmOYZ7Ei683y80ric3KzMPXtRGmchAmfjIRzghaHb4=
github.com/0xPolygon/cdk-data-availability v0.0.8/go.mod h1:3XkZ0zn0GsvAT01MPQMmukF534CVSFmtrcoK3F/BK6Q=
github.com/0xPolygon/cdk-rpc v0.0.0-20240419104226-c0a62ba0f49d h1:sxh6hZ2jF/sxxj2jd5o1vuNNCZjYmn4aRG9SRlVaEFs=
Expand Down
71 changes: 71 additions & 0 deletions test/contracts/abi/erc1967proxy.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_logic",
"type": "address"
},
{
"internalType": "bytes",
"name": "_data",
"type": "bytes"
}
],
"stateMutability": "payable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "previousAdmin",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "newAdmin",
"type": "address"
}
],
"name": "AdminChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "beacon",
"type": "address"
}
],
"name": "BeaconUpgraded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "implementation",
"type": "address"
}
],
"name": "Upgraded",
"type": "event"
},
{
"stateMutability": "payable",
"type": "fallback"
},
{
"stateMutability": "payable",
"type": "receive"
}
]
1 change: 1 addition & 0 deletions test/contracts/bin/erc1967proxy.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
60806040526040516104ee3803806104ee833981016040819052610022916102de565b61002e82826000610035565b50506103fb565b61003e83610061565b60008251118061004b5750805b1561005c5761005a83836100a1565b505b505050565b61006a816100cd565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606100c683836040518060600160405280602781526020016104c760279139610180565b9392505050565b6001600160a01b0381163b61013f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080856001600160a01b03168560405161019d91906103ac565b600060405180830381855af49150503d80600081146101d8576040519150601f19603f3d011682016040523d82523d6000602084013e6101dd565b606091505b5090925090506101ef868383876101f9565b9695505050505050565b60608315610268578251600003610261576001600160a01b0385163b6102615760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610136565b5081610272565b610272838361027a565b949350505050565b81511561028a5781518083602001fd5b8060405162461bcd60e51b815260040161013691906103c8565b634e487b7160e01b600052604160045260246000fd5b60005b838110156102d55781810151838201526020016102bd565b50506000910152565b600080604083850312156102f157600080fd5b82516001600160a01b038116811461030857600080fd5b60208401519092506001600160401b038082111561032557600080fd5b818501915085601f83011261033957600080fd5b81518181111561034b5761034b6102a4565b604051601f8201601f19908116603f01168101908382118183101715610373576103736102a4565b8160405282815288602084870101111561038c57600080fd5b61039d8360208301602088016102ba565b80955050505050509250929050565b600082516103be8184602087016102ba565b9190910192915050565b60208152600082518060208401526103e78160408501602087016102ba565b601f01601f19169190910160400192915050565b60be806104096000396000f3fe608060405236601057600e6013565b005b600e5b601f601b6021565b6065565b565b600060607f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b3660008037600080366000845af43d6000803e8080156083573d6000f35b3d6000fdfea2646970667358221220ffbfbaa210c1b5f5ca62a5eba67b7d993e0bdf919f51500f790fb7acf2fd784c64736f6c63430008140033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564
Loading

0 comments on commit b90342f

Please sign in to comment.