Skip to content

Commit

Permalink
[iip15] fix caused an error within EVM when the contract was not regi…
Browse files Browse the repository at this point in the history
…stered (#3929)
  • Loading branch information
millken authored and dustinxie committed Nov 16, 2023
1 parent 7e93d69 commit f173223
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 4 additions & 0 deletions blockindex/sgd_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ func (sgd *sgdRegistry) CheckContract(ctx context.Context, contract string, heig
}
sgdIndex, err := sgd.getSGDIndex(addr.Bytes())
if err != nil {
// if the contract is not registered, return nil to prevent the evm from throwing error
if errors.Cause(err) == db.ErrNotExist || errors.Cause(err) == db.ErrBucketNotExist {
return nil, 0, false, nil
}
return nil, 0, false, err
}

Expand Down
2 changes: 1 addition & 1 deletion blockindex/sgd_indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestNewSGDRegistry(t *testing.T) {
blk := createTestingBlock(builder, 4, h, exec, logs)
r.NoError(sgdRegistry.PutBlock(ctx, blk))
receiver, percentage, isApproved, err := sgdRegistry.CheckContract(ctx, registerAddress.String(), 4)
r.ErrorContains(err, "not exist in DB")
r.NoError(err)
r.Nil(receiver)
r.False(isApproved)
hh, err := sgdRegistry.Height()
Expand Down
3 changes: 0 additions & 3 deletions e2etest/sgd_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func TestSGDRegistry(t *testing.T) {
"c375c2ef0000000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc4",
},
checkContractExpect: checkContractExpectation{
errorContains: "not exist in DB",
contractAddress: registerAddress.String(),
},
},
Expand All @@ -187,7 +186,6 @@ func TestSGDRegistry(t *testing.T) {
"07f7aafb0000000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc4",
},
checkContractExpect: checkContractExpectation{
errorContains: "not exist in DB",
contractAddress: registerAddress.String(),
},
},
Expand Down Expand Up @@ -225,7 +223,6 @@ func TestSGDRegistry(t *testing.T) {
"07f7aafb0000000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc4",
},
checkContractExpect: checkContractExpectation{
errorContains: "not exist in DB",
contractAddress: registerAddress.String(),
},
},
Expand Down

0 comments on commit f173223

Please sign in to comment.