Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consortium_precompiled: fix typo in the validate finality proof function #347

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/vm/consortium_precompiled_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
consortiumVerifyHeadersAbi = `[{"outputs":[],"name":"getHeader","inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"parentHash","type":"bytes32"},{"internalType":"bytes32","name":"ommersHash","type":"bytes32"},{"internalType":"address","name":"coinbase","type":"address"},{"internalType":"bytes32","name":"stateRoot","type":"bytes32"},{"internalType":"bytes32","name":"transactionsRoot","type":"bytes32"},{"internalType":"bytes32","name":"receiptsRoot","type":"bytes32"},{"internalType":"uint8[256]","name":"logsBloom","type":"uint8[256]"},{"internalType":"uint256","name":"difficulty","type":"uint256"},{"internalType":"uint256","name":"number","type":"uint256"},{"internalType":"uint64","name":"gasLimit","type":"uint64"},{"internalType":"uint64","name":"gasUsed","type":"uint64"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"bytes","name":"extraData","type":"bytes"},{"internalType":"bytes32","name":"mixHash","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"consensusAddr","type":"address"},{"internalType":"bytes","name":"header1","type":"bytes"},{"internalType":"bytes","name":"header2","type":"bytes"}],"name":"validatingDoubleSignProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]`
consortiumPickValidatorSetAbi = `[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address[]","name":"_candidates","type":"address[]"},{"internalType":"uint256[]","name":"_weights","type":"uint256[]"},{"internalType":"uint256[]","name":"_trustedWeights","type":"uint256[]"},{"internalType":"uint256","name":"_maxValidatorNumber","type":"uint256"},{"internalType":"uint256","name":"_maxPrioritizedValidatorNumber","type":"uint256"}],"name":"pickValidatorSet","outputs":[{"internalType":"address[]","name":"_validators","type":"address[]"}],"stateMutability":"view","type":"function"}]`
getDoubleSignSlashingConfigsAbi = `[{"inputs":[],"name":"getDoubleSignSlashingConfigs","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]`
validateFinaltyVoteProofAbi = `[{"inputs":[{"internalType":"bytes","name":"voterPublicKey","type":"bytes"},{"internalType":"uint256","name":"targetBlockNumber","type":"uint256"},{"internalType":"bytes32[2]","name":"targetBlockHash","type":"bytes32[2]"},{"internalType":"bytes[][2]","name":"listOfPublicKey","type":"bytes[][2]"},{"internalType":"bytes[2]","name":"aggregatedSignature","type":"bytes[2]"}],"name":"validateFinaltyVoteProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]`
validateFinalityVoteProofAbi = `[{"inputs":[{"internalType":"bytes","name":"voterPublicKey","type":"bytes"},{"internalType":"uint256","name":"targetBlockNumber","type":"uint256"},{"internalType":"bytes32[2]","name":"targetBlockHash","type":"bytes32[2]"},{"internalType":"bytes[][2]","name":"listOfPublicKey","type":"bytes[][2]"},{"internalType":"bytes[2]","name":"aggregatedSignature","type":"bytes[2]"}],"name":"validateFinalityVoteProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]`
)

const (
Expand All @@ -44,7 +44,7 @@ const (
getDoubleSignSlashingConfigs = "getDoubleSignSlashingConfigs"
extraVanity = 32

validateFinaltyVoteProof = "validateFinaltyVoteProof"
validateFinalityVoteProof = "validateFinalityVoteProof"
maxBlsPublicKeyListLength = 100
)

Expand Down Expand Up @@ -550,11 +550,11 @@ func (contract *consortiumValidateFinalityProof) Run(input []byte) ([]byte, erro
}
}

_, method, args, err := loadMethodAndArgs(validateFinaltyVoteProofAbi, input)
_, method, args, err := loadMethodAndArgs(validateFinalityVoteProofAbi, input)
if err != nil {
return nil, err
}
if method.Name != validateFinaltyVoteProof {
if method.Name != validateFinalityVoteProof {
return nil, errors.New("invalid method")
}
if len(args) != 5 {
Expand Down
18 changes: 9 additions & 9 deletions core/vm/consortium_precompiled_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ func addressesToByte(addresses []common.Address) [][]byte {
func TestValidateFinalityVoteProof(t *testing.T) {
contract := consortiumValidateFinalityProof{}

contractAbi, err := abi.JSON(strings.NewReader(validateFinaltyVoteProofAbi))
contractAbi, err := abi.JSON(strings.NewReader(validateFinalityVoteProofAbi))
if err != nil {
t.Fatalf("Failed to parse ABI, err %s", err)
}
Expand Down Expand Up @@ -1773,7 +1773,7 @@ func TestValidateFinalityVoteProof(t *testing.T) {
}

input, err := contractAbi.Pack(
validateFinaltyVoteProof,
validateFinalityVoteProof,
voterPublicKey,
new(big.Int).Add(new(big.Int).SetUint64(1<<64-1), common.Big1),
targetBlockHashes,
Expand All @@ -1790,7 +1790,7 @@ func TestValidateFinalityVoteProof(t *testing.T) {
}

input, err = contractAbi.Pack(
validateFinaltyVoteProof,
validateFinalityVoteProof,
voterPublicKey,
big.NewInt(int64(blockNumber)),
targetBlockHashes,
Expand Down Expand Up @@ -1824,7 +1824,7 @@ func TestValidateFinalityVoteProof(t *testing.T) {
}

input, err = contractAbi.Pack(
validateFinaltyVoteProof,
validateFinalityVoteProof,
voterPublicKey,
big.NewInt(int64(blockNumber)),
targetBlockHashes,
Expand Down Expand Up @@ -1863,7 +1863,7 @@ func TestValidateFinalityVoteProof(t *testing.T) {
}

input, err = contractAbi.Pack(
validateFinaltyVoteProof,
validateFinalityVoteProof,
voterPublicKey,
big.NewInt(int64(blockNumber)),
targetBlockHashes,
Expand All @@ -1879,7 +1879,7 @@ func TestValidateFinalityVoteProof(t *testing.T) {
t.Fatalf("Expect to successfully verify proof, get %s", err)
}

ret, err := contractAbi.Unpack(validateFinaltyVoteProof, rawReturn)
ret, err := contractAbi.Unpack(validateFinalityVoteProof, rawReturn)
if err != nil {
t.Fatalf("Failed to unpack output, err: %s", err)
}
Expand All @@ -1891,7 +1891,7 @@ func TestValidateFinalityVoteProof(t *testing.T) {
}

func BenchmarkPrecompiledValidateFinalityVoteProof(b *testing.B) {
contractAbi, err := abi.JSON(strings.NewReader(validateFinaltyVoteProofAbi))
contractAbi, err := abi.JSON(strings.NewReader(validateFinalityVoteProofAbi))
if err != nil {
b.Fatalf("Failed to parse ABI, err %s", err)
}
Expand Down Expand Up @@ -1937,7 +1937,7 @@ func BenchmarkPrecompiledValidateFinalityVoteProof(b *testing.B) {
aggregatedSignature2 := blst.AggregateSignatures(signature[:])

input, err := contractAbi.Pack(
validateFinaltyVoteProof,
validateFinalityVoteProof,
secretKeys[0].PublicKey().Marshal(),
big.NewInt(int64(blockNumber)),
[2]common.Hash{
Expand All @@ -1954,7 +1954,7 @@ func BenchmarkPrecompiledValidateFinalityVoteProof(b *testing.B) {
b.Fatalf("Failed to pack contract input, err: %s", err)
}

output, err := contractAbi.Methods[validateFinaltyVoteProof].Outputs.Pack(true)
output, err := contractAbi.Methods[validateFinalityVoteProof].Outputs.Pack(true)
if err != nil {
b.Fatalf("Failed to pack contract output, err: %s", err)
}
Expand Down