From 3b984e10cd91018ca0d11806ba14fa4450f8ca5d Mon Sep 17 00:00:00 2001 From: Peter Kieltyka Date: Tue, 25 Jul 2023 13:00:22 -0400 Subject: [PATCH 1/4] ethreceipts: check for nil in isBlockFinal --- ethreceipts/ethreceipts.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ethreceipts/ethreceipts.go b/ethreceipts/ethreceipts.go index a5a4d812..bcf71d12 100644 --- a/ethreceipts/ethreceipts.go +++ b/ethreceipts/ethreceipts.go @@ -754,6 +754,9 @@ func (l *ReceiptsListener) getMaxWaitBlocks(maxWait *int) uint64 { } func (l *ReceiptsListener) isBlockFinal(blockNum *big.Int) bool { + if l == nil || l.latestBlockNum() == nil || blockNum == nil { + return false + } diff := big.NewInt(0).Sub(l.latestBlockNum(), blockNum) return diff.Cmp(big.NewInt(int64(l.options.NumBlocksToFinality))) >= 0 } From 605b3f7a88d601bbf05465b57fedd234f0c9b747 Mon Sep 17 00:00:00 2001 From: Peter Kieltyka Date: Tue, 25 Jul 2023 13:09:09 -0400 Subject: [PATCH 2/4] fix ethrpc test --- ethrpc/ethrpc_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ethrpc/ethrpc_test.go b/ethrpc/ethrpc_test.go index d09b8d8d..71a1afb2 100644 --- a/ethrpc/ethrpc_test.go +++ b/ethrpc/ethrpc_test.go @@ -82,7 +82,7 @@ func TestERC20MintAndTransfer(t *testing.T) { } func TestBlockByNumber(t *testing.T) { - p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon/test") + p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon") require.NoError(t, err) { @@ -101,7 +101,7 @@ func TestBlockByNumber(t *testing.T) { } // func TestBlockRange(t *testing.T) { -// p, err := ethrpc.NewProvider("https://dev-nodes.sequence.app/optimism/test") +// p, err := ethrpc.NewProvider("https://dev-nodes.sequence.app/optimism") // require.NoError(t, err) // { @@ -112,7 +112,7 @@ func TestBlockByNumber(t *testing.T) { // } func ExampleBatchCall() { - p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon/test") + p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon") if err != nil { panic(err) } @@ -143,7 +143,7 @@ func ExampleBatchCall() { func TestETHRPC(t *testing.T) { t.Run("Single", func(t *testing.T) { - p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon/test") + p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon") require.NoError(t, err) chainID, err := p.ChainID(context.Background()) @@ -153,7 +153,7 @@ func TestETHRPC(t *testing.T) { }) t.Run("Batch", func(t *testing.T) { - p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon/test") + p, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon") require.NoError(t, err) var ( From 463b84da7d21e0c7746f49674e80307acda22bb4 Mon Sep 17 00:00:00 2001 From: Peter Kieltyka Date: Tue, 25 Jul 2023 19:09:10 -0400 Subject: [PATCH 3/4] update --- ethreceipts/ethreceipts.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethreceipts/ethreceipts.go b/ethreceipts/ethreceipts.go index bcf71d12..34a8b428 100644 --- a/ethreceipts/ethreceipts.go +++ b/ethreceipts/ethreceipts.go @@ -754,7 +754,8 @@ func (l *ReceiptsListener) getMaxWaitBlocks(maxWait *int) uint64 { } func (l *ReceiptsListener) isBlockFinal(blockNum *big.Int) bool { - if l == nil || l.latestBlockNum() == nil || blockNum == nil { + latestBlockNum := l.latestBlockNum() + if latestBlockNum == nil || blockNum == nil { return false } diff := big.NewInt(0).Sub(l.latestBlockNum(), blockNum) From 7fe2b5f23b1ec12bc370178a5e432674aab94d77 Mon Sep 17 00:00:00 2001 From: William Hua Date: Tue, 25 Jul 2023 19:49:01 -0400 Subject: [PATCH 4/4] l.latestBlockNum() -> latestBlockNum --- ethreceipts/ethreceipts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethreceipts/ethreceipts.go b/ethreceipts/ethreceipts.go index 34a8b428..1d88ab02 100644 --- a/ethreceipts/ethreceipts.go +++ b/ethreceipts/ethreceipts.go @@ -758,7 +758,7 @@ func (l *ReceiptsListener) isBlockFinal(blockNum *big.Int) bool { if latestBlockNum == nil || blockNum == nil { return false } - diff := big.NewInt(0).Sub(l.latestBlockNum(), blockNum) + diff := big.NewInt(0).Sub(latestBlockNum, blockNum) return diff.Cmp(big.NewInt(int64(l.options.NumBlocksToFinality))) >= 0 }