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

[EC-231] ECIP 1017 Geth compatibility fixes and tests #307

Merged
merged 10 commits into from
Sep 26, 2017

Conversation

ntallar
Copy link

@ntallar ntallar commented Sep 19, 2017

Description

Includes integration tests that executes blocks generated by Geth, for which the eraDuration was reduced to 3. The purpose of these was to test the compatibility of Mantis with Geth, for which several changes were done to the BlockRewardCalculator, based on the formulas used on Geth.

During testing it was found that Geth and Parity aren't compatible, which is why this test doesn't check compatibility with Parity.

val ommersReward = (firstEraBlockReward * ommersCount * ommerInclusionRewardNumer * eraMultiplier) /
(ommerInclusionRewardDenom * eraDivisor)
val baseReward = calcMinerBaseReward(era)
val ommersReward = calcMinerRewardPerOmmer(era) * ommersCount
Copy link
Contributor

Choose a reason for hiding this comment

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

Take a note of ethereumproject/go-ethereum#352 and ethereumproject/ECIPs#15 (comment). Maybe we should at least add comments with those links until the issue is resolved. Ideally we should hold on merging this until we get some feedback (hopefully soon)

Copy link
Contributor

Choose a reason for hiding this comment

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

If we go with this implementation, comments need to be updated to reflect that these are separate rewards that have already been rounded down.

(firstEraBlockReward * ommerMiningRewardNumer * eraMultiplier) / (ommerMiningRewardDenom * eraDivisor)
}
} else
calcMinerBaseReward(era) * ommerMiningRewardNumer / ommerMiningRewardDenom
Copy link
Contributor

Choose a reason for hiding this comment

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

You're multiplying the result of division, thus introducing rounding errors

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this could cause rounding error, however as this seems to be the more closer approach to how it is calculated in Geth and ommerMiningRewardNumer=1, I decided to leave it this way.
Do you think it would be better to change this?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, if geth does it then it's fine. I thought about it and it's not devoid of logic to have it rounded down prior to another division.

val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/ecip1017Test")

val startBlock = 1
val endBlock = 100
Copy link
Contributor

@rtkaczyk rtkaczyk Sep 20, 2017

Choose a reason for hiding this comment

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

Could we have more blocks in this test? The further the era, the more chance of catching a rounding error. Ideally we should reach era #170 - IIRC, that's when rewards drop to zero.

Copy link
Contributor

Choose a reason for hiding this comment

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

Era #193 actually:

x = 1 - floor(ln(a) / ln(1 - m))

where:
  x - the era number where rewards drop to zero
  a - base reward (5 Ether)
  m - reduction rate (0.2)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make it an even 200 to be sure? 😃

Copy link
Author

Choose a reason for hiding this comment

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

Changed endBlock to 602, which is the first block that belongs to era 200.
No other compatibility error was found 😄

val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/ecip1017Test")

val startBlock = 1
val endBlock = 602
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we maybe add a comment about era 193 going zero, and how we want to go past that point.

@rtkaczyk
Copy link
Contributor

Could we maybe add some test cases to BlockRewardSpec that capture those tiny differences in rounding?

rtkaczyk
rtkaczyk previously approved these changes Sep 21, 2017
rtkaczyk
rtkaczyk previously approved these changes Sep 25, 2017
KonradStaniec
KonradStaniec previously approved these changes Sep 25, 2017
@ntallar ntallar dismissed stale reviews from KonradStaniec and rtkaczyk via 4f1d4bd September 25, 2017 15:03
@ntallar ntallar merged commit 4f1d4bd into phase/daedalus Sep 26, 2017
@ntallar ntallar deleted the feature/testECIP1017 branch September 26, 2017 13:22
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.

3 participants