@@ -16,9 +16,9 @@ use crate::{
1616use anyhow:: { anyhow, bail, Context } ;
1717use async_stm:: atomically;
1818use async_trait:: async_trait;
19- use fendermint_actor_blobs_shared:: params:: { GetBlobStatusParams , GetPendingBlobsParams } ;
20- use fendermint_actor_blobs_shared:: state:: BlobStatus ;
21- use fendermint_actor_blobs_shared:: Method :: DebitAccounts ;
19+ use fendermint_actor_blobs_shared:: params:: { GetBlobStatusParams , GetPendingBlobsParams , UpdatePowerTableParams } ;
20+ use fendermint_actor_blobs_shared:: state:: { BlobStatus , Power , PowerTable , Validator } ;
21+ use fendermint_actor_blobs_shared:: Method :: { DebitAccounts , UpdatePowerTable } ;
2222use fendermint_actor_blobs_shared:: {
2323 params:: FinalizeBlobParams ,
2424 Method :: { FinalizeBlob , GetBlobStatus , GetPendingBlobs } ,
@@ -43,7 +43,7 @@ use fendermint_vm_topdown::{
4343} ;
4444use fvm_ipld_blockstore:: Blockstore ;
4545use fvm_ipld_encoding:: RawBytes ;
46- use fvm_shared:: address:: Address ;
46+ use fvm_shared:: address:: { Address , Error } ;
4747use fvm_shared:: clock:: ChainEpoch ;
4848use fvm_shared:: econ:: TokenAmount ;
4949use fvm_shared:: message:: Message ;
@@ -584,6 +584,41 @@ where
584584 let proposer = state. validator_id ( ) . map ( |id| id. to_string ( ) ) ;
585585 let proposer_ref = proposer. as_deref ( ) ;
586586
587+ let ( _configuration_number, powers) = self . gateway_caller . current_power_table ( & mut state) ?;
588+ let power_table = PowerTable ( powers. iter ( ) . filter_map ( |validator| {
589+ let public_key = validator. public_key . 0 . serialize ( ) ;
590+ let address = Address :: new_secp256k1 ( & public_key) ;
591+ match address {
592+ Ok ( address) => {
593+ let validator = Validator {
594+ power : Power ( validator. power . 0 ) ,
595+ address,
596+ } ;
597+ Some ( validator)
598+ }
599+ Err ( _) => {
600+ tracing:: debug!(
601+ "can not construct secp256k1 address from public key"
602+ ) ;
603+ None
604+ }
605+ }
606+ } ) . collect ( ) ) ;
607+ let params = RawBytes :: serialize ( UpdatePowerTableParams ( power_table) ) ?;
608+ let msg = Message {
609+ version : Default :: default ( ) ,
610+ from : system:: SYSTEM_ACTOR_ADDR ,
611+ to : blobs:: BLOBS_ACTOR_ADDR ,
612+ sequence : 0 ,
613+ value : Default :: default ( ) ,
614+ method_num : UpdatePowerTable as u64 ,
615+ params : params,
616+ gas_limit : fvm_shared:: BLOCK_GAS_LIMIT ,
617+ gas_fee_cap : Default :: default ( ) ,
618+ gas_premium : Default :: default ( ) ,
619+ } ;
620+ state. execute_implicit ( msg) ?;
621+
587622 atomically ( || {
588623 env. parent_finality_provider
589624 . set_new_finality ( finality. clone ( ) , prev_finality. clone ( ) ) ?;
@@ -731,6 +766,9 @@ where
731766 ) -> anyhow:: Result < ( Self :: State , Self :: EndOutput ) > {
732767 let ( mut state, out) = self . inner . end ( state) . await ?;
733768
769+ // TODO SU Wrong
770+ let a = self . gateway_caller . current_power_table ( & mut state) ;
771+
734772 // Update any component that needs to know about changes in the power table.
735773 if !out. 0 . is_empty ( ) {
736774 let power_updates = out
0 commit comments