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

✨ intro: add interface #2

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
15 changes: 15 additions & 0 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{18}): &bls12381MapG2{},
}

var PrecompiledContractsNC = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{20}): &nCBlockVerify{},
}

var (
PrecompiledAddressesFjord []common.Address
PrecompiledAddressesCancun []common.Address
Expand Down Expand Up @@ -1191,3 +1195,14 @@ func (c *p256Verify) Run(input []byte) ([]byte, error) {
return nil, nil
}
}

type nCBlockVerify struct{}

func (c *nCBlockVerify) RequiredGas(input []byte) uint64 {
return params.NCBlockVerifyGas
}

func (c *nCBlockVerify) Run(input []byte) ([]byte, error) {
block := input[:32]
return common.LeftPadBytes(block, 32), nil
}
2 changes: 2 additions & 0 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ const (

P256VerifyGas uint64 = 3450 // secp256r1 elliptic curve signature verifier gas price

NCBlockVerifyGas uint64 = 100000 // Gas price for verifying a NineChronicles block

// The Refund Quotient is the cap on how much of the used gas can be refunded. Before EIP-3529,
// up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529
RefundQuotient uint64 = 2
Expand Down