mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
core: fix rebasing issues
This commit is contained in:
parent
24c56f2a4f
commit
a17f843f8f
5 changed files with 14 additions and 24 deletions
|
|
@ -4632,7 +4632,7 @@ func TestEOF(t *testing.T) {
|
||||||
byte(vm.PUSH1),
|
byte(vm.PUSH1),
|
||||||
byte(0),
|
byte(0),
|
||||||
byte(vm.RJUMPV), // jump over invalid op
|
byte(vm.RJUMPV), // jump over invalid op
|
||||||
byte(1),
|
byte(0),
|
||||||
byte(0),
|
byte(0),
|
||||||
byte(1),
|
byte(1),
|
||||||
|
|
||||||
|
|
@ -4658,6 +4658,7 @@ func TestEOF(t *testing.T) {
|
||||||
gspec.Config.BerlinBlock = common.Big0
|
gspec.Config.BerlinBlock = common.Big0
|
||||||
gspec.Config.LondonBlock = common.Big0
|
gspec.Config.LondonBlock = common.Big0
|
||||||
gspec.Config.ShanghaiTime = u64(0)
|
gspec.Config.ShanghaiTime = u64(0)
|
||||||
|
gspec.Config.PragueTime = u64(0)
|
||||||
signer := types.LatestSigner(gspec.Config)
|
signer := types.LatestSigner(gspec.Config)
|
||||||
|
|
||||||
container := vm.Container{
|
container := vm.Container{
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,6 @@ type Message struct {
|
||||||
BlobGasFeeCap *big.Int
|
BlobGasFeeCap *big.Int
|
||||||
BlobHashes []common.Hash
|
BlobHashes []common.Hash
|
||||||
AuthList types.AuthorizationList
|
AuthList types.AuthorizationList
|
||||||
InitCodes [][]byte
|
|
||||||
|
|
||||||
// When SkipAccountChecks is true, the message nonce is not checked against the
|
// When SkipAccountChecks is true, the message nonce is not checked against the
|
||||||
// account nonce in state. It also disables checking that the sender is an EOA.
|
// account nonce in state. It also disables checking that the sender is an EOA.
|
||||||
|
|
@ -172,7 +171,6 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In
|
||||||
SkipAccountChecks: false,
|
SkipAccountChecks: false,
|
||||||
BlobHashes: tx.BlobHashes(),
|
BlobHashes: tx.BlobHashes(),
|
||||||
BlobGasFeeCap: tx.BlobGasFeeCap(),
|
BlobGasFeeCap: tx.BlobGasFeeCap(),
|
||||||
InitCodes: tx.InitCodes(),
|
|
||||||
}
|
}
|
||||||
// If baseFee provided, set gasPrice to effectiveGasPrice.
|
// If baseFee provided, set gasPrice to effectiveGasPrice.
|
||||||
if baseFee != nil {
|
if baseFee != nil {
|
||||||
|
|
@ -424,17 +422,8 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||||
contractCreation = msg.To == nil
|
contractCreation = msg.To == nil
|
||||||
)
|
)
|
||||||
|
|
||||||
// Add the initcode data for calculation of the intrinsic gas
|
|
||||||
// TODO (MariusVanDerWijden): while this should work, it is very
|
|
||||||
// dirty, better to pass the initcodes directly to IntrinsicGas
|
|
||||||
// and duplicate the cost accounting logic there.
|
|
||||||
data := msg.Data
|
|
||||||
for _, initcode := range msg.InitCodes {
|
|
||||||
data = append(data, initcode...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check clauses 4-5, subtract intrinsic gas if everything is correct
|
// Check clauses 4-5, subtract intrinsic gas if everything is correct
|
||||||
gas, err := IntrinsicGas(data, msg.AccessList, msg.AuthList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
|
gas, err := IntrinsicGas(msg.Data, msg.AccessList, msg.AuthList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -872,7 +872,7 @@ func opEOFCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) (
|
||||||
value = scope.Stack.pop()
|
value = scope.Stack.pop()
|
||||||
salt = scope.Stack.pop()
|
salt = scope.Stack.pop()
|
||||||
offset, size = scope.Stack.pop(), scope.Stack.pop()
|
offset, size = scope.Stack.pop(), scope.Stack.pop()
|
||||||
input = scope.Memory.GetCopy(int64(offset.Uint64()), int64(size.Uint64()))
|
input = scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
|
||||||
)
|
)
|
||||||
if int(idx) >= len(scope.Contract.Container.ContainerCode) {
|
if int(idx) >= len(scope.Contract.Container.ContainerCode) {
|
||||||
return nil, fmt.Errorf("invalid subcontainer")
|
return nil, fmt.Errorf("invalid subcontainer")
|
||||||
|
|
@ -927,7 +927,7 @@ func opReturnContract(pc *uint64, interpreter *EVMInterpreter, scope *ScopeConte
|
||||||
if int(idx) >= len(scope.Contract.Container.ContainerSections) {
|
if int(idx) >= len(scope.Contract.Container.ContainerSections) {
|
||||||
return nil, fmt.Errorf("invalid subcontainer")
|
return nil, fmt.Errorf("invalid subcontainer")
|
||||||
}
|
}
|
||||||
ret := scope.Memory.GetPtr(int64(offset.Uint64()), int64(size.Uint64()))
|
ret := scope.Memory.GetPtr(offset.Uint64(), size.Uint64())
|
||||||
containerCode := scope.Contract.Container.ContainerCode[idx]
|
containerCode := scope.Contract.Container.ContainerCode[idx]
|
||||||
deployedCode := append(containerCode, ret...)
|
deployedCode := append(containerCode, ret...)
|
||||||
if len(deployedCode) == 0 {
|
if len(deployedCode) == 0 {
|
||||||
|
|
@ -1060,7 +1060,7 @@ func opExtCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
|
||||||
// safe a memory alloc
|
// safe a memory alloc
|
||||||
temp := addr
|
temp := addr
|
||||||
// Get the arguments from the memory.
|
// Get the arguments from the memory.
|
||||||
args := scope.Memory.GetPtr(int64(inOffset.Uint64()), int64(inSize.Uint64()))
|
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
||||||
|
|
||||||
if interpreter.readOnly && !value.IsZero() {
|
if interpreter.readOnly && !value.IsZero() {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
|
|
@ -1098,7 +1098,7 @@ func opExtDelegateCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeCont
|
||||||
// safe a memory alloc
|
// safe a memory alloc
|
||||||
temp := addr
|
temp := addr
|
||||||
// Get arguments from the memory.
|
// Get arguments from the memory.
|
||||||
args := scope.Memory.GetPtr(int64(inOffset.Uint64()), int64(inSize.Uint64()))
|
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
||||||
|
|
||||||
// Check that we're only calling non-legacy contracts
|
// Check that we're only calling non-legacy contracts
|
||||||
var (
|
var (
|
||||||
|
|
@ -1144,7 +1144,7 @@ func opExtStaticCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContex
|
||||||
// safe a memory alloc
|
// safe a memory alloc
|
||||||
temp := addr
|
temp := addr
|
||||||
// Get arguments from the memory.
|
// Get arguments from the memory.
|
||||||
args := scope.Memory.GetPtr(int64(inOffset.Uint64()), int64(inSize.Uint64()))
|
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
||||||
|
|
||||||
ret, returnGas, err := interpreter.evm.StaticCall(scope.Contract, toAddr, args, gas)
|
ret, returnGas, err := interpreter.evm.StaticCall(scope.Contract, toAddr, args, gas)
|
||||||
if err == ErrExecutionReverted {
|
if err == ErrExecutionReverted {
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func TestEOFMarshaling(t *testing.T) {
|
||||||
got Container
|
got Container
|
||||||
)
|
)
|
||||||
t.Logf("b: %#x", b)
|
t.Logf("b: %#x", b)
|
||||||
if err := got.UnmarshalBinary(b); err != nil && err != test.err {
|
if err := got.UnmarshalBinary(b, true); err != nil && err != test.err {
|
||||||
t.Fatalf("test %d: got error \"%v\", want \"%v\"", i, err, test.err)
|
t.Fatalf("test %d: got error \"%v\", want \"%v\"", i, err, test.err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, test.want) {
|
if !reflect.DeepEqual(got, test.want) {
|
||||||
|
|
@ -78,7 +78,7 @@ func TestEOFMarshaling(t *testing.T) {
|
||||||
|
|
||||||
func TestEOFSubcontainer(t *testing.T) {
|
func TestEOFSubcontainer(t *testing.T) {
|
||||||
var subcontainer = new(Container)
|
var subcontainer = new(Container)
|
||||||
if err := subcontainer.UnmarshalBinary(common.Hex2Bytes("ef000101000402000100010400000000800000fe")); err != nil {
|
if err := subcontainer.UnmarshalBinary(common.Hex2Bytes("ef000101000402000100010400000000800000fe"), true); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
container := Container{
|
container := Container{
|
||||||
|
|
@ -92,7 +92,7 @@ func TestEOFSubcontainer(t *testing.T) {
|
||||||
b = container.MarshalBinary()
|
b = container.MarshalBinary()
|
||||||
got Container
|
got Container
|
||||||
)
|
)
|
||||||
if err := got.UnmarshalBinary(b); err != nil {
|
if err := got.UnmarshalBinary(b, true); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
fmt.Print(got)
|
fmt.Print(got)
|
||||||
|
|
@ -112,7 +112,7 @@ func TestMarshaling(t *testing.T) {
|
||||||
t.Fatalf("test %d: error decoding: %v", i, err)
|
t.Fatalf("test %d: error decoding: %v", i, err)
|
||||||
}
|
}
|
||||||
var got Container
|
var got Container
|
||||||
if err := got.UnmarshalBinary(s); err != nil {
|
if err := got.UnmarshalBinary(s, true); err != nil {
|
||||||
t.Fatalf("test %d: got error %v", i, err)
|
t.Fatalf("test %d: got error %v", i, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -485,7 +485,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||||
if evm.chainRules.IsPrague {
|
if evm.chainRules.IsPrague {
|
||||||
if isInitcodeEOF {
|
if isInitcodeEOF {
|
||||||
if !fromEOF {
|
if !fromEOF {
|
||||||
return nil, common.Address{}, gas, ErrLegacyCode
|
return nil, common.Address{}, gas, fmt.Errorf("%w: %v", ErrInvalidEOFInitcode, ErrLegacyCode)
|
||||||
}
|
}
|
||||||
// If the initcode is EOF, verify it is well-formed.
|
// If the initcode is EOF, verify it is well-formed.
|
||||||
var c Container
|
var c Container
|
||||||
|
|
@ -564,7 +564,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||||
|
|
||||||
// Reject legacy contract deployment from EOF.
|
// Reject legacy contract deployment from EOF.
|
||||||
if err == nil && isInitcodeEOF && !hasEOFMagic(ret) {
|
if err == nil && isInitcodeEOF && !hasEOFMagic(ret) {
|
||||||
err = ErrLegacyCode
|
err = fmt.Errorf("%w: %v", ErrInvalidEOFInitcode, ErrLegacyCode)
|
||||||
}
|
}
|
||||||
// Reject EOF deployment from legacy.
|
// Reject EOF deployment from legacy.
|
||||||
if err == nil && !isInitcodeEOF && hasEOFMagic(ret) {
|
if err == nil && !isInitcodeEOF && hasEOFMagic(ret) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue