Commit 5ee9c745 authored by Hamdi Allam's avatar Hamdi Allam Committed by GitHub

feat(indexer): Remove goerli config options. Specify DisputeGameFactoryProxy...

feat(indexer): Remove goerli config options. Specify DisputeGameFactoryProxy address OP Sepolia (#10032)

* remove goerli. add dpf for optimism sepolia

* remove more goerli references & unit tests
parent 7b5c3380
...@@ -100,7 +100,7 @@ type ChainConfig struct { ...@@ -100,7 +100,7 @@ type ChainConfig struct {
L1Contracts L1Contracts `toml:"l1-contracts"` L1Contracts L1Contracts `toml:"l1-contracts"`
L2Contracts L2Contracts `toml:"-"` L2Contracts L2Contracts `toml:"-"`
// Bedrock starting heights only applicable for OP-Mainnet & OP-Goerli // Bedrock starting heights only applicable for OP-Mainnet
L1BedrockStartingHeight uint `toml:"-"` L1BedrockStartingHeight uint `toml:"-"`
L2BedrockStartingHeight uint `toml:"-"` L2BedrockStartingHeight uint `toml:"-"`
......
...@@ -20,7 +20,7 @@ func TestLoadConfig(t *testing.T) { ...@@ -20,7 +20,7 @@ func TestLoadConfig(t *testing.T) {
testData := ` testData := `
[chain] [chain]
preset = 420 preset = 10
l1-polling-interval = 5000 l1-polling-interval = 5000
l2-polling-interval = 5000 l2-polling-interval = 5000
...@@ -58,11 +58,11 @@ func TestLoadConfig(t *testing.T) { ...@@ -58,11 +58,11 @@ func TestLoadConfig(t *testing.T) {
conf, err := LoadConfig(logger, tmpfile.Name()) conf, err := LoadConfig(logger, tmpfile.Name())
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, conf.Chain.Preset, 420) require.Equal(t, conf.Chain.Preset, 10)
require.Equal(t, conf.Chain.L1Contracts.OptimismPortalProxy.String(), Presets[420].ChainConfig.L1Contracts.OptimismPortalProxy.String()) require.Equal(t, conf.Chain.L1Contracts.OptimismPortalProxy.String(), Presets[10].ChainConfig.L1Contracts.OptimismPortalProxy.String())
require.Equal(t, conf.Chain.L1Contracts.L1CrossDomainMessengerProxy.String(), Presets[420].ChainConfig.L1Contracts.L1CrossDomainMessengerProxy.String()) require.Equal(t, conf.Chain.L1Contracts.L1CrossDomainMessengerProxy.String(), Presets[10].ChainConfig.L1Contracts.L1CrossDomainMessengerProxy.String())
require.Equal(t, conf.Chain.L1Contracts.L1StandardBridgeProxy.String(), Presets[420].ChainConfig.L1Contracts.L1StandardBridgeProxy.String()) require.Equal(t, conf.Chain.L1Contracts.L1StandardBridgeProxy.String(), Presets[10].ChainConfig.L1Contracts.L1StandardBridgeProxy.String())
require.Equal(t, conf.Chain.L1Contracts.L2OutputOracleProxy.String(), Presets[420].ChainConfig.L1Contracts.L2OutputOracleProxy.String()) require.Equal(t, conf.Chain.L1Contracts.L2OutputOracleProxy.String(), Presets[10].ChainConfig.L1Contracts.L2OutputOracleProxy.String())
require.Equal(t, conf.Chain.L1PollingInterval, uint(5000)) require.Equal(t, conf.Chain.L1PollingInterval, uint(5000))
require.Equal(t, conf.Chain.L1HeaderBufferSize, uint(1000)) require.Equal(t, conf.Chain.L1HeaderBufferSize, uint(1000))
require.Equal(t, conf.Chain.L2PollingInterval, uint(5000)) require.Equal(t, conf.Chain.L2PollingInterval, uint(5000))
...@@ -285,15 +285,15 @@ func TestThrowsOnUnknownKeys(t *testing.T) { ...@@ -285,15 +285,15 @@ func TestThrowsOnUnknownKeys(t *testing.T) {
testData := ` testData := `
[chain] [chain]
unknown_key = 420 unknown_key = 420
preset = 420 preset = 10
[rpcs] [rpcs]
l1-rpc = "https://l1.example.com" l1-rpc = "https://l1.example.com"
l2-rpc = "https://l2.example.com" l2-rpc = "https://l2.example.com"
[db] [db]
another_unknownKey = 420 another_unknownKey = 420
host = "127.0.0.1" host = "127.0.0.1"
port = 5432 port = 5432
user = "postgres" user = "postgres"
......
...@@ -38,31 +38,6 @@ var Presets = map[int]Preset{ ...@@ -38,31 +38,6 @@ var Presets = map[int]Preset{
L2ConfirmationDepth: 75, L2ConfirmationDepth: 75,
}, },
}, },
420: {
Name: "Optimism Goerli",
ChainConfig: ChainConfig{
Preset: 420,
L1Contracts: L1Contracts{
AddressManager: common.HexToAddress("0xa6f73589243a6A7a9023b1Fa0651b1d89c177111"),
SystemConfigProxy: common.HexToAddress("0xAe851f927Ee40dE99aaBb7461C00f9622ab91d60"),
OptimismPortalProxy: common.HexToAddress("0x5b47E1A08Ea6d985D6649300584e6722Ec4B1383"),
L2OutputOracleProxy: common.HexToAddress("0xE6Dfba0953616Bacab0c9A8ecb3a9BBa77FC15c0"),
L1CrossDomainMessengerProxy: common.HexToAddress("0x5086d1eEF304eb5284A0f6720f79403b4e9bE294"),
L1StandardBridgeProxy: common.HexToAddress("0x636Af16bf2f682dD3109e60102b8E1A089FedAa8"),
L1ERC721BridgeProxy: common.HexToAddress("0x8DD330DdE8D9898d43b4dc840Da27A07dF91b3c9"),
DisputeGameFactoryProxy: common.HexToAddress("0x1111111111111111111111111111111111111111"),
// pre-bedrock
LegacyCanonicalTransactionChain: common.HexToAddress("0x607F755149cFEB3a14E1Dc3A4E2450Cde7dfb04D"),
LegacyStateCommitmentChain: common.HexToAddress("0x9c945aC97Baf48cB784AbBB61399beB71aF7A378"),
},
L1StartingHeight: 7017096,
L1BedrockStartingHeight: 8300214,
L2BedrockStartingHeight: 4061224,
L1ConfirmationDepth: 10,
L2ConfirmationDepth: 75,
},
},
11155420: { 11155420: {
Name: "Optimism Sepolia", Name: "Optimism Sepolia",
ChainConfig: ChainConfig{ ChainConfig: ChainConfig{
...@@ -75,7 +50,7 @@ var Presets = map[int]Preset{ ...@@ -75,7 +50,7 @@ var Presets = map[int]Preset{
L1CrossDomainMessengerProxy: common.HexToAddress("0x58Cc85b8D04EA49cC6DBd3CbFFd00B4B8D6cb3ef"), L1CrossDomainMessengerProxy: common.HexToAddress("0x58Cc85b8D04EA49cC6DBd3CbFFd00B4B8D6cb3ef"),
L1StandardBridgeProxy: common.HexToAddress("0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1"), L1StandardBridgeProxy: common.HexToAddress("0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1"),
L1ERC721BridgeProxy: common.HexToAddress("0xd83e03D576d23C9AEab8cC44Fa98d058D2176D1f"), L1ERC721BridgeProxy: common.HexToAddress("0xd83e03D576d23C9AEab8cC44Fa98d058D2176D1f"),
DisputeGameFactoryProxy: common.HexToAddress("0x1111111111111111111111111111111111111111"), DisputeGameFactoryProxy: common.HexToAddress("0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1"),
}, },
L1StartingHeight: 4071408, L1StartingHeight: 4071408,
L1ConfirmationDepth: 10, L1ConfirmationDepth: 10,
...@@ -101,25 +76,6 @@ var Presets = map[int]Preset{ ...@@ -101,25 +76,6 @@ var Presets = map[int]Preset{
L2ConfirmationDepth: 75, L2ConfirmationDepth: 75,
}, },
}, },
84531: {
Name: "Base Goerli",
ChainConfig: ChainConfig{
Preset: 84531,
L1Contracts: L1Contracts{
AddressManager: common.HexToAddress("0x4Cf6b56b14c6CFcB72A75611080514F94624c54e"),
SystemConfigProxy: common.HexToAddress("0xb15eea247eCE011C68a614e4a77AD648ff495bc1"),
OptimismPortalProxy: common.HexToAddress("0xe93c8cD0D409341205A592f8c4Ac1A5fe5585cfA"),
L2OutputOracleProxy: common.HexToAddress("0x2A35891ff30313CcFa6CE88dcf3858bb075A2298"),
L1CrossDomainMessengerProxy: common.HexToAddress("0x8e5693140eA606bcEB98761d9beB1BC87383706D"),
L1StandardBridgeProxy: common.HexToAddress("0xfA6D8Ee5BE770F84FC001D098C4bD604Fe01284a"),
L1ERC721BridgeProxy: common.HexToAddress("0x5E0c967457347D5175bF82E8CCCC6480FCD7e568"),
DisputeGameFactoryProxy: common.HexToAddress("0x1111111111111111111111111111111111111111"),
},
L1StartingHeight: 8410981,
L1ConfirmationDepth: 10,
L2ConfirmationDepth: 75,
},
},
84532: { 84532: {
Name: "Base Sepolia", Name: "Base Sepolia",
ChainConfig: ChainConfig{ ChainConfig: ChainConfig{
...@@ -158,25 +114,6 @@ var Presets = map[int]Preset{ ...@@ -158,25 +114,6 @@ var Presets = map[int]Preset{
L2ConfirmationDepth: 75, L2ConfirmationDepth: 75,
}, },
}, },
999: {
Name: "Zora Goerli",
ChainConfig: ChainConfig{
Preset: 999,
L1Contracts: L1Contracts{
AddressManager: common.HexToAddress("0x54f4676203dEDA6C08E0D40557A119c602bFA246"),
SystemConfigProxy: common.HexToAddress("0xF66C9A5E4fE1A8a9bc44a4aF80505a4C3620Ee64"),
OptimismPortalProxy: common.HexToAddress("0xDb9F51790365e7dc196e7D072728df39Be958ACe"),
L2OutputOracleProxy: common.HexToAddress("0xdD292C9eEd00f6A32Ff5245d0BCd7f2a15f24e00"),
L1CrossDomainMessengerProxy: common.HexToAddress("0xD87342e16352D33170557A7dA1e5fB966a60FafC"),
L1StandardBridgeProxy: common.HexToAddress("0x7CC09AC2452D6555d5e0C213Ab9E2d44eFbFc956"),
L1ERC721BridgeProxy: common.HexToAddress("0x57C1C6b596ce90C0e010c358DD4Aa052404bB70F"),
DisputeGameFactoryProxy: common.HexToAddress("0x1111111111111111111111111111111111111111"),
},
L1StartingHeight: 8942381,
L1ConfirmationDepth: 10,
L2ConfirmationDepth: 75,
},
},
424: { 424: {
Name: "PGN", Name: "PGN",
ChainConfig: ChainConfig{ ChainConfig: ChainConfig{
......
...@@ -226,7 +226,7 @@ func (b *BridgeProcessor) processInitiatedL1Events(latestL1Header *types.Header) ...@@ -226,7 +226,7 @@ func (b *BridgeProcessor) processInitiatedL1Events(latestL1Header *types.Header)
fromL1Height, toL1Height := new(big.Int).Add(lastL1BlockNumber, bigint.One), toL1Header.Number fromL1Height, toL1Height := new(big.Int).Add(lastL1BlockNumber, bigint.One), toL1Header.Number
if err := b.db.Transaction(func(tx *database.DB) error { if err := b.db.Transaction(func(tx *database.DB) error {
l1BedrockStartingHeight := big.NewInt(int64(b.chainConfig.L1BedrockStartingHeight)) l1BedrockStartingHeight := big.NewInt(int64(b.chainConfig.L1BedrockStartingHeight))
if l1BedrockStartingHeight.Cmp(fromL1Height) > 0 { // OP Mainnet & OP Goerli Only. if l1BedrockStartingHeight.Cmp(fromL1Height) > 0 { // OP Mainnet
legacyFromL1Height, legacyToL1Height := fromL1Height, toL1Height legacyFromL1Height, legacyToL1Height := fromL1Height, toL1Height
if l1BedrockStartingHeight.Cmp(toL1Height) <= 0 { if l1BedrockStartingHeight.Cmp(toL1Height) <= 0 {
legacyToL1Height = new(big.Int).Sub(l1BedrockStartingHeight, bigint.One) legacyToL1Height = new(big.Int).Sub(l1BedrockStartingHeight, bigint.One)
...@@ -279,7 +279,7 @@ func (b *BridgeProcessor) processInitiatedL2Events(latestL2Header *types.Header) ...@@ -279,7 +279,7 @@ func (b *BridgeProcessor) processInitiatedL2Events(latestL2Header *types.Header)
fromL2Height, toL2Height := new(big.Int).Add(lastL2BlockNumber, bigint.One), toL2Header.Number fromL2Height, toL2Height := new(big.Int).Add(lastL2BlockNumber, bigint.One), toL2Header.Number
if err := b.db.Transaction(func(tx *database.DB) error { if err := b.db.Transaction(func(tx *database.DB) error {
l2BedrockStartingHeight := big.NewInt(int64(b.chainConfig.L2BedrockStartingHeight)) l2BedrockStartingHeight := big.NewInt(int64(b.chainConfig.L2BedrockStartingHeight))
if l2BedrockStartingHeight.Cmp(fromL2Height) > 0 { // OP Mainnet & OP Goerli Only if l2BedrockStartingHeight.Cmp(fromL2Height) > 0 { // OP Mainnet
legacyFromL2Height, legacyToL2Height := fromL2Height, toL2Height legacyFromL2Height, legacyToL2Height := fromL2Height, toL2Height
if l2BedrockStartingHeight.Cmp(toL2Height) <= 0 { if l2BedrockStartingHeight.Cmp(toL2Height) <= 0 {
legacyToL2Height = new(big.Int).Sub(l2BedrockStartingHeight, bigint.One) legacyToL2Height = new(big.Int).Sub(l2BedrockStartingHeight, bigint.One)
......
...@@ -6,53 +6,18 @@ import ( ...@@ -6,53 +6,18 @@ import (
"github.com/ethereum-optimism/optimism/indexer/bigint" "github.com/ethereum-optimism/optimism/indexer/bigint"
"github.com/ethereum-optimism/optimism/indexer/database" "github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum-optimism/optimism/indexer/processors/contracts"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func TestLegacyWithdrawalAndMessageHash(t *testing.T) { func TestLegacyWithdrawalAndMessageHash(t *testing.T) {
// Pre-Bedrock OP-Goerli withdrawal that was proven post-bedrock
// - L1 proven withdrawal tx: 0xa8853a3532f40052385602c66512e438bc1e3736d3cb7abde359f5b9377441c7
value := bigint.Zero
expectedWithdrawalHash := common.HexToHash("0xae99d25df3e38730f6ee6588733417e20a131923b84870be6aedb4f863b6302d")
// Ensure the L2 Tx which correlates with the above proven withdrawal results in the same computed withdrawal hash
// - L2 withdrawal tx: 0x254d9c28add020404142f840ed794cea51f86c0f0a737e3e7bdd7e1e4550962e
abi, err := bindings.CrossDomainMessengerMetaData.GetAbi()
require.NoError(t, err)
var sentMessage bindings.CrossDomainMessengerSentMessage
sentMessageEvent := abi.Events["SentMessage"]
logData := common.FromHex("0x0000000000000000000000004200000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e4a9f9e67500000000000000000000000007865c6e87b9f70255377e024ace6630c1eaa37f0000000000000000000000003b8e53b3ab8e01fb57d0c9e893bc4d655aa67d84000000000000000000000000b91882244f7f82540f2941a759724523c7b9a166000000000000000000000000b91882244f7f82540f2941a759724523c7b9a166000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, contracts.UnpackLog(&sentMessage, &types.Log{Data: logData, Topics: []common.Hash{sentMessageEvent.ID, common.HexToHash("0x000000000000000000000000636af16bf2f682dd3109e60102b8e1a089fedaa8")}}, sentMessageEvent.Name, abi))
// timestamp and message hash are filled in fields. not core to the event
msg := database.BridgeMessage{
Nonce: sentMessage.MessageNonce,
GasLimit: sentMessage.GasLimit,
Tx: database.Transaction{FromAddress: sentMessage.Sender, ToAddress: sentMessage.Target, Amount: value, Data: sentMessage.Message},
}
hash, err := LegacyBridgeMessageWithdrawalHash(420, &msg)
require.NoError(t, err)
require.Equal(t, expectedWithdrawalHash, hash)
// Ensure the relayed message hash (v1) matches
expectedMessageHash := common.HexToHash("0xcb16ecc1967f5d7aed909349a4351d28fbb396429ef7faf1c9d2a670e3ca906f")
v1MessageHash, err := LegacyBridgeMessageV1MessageHash(&msg)
require.NoError(t, err)
require.Equal(t, expectedMessageHash, v1MessageHash)
// OP Mainnet hashes to also check for // OP Mainnet hashes to also check for
// - since the message hash doesn't depend on the preset, we only need to check for the withdrawal hash // - since the message hash doesn't depend on the preset, we only need to check for the withdrawal hash
expectedWithdrawalHash = common.HexToHash("0x9c0bc28a77328a405f21d51a32d32f038ebf7ce70e377ca48b2cd194ec024f15") expectedWithdrawalHash := common.HexToHash("0x9c0bc28a77328a405f21d51a32d32f038ebf7ce70e377ca48b2cd194ec024f15")
msg = database.BridgeMessage{ msg := database.BridgeMessage{
Nonce: big.NewInt(100180), Nonce: big.NewInt(100180),
GasLimit: bigint.Zero, GasLimit: bigint.Zero,
Tx: database.Transaction{ Tx: database.Transaction{
...@@ -63,7 +28,7 @@ func TestLegacyWithdrawalAndMessageHash(t *testing.T) { ...@@ -63,7 +28,7 @@ func TestLegacyWithdrawalAndMessageHash(t *testing.T) {
}, },
} }
hash, err = LegacyBridgeMessageWithdrawalHash(10, &msg) hash, err := LegacyBridgeMessageWithdrawalHash(10, &msg)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, expectedWithdrawalHash, hash) require.Equal(t, expectedWithdrawalHash, hash)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment