Skip to content

Commit e859f36

Browse files
authored
Merge pull request ethereum#3035 from Gustav-Simonsson/zero_value_transfer_noop
core/state: short-circuit balance change if zero value
2 parents 3778f1b + 25ed5fe commit e859f36

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/state/state_object.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ func (self *StateObject) Update() {
152152
}
153153

154154
func (c *StateObject) AddBalance(amount *big.Int) {
155+
if amount.Cmp(common.Big0) == 0 {
156+
return
157+
}
155158
c.SetBalance(new(big.Int).Add(c.balance, amount))
156159

157160
if glog.V(logger.Core) {
@@ -160,6 +163,9 @@ func (c *StateObject) AddBalance(amount *big.Int) {
160163
}
161164

162165
func (c *StateObject) SubBalance(amount *big.Int) {
166+
if amount.Cmp(common.Big0) == 0 {
167+
return
168+
}
163169
c.SetBalance(new(big.Int).Sub(c.balance, amount))
164170

165171
if glog.V(logger.Core) {

0 commit comments

Comments
 (0)