mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-23 23:05:18 +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
|
||||
|
||||
DASignersFunctionParams = "params"
|
||||
DASignersFunctionEpochNumber = "epochNumber"
|
||||
DASignersFunctionQuorumCount = "quorumCount"
|
||||
DASignersFunctionGetSigner = "getSigner"
|
||||
@ -32,6 +33,7 @@ const (
|
||||
)
|
||||
|
||||
var RequiredGasBasic = map[string]uint64{
|
||||
DASignersFunctionParams: 1000,
|
||||
DASignersFunctionEpochNumber: 1000,
|
||||
DASignersFunctionQuorumCount: 1000,
|
||||
DASignersFunctionGetSigner: 100000,
|
||||
@ -117,6 +119,8 @@ func (d *DASignersPrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly b
|
||||
var bz []byte
|
||||
switch method.Name {
|
||||
// queries
|
||||
case DASignersFunctionParams:
|
||||
bz, err = d.Params(ctx, evm, method, args)
|
||||
case DASignersFunctionEpochNumber:
|
||||
bz, err = d.EpochNumber(ctx, evm, method, args)
|
||||
case DASignersFunctionQuorumCount:
|
||||
|
@ -11,6 +11,17 @@ import (
|
||||
"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) {
|
||||
epochNumber, err := d.dasignersKeeper.GetEpochNumber(ctx)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user