mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-20 15:05:21 +00:00
feat: evm precompile query func
This commit is contained in:
parent
550fdc331e
commit
da02dc7eb7
@ -18,6 +18,7 @@ const (
|
|||||||
|
|
||||||
RequiredGasMax uint64 = 1000_000_000
|
RequiredGasMax uint64 = 1000_000_000
|
||||||
|
|
||||||
|
DASignersFunctionParams = "params"
|
||||||
DASignersFunctionEpochNumber = "epochNumber"
|
DASignersFunctionEpochNumber = "epochNumber"
|
||||||
DASignersFunctionQuorumCount = "quorumCount"
|
DASignersFunctionQuorumCount = "quorumCount"
|
||||||
DASignersFunctionGetSigner = "getSigner"
|
DASignersFunctionGetSigner = "getSigner"
|
||||||
@ -32,6 +33,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var RequiredGasBasic = map[string]uint64{
|
var RequiredGasBasic = map[string]uint64{
|
||||||
|
DASignersFunctionParams: 1000,
|
||||||
DASignersFunctionEpochNumber: 1000,
|
DASignersFunctionEpochNumber: 1000,
|
||||||
DASignersFunctionQuorumCount: 1000,
|
DASignersFunctionQuorumCount: 1000,
|
||||||
DASignersFunctionGetSigner: 100000,
|
DASignersFunctionGetSigner: 100000,
|
||||||
@ -117,6 +119,8 @@ func (d *DASignersPrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly b
|
|||||||
var bz []byte
|
var bz []byte
|
||||||
switch method.Name {
|
switch method.Name {
|
||||||
// queries
|
// queries
|
||||||
|
case DASignersFunctionParams:
|
||||||
|
bz, err = d.Params(ctx, evm, method, args)
|
||||||
case DASignersFunctionEpochNumber:
|
case DASignersFunctionEpochNumber:
|
||||||
bz, err = d.EpochNumber(ctx, evm, method, args)
|
bz, err = d.EpochNumber(ctx, evm, method, args)
|
||||||
case DASignersFunctionQuorumCount:
|
case DASignersFunctionQuorumCount:
|
||||||
|
@ -11,6 +11,17 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (d *DASignersPrecompile) Params(ctx sdk.Context, _ *vm.EVM, method *abi.Method, _ []interface{}) ([]byte, error) {
|
||||||
|
params := d.dasignersKeeper.GetParams(ctx)
|
||||||
|
return method.Outputs.Pack(IDASignersParams{
|
||||||
|
TokensPerVote: big.NewInt(int64(params.TokensPerVote)),
|
||||||
|
MaxVotesPerSigner: big.NewInt(int64(params.MaxVotesPerSigner)),
|
||||||
|
MaxQuorums: big.NewInt(int64(params.MaxQuorums)),
|
||||||
|
EpochBlocks: big.NewInt(int64(params.EpochBlocks)),
|
||||||
|
EncodedSlices: big.NewInt(int64(params.EncodedSlices)),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DASignersPrecompile) EpochNumber(ctx sdk.Context, _ *vm.EVM, method *abi.Method, _ []interface{}) ([]byte, error) {
|
func (d *DASignersPrecompile) EpochNumber(ctx sdk.Context, _ *vm.EVM, method *abi.Method, _ []interface{}) ([]byte, error) {
|
||||||
epochNumber, err := d.dasignersKeeper.GetEpochNumber(ctx)
|
epochNumber, err := d.dasignersKeeper.GetEpochNumber(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user