Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

core/block_validator.go#calcDifficultyAtlantis: should not use hardcoded bomb delay #66

Closed
meowsbits opened this issue Jun 17, 2019 · 2 comments

Comments

@meowsbits
Copy link

https://github.com/eth-classic/go-ethereum/blob/development/core/block_validator.go#L326

func calcDifficultyAtlantis(time uint64, parent *types.Header) *big.Int {
	bombDelayFromParent := new(big.Int).Sub(big.NewInt(3000000), big1)
	// https://github.com/ethereum/EIPs/issues/100.
	// algorithm:
	// diff = (parent_diff +
	//         (parent_diff / 2048 * max((2 if len(parent.uncles) else 1) - ((timestamp - parent.timestamp) // 9), -99))
	//        ) + 2^(periodCount - 2)

	bigTime := new(big.Int).SetUint64(time)
	bigParentTime := parent.Time

	// holds intermediate values to make the algo easier to read & audit
	x := new(big.Int)
	y := new(big.Int)
@soc1c
Copy link
Contributor

soc1c commented Jun 18, 2019

Sorry, how does this differ from #67?

@meowsbits
Copy link
Author

meowsbits commented Jun 18, 2019

It doesn't much; this was just the preliminary result of a review that then grew larger in scope.

With that, however, the case of using "magic" values like this (aside from the contextual incorrectness reported in #67) can be seen to stand as an issue in it's own right, with hopefully few to none other such cases.

Resolution of bespoke subsequent issue will also resolve this one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants