|
| 1 | +package vm |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/ethereum/go-ethereum/common" |
| 7 | +) |
| 8 | + |
| 9 | +// 0x64/0x65 are deprecated from Pasteur; 0x67 switches to a per-byte-priced variant. |
| 10 | +func TestPasteurSuspendsLegacyTendermintPrecompiles(t *testing.T) { |
| 11 | + addr64 := common.BytesToAddress([]byte{0x64}) |
| 12 | + addr65 := common.BytesToAddress([]byte{0x65}) |
| 13 | + |
| 14 | + // Under Pasteur, 0x64/0x65 return "deprecated" for any input. |
| 15 | + for _, addr := range []common.Address{addr64, addr65} { |
| 16 | + p := PrecompiledContractsPasteur[addr] |
| 17 | + if p == nil { |
| 18 | + t.Fatalf("%s missing from Pasteur precompile set", addr.Hex()) |
| 19 | + } |
| 20 | + if _, err := p.Run([]byte("x")); err == nil || err.Error() != "deprecated" { |
| 21 | + t.Fatalf("%s under Pasteur: expected deprecated error, got %v", addr.Hex(), err) |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + // Pre-Pasteur (Osaka) they are still the live, active implementations. |
| 26 | + if _, ok := PrecompiledContractsOsaka[addr64].(*tmHeaderValidate); !ok { |
| 27 | + t.Fatalf("0x64 must remain active (tmHeaderValidate) pre-Pasteur") |
| 28 | + } |
| 29 | + if _, ok := PrecompiledContractsOsaka[addr65].(*iavlMerkleProofValidatePlato); !ok { |
| 30 | + t.Fatalf("0x65 must remain active (iavlMerkleProofValidatePlato) pre-Pasteur") |
| 31 | + } |
| 32 | + |
| 33 | + // 0x67 stays active but switches to the per-byte-priced Pasteur variant |
| 34 | + // (Hertz/flat-gas pre-Pasteur, for replay of earlier blocks). |
| 35 | + addr67 := common.BytesToAddress([]byte{0x67}) |
| 36 | + if _, ok := PrecompiledContractsPasteur[addr67].(*cometBFTLightBlockValidatePasteur); !ok { |
| 37 | + t.Fatalf("0x67 must be the Pasteur variant under Pasteur") |
| 38 | + } |
| 39 | + if _, ok := PrecompiledContractsOsaka[addr67].(*cometBFTLightBlockValidateHertz); !ok { |
| 40 | + t.Fatalf("0x67 must remain the Hertz variant pre-Pasteur") |
| 41 | + } |
| 42 | + |
| 43 | + // The still-needed precompiles (0x66, 0x68, 0x69) remain present under Pasteur. |
| 44 | + for _, b := range []byte{0x66, 0x68, 0x69} { |
| 45 | + addr := common.BytesToAddress([]byte{b}) |
| 46 | + if PrecompiledContractsPasteur[addr] == nil { |
| 47 | + t.Fatalf("%s must remain present under Pasteur", addr.Hex()) |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + // 0x67 gas scales with input size under Pasteur, but is flat pre-Pasteur. |
| 52 | + small := make([]byte, 1024) |
| 53 | + large := make([]byte, 16*1024) |
| 54 | + pasteur67 := PrecompiledContractsPasteur[addr67] |
| 55 | + if pasteur67.RequiredGas(large) <= pasteur67.RequiredGas(small) { |
| 56 | + t.Fatalf("Pasteur 0x67 gas must scale with input size") |
| 57 | + } |
| 58 | + osaka67 := PrecompiledContractsOsaka[addr67] |
| 59 | + if osaka67.RequiredGas(large) != osaka67.RequiredGas(small) { |
| 60 | + t.Fatalf("pre-Pasteur 0x67 gas must stay flat") |
| 61 | + } |
| 62 | +} |
0 commit comments