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

CT: no code stop effect #958

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
go.uber.org/mock v0.4.0
golang.org/x/crypto v0.22.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/sync v0.7.0
pgregory.net/rand v1.0.2
)

Expand Down Expand Up @@ -78,13 +79,12 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum => github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20240916105249-e7951db0c00b
replace github.com/ethereum/go-ethereum => github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20241210083612-373029913b2e
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to be sure: please update this once the corresponding go-ethereum-sonic change is merged to make sure the version number points to a commit on a non-development branch of go-ethereum-sonic.


replace github.com/ethereum/evmc/v11 => ./third_party/evmc
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20240916105249-e7951db0c00b h1:RkK1XUuFi2z0A2XGMgRsI9Cd1+v70Da8jzEPeqnZ+vI=
github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20240916105249-e7951db0c00b/go.mod h1:p4knNH76zBuqbEfc6CbZTOnaQNU0WvhzW5f0qq6aMoU=
github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20241210083612-373029913b2e h1:3YwOb0qbVo2c8tV3FNIZ6VWMGBO6uiZrST1xiyEFJn8=
github.com/Fantom-foundation/go-ethereum-sonic v0.0.0-20241210083612-373029913b2e/go.mod h1:p4knNH76zBuqbEfc6CbZTOnaQNU0WvhzW5f0qq6aMoU=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
Expand Down
8 changes: 1 addition & 7 deletions go/ct/gen/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,6 @@ func (g *StateGenerator) generateWith(rnd *rand.Rand, assignment Assignment) (*s
// Generate return data of last call
resultLastCallReturnData := RandomBytes(rnd, st.MaxDataSize)

// Generate return data for terminal states.
var resultReturnData Bytes
if resultStatus == st.Stopped || resultStatus == st.Reverted {
resultReturnData = RandomBytes(rnd, st.MaxDataSize)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, I have a concern about removing the generation of resutlReturnData.
The returned data is used in two different contexes:

  • As write buffer for a "callee" contract, used by the RETURN op. This buffer cannot be accessed by the contract again, as the execution terminates right away. Regarding this OP, we can remove the buffer generation
  • As read buffer for the "caller" contract, accessed via RETURNDATASIZE and RETURNDATACOPY.

The later is a state that would require the generation of a returned data buffer. Right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the specification, the data returned by a call and the data returned by the current contract execution are stored in different fields of the state (see here).

For instance, if you look into the specification of the RETURNDATASIZE here, it is reading the size of the state's LastCallReturnData field.

The fact that all implementations use the same field for the last call return data and the return data of the current call is a (valid) optimization, but not reflected in the specification.

// Invoke SelfDestructedGenerator
resultHasSelfdestructed, err := g.hasSelfDestructedGen.Generate(rnd)
if err != nil {
Expand Down Expand Up @@ -534,6 +528,7 @@ func (g *StateGenerator) generateWith(rnd *rand.Rand, assignment Assignment) (*s

resultRevision := GetRevisionForBlock(resultBlockContext.BlockNumber)

// Return data is not set as it should only be set by RETURN/REVERT opcodes.
result := st.NewState(resultCode)
result.Status = resultStatus
result.Revision = resultRevision
Expand All @@ -552,7 +547,6 @@ func (g *StateGenerator) generateWith(rnd *rand.Rand, assignment Assignment) (*s
result.TransactionContext = resultTransactionContext
result.CallData = resultCallData
result.LastCallReturnData = resultLastCallReturnData
result.ReturnData = resultReturnData
result.HasSelfDestructed = resultHasSelfdestructed
result.RecentBlockHashes = resultRecentBlockHashes

Expand Down
16 changes: 16 additions & 0 deletions regression_inputs/no_code_#958.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Status": "running",
"Revision": "Berlin",
"ReadOnly": false,
"Pc": 0 ,
"Gas": 766154147,
"GasRefund": -386980389124,
"Code": "",
"Stack": [
"73d98e21930ee3c4 9adfe6af5c3129a6 14d8827ba8c91ac6 aad5465e39e7224f",
"fbe73cec10215f25 b4b4cdc59461cf5e 0bdbdfbd8bb66463 8d8f315fa500dfd2",
"44e536d9beb6692f f1771bc7786d984f e8121ed7845eb679 7481234b5f8357fc",
"a4908db06f82ce80 fa765578d53df1b1 79aa3a06d8ea630a 5946bb7a396ca860",
"5567e6eac386c167 503cbc87f4045ae3 03416fcf004cb556 f2339e0f9dad807a"
]
}
Loading