-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix l1infotreesync. Error UNIQUE constraint failed: rollup_exit_root.hash on VerifyBatches Event - l1infotreesync: Add verification for contract address. The problem is that if you set bad address cdk run normally but you don't get any information about L1InfoTree. - l1infotreesync: Add support to `InitL1InfoRootMap` - Allow to use `InitL1InfoRootMap` if there are no leaves on L1InfoTree Internal: - Fix local config file generation for debug on vscode (`./scripts/local_config`) - Add support to `contractVersions` - Remove param `-custom-network-file` that is no longer used - Refactor `l1infotreesync/processor.go` in multiples files - Change some tree functions to use a `tx db.Querier` instead of `ctx context.Context`: context was not used to do DB query was using `db` directly. In some test I need to query over current tx
- Loading branch information
1 parent
6c148e9
commit c4c790f
Showing
36 changed files
with
2,050 additions
and
209 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
package l1infotreesync | ||
|
||
import ( | ||
"fmt" | ||
"math/big" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/0xPolygon/cdk-contracts-tooling/contracts/banana/polygonzkevmglobalexitrootv2" | ||
mocks_l1infotreesync "github.com/0xPolygon/cdk/l1infotreesync/mocks" | ||
"github.com/ethereum/go-ethereum/accounts/abi" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/mock" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBuildAppenderErrorOnBadContractAddr(t *testing.T) { | ||
l1Client := mocks_l1infotreesync.NewEthClienter(t) | ||
globalExitRoot := common.HexToAddress("0x1") | ||
rollupManager := common.HexToAddress("0x2") | ||
l1Client.EXPECT().CallContract(mock.Anything, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("test-error")) | ||
flags := FlagNone | ||
_, err := buildAppender(l1Client, globalExitRoot, rollupManager, flags) | ||
require.Error(t, err) | ||
} | ||
|
||
func TestBuildAppenderBypassBadContractAddr(t *testing.T) { | ||
l1Client := mocks_l1infotreesync.NewEthClienter(t) | ||
globalExitRoot := common.HexToAddress("0x1") | ||
rollupManager := common.HexToAddress("0x2") | ||
l1Client.EXPECT().CallContract(mock.Anything, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("test-error")) | ||
flags := FlagAllowWrongContractsAddrs | ||
_, err := buildAppender(l1Client, globalExitRoot, rollupManager, flags) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestBuildAppenderVerifiedContractAddr(t *testing.T) { | ||
l1Client := mocks_l1infotreesync.NewEthClienter(t) | ||
globalExitRoot := common.HexToAddress("0x1") | ||
rollupManager := common.HexToAddress("0x2") | ||
|
||
smcAbi, err := abi.JSON(strings.NewReader(polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2ABI)) | ||
require.NoError(t, err) | ||
bigInt := big.NewInt(1) | ||
returnGER, err := smcAbi.Methods["depositCount"].Outputs.Pack(bigInt) | ||
require.NoError(t, err) | ||
l1Client.EXPECT().CallContract(mock.Anything, mock.Anything, mock.Anything).Return(returnGER, nil).Once() | ||
v := common.HexToAddress("0x1234") | ||
returnRM, err := smcAbi.Methods["bridgeAddress"].Outputs.Pack(v) | ||
require.NoError(t, err) | ||
l1Client.EXPECT().CallContract(mock.Anything, mock.Anything, mock.Anything).Return(returnRM, nil).Once() | ||
flags := FlagNone | ||
_, err = buildAppender(l1Client, globalExitRoot, rollupManager, flags) | ||
require.NoError(t, err) | ||
} |
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,14 @@ | ||
-- +migrate Down | ||
DROP TABLE IF EXISTS l1info_initial; | ||
|
||
-- +migrate Up | ||
|
||
CREATE TABLE l1info_initial ( | ||
-- single_row_id prevent to have more than 1 row in this table | ||
single_row_id INTEGER check(single_row_id=1) NOT NULL DEFAULT 1, | ||
block_num INTEGER NOT NULL REFERENCES block(num) ON DELETE CASCADE, | ||
leaf_count INTEGER NOT NULL, | ||
l1_info_root VARCHAR NOT NULL, | ||
PRIMARY KEY (single_row_id) | ||
); | ||
|
Oops, something went wrong.