fix tests

This commit is contained in:
jagdeep sidhu 2024-10-07 14:42:31 -07:00
parent c2f7ed163d
commit 26d4ed0791
15 changed files with 60 additions and 30 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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)
}
}

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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),

View file

@ -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")
}

View file

@ -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()

View file

@ -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)

View file

@ -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
}

View file

@ -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

View file

@ -39,8 +39,4 @@ const (
Shanghai
Cancun
Prague
// SYSCOIN
Syscoin
Rollux
Nexus
)

View file

@ -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))
}