Skip to content

Commit

Permalink
chain: explicitly check that gasLimit is above zero
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Feb 8, 2023
1 parent 5c0f750 commit 9f38d72
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions venus-shared/actors/types/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,18 @@ func (m *Message) ValidForBlockInclusion(minGas int64, version network.Version)
return fmt.Errorf("invalid 'To' address")
}

if !abi.AddressValidForNetworkVersion(m.To, version) {
return fmt.Errorf("'To' address protocol unsupported for network version")
}

if m.From == address.Undef {
return fmt.Errorf("'From' address cannot be empty")
}

if !abi.AddressValidForNetworkVersion(m.From, version) {
return fmt.Errorf("'From' address protocol unsupported for network version")
}

if m.Value.Int == nil {
return fmt.Errorf("'Value' cannot be nil")
}
Expand Down Expand Up @@ -193,6 +201,10 @@ func (m *Message) ValidForBlockInclusion(minGas int64, version network.Version)
return fmt.Errorf("'GasLimit' field cannot be greater than a block's gas limit")
}

if m.GasLimit <= 0 {
return fmt.Errorf("'GasLimit' field %d must be positive", m.GasLimit)
}

// since prices might vary with time, this is technically semantic validation
if m.GasLimit < minGas {
return fmt.Errorf("'GasLimit' field cannot be less than the cost of storing a message on chain %d < %d", m.GasLimit, minGas)
Expand Down

0 comments on commit 9f38d72

Please sign in to comment.