Skip to content

Throw error in case of a bad merge - #384

Merged
JonoPrest merged 5 commits into
mainfrom
jp/throw-error-on-bad-merge
Dec 13, 2024
Merged

Throw error in case of a bad merge#384
JonoPrest merged 5 commits into
mainfrom
jp/throw-error-on-bad-merge

Conversation

@JonoPrest

Copy link
Copy Markdown
Collaborator

No description provided.

@JonoPrest
JonoPrest requested a review from DZakh December 12, 2024 11:56
nextRegister.latestFetchedBlock.blockNumber => merged
| DynamicContractRegister(_) =>
| DynamicContractRegister({nextRegister}) =>
if register.latestFetchedBlock.blockNumber > nextRegister.latestFetchedBlock.blockNumber {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I want to validate whether this case is happening. It should never but I have know way of validating without adding a log. I could just add a log and stop it from crashing but it would be invalid if we ever hit this.

Registers should only merge when the latestFetchedBlockNumber is equal.

@JonoPrest
JonoPrest force-pushed the jp/throw-error-on-bad-merge branch from 1e9ea98 to 0bc3eaa Compare December 13, 2024 11:25

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, but I'd prefer to avoid unreachable code to decrease maintenance burden.

Comment on lines +982 to +990
let exists = dcr.contractAddress == contractAddress
if exists {
warnIfAttemptedAddressRegisterOnDifferentContracts(
~contractAddress,
~contractName,
~existingContractName=(dcr.contractType :> string),
~chainId,
)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will it ever reach this code with an exception thrown from addAddress?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes it can because the error thrown will only occur for an individual contractAddressMapping when the address actually gets added or if two mappings are combined etc.

There is no global contractAddressMapping.

What was happening before is checkContractIsRegistered would return false in the case that the address is exists but the contractName does not match. Now it returns true so it stops it from overwriting but there is no feedback to the user that this is happening and no way for us to trace it without a log. We don't need the log but it can be helpful for debugging.

@JonoPrest
JonoPrest merged commit 79f82fb into main Dec 13, 2024
@JonoPrest
JonoPrest deleted the jp/throw-error-on-bad-merge branch December 13, 2024 13:28
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