mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
ensure latest HF is always with p256 verify
This commit is contained in:
parent
1de5835163
commit
9b0ca36507
2 changed files with 44 additions and 19 deletions
|
|
@ -138,6 +138,7 @@ var PrecompiledContractsPrague = PrecompiledContracts{
|
|||
common.BytesToAddress([]byte{0x11}): &bls12381Pairing{},
|
||||
common.BytesToAddress([]byte{0x12}): &bls12381MapG1{},
|
||||
common.BytesToAddress([]byte{0x13}): &bls12381MapG2{},
|
||||
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{},
|
||||
}
|
||||
|
||||
var PrecompiledContractsBLS = PrecompiledContractsPrague
|
||||
|
|
|
|||
|
|
@ -20,11 +20,15 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
// precompiledTest defines the input/output pairs for precompiled contract tests.
|
||||
|
|
@ -434,3 +438,23 @@ func TestPrecompiledP256Verify(t *testing.T) {
|
|||
|
||||
testJson("p256Verify", "100", t)
|
||||
}
|
||||
|
||||
// BOR: if this test failed, it means you should include PrecompiledP256Verify in the PrecompiledContracts
|
||||
// TODO: handle when common.BytesToAddress([]byte{0x01, 0x00}) will colide a new Ethereum's precompile
|
||||
func TestPrecompiledP256VerifyAlwaysAvailableInHFs(t *testing.T) {
|
||||
latestHfRules := params.BorMainnetChainConfig.Rules(big.NewInt(math.MaxInt64), true, 0)
|
||||
precompiledP256VerifyAddress := common.BytesToAddress([]byte{0x01, 0x00})
|
||||
|
||||
addresses := ActivePrecompiles(latestHfRules)
|
||||
addressFound := false
|
||||
for _, addr := range addresses {
|
||||
if addr == precompiledP256VerifyAddress {
|
||||
addressFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.Equal(t, true, addressFound)
|
||||
|
||||
preCompiledContracts := ActivePrecompiledContracts(latestHfRules)
|
||||
assert.Equal(t, &p256Verify{}, preCompiledContracts[precompiledP256VerifyAddress])
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue