-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix block number bug in balanceAt #20112
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
Conversation
2ae7df6 to
62af7c8
Compare
62af7c8 to
81da3d9
Compare
core/capabilities/fakes/evm_chain.go
Outdated
| // Convert proto big-int to *big.Int; nil ⇒ latest (handled by geth toBlockNumArg) | ||
| var blockArg *big.Int | ||
| if input != nil { | ||
| blockArg = pb.NewIntFromBigInt(input.BlockNumber) // returns nil if input.BlockNumber is nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be fined in FromBigInt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the implementation:
func NewIntFromBigInt(b *BigInt) *big.Int {
if b == nil {
return nil
}
bigInt := new(big.Int).SetBytes(b.AbsVal)
if b.Sign < 0 {
bigInt = bigInt.Neg(bigInt)
}
return bigInt
}
nil will be returned as nil, others will be converted to *big.Int and return.
core/capabilities/fakes/evm_chain.go
Outdated
|
|
||
| // Convert proto big-int to *big.Int; nil ⇒ latest (handled by geth toBlockNumArg) | ||
| var blockArg *big.Int | ||
| if input != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter is complaning here
<file name="core/capabilities/fakes/evm_chain.go">
<error column="5" line="308" message="SA5011(related information): this check suggests that the pointer can be nil" severity="error" source="staticcheck"></error>
</file>
</checkstyle>
I see we directly access input.Account before. should that also be fixed to be under nil check or can we just expect this to be non nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safe to just add a check.
7ec6163 to
c0ac9fb
Compare
|




confirmed @george-dorin 's workflow succeeded after the fix: