-
Notifications
You must be signed in to change notification settings - Fork 72
feat(core): implement eip-7954 increase Maximum Contract Size #33832 #2222
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,12 +17,43 @@ | |
| package vm | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "math" | ||
|
|
||
| "github.com/XinFinOrg/XDPoSChain/common" | ||
| "github.com/XinFinOrg/XDPoSChain/params" | ||
| "github.com/holiman/uint256" | ||
| ) | ||
|
|
||
| // CheckMaxInitCodeSize checks the size of contract initcode against the protocol-defined limit. | ||
| func CheckMaxInitCodeSize(rules *params.Rules, size uint64) error { | ||
| if rules.IsOsaka { | ||
| if size > params.MaxInitCodeSizeOsaka { | ||
| return fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, size, params.MaxInitCodeSizeOsaka) | ||
| } | ||
| } else if rules.IsEIP1559 { | ||
| if size > params.MaxInitCodeSize { | ||
| return fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, size, params.MaxInitCodeSize) | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // CheckMaxCodeSize checks the size of contract code against the protocol-defined limit. | ||
| func CheckMaxCodeSize(rules *params.Rules, size uint64) error { | ||
| if rules.IsOsaka { | ||
| if size > params.MaxCodeSizeOsaka { | ||
| return fmt.Errorf("%w: code size %v limit %v", ErrMaxCodeSizeExceeded, size, params.MaxCodeSizeOsaka) | ||
| } | ||
| } else if rules.IsEIP158 { | ||
| if size > params.MaxCodeSize { | ||
| return fmt.Errorf("%w: code size %v limit %v", ErrMaxCodeSizeExceeded, size, params.MaxCodeSize) | ||
| } | ||
|
Comment on lines
+43
to
+52
|
||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // calcMemSize64 calculates the required memory size, and returns | ||
| // the size and whether the result overflowed uint64 | ||
| func calcMemSize64(off, l *uint256.Int) (uint64, bool) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Copyright 2024 The go-ethereum Authors | ||
| // This file is part of the go-ethereum library. | ||
| // | ||
| // The go-ethereum library is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Lesser General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // The go-ethereum library is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Lesser General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Lesser General Public License | ||
| // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| package native | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestConvertErrorToParity(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| in string | ||
| want string | ||
| }{ | ||
| { | ||
| name: "exact map key", | ||
| in: "max code size exceeded", | ||
| want: "Out of gas", | ||
| }, | ||
| { | ||
| name: "wrapped map key", | ||
| in: "max code size exceeded: code size 24577 limit 24576", | ||
| want: "Out of gas", | ||
| }, | ||
| { | ||
| name: "existing prefix rule", | ||
| in: "out of gas: not enough gas for reentrancy sentry", | ||
| want: "Out of gas", | ||
| }, | ||
| { | ||
| name: "unknown error unchanged", | ||
| in: "some unknown error", | ||
| want: "some unknown error", | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| frame := &flatCallFrame{Error: tc.in} | ||
| convertErrorToParity(frame) | ||
| if frame.Error != tc.want { | ||
| t.Fatalf("unexpected mapped error, got=%q want=%q", frame.Error, tc.want) | ||
| } | ||
| }) | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.