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

refactor: add error checks for missing chain id #781

Merged
merged 6 commits into from
Jul 6, 2023

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Jul 6, 2023

Description

When dereferencing chain id from core parameters, there is the possibility of a segmentation fault. If the chain ID component of inbound transaction is unknown to zetacore + zetaclient, a nil pointer is dereferenced in an attempt to retrieve info.

Closes:

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Copy link
Collaborator

@brewmaster012 brewmaster012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should just fix the immediate segmentation fault site.

zetaclient/evm_client.go Show resolved Hide resolved
if destChain == nil {
ob.logger.ExternalChainWatcher.Warn().Msgf("chain id not supported %d", event.DestinationChainId.Int64())
continue
}
destAddr := clienttypes.BytesToEthHex(event.DestinationAddress)

if strings.EqualFold(destAddr, ob.cfg.EVMChainConfigs[destChain.ChainId].CoreParams.ZETATokenContractAddress) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be defensive and check whether ob.cfg.EVMChainConfigs[destChain.ChainId] is nil or not.

@kingpinXD kingpinXD merged commit 542eb37 into develop Jul 6, 2023
14 checks passed
@kingpinXD kingpinXD deleted the fix/chainid-checks branch July 6, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants