Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iip15] fix caused EVM error when the contract was not registered #3929

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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