Returns an overflow-safe slice of an array. It right-pads
the data with zeros to `length`.
@param {BN} offset
@param {BN} length
@param {Buffer} data
function getDataSlice (data, offset, length) {
  let len = new BN(data.length)
  if (offset.gt(len)) {
    offset = len
  }

  let end = offset.add(length)
  if (end.gt(len)) {
    end = len
  }

  data = data.slice(offset.toNumber(), end.toNumber())
  // Right-pad with zeros to fill dataLength bytes
  data = utils.setLengthRight(data, length.toNumber())

  return data
}