diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index f627c888e6..d76e396687 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -230,7 +230,7 @@ func applyLondonChecks(env *stEnv, chainConfig *params.ChainConfig) error { func applyShanghaiChecks(env *stEnv, chainConfig *params.ChainConfig) error { // SYSCOIN - if !chainConfig.IsSyscoin(big.NewInt(int64(env.Number))) || !chainConfig.IsShanghai(big.NewInt(int64(env.Number)), env.Timestamp) { + if chainConfig.IsSyscoin(big.NewInt(int64(env.Number))) || !chainConfig.IsShanghai(big.NewInt(int64(env.Number)), env.Timestamp) { return nil } if env.Withdrawals == nil { diff --git a/cmd/evm/testdata/eof/results.initcode.txt b/cmd/evm/testdata/eof/results.initcode.txt index 311b93d954..d3aefb7f83 100644 --- a/cmd/evm/testdata/eof/results.initcode.txt +++ b/cmd/evm/testdata/eof/results.initcode.txt @@ -189,7 +189,7 @@ ERR: undefined instruction: op opcode 0x4b not defined, pos 0 ERR: undefined instruction: op opcode 0x4c not defined, pos 0 ERR: undefined instruction: op opcode 0x4d not defined, pos 0 ERR: undefined instruction: op opcode 0x4e not defined, pos 0 -ERR: undefined instruction: op opcode 0x4f not defined, pos 0 +ERR: initcode contains a RETURN or STOP opcode ERR: initcode contains a RETURN or STOP opcode ERR: undefined instruction: op opcode 0xa5 not defined, pos 0 ERR: undefined instruction: op opcode 0xa6 not defined, pos 0 diff --git a/cmd/evm/testdata/eof/results.regular.txt b/cmd/evm/testdata/eof/results.regular.txt index 43594ec1b3..767631a1d8 100644 --- a/cmd/evm/testdata/eof/results.regular.txt +++ b/cmd/evm/testdata/eof/results.regular.txt @@ -189,7 +189,7 @@ ERR: undefined instruction: op opcode 0x4b not defined, pos 0 ERR: undefined instruction: op opcode 0x4c not defined, pos 0 ERR: undefined instruction: op opcode 0x4d not defined, pos 0 ERR: undefined instruction: op opcode 0x4e not defined, pos 0 -ERR: undefined instruction: op opcode 0x4f not defined, pos 0 +ERR: stack underflow (0 <=> 1): at pos 0 OK ERR: undefined instruction: op opcode 0xa5 not defined, pos 0 ERR: undefined instruction: op opcode 0xa6 not defined, pos 0 diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index e1902a7749..49047d73bf 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -382,7 +382,7 @@ func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.H // accumulateRewards credits the coinbase of the given block with the mining // reward. The total reward consists of the static block reward and rewards for // included uncles. The coinbase of each uncle block is also rewarded. -func accumulateRewards(config *params.ChainConfig, stateDB *state.StateDB, header *types.Header) { +func accumulateRewards(stateDB *state.StateDB, header *types.Header) { stateDB.AddBalance(header.Coinbase, uint256.MustFromBig(SyscoinBlockReward), tracing.BalanceIncreaseRewardMineBlock) } @@ -401,7 +401,7 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. } // SYSCOIN Accumulate any block if(chain.Config().IsSyscoin(header.Number)) { - accumulateRewards(chain.Config(), state, header) + accumulateRewards(state, header) } } diff --git a/core/txpool/validation.go b/core/txpool/validation.go index 3a401cae2c..1bab2d354e 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -71,7 +71,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types return fmt.Errorf("%w: type %d rejected, pool not yet in London", core.ErrTxTypeNotSupported, tx.Type()) } // SYSCOIN - if (!opts.Config.IsSyscoin(head.Number) || !opts.Config.IsCancun(head.Number, head.Time)) && tx.Type() == types.BlobTxType { + if (opts.Config.IsSyscoin(head.Number) || !opts.Config.IsCancun(head.Number, head.Time)) && tx.Type() == types.BlobTxType { return fmt.Errorf("%w: type %d rejected, pool not yet in Cancun", core.ErrTxTypeNotSupported, tx.Type()) } // Check whether the init code size has been exceeded diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 658014f24c..6d340884bb 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -509,6 +509,13 @@ func newFrontierInstructionSet() JumpTable { minStack: minStack(1, 1), maxStack: maxStack(1, 1), }, + // SYSCOIN + SYSBLOCKHASH: { + execute: opSYSBlockhash, + constantGas: GasExtStep, + minStack: minStack(1, 1), + maxStack: maxStack(1, 1), + }, COINBASE: { execute: opCoinbase, constantGas: GasQuickStep, diff --git a/core/vm/opcodes.go b/core/vm/opcodes.go index 162be8f6c8..2dc0e3545e 100644 --- a/core/vm/opcodes.go +++ b/core/vm/opcodes.go @@ -104,6 +104,8 @@ const ( BASEFEE OpCode = 0x48 BLOBHASH OpCode = 0x49 BLOBBASEFEE OpCode = 0x4a + // SYSCOIN + SYSBLOCKHASH OpCode = 0x4f ) // 0x50 range - 'storage' and execution. @@ -316,6 +318,8 @@ var opCodeToString = [256]string{ CHAINID: "CHAINID", SELFBALANCE: "SELFBALANCE", BASEFEE: "BASEFEE", + // SYSCOIN + SYSBLOCKHASH: "SYSBLOCKHASH", BLOBHASH: "BLOBHASH", BLOBBASEFEE: "BLOBBASEFEE", @@ -498,6 +502,8 @@ var stringToOp = map[string]OpCode{ "CHAINID": CHAINID, "BASEFEE": BASEFEE, "BLOBHASH": BLOBHASH, + // SYSCOIN + "SYSBLOCKHASH": SYSBLOCKHASH, "BLOBBASEFEE": BLOBBASEFEE, "DELEGATECALL": DELEGATECALL, "STATICCALL": STATICCALL, diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 9b3bcabce3..a7f0d15db3 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -51,6 +51,10 @@ type Config struct { State *state.StateDB GetHashFn func(n uint64) common.Hash + // SYSCOIN + ReadSYSHashFn func(n uint64) []byte + ReadDataHashFn func(hash common.Hash) []byte + GetNEVMAddressFn func(address common.Address) []byte } // sets defaults on the config @@ -76,9 +80,9 @@ func setDefaults(cfg *Config) { BerlinBlock: new(big.Int), LondonBlock: new(big.Int), // SYSCOIN - SyscoinBlock: new(big.Int), - RolluxBlock: new(big.Int), - NexusBlock: new(big.Int), + SyscoinBlock: nil, + RolluxBlock: nil, + NexusBlock: nil, ArrowGlacierBlock: nil, GrayGlacierBlock: nil, TerminalTotalDifficulty: big.NewInt(0), diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index c8feae062b..938e86be9d 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -61,16 +61,6 @@ func TestDefaults(t *testing.T) { if cfg.GetHashFn == nil { t.Error("expected time to be non nil") } - // SYSCOIN - if cfg.ReadSYSHashFn == nil { - t.Error("expected time to be non nil") - } - if cfg.ReadDataHashFn == nil { - t.Error("expected time to be non nil") - } - if cfg.GetNEVMAddressFn == nil { - t.Error("expected time to be non nil") - } if cfg.BlockNumber == nil { t.Error("expected block number to be non nil") } diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 47e3693495..cc4315db1e 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -185,6 +185,16 @@ func (b *testBackend) StateAtTransaction(ctx context.Context, block *types.Block } return nil, vm.BlockContext{}, nil, nil, fmt.Errorf("transaction index %d out of range for block %#x", txIndex, block.Hash()) } +// SYSCOIN +func (b *testBackend) ReadSYSHash(ctx context.Context, number rpc.BlockNumber) ([]byte, error) { + return []byte{}, nil +} +func (b *testBackend) ReadDataHash(ctx context.Context, hash common.Hash) ([]byte, error) { + return []byte{}, nil +} +func (b *testBackend) GetNEVMAddress(ctx context.Context, address common.Address) ([]byte, error) { + return []byte{}, nil +} func TestTraceCall(t *testing.T) { t.Parallel() diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index 384ca9f1cc..11de63cbe9 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -627,6 +627,16 @@ func (b testBackend) BloomStatus() (uint64, uint64) { panic("implement me") } func (b testBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) { panic("implement me") } +// SYSCOIN +func (b testBackend) ReadSYSHash(ctx context.Context, number rpc.BlockNumber) ([]byte, error) { + return []byte{}, nil +} +func (b testBackend) ReadDataHash(ctx context.Context, hash common.Hash) ([]byte, error) { + return []byte{}, nil +} +func (b testBackend) GetNEVMAddress(ctx context.Context, address common.Address) ([]byte, error) { + return []byte{}, nil +} func TestEstimateGas(t *testing.T) { t.Parallel() @@ -3292,8 +3302,8 @@ func TestRPCGetBlockReceipts(t *testing.T) { type precompileContract struct{} func (p *precompileContract) RequiredGas(input []byte) uint64 { return 0 } - -func (p *precompileContract) Run(input []byte) ([]byte, error) { return nil, nil } +// SYSCOIN +func (p *precompileContract) Run(input []byte, interpreter* vm.EVMInterpreter) ([]byte, error) { return nil, nil } func TestStateOverrideMovePrecompile(t *testing.T) { db := state.NewDatabase(triedb.NewDatabase(rawdb.NewMemoryDatabase(), nil), nil) diff --git a/internal/ethapi/transaction_args_test.go b/internal/ethapi/transaction_args_test.go index 5317828173..7e6ffb73b0 100644 --- a/internal/ethapi/transaction_args_test.go +++ b/internal/ethapi/transaction_args_test.go @@ -405,3 +405,13 @@ func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) } func (b *backendMock) Engine() consensus.Engine { return nil } +// SYSCOIN +func (b *backendMock) ReadSYSHash(ctx context.Context, number rpc.BlockNumber) ([]byte, error) { + return []byte{}, nil +} +func (b *backendMock) ReadDataHash(ctx context.Context, hash common.Hash) ([]byte, error) { + return []byte{}, nil +} +func (b *backendMock) GetNEVMAddress(ctx context.Context, address common.Address) ([]byte, error) { + return []byte{}, nil +} \ No newline at end of file diff --git a/params/config.go b/params/config.go index 6aa4a8956f..dae28b6cd3 100644 --- a/params/config.go +++ b/params/config.go @@ -809,10 +809,6 @@ func (c *ChainConfig) ElasticityMultiplier() uint64 { func (c *ChainConfig) LatestFork(time uint64) forks.Fork { // Assume last non-time-based fork has passed. london := c.LondonBlock - // SYSCOIN - if c.NexusBlock != nil { - london = c.NexusBlock - } switch { case c.IsPrague(london, time): return forks.Prague diff --git a/params/forks/forks.go b/params/forks/forks.go index 4c12c266f5..4f50ff5aed 100644 --- a/params/forks/forks.go +++ b/params/forks/forks.go @@ -39,8 +39,4 @@ const ( Shanghai Cancun Prague - // SYSCOIN - Syscoin - Rollux - Nexus ) diff --git a/tests/fuzzers/bls12381/precompile_fuzzer.go b/tests/fuzzers/bls12381/precompile_fuzzer.go index 4df4db73d1..cde2f64e13 100644 --- a/tests/fuzzers/bls12381/precompile_fuzzer.go +++ b/tests/fuzzers/bls12381/precompile_fuzzer.go @@ -82,7 +82,8 @@ func fuzz(id byte, data []byte) int { } cpy := make([]byte, len(data)) copy(cpy, data) - _, err := precompile.Run(cpy) + // SYSCOIN + _, err := precompile.Run(cpy, nil) if !bytes.Equal(cpy, data) { panic(fmt.Sprintf("input data modified, precompile %d: %x %x", id, data, cpy)) }