Skip to content

Commit

Permalink
fix(test): fix issue causing required field 'gasPrice' in transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
jakim929 committed Oct 22, 2024
1 parent 3acbd0a commit d1b2bea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum v1.14.11 => github.com/ethereum-optimism/op-geth v1.101411.0-rc.1
replace github.com/ethereum/go-ethereum v1.14.11 => github.com/ethereum-optimism/op-geth v1.101411.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v1.101411.0-rc.1 h1:xRheNbOM+Js9a+dqVt5LmBqQK8L5IyHKU8FfI4Cy9qw=
github.com/ethereum-optimism/op-geth v1.101411.0-rc.1/go.mod h1:7S4pp8KHBmEmKkRjL1BPOc6jY9hW+64YeMUjR3RVLw4=
github.com/ethereum-optimism/op-geth v1.101411.0 h1:K5QDCehYwOHSNAwI5SKpi/WhpnLophjbePtOo4qHTVc=
github.com/ethereum-optimism/op-geth v1.101411.0/go.mod h1:7S4pp8KHBmEmKkRjL1BPOc6jY9hW+64YeMUjR3RVLw4=
github.com/ethereum-optimism/optimism v1.9.5-0.20241021150032-1e59d08322f8 h1:bhG/9dttuyOPZZUhMb3e5zApDunSAE5a8sy42P/V7sw=
github.com/ethereum-optimism/optimism v1.9.5-0.20241021150032-1e59d08322f8/go.mod h1:5vH0W+a+76TjhxA//o8jr5d/zouHQaFtspVu0N2jumk=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241002103526-9083af857790 h1:yZlEBCdD0izqzTvmhET1roNSzMfXL50DhL+dALYlnXk=
Expand Down
6 changes: 3 additions & 3 deletions interop/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ func (i *L2ToL2MessageIndexer) createSubscription(key string, messageChan chan<-
}

func getIdentifier(ctx context.Context, backend ethereum.ChainReader, chainID uint64, log *types.Log) (*bindings.ICrossL2InboxIdentifier, error) {
block, err := backend.BlockByNumber(ctx, big.NewInt(int64(log.BlockNumber)))
blockHeader, err := backend.HeaderByNumber(ctx, big.NewInt(int64(log.BlockNumber)))
if err != nil {
return nil, fmt.Errorf("failed to get block: %w", err)
}

return &bindings.ICrossL2InboxIdentifier{
Origin: log.Address,
BlockNumber: block.Number(),
BlockNumber: blockHeader.Number,
LogIndex: big.NewInt(int64(log.Index)),
Timestamp: big.NewInt(int64(block.Time())),
Timestamp: big.NewInt(int64(blockHeader.Time)),
ChainId: big.NewInt(int64(chainID)),
}, nil
}
4 changes: 2 additions & 2 deletions opsimulator/opsimulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,12 @@ func (opSim *OpSimulator) checkInteropInvariants(ctx context.Context, tx *types.
}

sourceClient := sourceChain.EthClient()
identifierBlock, err := sourceClient.BlockByNumber(ctx, identifier.BlockNumber)
identifierBlockHeader, err := sourceClient.HeaderByNumber(ctx, identifier.BlockNumber)
if err != nil {
return fmt.Errorf("failed to fetch executing message block: %w", err)
}

if identifier.Timestamp.Cmp(new(big.Int).SetUint64(identifierBlock.Time())) != 0 {
if identifier.Timestamp.Cmp(new(big.Int).SetUint64(identifierBlockHeader.Time)) != 0 {
return fmt.Errorf("executing message identifier does not match block timestamp: %w", err)
}

Expand Down
24 changes: 12 additions & 12 deletions supersim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,14 @@ func TestBatchJsonRpcRequestErrorHandling(t *testing.T) {
// Create a bad executing message that will throw an error using CrossL2Inbox
executeMessageNonce, err := testSuite.DestEthClient.PendingNonceAt(context.Background(), fromAddress)
require.NoError(t, err)
initiatingMessageBlock, err := testSuite.SourceEthClient.BlockByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
initiatingMessageBlockHeader, err := testSuite.SourceEthClient.HeaderByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
require.NoError(t, err)
initiatingMessageLog := initiatingMessageTxReceipt.Logs[0]
identifier := bindings.ICrossL2InboxIdentifier{
Origin: origin,
BlockNumber: initiatingMessageTxReceipt.BlockNumber,
LogIndex: big.NewInt(0),
Timestamp: new(big.Int).Sub(new(big.Int).SetUint64(initiatingMessageBlock.Time()), big.NewInt(1)),
Timestamp: new(big.Int).Sub(new(big.Int).SetUint64(initiatingMessageBlockHeader.Time), big.NewInt(1)),
ChainId: testSuite.SourceChainID,
}
executeMessageCallData, err := bindings.CrossL2InboxParsedABI.Pack("executeMessage", identifier, fromAddress, initiatingMessageLog.Data)
Expand Down Expand Up @@ -497,14 +497,14 @@ func TestInteropInvariantCheckSucceeds(t *testing.T) {

l2tol2CDM, err := bindings.NewL2ToL2CrossDomainMessengerTransactor(predeploys.L2toL2CrossDomainMessengerAddr, testSuite.DestEthClient)
require.NoError(t, err)
initiatingMessageBlock, err := testSuite.SourceEthClient.BlockByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
initiatingMessageBlockHeader, err := testSuite.SourceEthClient.HeaderByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
require.NoError(t, err)
initiatingMessageLog := initiatingMessageTxReceipt.Logs[0]
identifier := bindings.ICrossL2InboxIdentifier{
Origin: origin,
BlockNumber: initiatingMessageTxReceipt.BlockNumber,
LogIndex: big.NewInt(0),
Timestamp: new(big.Int).SetUint64(initiatingMessageBlock.Time()),
Timestamp: new(big.Int).SetUint64(initiatingMessageBlockHeader.Time),
ChainId: testSuite.SourceChainID,
}
transactor, err := bind.NewKeyedTransactorWithChainID(privateKey, testSuite.DestChainID)
Expand Down Expand Up @@ -551,15 +551,15 @@ func TestInteropInvariantCheckFailsBadLogIndex(t *testing.T) {

crossL2Inbox, err := bindings.NewCrossL2Inbox(predeploys.CrossL2InboxAddr, testSuite.DestEthClient)
require.NoError(t, err)
initiatingMessageBlock, err := testSuite.SourceEthClient.BlockByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
initiatingMessageBlockHeader, err := testSuite.SourceEthClient.HeaderByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
require.NoError(t, err)

initiatingMessageLog := initiatingMessageTxReceipt.Logs[0]
identifier := bindings.ICrossL2InboxIdentifier{
Origin: origin,
BlockNumber: initiatingMessageTxReceipt.BlockNumber,
LogIndex: big.NewInt(1), // Wrong index
Timestamp: new(big.Int).SetUint64(initiatingMessageBlock.Time()),
Timestamp: new(big.Int).SetUint64(initiatingMessageBlockHeader.Time),
ChainId: testSuite.SourceChainID,
}
transactor, err := bind.NewKeyedTransactorWithChainID(privateKey, testSuite.DestChainID)
Expand Down Expand Up @@ -603,14 +603,14 @@ func TestInteropInvariantCheckBadBlockNumber(t *testing.T) {
crossL2Inbox, err := bindings.NewCrossL2Inbox(predeploys.CrossL2InboxAddr, testSuite.DestEthClient)
require.NoError(t, err)
wrongBlockNumber := new(big.Int).Add(initiatingMessageTxReceipt.BlockNumber, big.NewInt(1))
wrongMessageBlock, err := testSuite.SourceEthClient.BlockByNumber(context.Background(), wrongBlockNumber)
wrongMessageBlockHeader, err := testSuite.SourceEthClient.HeaderByNumber(context.Background(), wrongBlockNumber)
require.NoError(t, err)
initiatingMessageLog := initiatingMessageTxReceipt.Logs[0]
identifier := bindings.ICrossL2InboxIdentifier{
Origin: origin,
BlockNumber: wrongBlockNumber,
LogIndex: big.NewInt(0),
Timestamp: new(big.Int).SetUint64(wrongMessageBlock.Time()),
Timestamp: new(big.Int).SetUint64(wrongMessageBlockHeader.Time),
ChainId: testSuite.SourceChainID,
}
transactor, err := bind.NewKeyedTransactorWithChainID(privateKey, testSuite.DestChainID)
Expand Down Expand Up @@ -653,14 +653,14 @@ func TestInteropInvariantCheckBadBlockTimestamp(t *testing.T) {

crossL2Inbox, err := bindings.NewCrossL2Inbox(predeploys.CrossL2InboxAddr, testSuite.DestEthClient)
require.NoError(t, err)
initiatingMessageBlock, err := testSuite.SourceEthClient.BlockByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
initiatingMessageBlockHeader, err := testSuite.SourceEthClient.HeaderByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
require.NoError(t, err)
initiatingMessageLog := initiatingMessageTxReceipt.Logs[0]
identifier := bindings.ICrossL2InboxIdentifier{
Origin: origin,
BlockNumber: initiatingMessageTxReceipt.BlockNumber,
LogIndex: big.NewInt(0),
Timestamp: new(big.Int).SetUint64(initiatingMessageBlock.Time() + 1),
Timestamp: new(big.Int).SetUint64(initiatingMessageBlockHeader.Time + 1),
ChainId: testSuite.SourceChainID,
}
transactor, err := bind.NewKeyedTransactorWithChainID(privateKey, testSuite.DestChainID)
Expand Down Expand Up @@ -703,14 +703,14 @@ func TestForkedInteropInvariantCheckSucceeds(t *testing.T) {

l2tol2CDM, err := bindings.NewL2ToL2CrossDomainMessengerTransactor(predeploys.L2toL2CrossDomainMessengerAddr, testSuite.DestEthClient)
require.NoError(t, err)
initiatingMessageBlock, err := testSuite.SourceEthClient.BlockByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
initiatingMessageBlockHeader, err := testSuite.SourceEthClient.HeaderByNumber(context.Background(), initiatingMessageTxReceipt.BlockNumber)
require.NoError(t, err)
initiatingMessageLog := initiatingMessageTxReceipt.Logs[0]
identifier := bindings.ICrossL2InboxIdentifier{
Origin: origin,
BlockNumber: initiatingMessageTxReceipt.BlockNumber,
LogIndex: big.NewInt(0),
Timestamp: new(big.Int).SetUint64(initiatingMessageBlock.Time()),
Timestamp: new(big.Int).SetUint64(initiatingMessageBlockHeader.Time),
ChainId: testSuite.SourceChainID,
}
transactor, err := bind.NewKeyedTransactorWithChainID(privateKey, testSuite.DestChainID)
Expand Down

0 comments on commit d1b2bea

Please sign in to comment.