Skip to content
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

Drop go 1.12 and fix some things #1281

Merged
merged 10 commits into from
Aug 7, 2020
Merged

Conversation

roman-khimov
Copy link
Member

We no longer need to support Go 1.12, so we can fix #349 and #350. At the same time I've noticed some other minor problems, so they were also fixed (albeit it makes this PR somewhat unfocused).

It's old and not maintained. Use latest Go for builds and test only with 1.13
and 1.14.
@codecov
Copy link

codecov bot commented Aug 6, 2020

Codecov Report

Merging #1281 into master will increase coverage by 6.64%.
The diff coverage is 18.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1281      +/-   ##
==========================================
+ Coverage   61.26%   67.91%   +6.64%     
==========================================
  Files         216      216              
  Lines       18490    18464      -26     
==========================================
+ Hits        11328    12539    +1211     
+ Misses       6542     5263    -1279     
- Partials      620      662      +42     
Impacted Files Coverage Δ
cli/server/server.go 0.00% <0.00%> (ø)
cli/smartcontract/smart_contract.go 0.00% <0.00%> (ø)
cli/wallet/multisig.go 0.00% <0.00%> (ø)
cli/wallet/nep5.go 0.00% <0.00%> (ø)
cli/wallet/wallet.go 0.00% <0.00%> (ø)
pkg/compiler/compiler.go 53.40% <0.00%> (ø)
pkg/config/config.go 70.00% <0.00%> (ø)
pkg/consensus/recovery_message.go 84.43% <ø> (+84.43%) ⬆️
pkg/core/interop/runtime/util.go 76.31% <ø> (ø)
pkg/core/interop/runtime/witness.go 45.09% <0.00%> (ø)
... and 62 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1d3223...433e9aa. Read the comment docs.

}
size := io.GetVarSize(t)
if size > transaction.MaxTransactionSize {
return errors.Errorf("invalid transaction size = %d. It shoud be less then MaxTransactionSize = %d", io.GetVarSize(t), transaction.MaxTransactionSize)
return fmt.Errorf("invalid transaction size = %d. It shoud be less then MaxTransactionSize = %d", io.GetVarSize(t), transaction.MaxTransactionSize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve this message by putting size instead of io.GetVarSize(t).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors.Errorf -> fmt.Errorf was done automatically, so messages were not improved there, but thanks for comments, I'll improve them where possible.

@@ -160,7 +161,7 @@ func ParseParamType(typ string) (ParamType, error) {
case "any":
return AnyType, nil
default:
return UnknownType, errors.Errorf("Unknown contract parameter type: %s", typ)
return UnknownType, fmt.Errorf("Unknown contract parameter type: %s", typ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous errors start with lowercase letter, although it's not so important.

@@ -94,7 +94,7 @@ func (p Parameter) MarshalJSON() ([]byte, error) {
case InteropInterfaceType, AnyType:
resultRawValue = nil
default:
resultErr = errors.Errorf("Marshaller for type %s not implemented", p.Type)
resultErr = fmt.Errorf("Marshaller for type %s not implemented", p.Type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First capital letter.

@@ -183,7 +183,7 @@ func (p *Parameter) UnmarshalJSON(data []byte) (err error) {
// stub, ignore value, it can only be null
p.Value = nil
default:
return errors.Errorf("Unmarshaller for type %s not implemented", p.Type)
return fmt.Errorf("Unmarshaller for type %s not implemented", p.Type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First capital letter.

@@ -412,7 +412,7 @@ func NewParameterFromString(in string) (*Parameter, error) {
}
// We currently do not support following types:
if res.Type == ArrayType || res.Type == MapType || res.Type == InteropInterfaceType || res.Type == VoidType {
return nil, errors.Errorf("Unsupported contract parameter type: %s", res.Type)
return nil, fmt.Errorf("Unsupported contract parameter type: %s", res.Type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Comment on lines +529 to +533
maxBlockSystemFee := p.GetMaxBlockSystemFeeInternal(d)
if maxBlockSystemFee < tx.SystemFee {
return fmt.Errorf("transaction's fee can't exceed maximum block system fee %d", maxBlockSystemFee)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment to CheckPolicy should also be updated according to these changes.

@roman-khimov roman-khimov force-pushed the drop-go-1.12-and-fix-some-things branch from 433e9aa to ff66307 Compare August 7, 2020 09:20
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.

Fix #350.
ErrAlreadyExists should be returned for ErrDup, not ErrConflict.
It no longer depends on blockchain state and there can't ever be an error, in
fact we can always iterate over signers, so copying these hashes doesn't make
much sense at all as well as sorting arrays in verifyTxWitnesses (witnesses
order must match signers order).
We were checking blocked accounts twice which is obviously excessive. We also
have our accounts sorted, so we can rely on that in CheckPolicy(). It also
doesn't make much sense to check MaxBlockSystemFee in Blockchain code, policy
contract can handle that.
@roman-khimov roman-khimov merged commit c3c88a5 into master Aug 7, 2020
@roman-khimov roman-khimov deleted the drop-go-1.12-and-fix-some-things branch August 7, 2020 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Go 1.13 trimpath flag
3 participants