├── .gitignore ├── COPYRIGHT ├── LICENSE-APACHE ├── LICENSE-MIT ├── Makefile ├── README.md ├── abi ├── actor.go ├── address.go ├── address_test.go ├── cbor_bytes.go ├── cbor_bytes_transparent.go ├── cbor_gen.go ├── cbor_string.go ├── cbor_test.go ├── chain.go ├── cid.go ├── deal.go ├── empty.go ├── key.go ├── key_test.go ├── piece.go ├── piece_test.go ├── sector.go └── sector_test.go ├── actors └── version.go ├── actors_version_checklist.md ├── batch ├── batch_return.go ├── batch_return_test.go ├── cbor_gen.go └── gen │ └── gen.go ├── big ├── int.go └── int_test.go ├── builtin ├── actor_tree.go ├── cbor_gen.go ├── frc_0042.go ├── message_accumulator.go ├── method_meta.go ├── methods.go ├── methods_test.go ├── network.go ├── quantize.go ├── sector.go ├── shared.go ├── singletons.go ├── v10 │ ├── account │ │ ├── account_state.go │ │ ├── account_types.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── datacap │ │ ├── cbor_gen.go │ │ ├── datacap_state.go │ │ ├── datacap_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── eam │ │ ├── cbor_gen.go │ │ ├── eam_types.go │ │ └── methods.go │ ├── ethaccount │ │ ├── methods.go │ │ └── types.go │ ├── evm │ │ ├── cbor_gen.go │ │ ├── evm_state.go │ │ ├── evm_types.go │ │ ├── evm_types_test.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── migration │ │ ├── README.md │ │ ├── eam.go │ │ ├── init.go │ │ ├── system.go │ │ └── top.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── monies.go │ │ ├── partition_state.go │ │ ├── policy.go │ │ └── unmarshall_test.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── placeholder │ │ └── methods.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ └── power_types.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── policy.go │ │ ├── verified_registry_state.go │ │ └── verifreg_types.go ├── v11 │ ├── account │ │ ├── account_state.go │ │ ├── account_types.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── datacap │ │ ├── cbor_gen.go │ │ ├── datacap_state.go │ │ ├── datacap_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── eam │ │ ├── cbor_gen.go │ │ ├── eam_types.go │ │ └── methods.go │ ├── ethaccount │ │ ├── methods.go │ │ └── types.go │ ├── evm │ │ ├── cbor_gen.go │ │ ├── evm_state.go │ │ ├── evm_types.go │ │ ├── evm_types_test.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── migration │ │ ├── miner.go │ │ ├── power.go │ │ ├── system.go │ │ └── top.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── monies.go │ │ ├── partition_state.go │ │ ├── policy.go │ │ └── unmarshall_test.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── placeholder │ │ └── methods.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ └── power_types.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── policy.go │ │ ├── verified_registry_state.go │ │ └── verifreg_types.go ├── v12 │ ├── account │ │ ├── account_state.go │ │ ├── account_types.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── datacap │ │ ├── cbor_gen.go │ │ ├── datacap_state.go │ │ ├── datacap_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── eam │ │ ├── cbor_gen.go │ │ ├── eam_types.go │ │ └── methods.go │ ├── ethaccount │ │ ├── methods.go │ │ └── types.go │ ├── evm │ │ ├── cbor_gen.go │ │ ├── evm_state.go │ │ ├── evm_types.go │ │ ├── evm_types_test.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── migration │ │ ├── miner.go │ │ ├── system.go │ │ └── top.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── monies.go │ │ ├── partition_state.go │ │ ├── policy.go │ │ └── unmarshall_test.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── placeholder │ │ └── methods.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ └── power_types.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── policy.go │ │ ├── verified_registry_state.go │ │ ├── verifreg_types.go │ │ └── verifreg_types_test.go ├── v13 │ ├── account │ │ ├── account_state.go │ │ ├── account_types.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── datacap │ │ ├── cbor_gen.go │ │ ├── datacap_state.go │ │ ├── datacap_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── eam │ │ ├── cbor_gen.go │ │ ├── eam_types.go │ │ └── methods.go │ ├── ethaccount │ │ ├── methods.go │ │ └── types.go │ ├── evm │ │ ├── cbor_gen.go │ │ ├── evm_state.go │ │ ├── evm_types.go │ │ ├── evm_types_test.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── migration │ │ ├── market.go │ │ ├── miner.go │ │ ├── system.go │ │ └── top.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── monies.go │ │ ├── partition_state.go │ │ ├── policy.go │ │ └── unmarshall_test.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── placeholder │ │ └── methods.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ └── power_types.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── map_test.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── policy.go │ │ ├── verified_registry_state.go │ │ ├── verifreg_types.go │ │ └── verifreg_types_test.go ├── v14 │ ├── account │ │ ├── account_state.go │ │ ├── account_types.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── datacap │ │ ├── cbor_gen.go │ │ ├── datacap_state.go │ │ ├── datacap_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── eam │ │ ├── cbor_gen.go │ │ ├── eam_types.go │ │ └── methods.go │ ├── ethaccount │ │ ├── methods.go │ │ └── types.go │ ├── evm │ │ ├── cbor_gen.go │ │ ├── evm_state.go │ │ ├── evm_types.go │ │ ├── evm_types_test.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── migration │ │ ├── system.go │ │ └── top.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── miner_types_test.go │ │ ├── monies.go │ │ ├── partition_state.go │ │ ├── policy.go │ │ └── unmarshall_test.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── placeholder │ │ └── methods.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ └── power_types.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── map_test.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── policy.go │ │ ├── verified_registry_state.go │ │ ├── verifreg_types.go │ │ └── verifreg_types_test.go ├── v15 │ ├── account │ │ ├── account_state.go │ │ ├── account_types.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── datacap │ │ ├── cbor_gen.go │ │ ├── datacap_state.go │ │ ├── datacap_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── eam │ │ ├── cbor_gen.go │ │ ├── eam_types.go │ │ └── methods.go │ ├── ethaccount │ │ ├── methods.go │ │ └── types.go │ ├── evm │ │ ├── cbor_gen.go │ │ ├── evm_state.go │ │ ├── evm_types.go │ │ ├── evm_types_test.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── migration │ │ ├── power.go │ │ ├── power_test.go │ │ ├── system.go │ │ └── top.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── miner_types_test.go │ │ ├── monies.go │ │ ├── monies_test.go │ │ ├── partition_state.go │ │ ├── policy.go │ │ ├── policy_test.go │ │ └── unmarshall_test.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── placeholder │ │ └── methods.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ ├── power_types.go │ │ └── power_types_test.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── map_test.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── policy.go │ │ ├── verified_registry_state.go │ │ ├── verifreg_types.go │ │ └── verifreg_types_test.go ├── v16 │ ├── account │ │ ├── account_state.go │ │ ├── account_types.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── datacap │ │ ├── cbor_gen.go │ │ ├── datacap_state.go │ │ ├── datacap_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── eam │ │ ├── cbor_gen.go │ │ ├── eam_types.go │ │ └── methods.go │ ├── ethaccount │ │ ├── methods.go │ │ └── types.go │ ├── evm │ │ ├── cbor_gen.go │ │ ├── evm_state.go │ │ ├── evm_types.go │ │ ├── evm_types_test.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── migration │ │ ├── evm.go │ │ ├── miner.go │ │ ├── system.go │ │ └── top.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── miner_types_test.go │ │ ├── monies.go │ │ ├── monies_test.go │ │ ├── partition_state.go │ │ ├── policy.go │ │ ├── policy_test.go │ │ └── unmarshall_test.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── placeholder │ │ └── methods.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ ├── power_types.go │ │ └── power_types_test.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── map_test.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── policy.go │ │ ├── verified_registry_state.go │ │ ├── verifreg_types.go │ │ └── verifreg_types_test.go ├── v17 │ ├── account │ │ ├── account_state.go │ │ ├── account_types.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── datacap │ │ ├── cbor_gen.go │ │ ├── datacap_state.go │ │ ├── datacap_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── eam │ │ ├── cbor_gen.go │ │ ├── eam_types.go │ │ └── methods.go │ ├── ethaccount │ │ ├── methods.go │ │ └── types.go │ ├── evm │ │ ├── cbor_gen.go │ │ ├── evm_state.go │ │ ├── evm_types.go │ │ ├── evm_types_test.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── migration │ │ ├── system.go │ │ └── top.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── miner_types_test.go │ │ ├── monies.go │ │ ├── monies_test.go │ │ ├── partition_state.go │ │ ├── policy.go │ │ ├── policy_test.go │ │ └── unmarshall_test.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── placeholder │ │ └── methods.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ ├── power_types.go │ │ └── power_types_test.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── map_test.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── policy.go │ │ ├── verified_registry_state.go │ │ ├── verifreg_types.go │ │ └── verifreg_types_test.go ├── v8 │ ├── account │ │ ├── account_state.go │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ └── methods.go │ ├── check.go │ ├── cron │ │ ├── cbor_gen.go │ │ ├── cron_state.go │ │ ├── cron_types.go │ │ ├── invariants.go │ │ └── methods.go │ ├── gen │ │ └── gen.go │ ├── init │ │ ├── cbor_gen.go │ │ ├── init_actor_params.go │ │ ├── init_actor_state.go │ │ ├── invariants.go │ │ └── methods.go │ ├── market │ │ ├── cbor_gen.go │ │ ├── deal.go │ │ ├── deal_test.go │ │ ├── invariants.go │ │ ├── market_state.go │ │ ├── market_types.go │ │ ├── methods.go │ │ ├── policy.go │ │ └── set_multimap.go │ ├── miner │ │ ├── cbor_gen.go │ │ ├── deadline_state.go │ │ ├── deadlines.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── miner_state.go │ │ ├── miner_types.go │ │ ├── monies.go │ │ ├── partition_state.go │ │ └── policy.go │ ├── multisig │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── multisig_state.go │ │ ├── multisig_types.go │ │ └── policy.go │ ├── paych │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── paych_state.go │ │ ├── paych_types.go │ │ └── policy.go │ ├── power │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── power_state.go │ │ └── power_types.go │ ├── reward │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── reward_logic.go │ │ ├── reward_state.go │ │ └── reward_types.go │ ├── system │ │ ├── cbor_gen.go │ │ ├── methods.go │ │ └── system_actor_state.go │ ├── util │ │ ├── adt │ │ │ ├── array.go │ │ │ ├── balancetable.go │ │ │ ├── map.go │ │ │ ├── multimap.go │ │ │ ├── set.go │ │ │ └── store.go │ │ ├── bitfield.go │ │ ├── bitfield_queue.go │ │ ├── math │ │ │ ├── expneg.go │ │ │ ├── ln.go │ │ │ ├── ln_test.go │ │ │ ├── parse.go │ │ │ └── polyval.go │ │ └── smoothing │ │ │ ├── alpha_beta_filter.go │ │ │ └── cbor_gen.go │ └── verifreg │ │ ├── cbor_gen.go │ │ ├── invariants.go │ │ ├── methods.go │ │ ├── verified_registry_state.go │ │ └── verifreg_types.go └── v9 │ ├── account │ ├── account_state.go │ ├── account_types.go │ ├── cbor_gen.go │ ├── invariants.go │ └── methods.go │ ├── check.go │ ├── cron │ ├── cbor_gen.go │ ├── cron_state.go │ ├── cron_types.go │ ├── invariants.go │ └── methods.go │ ├── datacap │ ├── cbor_gen.go │ ├── datacap_state.go │ ├── datacap_types.go │ ├── invariants.go │ └── methods.go │ ├── gen │ └── gen.go │ ├── init │ ├── cbor_gen.go │ ├── init_actor_params.go │ ├── init_actor_state.go │ ├── invariants.go │ └── methods.go │ ├── market │ ├── cbor_gen.go │ ├── deal.go │ ├── deal_test.go │ ├── invariants.go │ ├── market_state.go │ ├── market_types.go │ ├── methods.go │ ├── policy.go │ └── set_multimap.go │ ├── migration │ ├── datacap.go │ ├── market.go │ ├── miner.go │ ├── system.go │ ├── test │ │ ├── migration_test.go │ │ ├── miner_test.go │ │ ├── parallel_migration_test.go │ │ └── util.go │ ├── top.go │ ├── util.go │ └── verifreg.go │ ├── miner │ ├── cbor_gen.go │ ├── deadline_state.go │ ├── deadlines.go │ ├── invariants.go │ ├── methods.go │ ├── miner_state.go │ ├── miner_types.go │ ├── monies.go │ ├── partition_state.go │ └── policy.go │ ├── multisig │ ├── cbor_gen.go │ ├── invariants.go │ ├── methods.go │ ├── multisig_state.go │ ├── multisig_types.go │ └── policy.go │ ├── paych │ ├── cbor_gen.go │ ├── invariants.go │ ├── methods.go │ ├── paych_state.go │ ├── paych_types.go │ └── policy.go │ ├── power │ ├── cbor_gen.go │ ├── invariants.go │ ├── methods.go │ ├── power_state.go │ └── power_types.go │ ├── reward │ ├── cbor_gen.go │ ├── invariants.go │ ├── methods.go │ ├── reward_logic.go │ ├── reward_state.go │ └── reward_types.go │ ├── system │ ├── cbor_gen.go │ ├── methods.go │ └── system_actor_state.go │ ├── util │ ├── adt │ │ ├── array.go │ │ ├── balancetable.go │ │ ├── map.go │ │ ├── multimap.go │ │ ├── set.go │ │ └── store.go │ ├── bitfield.go │ ├── bitfield_queue.go │ ├── math │ │ ├── expneg.go │ │ ├── ln.go │ │ ├── ln_test.go │ │ ├── parse.go │ │ └── polyval.go │ └── smoothing │ │ ├── alpha_beta_filter.go │ │ └── cbor_gen.go │ └── verifreg │ ├── cbor_gen.go │ ├── invariants.go │ ├── methods.go │ ├── policy.go │ ├── verified_registry_state.go │ └── verifreg_types.go ├── cbor └── cbor.go ├── crypto ├── randomness.go ├── signature.go └── signature_test.go ├── dline ├── deadline.go └── deadline_test.go ├── exitcode ├── common.go ├── exitcode.go ├── exitcode_test.go ├── names.go └── reserved.go ├── gen └── gen.go ├── go.mod ├── go.sum ├── ipld ├── bindnodeoptions.go └── bindnodeoptions_test.go ├── manifest ├── cbor_gen.go ├── gen │ └── gen.go └── manifest.go ├── migration ├── job.go ├── runner.go └── util.go ├── network └── version.go ├── proof ├── cbor_gen.go ├── gen │ └── gen.go └── proof_types.go ├── rt ├── actor.go └── log.go ├── store └── ctx_store.go ├── test_util └── blockstore.go └── version.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # IDE project files 15 | .idea 16 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright 2020. Protocol Labs, Inc. 2 | 3 | This library is dual-licensed under Apache 2.0 and MIT terms. 4 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Copyright 2020. Protocol Labs, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright 2020. Protocol Labs, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GO_BIN ?= go 2 | GOLINT ?= golangci-lint 3 | 4 | all: build lint test tidy 5 | .PHONY: all 6 | 7 | build: 8 | $(GO_BIN) build ./... 9 | .PHONY: build 10 | 11 | test: 12 | $(GO_BIN) test ./... 13 | .PHONY: test 14 | 15 | test-coverage: 16 | $(GO_BIN) test -coverprofile=coverage.out ./... 17 | .PHONY: test-coverage 18 | 19 | tidy: 20 | $(GO_BIN) mod tidy 21 | .PHONY: tidy 22 | 23 | gen: 24 | $(GO_BIN) run ./gen/gen.go 25 | $(GO_BIN) run ./manifest/gen/gen.go 26 | $(GO_BIN) run ./proof/gen/gen.go 27 | $(GO_BIN) run ./batch/gen/gen.go 28 | $(GO_BIN) run ./builtin/v8/gen/gen.go 29 | $(GO_BIN) run ./builtin/v9/gen/gen.go 30 | $(GO_BIN) run ./builtin/v10/gen/gen.go 31 | $(GO_BIN) run ./builtin/v11/gen/gen.go 32 | $(GO_BIN) run ./builtin/v12/gen/gen.go 33 | $(GO_BIN) run ./builtin/v13/gen/gen.go 34 | $(GO_BIN) run ./builtin/v14/gen/gen.go 35 | $(GO_BIN) run ./builtin/v15/gen/gen.go 36 | $(GO_BIN) run ./builtin/v16/gen/gen.go 37 | $(GO_BIN) run ./builtin/v17/gen/gen.go 38 | .PHONY: gen 39 | 40 | lint: 41 | $(GOLINT) run ./... 42 | .PHONY: lint 43 | -------------------------------------------------------------------------------- /abi/address.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/network" 6 | ) 7 | 8 | // AddressValidForNetworkVersion returns true if the address is supported by the given network 9 | // version. 10 | // 11 | // NOTE: It will _also_ return true if the address is "empty", because all versions support empty 12 | // addresses in some places. I.e., it's not a version specific check. 13 | func AddressValidForNetworkVersion(addr address.Address, nv network.Version) bool { 14 | // We define "undefined" addresses as "supported". The user should check for those 15 | // separately. 16 | if addr == address.Undef { 17 | return true 18 | } 19 | 20 | switch addr.Protocol() { 21 | case address.ID, address.SECP256K1, address.Actor, address.BLS: 22 | return true 23 | case address.Delegated: 24 | return nv >= network.Version18 25 | default: 26 | return false 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /abi/address_test.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/filecoin-project/go-address" 7 | "github.com/shorttermbons/go-state-types/network" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | func TestAddressValidForNetworkVersion(t *testing.T) { 12 | id, _ := address.NewIDAddress(1) 13 | bls, _ := address.NewBLSAddress(make([]byte, address.BlsPublicKeyBytes)) 14 | secp, _ := address.NewSecp256k1Address(make([]byte, address.PayloadHashLength)) 15 | actor, _ := address.NewActorAddress(make([]byte, address.PayloadHashLength)) 16 | for _, addr := range []address.Address{id, bls, secp, actor} { 17 | require.True(t, AddressValidForNetworkVersion(addr, network.Version17)) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /abi/cbor_bytes.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | cbg "github.com/whyrusleeping/cbor-gen" 8 | "golang.org/x/xerrors" 9 | ) 10 | 11 | type CborBytes []byte 12 | 13 | func (t *CborBytes) MarshalCBOR(w io.Writer) error { 14 | if len(*t) > cbg.ByteArrayMaxLen { 15 | return xerrors.Errorf("byte array was too long") 16 | } 17 | 18 | if err := cbg.WriteMajorTypeHeader(w, cbg.MajByteString, uint64(len(*t))); err != nil { 19 | return err 20 | } 21 | 22 | _, err := w.Write((*t)[:]) 23 | return err 24 | } 25 | 26 | func (t *CborBytes) UnmarshalCBOR(r io.Reader) error { 27 | 28 | br := cbg.GetPeeker(r) 29 | maj, extra, err := cbg.CborReadHeader(br) 30 | if err != nil { 31 | return err 32 | } 33 | 34 | if extra > cbg.ByteArrayMaxLen { 35 | return fmt.Errorf("byte array too large (%d)", extra) 36 | } 37 | if maj != cbg.MajByteString { 38 | return fmt.Errorf("expected byte array") 39 | } 40 | 41 | if extra > 0 { 42 | ret := make([]byte, extra) 43 | if _, err := io.ReadFull(br, ret[:]); err != nil { 44 | return err 45 | } 46 | 47 | *t = ret 48 | } 49 | 50 | return nil 51 | } 52 | -------------------------------------------------------------------------------- /abi/cbor_bytes_transparent.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // CborBytesTransparent NOTE This struct does not create a valid cbor-encoded byte slice. It just passes the bytes through as-is. 8 | type CborBytesTransparent []byte 9 | 10 | // MarshalCBOR Does NOT marshall to a cbor-encoding. This is just syntactic sugar to let us pass bytes transparently through lotus which requires a cbor-marshallable object. 11 | func (t *CborBytesTransparent) MarshalCBOR(w io.Writer) error { 12 | _, err := w.Write(*t) 13 | return err 14 | } 15 | 16 | // UnmarshalCBOR CANNOT read a cbor-encoded byte slice. This will just transparently pass the underlying bytes. 17 | // This method is also risky, as it reads unboundedly. Do NOT use it for anything vulnerable. 18 | func (t *CborBytesTransparent) UnmarshalCBOR(r io.Reader) error { 19 | var err error 20 | *t, err = io.ReadAll(r) 21 | return err 22 | } 23 | -------------------------------------------------------------------------------- /abi/cbor_string.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import ( 4 | "io" 5 | 6 | "golang.org/x/xerrors" 7 | 8 | cbg "github.com/whyrusleeping/cbor-gen" 9 | ) 10 | 11 | type CborString string 12 | 13 | func (t *CborString) MarshalCBOR(w io.Writer) error { 14 | scratch := make([]byte, 8) 15 | 16 | if len(*t) > cbg.MaxLength { 17 | return xerrors.Errorf("Value in t was too long") 18 | } 19 | 20 | if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len(*t))); err != nil { 21 | return err 22 | } 23 | if _, err := io.WriteString(w, string(*t)); err != nil { 24 | return err 25 | } 26 | 27 | return nil 28 | } 29 | 30 | func (t *CborString) UnmarshalCBOR(r io.Reader) error { 31 | *t = "" 32 | { 33 | sval, err := cbg.ReadString(r) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | *t = CborString(sval) 39 | } 40 | 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /abi/cbor_test.go: -------------------------------------------------------------------------------- 1 | package abi_test 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/shorttermbons/go-state-types/abi" 10 | ) 11 | 12 | func TestCborBytesTransparent(t *testing.T) { 13 | tBytes := abi.CborBytesTransparent([]byte{0xde, 0xad, 0xbe, 0xef}) 14 | 15 | buf := new(bytes.Buffer) 16 | require.NoError(t, tBytes.MarshalCBOR(buf)) 17 | 18 | bytesSer := buf.Bytes() 19 | require.Equal(t, []byte(tBytes), bytesSer) 20 | 21 | var bytesDeSer abi.CborBytesTransparent 22 | require.NoError(t, bytesDeSer.UnmarshalCBOR(bytes.NewReader(tBytes))) 23 | require.Equal(t, tBytes, bytesDeSer) 24 | } 25 | -------------------------------------------------------------------------------- /abi/chain.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/shorttermbons/go-state-types/big" 7 | ) 8 | 9 | // Epoch number of the chain state, which acts as a proxy for time within the VM. 10 | type ChainEpoch int64 11 | 12 | func (e ChainEpoch) String() string { 13 | return strconv.FormatInt(int64(e), 10) 14 | } 15 | 16 | // TokenAmount is an amount of Filecoin tokens. This type is used within 17 | // the VM in message execution, to account movement of tokens, payment 18 | // of VM gas, and more. 19 | // 20 | // BigInt types are aliases rather than new types because the latter introduce incredible amounts of noise converting to 21 | // and from types in order to manipulate values. We give up some type safety for ergonomics. 22 | type TokenAmount = big.Int 23 | 24 | func NewTokenAmount(t int64) TokenAmount { 25 | return big.NewInt(t) 26 | } 27 | 28 | // Randomness is a string of random bytes 29 | type Randomness []byte 30 | 31 | // RandomnessLength is the length of the randomness slice. 32 | const RandomnessLength = 32 33 | -------------------------------------------------------------------------------- /abi/deal.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import "github.com/shorttermbons/go-state-types/big" 4 | 5 | type DealID uint64 6 | 7 | type DealIDList []DealID 8 | 9 | // BigInt types are aliases rather than new types because the latter introduce incredible amounts of noise 10 | // converting to and from types in order to manipulate values. 11 | // We give up some type safety for ergonomics. 12 | type DealWeight = big.Int // units: byte-epochs 13 | -------------------------------------------------------------------------------- /actors_version_checklist.md: -------------------------------------------------------------------------------- 1 | ### Actor version integration checklist 2 | 3 | For detailed steps on integrating a new actor version, please refer to the [Go-State-Types Checklist in the Lotus repository](https://github.com/filecoin-project/lotus/blob/master/documentation/misc/Building_a_network_skeleton.md#go-state-types-checklist). -------------------------------------------------------------------------------- /batch/gen/gen.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/batch" 5 | gen "github.com/whyrusleeping/cbor-gen" 6 | ) 7 | 8 | func main() { 9 | // Actor manifest 10 | if err := gen.WriteTupleEncodersToFile("./batch/cbor_gen.go", "batch", 11 | // actor manifest 12 | batch.BatchReturn{}, 13 | batch.FailCode{}, 14 | ); err != nil { 15 | panic(err) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /builtin/method_meta.go: -------------------------------------------------------------------------------- 1 | package builtin 2 | 3 | type MethodMeta struct { 4 | Name string 5 | Method interface{} 6 | } 7 | 8 | func NewMethodMeta(name string, method interface{}) MethodMeta { 9 | return MethodMeta{ 10 | Name: name, 11 | Method: method, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /builtin/methods_test.go: -------------------------------------------------------------------------------- 1 | package builtin 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/shorttermbons/go-state-types/abi" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestGenerateMethodNum(t *testing.T) { 11 | 12 | methodNum, err := GenerateFRCMethodNum("Receive") 13 | require.NoError(t, err) 14 | require.Equal(t, methodNum, abi.MethodNum(3726118371)) 15 | } 16 | -------------------------------------------------------------------------------- /builtin/shared.go: -------------------------------------------------------------------------------- 1 | package builtin 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/shorttermbons/go-state-types/big" 7 | "github.com/ipfs/go-cid" 8 | cbor "github.com/ipfs/go-ipld-cbor" 9 | "golang.org/x/xerrors" 10 | ) 11 | 12 | ///// Code shared by multiple built-in actors. ///// 13 | 14 | // Default log2 of branching factor for HAMTs. 15 | // This value has been empirically chosen, but the optimal value for maps with different mutation profiles may differ. 16 | const DefaultHamtBitwidth = 5 17 | 18 | const DefaultTokenActorBitwidth = 3 19 | 20 | type BigFrac struct { 21 | Numerator big.Int 22 | Denominator big.Int 23 | } 24 | 25 | func MakeEmptyState() (cid.Cid, error) { 26 | store := cbor.NewMemCborStore() 27 | emptyObject, err := store.Put(context.TODO(), []struct{}{}) 28 | if err != nil { 29 | return cid.Undef, xerrors.Errorf("failed to make empty object: %w", err) 30 | } 31 | 32 | return emptyObject, nil 33 | } 34 | -------------------------------------------------------------------------------- /builtin/v10/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v10/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v10/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type StateSummary struct { 10 | PubKeyAddr address.Address 11 | } 12 | 13 | // Checks internal invariants of account state. 14 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | accountSummary := &StateSummary{ 17 | PubKeyAddr: st.Address, 18 | } 19 | 20 | if id, err := address.IDFromAddress(idAddr); err != nil { 21 | acc.Addf("error extracting actor ID from address: %v", err) 22 | } else if id >= builtin.FirstNonSingletonActorId { 23 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 24 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 25 | } 26 | 27 | return accountSummary, acc 28 | } 29 | -------------------------------------------------------------------------------- /builtin/v10/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | typegen "github.com/whyrusleeping/cbor-gen" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | ) 10 | 11 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 12 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 13 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 14 | builtin.MustGenerateFRCMethodNum("AuthenticateMessage"): builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *typegen.CborBool)), // AuthenticateMessage 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v10/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v10/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v10/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | "github.com/shorttermbons/go-state-types/builtin/v10/util/adt" 8 | ) 9 | 10 | type StateSummary struct { 11 | EntryCount int 12 | } 13 | 14 | // Checks internal invariants of cron state. 15 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 16 | acc := &builtin.MessageAccumulator{} 17 | cronSummary := &StateSummary{ 18 | EntryCount: len(st.Entries), 19 | } 20 | for i, e := range st.Entries { 21 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 22 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 23 | } 24 | return cronSummary, acc 25 | } 26 | -------------------------------------------------------------------------------- /builtin/v10/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v10/eam/eam_types.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type CreateParams struct { 8 | Initcode []byte 9 | Nonce uint64 10 | } 11 | 12 | type Create2Params struct { 13 | Initcode []byte 14 | Salt [32]byte 15 | } 16 | 17 | type Return struct { 18 | ActorID uint64 19 | RobustAddress *address.Address 20 | EthAddress [20]byte 21 | } 22 | 23 | type CreateReturn Return 24 | type Create2Return Return 25 | type CreateExternalReturn Return 26 | -------------------------------------------------------------------------------- /builtin/v10/eam/methods.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Create", *new(func(*CreateParams) *CreateReturn)), // Create 11 | 3: builtin.NewMethodMeta("Create2", *new(func(*Create2Params) *Create2Return)), // Create2 12 | 4: builtin.NewMethodMeta("CreateExternal", *new(func(*abi.CborBytes) *CreateExternalReturn)), // CreateExternal 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v10/ethaccount/methods.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(value *abi.EmptyValue) *abi.EmptyValue)), 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v10/ethaccount/types.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v10/evm/evm_state.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/ipfs/go-cid" 6 | xerrors "golang.org/x/xerrors" 7 | 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | "github.com/shorttermbons/go-state-types/builtin/v10/util/adt" 10 | ) 11 | 12 | type Tombstone struct { 13 | Origin abi.ActorID 14 | Nonce uint64 15 | } 16 | 17 | type State struct { 18 | Bytecode cid.Cid 19 | BytecodeHash [32]byte 20 | ContractState cid.Cid 21 | Nonce uint64 22 | Tombstone *Tombstone 23 | } 24 | 25 | func ConstructState(store adt.Store, bytecode cid.Cid) (*State, error) { 26 | emptyMapCid, err := adt.StoreEmptyMap(store, builtin.DefaultHamtBitwidth) 27 | if err != nil { 28 | return nil, xerrors.Errorf("failed to create empty map: %w", err) 29 | } 30 | 31 | return &State{ 32 | Bytecode: bytecode, 33 | ContractState: emptyMapCid, 34 | Nonce: 0, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /builtin/v10/evm/evm_types_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/ipfs/go-cid" 8 | "github.com/stretchr/testify/require" 9 | cbg "github.com/whyrusleeping/cbor-gen" 10 | ) 11 | 12 | func TestGetBytecodeReturn(t *testing.T) { 13 | randomCid, err := cid.Decode("bafy2bzacecu7n7wbtogznrtuuvf73dsz7wasgyneqasksdblxupnyovmtwxxu") 14 | require.NoError(t, err) 15 | 16 | var cidbuf bytes.Buffer 17 | require.NoError(t, cbg.WriteCid(&cidbuf, randomCid)) 18 | 19 | in := &GetBytecodeReturn{ 20 | Cid: &randomCid, 21 | } 22 | var buf bytes.Buffer 23 | require.NoError(t, in.MarshalCBOR(&buf)) 24 | require.Equal(t, cidbuf.Bytes(), buf.Bytes()) 25 | 26 | var out GetBytecodeReturn 27 | require.NoError(t, out.UnmarshalCBOR(&buf)) 28 | require.Equal(t, &randomCid, out.Cid) 29 | 30 | in.Cid = nil 31 | buf.Reset() 32 | require.NoError(t, in.MarshalCBOR(&buf)) 33 | require.Equal(t, cbg.CborNull, buf.Bytes()) 34 | 35 | require.NoError(t, out.UnmarshalCBOR(&buf)) 36 | require.Nil(t, out.Cid) 37 | } 38 | -------------------------------------------------------------------------------- /builtin/v10/evm/methods.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), 10 | 2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)), 11 | 3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)), 12 | 4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)), 13 | 5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)), 14 | 6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)), 15 | builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)), 16 | } 17 | -------------------------------------------------------------------------------- /builtin/v10/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/ipfs/go-cid" 6 | ) 7 | 8 | type ConstructorParams struct { 9 | NetworkName string 10 | } 11 | 12 | type ExecParams struct { 13 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 14 | ConstructorParams []byte 15 | } 16 | 17 | type ExecReturn struct { 18 | IDAddress addr.Address // The canonical ID-based address for the actor. 19 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 20 | } 21 | 22 | type Exec4Params struct { 23 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 24 | ConstructorParams []byte 25 | SubAddress []byte 26 | } 27 | 28 | type Exec4Return = ExecReturn 29 | -------------------------------------------------------------------------------- /builtin/v10/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | // TODO Are we exporting Exec4 12 | 3: builtin.NewMethodMeta("Exec4", *new(func(*Exec4Params) *ExecReturn)), // Exec4 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v10/migration/README.md: -------------------------------------------------------------------------------- 1 | We are not even at v9 yet, so there is no v10 migration yet; to be added later. 2 | -------------------------------------------------------------------------------- /builtin/v10/migration/eam.go: -------------------------------------------------------------------------------- 1 | package migration 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/manifest" 5 | 6 | "github.com/shorttermbons/go-state-types/abi" 7 | "github.com/shorttermbons/go-state-types/builtin" 8 | 9 | "golang.org/x/xerrors" 10 | 11 | "github.com/ipfs/go-cid" 12 | ) 13 | 14 | func CreateEAMActor(m *manifest.Manifest, head cid.Cid) (*builtin.ActorV5, error) { 15 | eamCode, ok := m.Get(manifest.EamKey) 16 | if !ok { 17 | return nil, xerrors.Errorf("didn't find EAM code CID") 18 | } 19 | 20 | return &builtin.ActorV5{ 21 | Code: eamCode, 22 | Head: head, 23 | CallSeqNum: 0, 24 | Balance: abi.NewTokenAmount(0), 25 | DelegatedAddress: nil, 26 | }, nil 27 | } 28 | -------------------------------------------------------------------------------- /builtin/v10/miner/unmarshall_test.go: -------------------------------------------------------------------------------- 1 | package miner 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/big" 9 | 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestCborVestingFunds(t *testing.T) { 14 | var vf = VestingFunds{ 15 | Funds: []VestingFund{ 16 | { 17 | Epoch: 1, 18 | Amount: big.NewInt(3), 19 | }, 20 | { 21 | Epoch: 2, 22 | Amount: big.NewInt(4), 23 | }, 24 | }, 25 | } 26 | buf := new(bytes.Buffer) 27 | err := vf.MarshalCBOR(buf) 28 | require.NoError(t, err) 29 | 30 | // Value taken from builtin-actors test. 31 | b := []byte{129, 130, 130, 1, 66, 0, 3, 130, 2, 66, 0, 4} 32 | 33 | require.Equal(t, b, buf.Bytes()) 34 | 35 | var vf2 VestingFunds 36 | err = vf2.UnmarshalCBOR(bytes.NewReader(b)) 37 | require.NoError(t, err) 38 | require.Equal(t, abi.ChainEpoch(1), vf2.Funds[0].Epoch) 39 | require.Equal(t, abi.ChainEpoch(2), vf2.Funds[1].Epoch) 40 | require.Equal(t, big.NewInt(3), vf2.Funds[0].Amount) 41 | require.Equal(t, big.NewInt(4), vf2.Funds[1].Amount) 42 | } 43 | -------------------------------------------------------------------------------- /builtin/v10/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v10/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v10/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v10/placeholder/methods.go: -------------------------------------------------------------------------------- 1 | package placeholder 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | // Placeholder has no methods, not even a constructor 9 | var Methods = map[abi.MethodNum]builtin.MethodMeta{} 10 | -------------------------------------------------------------------------------- /builtin/v10/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v10/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v10/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v10/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v10/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/shorttermbons/go-state-types/manifest" 7 | 8 | "github.com/shorttermbons/go-state-types/builtin/v10/util/adt" 9 | 10 | "github.com/ipfs/go-cid" 11 | "golang.org/x/xerrors" 12 | ) 13 | 14 | type State struct { 15 | BuiltinActors cid.Cid // ManifestData 16 | } 17 | 18 | func ConstructState(store adt.Store) (*State, error) { 19 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 20 | if err != nil { 21 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 22 | } 23 | 24 | return &State{BuiltinActors: empty}, nil 25 | } 26 | -------------------------------------------------------------------------------- /builtin/v10/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v10/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v10/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v10/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | 17 | const MinimumVerifiedAllocationSize = 1 << 20 18 | -------------------------------------------------------------------------------- /builtin/v11/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v11/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v11/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type StateSummary struct { 10 | PubKeyAddr address.Address 11 | } 12 | 13 | // Checks internal invariants of account state. 14 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | accountSummary := &StateSummary{ 17 | PubKeyAddr: st.Address, 18 | } 19 | 20 | if id, err := address.IDFromAddress(idAddr); err != nil { 21 | acc.Addf("error extracting actor ID from address: %v", err) 22 | } else if id >= builtin.FirstNonSingletonActorId { 23 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 24 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 25 | } 26 | 27 | return accountSummary, acc 28 | } 29 | -------------------------------------------------------------------------------- /builtin/v11/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | typegen "github.com/whyrusleeping/cbor-gen" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | ) 10 | 11 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 12 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 13 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 14 | builtin.MustGenerateFRCMethodNum("AuthenticateMessage"): builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *typegen.CborBool)), // AuthenticateMessage 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v11/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v11/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v11/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | "github.com/shorttermbons/go-state-types/builtin/v11/util/adt" 8 | ) 9 | 10 | type StateSummary struct { 11 | EntryCount int 12 | } 13 | 14 | // Checks internal invariants of cron state. 15 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 16 | acc := &builtin.MessageAccumulator{} 17 | cronSummary := &StateSummary{ 18 | EntryCount: len(st.Entries), 19 | } 20 | for i, e := range st.Entries { 21 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 22 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 23 | } 24 | return cronSummary, acc 25 | } 26 | -------------------------------------------------------------------------------- /builtin/v11/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v11/eam/eam_types.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type CreateParams struct { 8 | Initcode []byte 9 | Nonce uint64 10 | } 11 | 12 | type Create2Params struct { 13 | Initcode []byte 14 | Salt [32]byte 15 | } 16 | 17 | type Return struct { 18 | ActorID uint64 19 | RobustAddress *address.Address 20 | EthAddress [20]byte 21 | } 22 | 23 | type CreateReturn Return 24 | type Create2Return Return 25 | type CreateExternalReturn Return 26 | -------------------------------------------------------------------------------- /builtin/v11/eam/methods.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Create", *new(func(*CreateParams) *CreateReturn)), // Create 11 | 3: builtin.NewMethodMeta("Create2", *new(func(*Create2Params) *Create2Return)), // Create2 12 | 4: builtin.NewMethodMeta("CreateExternal", *new(func(*abi.CborBytes) *CreateExternalReturn)), // CreateExternal 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v11/ethaccount/methods.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(value *abi.EmptyValue) *abi.EmptyValue)), 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v11/ethaccount/types.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v11/evm/evm_state.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/ipfs/go-cid" 6 | xerrors "golang.org/x/xerrors" 7 | 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | "github.com/shorttermbons/go-state-types/builtin/v11/util/adt" 10 | ) 11 | 12 | type Tombstone struct { 13 | Origin abi.ActorID 14 | Nonce uint64 15 | } 16 | 17 | type State struct { 18 | Bytecode cid.Cid 19 | BytecodeHash [32]byte 20 | ContractState cid.Cid 21 | Nonce uint64 22 | Tombstone *Tombstone 23 | } 24 | 25 | func ConstructState(store adt.Store, bytecode cid.Cid) (*State, error) { 26 | emptyMapCid, err := adt.StoreEmptyMap(store, builtin.DefaultHamtBitwidth) 27 | if err != nil { 28 | return nil, xerrors.Errorf("failed to create empty map: %w", err) 29 | } 30 | 31 | return &State{ 32 | Bytecode: bytecode, 33 | ContractState: emptyMapCid, 34 | Nonce: 0, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /builtin/v11/evm/evm_types_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/ipfs/go-cid" 8 | "github.com/stretchr/testify/require" 9 | cbg "github.com/whyrusleeping/cbor-gen" 10 | ) 11 | 12 | func TestGetBytecodeReturn(t *testing.T) { 13 | randomCid, err := cid.Decode("bafy2bzacecu7n7wbtogznrtuuvf73dsz7wasgyneqasksdblxupnyovmtwxxu") 14 | require.NoError(t, err) 15 | 16 | var cidbuf bytes.Buffer 17 | require.NoError(t, cbg.WriteCid(&cidbuf, randomCid)) 18 | 19 | in := &GetBytecodeReturn{ 20 | Cid: &randomCid, 21 | } 22 | var buf bytes.Buffer 23 | require.NoError(t, in.MarshalCBOR(&buf)) 24 | require.Equal(t, cidbuf.Bytes(), buf.Bytes()) 25 | 26 | var out GetBytecodeReturn 27 | require.NoError(t, out.UnmarshalCBOR(&buf)) 28 | require.Equal(t, &randomCid, out.Cid) 29 | 30 | in.Cid = nil 31 | buf.Reset() 32 | require.NoError(t, in.MarshalCBOR(&buf)) 33 | require.Equal(t, cbg.CborNull, buf.Bytes()) 34 | 35 | require.NoError(t, out.UnmarshalCBOR(&buf)) 36 | require.Nil(t, out.Cid) 37 | } 38 | -------------------------------------------------------------------------------- /builtin/v11/evm/methods.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), 10 | 2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)), 11 | 3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)), 12 | 4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)), 13 | 5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)), 14 | 6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)), 15 | builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)), 16 | } 17 | -------------------------------------------------------------------------------- /builtin/v11/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/ipfs/go-cid" 6 | ) 7 | 8 | type ConstructorParams struct { 9 | NetworkName string 10 | } 11 | 12 | type ExecParams struct { 13 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 14 | ConstructorParams []byte 15 | } 16 | 17 | type ExecReturn struct { 18 | IDAddress addr.Address // The canonical ID-based address for the actor. 19 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 20 | } 21 | 22 | type Exec4Params struct { 23 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 24 | ConstructorParams []byte 25 | SubAddress []byte 26 | } 27 | 28 | type Exec4Return = ExecReturn 29 | -------------------------------------------------------------------------------- /builtin/v11/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | // TODO Are we exporting Exec4 12 | 3: builtin.NewMethodMeta("Exec4", *new(func(*Exec4Params) *ExecReturn)), // Exec4 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v11/miner/unmarshall_test.go: -------------------------------------------------------------------------------- 1 | package miner 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/big" 9 | 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestCborVestingFunds(t *testing.T) { 14 | var vf = VestingFunds{ 15 | Funds: []VestingFund{ 16 | { 17 | Epoch: 1, 18 | Amount: big.NewInt(3), 19 | }, 20 | { 21 | Epoch: 2, 22 | Amount: big.NewInt(4), 23 | }, 24 | }, 25 | } 26 | buf := new(bytes.Buffer) 27 | err := vf.MarshalCBOR(buf) 28 | require.NoError(t, err) 29 | 30 | // Value taken from builtin-actors test. 31 | b := []byte{129, 130, 130, 1, 66, 0, 3, 130, 2, 66, 0, 4} 32 | 33 | require.Equal(t, b, buf.Bytes()) 34 | 35 | var vf2 VestingFunds 36 | err = vf2.UnmarshalCBOR(bytes.NewReader(b)) 37 | require.NoError(t, err) 38 | require.Equal(t, abi.ChainEpoch(1), vf2.Funds[0].Epoch) 39 | require.Equal(t, abi.ChainEpoch(2), vf2.Funds[1].Epoch) 40 | require.Equal(t, big.NewInt(3), vf2.Funds[0].Amount) 41 | require.Equal(t, big.NewInt(4), vf2.Funds[1].Amount) 42 | } 43 | -------------------------------------------------------------------------------- /builtin/v11/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v11/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v11/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v11/placeholder/methods.go: -------------------------------------------------------------------------------- 1 | package placeholder 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | // Placeholder has no methods, not even a constructor 9 | var Methods = map[abi.MethodNum]builtin.MethodMeta{} 10 | -------------------------------------------------------------------------------- /builtin/v11/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v11/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v11/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v11/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v11/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/shorttermbons/go-state-types/manifest" 7 | 8 | "github.com/shorttermbons/go-state-types/builtin/v11/util/adt" 9 | 10 | "github.com/ipfs/go-cid" 11 | "golang.org/x/xerrors" 12 | ) 13 | 14 | type State struct { 15 | BuiltinActors cid.Cid // ManifestData 16 | } 17 | 18 | func ConstructState(store adt.Store) (*State, error) { 19 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 20 | if err != nil { 21 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 22 | } 23 | 24 | return &State{BuiltinActors: empty}, nil 25 | } 26 | -------------------------------------------------------------------------------- /builtin/v11/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v11/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v11/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v11/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | 17 | const MinimumVerifiedAllocationSize = 1 << 20 18 | -------------------------------------------------------------------------------- /builtin/v12/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v12/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v12/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | type StateSummary struct { 9 | PubKeyAddr address.Address 10 | } 11 | 12 | // Checks internal invariants of account state. 13 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 14 | acc := &builtin.MessageAccumulator{} 15 | accountSummary := &StateSummary{ 16 | PubKeyAddr: st.Address, 17 | } 18 | 19 | if id, err := address.IDFromAddress(idAddr); err != nil { 20 | acc.Addf("error extracting actor ID from address: %v", err) 21 | } else if id >= builtin.FirstNonSingletonActorId { 22 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 23 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 24 | } 25 | 26 | return accountSummary, acc 27 | } 28 | -------------------------------------------------------------------------------- /builtin/v12/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | typegen "github.com/whyrusleeping/cbor-gen" 5 | 6 | "github.com/filecoin-project/go-address" 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | ) 10 | 11 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 12 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 13 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 14 | builtin.MustGenerateFRCMethodNum("AuthenticateMessage"): builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *typegen.CborBool)), // AuthenticateMessage 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v12/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v12/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v12/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | "github.com/shorttermbons/go-state-types/builtin/v12/util/adt" 7 | ) 8 | 9 | type StateSummary struct { 10 | EntryCount int 11 | } 12 | 13 | // Checks internal invariants of cron state. 14 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | cronSummary := &StateSummary{ 17 | EntryCount: len(st.Entries), 18 | } 19 | for i, e := range st.Entries { 20 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 21 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 22 | } 23 | return cronSummary, acc 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v12/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v12/eam/eam_types.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type CreateParams struct { 8 | Initcode []byte 9 | Nonce uint64 10 | } 11 | 12 | type Create2Params struct { 13 | Initcode []byte 14 | Salt [32]byte 15 | } 16 | 17 | type Return struct { 18 | ActorID uint64 19 | RobustAddress *address.Address 20 | EthAddress [20]byte 21 | } 22 | 23 | type CreateReturn Return 24 | type Create2Return Return 25 | type CreateExternalReturn Return 26 | -------------------------------------------------------------------------------- /builtin/v12/eam/methods.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Create", *new(func(*CreateParams) *CreateReturn)), // Create 11 | 3: builtin.NewMethodMeta("Create2", *new(func(*Create2Params) *Create2Return)), // Create2 12 | 4: builtin.NewMethodMeta("CreateExternal", *new(func(*abi.CborBytes) *CreateExternalReturn)), // CreateExternal 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v12/ethaccount/methods.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(value *abi.EmptyValue) *abi.EmptyValue)), 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v12/ethaccount/types.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v12/evm/evm_state.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | xerrors "golang.org/x/xerrors" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | "github.com/shorttermbons/go-state-types/builtin/v12/util/adt" 10 | ) 11 | 12 | type Tombstone struct { 13 | Origin abi.ActorID 14 | Nonce uint64 15 | } 16 | 17 | type State struct { 18 | Bytecode cid.Cid 19 | BytecodeHash [32]byte 20 | ContractState cid.Cid 21 | Nonce uint64 22 | Tombstone *Tombstone 23 | } 24 | 25 | func ConstructState(store adt.Store, bytecode cid.Cid) (*State, error) { 26 | emptyMapCid, err := adt.StoreEmptyMap(store, builtin.DefaultHamtBitwidth) 27 | if err != nil { 28 | return nil, xerrors.Errorf("failed to create empty map: %w", err) 29 | } 30 | 31 | return &State{ 32 | Bytecode: bytecode, 33 | ContractState: emptyMapCid, 34 | Nonce: 0, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /builtin/v12/evm/evm_types_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/ipfs/go-cid" 8 | "github.com/stretchr/testify/require" 9 | cbg "github.com/whyrusleeping/cbor-gen" 10 | ) 11 | 12 | func TestGetBytecodeReturn(t *testing.T) { 13 | randomCid, err := cid.Decode("bafy2bzacecu7n7wbtogznrtuuvf73dsz7wasgyneqasksdblxupnyovmtwxxu") 14 | require.NoError(t, err) 15 | 16 | var cidbuf bytes.Buffer 17 | require.NoError(t, cbg.WriteCid(&cidbuf, randomCid)) 18 | 19 | in := &GetBytecodeReturn{ 20 | Cid: &randomCid, 21 | } 22 | var buf bytes.Buffer 23 | require.NoError(t, in.MarshalCBOR(&buf)) 24 | require.Equal(t, cidbuf.Bytes(), buf.Bytes()) 25 | 26 | var out GetBytecodeReturn 27 | require.NoError(t, out.UnmarshalCBOR(&buf)) 28 | require.Equal(t, &randomCid, out.Cid) 29 | 30 | in.Cid = nil 31 | buf.Reset() 32 | require.NoError(t, in.MarshalCBOR(&buf)) 33 | require.Equal(t, cbg.CborNull, buf.Bytes()) 34 | 35 | require.NoError(t, out.UnmarshalCBOR(&buf)) 36 | require.Nil(t, out.Cid) 37 | } 38 | -------------------------------------------------------------------------------- /builtin/v12/evm/methods.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), 10 | 2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)), 11 | 3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)), 12 | 4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)), 13 | 5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)), 14 | 6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)), 15 | builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)), 16 | } 17 | -------------------------------------------------------------------------------- /builtin/v12/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | 6 | addr "github.com/filecoin-project/go-address" 7 | ) 8 | 9 | type ConstructorParams struct { 10 | NetworkName string 11 | } 12 | 13 | type ExecParams struct { 14 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 15 | ConstructorParams []byte 16 | } 17 | 18 | type ExecReturn struct { 19 | IDAddress addr.Address // The canonical ID-based address for the actor. 20 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 21 | } 22 | 23 | type Exec4Params struct { 24 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 25 | ConstructorParams []byte 26 | SubAddress []byte 27 | } 28 | 29 | type Exec4Return = ExecReturn 30 | -------------------------------------------------------------------------------- /builtin/v12/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | // TODO Are we exporting Exec4 12 | 3: builtin.NewMethodMeta("Exec4", *new(func(*Exec4Params) *ExecReturn)), // Exec4 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v12/miner/unmarshall_test.go: -------------------------------------------------------------------------------- 1 | package miner 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/shorttermbons/go-state-types/abi" 10 | "github.com/shorttermbons/go-state-types/big" 11 | ) 12 | 13 | func TestCborVestingFunds(t *testing.T) { 14 | var vf = VestingFunds{ 15 | Funds: []VestingFund{ 16 | { 17 | Epoch: 1, 18 | Amount: big.NewInt(3), 19 | }, 20 | { 21 | Epoch: 2, 22 | Amount: big.NewInt(4), 23 | }, 24 | }, 25 | } 26 | buf := new(bytes.Buffer) 27 | err := vf.MarshalCBOR(buf) 28 | require.NoError(t, err) 29 | 30 | // Value taken from builtin-actors test. 31 | b := []byte{129, 130, 130, 1, 66, 0, 3, 130, 2, 66, 0, 4} 32 | 33 | require.Equal(t, b, buf.Bytes()) 34 | 35 | var vf2 VestingFunds 36 | err = vf2.UnmarshalCBOR(bytes.NewReader(b)) 37 | require.NoError(t, err) 38 | require.Equal(t, abi.ChainEpoch(1), vf2.Funds[0].Epoch) 39 | require.Equal(t, abi.ChainEpoch(2), vf2.Funds[1].Epoch) 40 | require.Equal(t, big.NewInt(3), vf2.Funds[0].Amount) 41 | require.Equal(t, big.NewInt(4), vf2.Funds[1].Amount) 42 | } 43 | -------------------------------------------------------------------------------- /builtin/v12/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v12/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v12/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v12/placeholder/methods.go: -------------------------------------------------------------------------------- 1 | package placeholder 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | // Placeholder has no methods, not even a constructor 9 | var Methods = map[abi.MethodNum]builtin.MethodMeta{} 10 | -------------------------------------------------------------------------------- /builtin/v12/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v12/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v12/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v12/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v12/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/ipfs/go-cid" 7 | "golang.org/x/xerrors" 8 | 9 | "github.com/shorttermbons/go-state-types/builtin/v12/util/adt" 10 | "github.com/shorttermbons/go-state-types/manifest" 11 | ) 12 | 13 | type State struct { 14 | BuiltinActors cid.Cid // ManifestData 15 | } 16 | 17 | func ConstructState(store adt.Store) (*State, error) { 18 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 19 | if err != nil { 20 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 21 | } 22 | 23 | return &State{BuiltinActors: empty}, nil 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v12/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v12/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v12/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v12/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | 17 | const MinimumVerifiedAllocationSize = 1 << 20 18 | -------------------------------------------------------------------------------- /builtin/v13/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v13/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v13/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | type StateSummary struct { 9 | PubKeyAddr address.Address 10 | } 11 | 12 | // Checks internal invariants of account state. 13 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 14 | acc := &builtin.MessageAccumulator{} 15 | accountSummary := &StateSummary{ 16 | PubKeyAddr: st.Address, 17 | } 18 | 19 | if id, err := address.IDFromAddress(idAddr); err != nil { 20 | acc.Addf("error extracting actor ID from address: %v", err) 21 | } else if id >= builtin.FirstNonSingletonActorId { 22 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 23 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 24 | } 25 | 26 | return accountSummary, acc 27 | } 28 | -------------------------------------------------------------------------------- /builtin/v13/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | typegen "github.com/whyrusleeping/cbor-gen" 5 | 6 | "github.com/filecoin-project/go-address" 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | ) 10 | 11 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 12 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 13 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 14 | builtin.MustGenerateFRCMethodNum("AuthenticateMessage"): builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *typegen.CborBool)), // AuthenticateMessage 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v13/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v13/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v13/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | "github.com/shorttermbons/go-state-types/builtin/v13/util/adt" 7 | ) 8 | 9 | type StateSummary struct { 10 | EntryCount int 11 | } 12 | 13 | // Checks internal invariants of cron state. 14 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | cronSummary := &StateSummary{ 17 | EntryCount: len(st.Entries), 18 | } 19 | for i, e := range st.Entries { 20 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 21 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 22 | } 23 | return cronSummary, acc 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v13/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v13/eam/eam_types.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type CreateParams struct { 8 | Initcode []byte 9 | Nonce uint64 10 | } 11 | 12 | type Create2Params struct { 13 | Initcode []byte 14 | Salt [32]byte 15 | } 16 | 17 | type Return struct { 18 | ActorID uint64 19 | RobustAddress *address.Address 20 | EthAddress [20]byte 21 | } 22 | 23 | type CreateReturn Return 24 | type Create2Return Return 25 | type CreateExternalReturn Return 26 | -------------------------------------------------------------------------------- /builtin/v13/eam/methods.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Create", *new(func(*CreateParams) *CreateReturn)), // Create 11 | 3: builtin.NewMethodMeta("Create2", *new(func(*Create2Params) *Create2Return)), // Create2 12 | 4: builtin.NewMethodMeta("CreateExternal", *new(func(*abi.CborBytes) *CreateExternalReturn)), // CreateExternal 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v13/ethaccount/methods.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(value *abi.EmptyValue) *abi.EmptyValue)), 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v13/ethaccount/types.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v13/evm/evm_state.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | xerrors "golang.org/x/xerrors" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | "github.com/shorttermbons/go-state-types/builtin/v13/util/adt" 10 | ) 11 | 12 | type Tombstone struct { 13 | Origin abi.ActorID 14 | Nonce uint64 15 | } 16 | 17 | type State struct { 18 | Bytecode cid.Cid 19 | BytecodeHash [32]byte 20 | ContractState cid.Cid 21 | Nonce uint64 22 | Tombstone *Tombstone 23 | } 24 | 25 | func ConstructState(store adt.Store, bytecode cid.Cid) (*State, error) { 26 | emptyMapCid, err := adt.StoreEmptyMap(store, builtin.DefaultHamtBitwidth) 27 | if err != nil { 28 | return nil, xerrors.Errorf("failed to create empty map: %w", err) 29 | } 30 | 31 | return &State{ 32 | Bytecode: bytecode, 33 | ContractState: emptyMapCid, 34 | Nonce: 0, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /builtin/v13/evm/evm_types_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/ipfs/go-cid" 8 | "github.com/stretchr/testify/require" 9 | cbg "github.com/whyrusleeping/cbor-gen" 10 | ) 11 | 12 | func TestGetBytecodeReturn(t *testing.T) { 13 | randomCid, err := cid.Decode("bafy2bzacecu7n7wbtogznrtuuvf73dsz7wasgyneqasksdblxupnyovmtwxxu") 14 | require.NoError(t, err) 15 | 16 | var cidbuf bytes.Buffer 17 | require.NoError(t, cbg.WriteCid(&cidbuf, randomCid)) 18 | 19 | in := &GetBytecodeReturn{ 20 | Cid: &randomCid, 21 | } 22 | var buf bytes.Buffer 23 | require.NoError(t, in.MarshalCBOR(&buf)) 24 | require.Equal(t, cidbuf.Bytes(), buf.Bytes()) 25 | 26 | var out GetBytecodeReturn 27 | require.NoError(t, out.UnmarshalCBOR(&buf)) 28 | require.Equal(t, &randomCid, out.Cid) 29 | 30 | in.Cid = nil 31 | buf.Reset() 32 | require.NoError(t, in.MarshalCBOR(&buf)) 33 | require.Equal(t, cbg.CborNull, buf.Bytes()) 34 | 35 | require.NoError(t, out.UnmarshalCBOR(&buf)) 36 | require.Nil(t, out.Cid) 37 | } 38 | -------------------------------------------------------------------------------- /builtin/v13/evm/methods.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), 10 | 2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)), 11 | 3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)), 12 | 4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)), 13 | 5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)), 14 | 6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)), 15 | builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)), 16 | } 17 | -------------------------------------------------------------------------------- /builtin/v13/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | 6 | addr "github.com/filecoin-project/go-address" 7 | ) 8 | 9 | type ConstructorParams struct { 10 | NetworkName string 11 | } 12 | 13 | type ExecParams struct { 14 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 15 | ConstructorParams []byte 16 | } 17 | 18 | type ExecReturn struct { 19 | IDAddress addr.Address // The canonical ID-based address for the actor. 20 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 21 | } 22 | 23 | type Exec4Params struct { 24 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 25 | ConstructorParams []byte 26 | SubAddress []byte 27 | } 28 | 29 | type Exec4Return = ExecReturn 30 | -------------------------------------------------------------------------------- /builtin/v13/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | // TODO Are we exporting Exec4 12 | 3: builtin.NewMethodMeta("Exec4", *new(func(*Exec4Params) *ExecReturn)), // Exec4 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v13/miner/unmarshall_test.go: -------------------------------------------------------------------------------- 1 | package miner 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/shorttermbons/go-state-types/abi" 10 | "github.com/shorttermbons/go-state-types/big" 11 | ) 12 | 13 | func TestCborVestingFunds(t *testing.T) { 14 | var vf = VestingFunds{ 15 | Funds: []VestingFund{ 16 | { 17 | Epoch: 1, 18 | Amount: big.NewInt(3), 19 | }, 20 | { 21 | Epoch: 2, 22 | Amount: big.NewInt(4), 23 | }, 24 | }, 25 | } 26 | buf := new(bytes.Buffer) 27 | err := vf.MarshalCBOR(buf) 28 | require.NoError(t, err) 29 | 30 | // Value taken from builtin-actors test. 31 | b := []byte{129, 130, 130, 1, 66, 0, 3, 130, 2, 66, 0, 4} 32 | 33 | require.Equal(t, b, buf.Bytes()) 34 | 35 | var vf2 VestingFunds 36 | err = vf2.UnmarshalCBOR(bytes.NewReader(b)) 37 | require.NoError(t, err) 38 | require.Equal(t, abi.ChainEpoch(1), vf2.Funds[0].Epoch) 39 | require.Equal(t, abi.ChainEpoch(2), vf2.Funds[1].Epoch) 40 | require.Equal(t, big.NewInt(3), vf2.Funds[0].Amount) 41 | require.Equal(t, big.NewInt(4), vf2.Funds[1].Amount) 42 | } 43 | -------------------------------------------------------------------------------- /builtin/v13/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v13/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v13/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v13/placeholder/methods.go: -------------------------------------------------------------------------------- 1 | package placeholder 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | // Placeholder has no methods, not even a constructor 9 | var Methods = map[abi.MethodNum]builtin.MethodMeta{} 10 | -------------------------------------------------------------------------------- /builtin/v13/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v13/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v13/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v13/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v13/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/ipfs/go-cid" 7 | "golang.org/x/xerrors" 8 | 9 | "github.com/shorttermbons/go-state-types/builtin/v13/util/adt" 10 | "github.com/shorttermbons/go-state-types/manifest" 11 | ) 12 | 13 | type State struct { 14 | BuiltinActors cid.Cid // ManifestData 15 | } 16 | 17 | func ConstructState(store adt.Store) (*State, error) { 18 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 19 | if err != nil { 20 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 21 | } 22 | 23 | return &State{BuiltinActors: empty}, nil 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v13/util/adt/map_test.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | 9 | "github.com/shorttermbons/go-state-types/test_util" 10 | cbor "github.com/ipfs/go-ipld-cbor" 11 | 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestIsEmpty(t *testing.T) { 16 | m, err := MakeEmptyMap(WrapStore(context.Background(), cbor.NewCborStore(test_util.NewBlockStoreInMemory())), 5) 17 | require.NoError(t, err) 18 | 19 | isEmpty, err := m.IsEmpty() 20 | require.NoError(t, err) 21 | require.True(t, isEmpty) 22 | 23 | val := abi.CborString("val") 24 | require.NoError(t, m.Put(abi.IntKey(5), &val)) 25 | 26 | isEmpty, err = m.IsEmpty() 27 | require.NoError(t, err) 28 | require.False(t, isEmpty) 29 | } 30 | -------------------------------------------------------------------------------- /builtin/v13/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v13/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v13/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v13/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | 17 | const MinimumVerifiedAllocationSize = 1 << 20 18 | -------------------------------------------------------------------------------- /builtin/v14/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v14/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v14/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | type StateSummary struct { 9 | PubKeyAddr address.Address 10 | } 11 | 12 | // Checks internal invariants of account state. 13 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 14 | acc := &builtin.MessageAccumulator{} 15 | accountSummary := &StateSummary{ 16 | PubKeyAddr: st.Address, 17 | } 18 | 19 | if id, err := address.IDFromAddress(idAddr); err != nil { 20 | acc.Addf("error extracting actor ID from address: %v", err) 21 | } else if id >= builtin.FirstNonSingletonActorId { 22 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 23 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 24 | } 25 | 26 | return accountSummary, acc 27 | } 28 | -------------------------------------------------------------------------------- /builtin/v14/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | typegen "github.com/whyrusleeping/cbor-gen" 5 | 6 | "github.com/filecoin-project/go-address" 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | ) 10 | 11 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 12 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 13 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 14 | builtin.MustGenerateFRCMethodNum("AuthenticateMessage"): builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *typegen.CborBool)), // AuthenticateMessage 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v14/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v14/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v14/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | "github.com/shorttermbons/go-state-types/builtin/v14/util/adt" 7 | ) 8 | 9 | type StateSummary struct { 10 | EntryCount int 11 | } 12 | 13 | // Checks internal invariants of cron state. 14 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | cronSummary := &StateSummary{ 17 | EntryCount: len(st.Entries), 18 | } 19 | for i, e := range st.Entries { 20 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 21 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 22 | } 23 | return cronSummary, acc 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v14/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v14/eam/eam_types.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type CreateParams struct { 8 | Initcode []byte 9 | Nonce uint64 10 | } 11 | 12 | type Create2Params struct { 13 | Initcode []byte 14 | Salt [32]byte 15 | } 16 | 17 | type Return struct { 18 | ActorID uint64 19 | RobustAddress *address.Address 20 | EthAddress [20]byte 21 | } 22 | 23 | type CreateReturn Return 24 | type Create2Return Return 25 | type CreateExternalReturn Return 26 | -------------------------------------------------------------------------------- /builtin/v14/eam/methods.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Create", *new(func(*CreateParams) *CreateReturn)), // Create 11 | 3: builtin.NewMethodMeta("Create2", *new(func(*Create2Params) *Create2Return)), // Create2 12 | 4: builtin.NewMethodMeta("CreateExternal", *new(func(*abi.CborBytes) *CreateExternalReturn)), // CreateExternal 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v14/ethaccount/methods.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(value *abi.EmptyValue) *abi.EmptyValue)), 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v14/ethaccount/types.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v14/evm/evm_state.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | xerrors "golang.org/x/xerrors" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | "github.com/shorttermbons/go-state-types/builtin/v14/util/adt" 10 | ) 11 | 12 | type Tombstone struct { 13 | Origin abi.ActorID 14 | Nonce uint64 15 | } 16 | 17 | type State struct { 18 | Bytecode cid.Cid 19 | BytecodeHash [32]byte 20 | ContractState cid.Cid 21 | Nonce uint64 22 | Tombstone *Tombstone 23 | } 24 | 25 | func ConstructState(store adt.Store, bytecode cid.Cid) (*State, error) { 26 | emptyMapCid, err := adt.StoreEmptyMap(store, builtin.DefaultHamtBitwidth) 27 | if err != nil { 28 | return nil, xerrors.Errorf("failed to create empty map: %w", err) 29 | } 30 | 31 | return &State{ 32 | Bytecode: bytecode, 33 | ContractState: emptyMapCid, 34 | Nonce: 0, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /builtin/v14/evm/evm_types_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/ipfs/go-cid" 8 | "github.com/stretchr/testify/require" 9 | cbg "github.com/whyrusleeping/cbor-gen" 10 | ) 11 | 12 | func TestGetBytecodeReturn(t *testing.T) { 13 | randomCid, err := cid.Decode("bafy2bzacecu7n7wbtogznrtuuvf73dsz7wasgyneqasksdblxupnyovmtwxxu") 14 | require.NoError(t, err) 15 | 16 | var cidbuf bytes.Buffer 17 | require.NoError(t, cbg.WriteCid(&cidbuf, randomCid)) 18 | 19 | in := &GetBytecodeReturn{ 20 | Cid: &randomCid, 21 | } 22 | var buf bytes.Buffer 23 | require.NoError(t, in.MarshalCBOR(&buf)) 24 | require.Equal(t, cidbuf.Bytes(), buf.Bytes()) 25 | 26 | var out GetBytecodeReturn 27 | require.NoError(t, out.UnmarshalCBOR(&buf)) 28 | require.Equal(t, &randomCid, out.Cid) 29 | 30 | in.Cid = nil 31 | buf.Reset() 32 | require.NoError(t, in.MarshalCBOR(&buf)) 33 | require.Equal(t, cbg.CborNull, buf.Bytes()) 34 | 35 | require.NoError(t, out.UnmarshalCBOR(&buf)) 36 | require.Nil(t, out.Cid) 37 | } 38 | -------------------------------------------------------------------------------- /builtin/v14/evm/methods.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), 10 | 2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)), 11 | 3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)), 12 | 4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)), 13 | 5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)), 14 | 6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)), 15 | builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)), 16 | } 17 | -------------------------------------------------------------------------------- /builtin/v14/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | 6 | addr "github.com/filecoin-project/go-address" 7 | ) 8 | 9 | type ConstructorParams struct { 10 | NetworkName string 11 | } 12 | 13 | type ExecParams struct { 14 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 15 | ConstructorParams []byte 16 | } 17 | 18 | type ExecReturn struct { 19 | IDAddress addr.Address // The canonical ID-based address for the actor. 20 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 21 | } 22 | 23 | type Exec4Params struct { 24 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 25 | ConstructorParams []byte 26 | SubAddress []byte 27 | } 28 | 29 | type Exec4Return = ExecReturn 30 | -------------------------------------------------------------------------------- /builtin/v14/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | // TODO Are we exporting Exec4 12 | 3: builtin.NewMethodMeta("Exec4", *new(func(*Exec4Params) *ExecReturn)), // Exec4 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v14/miner/unmarshall_test.go: -------------------------------------------------------------------------------- 1 | package miner 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/shorttermbons/go-state-types/abi" 10 | "github.com/shorttermbons/go-state-types/big" 11 | ) 12 | 13 | func TestCborVestingFunds(t *testing.T) { 14 | var vf = VestingFunds{ 15 | Funds: []VestingFund{ 16 | { 17 | Epoch: 1, 18 | Amount: big.NewInt(3), 19 | }, 20 | { 21 | Epoch: 2, 22 | Amount: big.NewInt(4), 23 | }, 24 | }, 25 | } 26 | buf := new(bytes.Buffer) 27 | err := vf.MarshalCBOR(buf) 28 | require.NoError(t, err) 29 | 30 | // Value taken from builtin-actors test. 31 | b := []byte{129, 130, 130, 1, 66, 0, 3, 130, 2, 66, 0, 4} 32 | 33 | require.Equal(t, b, buf.Bytes()) 34 | 35 | var vf2 VestingFunds 36 | err = vf2.UnmarshalCBOR(bytes.NewReader(b)) 37 | require.NoError(t, err) 38 | require.Equal(t, abi.ChainEpoch(1), vf2.Funds[0].Epoch) 39 | require.Equal(t, abi.ChainEpoch(2), vf2.Funds[1].Epoch) 40 | require.Equal(t, big.NewInt(3), vf2.Funds[0].Amount) 41 | require.Equal(t, big.NewInt(4), vf2.Funds[1].Amount) 42 | } 43 | -------------------------------------------------------------------------------- /builtin/v14/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v14/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v14/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v14/placeholder/methods.go: -------------------------------------------------------------------------------- 1 | package placeholder 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | // Placeholder has no methods, not even a constructor 9 | var Methods = map[abi.MethodNum]builtin.MethodMeta{} 10 | -------------------------------------------------------------------------------- /builtin/v14/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v14/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v14/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v14/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v14/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/ipfs/go-cid" 7 | "golang.org/x/xerrors" 8 | 9 | "github.com/shorttermbons/go-state-types/builtin/v14/util/adt" 10 | "github.com/shorttermbons/go-state-types/manifest" 11 | ) 12 | 13 | type State struct { 14 | BuiltinActors cid.Cid // ManifestData 15 | } 16 | 17 | func ConstructState(store adt.Store) (*State, error) { 18 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 19 | if err != nil { 20 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 21 | } 22 | 23 | return &State{BuiltinActors: empty}, nil 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v14/util/adt/map_test.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | 9 | "github.com/shorttermbons/go-state-types/test_util" 10 | cbor "github.com/ipfs/go-ipld-cbor" 11 | 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestIsEmpty(t *testing.T) { 16 | m, err := MakeEmptyMap(WrapStore(context.Background(), cbor.NewCborStore(test_util.NewBlockStoreInMemory())), 5) 17 | require.NoError(t, err) 18 | 19 | isEmpty, err := m.IsEmpty() 20 | require.NoError(t, err) 21 | require.True(t, isEmpty) 22 | 23 | val := abi.CborString("val") 24 | require.NoError(t, m.Put(abi.IntKey(5), &val)) 25 | 26 | isEmpty, err = m.IsEmpty() 27 | require.NoError(t, err) 28 | require.False(t, isEmpty) 29 | } 30 | -------------------------------------------------------------------------------- /builtin/v14/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v14/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v14/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v14/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | 17 | const MinimumVerifiedAllocationSize = 1 << 20 18 | -------------------------------------------------------------------------------- /builtin/v15/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v15/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v15/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | type StateSummary struct { 9 | PubKeyAddr address.Address 10 | } 11 | 12 | // Checks internal invariants of account state. 13 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 14 | acc := &builtin.MessageAccumulator{} 15 | accountSummary := &StateSummary{ 16 | PubKeyAddr: st.Address, 17 | } 18 | 19 | if id, err := address.IDFromAddress(idAddr); err != nil { 20 | acc.Addf("error extracting actor ID from address: %v", err) 21 | } else if id >= builtin.FirstNonSingletonActorId { 22 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 23 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 24 | } 25 | 26 | return accountSummary, acc 27 | } 28 | -------------------------------------------------------------------------------- /builtin/v15/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | typegen "github.com/whyrusleeping/cbor-gen" 5 | 6 | "github.com/filecoin-project/go-address" 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | ) 10 | 11 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 12 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 13 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 14 | builtin.MustGenerateFRCMethodNum("AuthenticateMessage"): builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *typegen.CborBool)), // AuthenticateMessage 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v15/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v15/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v15/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | "github.com/shorttermbons/go-state-types/builtin/v15/util/adt" 7 | ) 8 | 9 | type StateSummary struct { 10 | EntryCount int 11 | } 12 | 13 | // Checks internal invariants of cron state. 14 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | cronSummary := &StateSummary{ 17 | EntryCount: len(st.Entries), 18 | } 19 | for i, e := range st.Entries { 20 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 21 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 22 | } 23 | return cronSummary, acc 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v15/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v15/eam/eam_types.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type CreateParams struct { 8 | Initcode []byte 9 | Nonce uint64 10 | } 11 | 12 | type Create2Params struct { 13 | Initcode []byte 14 | Salt [32]byte 15 | } 16 | 17 | type Return struct { 18 | ActorID uint64 19 | RobustAddress *address.Address 20 | EthAddress [20]byte 21 | } 22 | 23 | type CreateReturn Return 24 | type Create2Return Return 25 | type CreateExternalReturn Return 26 | -------------------------------------------------------------------------------- /builtin/v15/eam/methods.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Create", *new(func(*CreateParams) *CreateReturn)), // Create 11 | 3: builtin.NewMethodMeta("Create2", *new(func(*Create2Params) *Create2Return)), // Create2 12 | 4: builtin.NewMethodMeta("CreateExternal", *new(func(*abi.CborBytes) *CreateExternalReturn)), // CreateExternal 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v15/ethaccount/methods.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(value *abi.EmptyValue) *abi.EmptyValue)), 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v15/ethaccount/types.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v15/evm/evm_state.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | xerrors "golang.org/x/xerrors" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | "github.com/shorttermbons/go-state-types/builtin/v15/util/adt" 10 | ) 11 | 12 | type Tombstone struct { 13 | Origin abi.ActorID 14 | Nonce uint64 15 | } 16 | 17 | type State struct { 18 | Bytecode cid.Cid 19 | BytecodeHash [32]byte 20 | ContractState cid.Cid 21 | Nonce uint64 22 | Tombstone *Tombstone 23 | } 24 | 25 | func ConstructState(store adt.Store, bytecode cid.Cid) (*State, error) { 26 | emptyMapCid, err := adt.StoreEmptyMap(store, builtin.DefaultHamtBitwidth) 27 | if err != nil { 28 | return nil, xerrors.Errorf("failed to create empty map: %w", err) 29 | } 30 | 31 | return &State{ 32 | Bytecode: bytecode, 33 | ContractState: emptyMapCid, 34 | Nonce: 0, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /builtin/v15/evm/evm_types_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/ipfs/go-cid" 8 | "github.com/stretchr/testify/require" 9 | cbg "github.com/whyrusleeping/cbor-gen" 10 | ) 11 | 12 | func TestGetBytecodeReturn(t *testing.T) { 13 | randomCid, err := cid.Decode("bafy2bzacecu7n7wbtogznrtuuvf73dsz7wasgyneqasksdblxupnyovmtwxxu") 14 | require.NoError(t, err) 15 | 16 | var cidbuf bytes.Buffer 17 | require.NoError(t, cbg.WriteCid(&cidbuf, randomCid)) 18 | 19 | in := &GetBytecodeReturn{ 20 | Cid: &randomCid, 21 | } 22 | var buf bytes.Buffer 23 | require.NoError(t, in.MarshalCBOR(&buf)) 24 | require.Equal(t, cidbuf.Bytes(), buf.Bytes()) 25 | 26 | var out GetBytecodeReturn 27 | require.NoError(t, out.UnmarshalCBOR(&buf)) 28 | require.Equal(t, &randomCid, out.Cid) 29 | 30 | in.Cid = nil 31 | buf.Reset() 32 | require.NoError(t, in.MarshalCBOR(&buf)) 33 | require.Equal(t, cbg.CborNull, buf.Bytes()) 34 | 35 | require.NoError(t, out.UnmarshalCBOR(&buf)) 36 | require.Nil(t, out.Cid) 37 | } 38 | -------------------------------------------------------------------------------- /builtin/v15/evm/methods.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), 10 | 2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)), 11 | 3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)), 12 | 4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)), 13 | 5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)), 14 | 6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)), 15 | builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)), 16 | } 17 | -------------------------------------------------------------------------------- /builtin/v15/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | 6 | addr "github.com/filecoin-project/go-address" 7 | ) 8 | 9 | type ConstructorParams struct { 10 | NetworkName string 11 | } 12 | 13 | type ExecParams struct { 14 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 15 | ConstructorParams []byte 16 | } 17 | 18 | type ExecReturn struct { 19 | IDAddress addr.Address // The canonical ID-based address for the actor. 20 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 21 | } 22 | 23 | type Exec4Params struct { 24 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 25 | ConstructorParams []byte 26 | SubAddress []byte 27 | } 28 | 29 | type Exec4Return = ExecReturn 30 | -------------------------------------------------------------------------------- /builtin/v15/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | // TODO Are we exporting Exec4 12 | 3: builtin.NewMethodMeta("Exec4", *new(func(*Exec4Params) *ExecReturn)), // Exec4 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v15/miner/unmarshall_test.go: -------------------------------------------------------------------------------- 1 | package miner 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/shorttermbons/go-state-types/abi" 10 | "github.com/shorttermbons/go-state-types/big" 11 | ) 12 | 13 | func TestCborVestingFunds(t *testing.T) { 14 | var vf = VestingFunds{ 15 | Funds: []VestingFund{ 16 | { 17 | Epoch: 1, 18 | Amount: big.NewInt(3), 19 | }, 20 | { 21 | Epoch: 2, 22 | Amount: big.NewInt(4), 23 | }, 24 | }, 25 | } 26 | buf := new(bytes.Buffer) 27 | err := vf.MarshalCBOR(buf) 28 | require.NoError(t, err) 29 | 30 | // Value taken from builtin-actors test. 31 | b := []byte{129, 130, 130, 1, 66, 0, 3, 130, 2, 66, 0, 4} 32 | 33 | require.Equal(t, b, buf.Bytes()) 34 | 35 | var vf2 VestingFunds 36 | err = vf2.UnmarshalCBOR(bytes.NewReader(b)) 37 | require.NoError(t, err) 38 | require.Equal(t, abi.ChainEpoch(1), vf2.Funds[0].Epoch) 39 | require.Equal(t, abi.ChainEpoch(2), vf2.Funds[1].Epoch) 40 | require.Equal(t, big.NewInt(3), vf2.Funds[0].Amount) 41 | require.Equal(t, big.NewInt(4), vf2.Funds[1].Amount) 42 | } 43 | -------------------------------------------------------------------------------- /builtin/v15/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v15/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v15/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v15/placeholder/methods.go: -------------------------------------------------------------------------------- 1 | package placeholder 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | // Placeholder has no methods, not even a constructor 9 | var Methods = map[abi.MethodNum]builtin.MethodMeta{} 10 | -------------------------------------------------------------------------------- /builtin/v15/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v15/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v15/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v15/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v15/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/ipfs/go-cid" 7 | "golang.org/x/xerrors" 8 | 9 | "github.com/shorttermbons/go-state-types/builtin/v15/util/adt" 10 | "github.com/shorttermbons/go-state-types/manifest" 11 | ) 12 | 13 | type State struct { 14 | BuiltinActors cid.Cid // ManifestData 15 | } 16 | 17 | func ConstructState(store adt.Store) (*State, error) { 18 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 19 | if err != nil { 20 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 21 | } 22 | 23 | return &State{BuiltinActors: empty}, nil 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v15/util/adt/map_test.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | 9 | "github.com/shorttermbons/go-state-types/test_util" 10 | cbor "github.com/ipfs/go-ipld-cbor" 11 | 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestIsEmpty(t *testing.T) { 16 | m, err := MakeEmptyMap(WrapStore(context.Background(), cbor.NewCborStore(test_util.NewBlockStoreInMemory())), 5) 17 | require.NoError(t, err) 18 | 19 | isEmpty, err := m.IsEmpty() 20 | require.NoError(t, err) 21 | require.True(t, isEmpty) 22 | 23 | val := abi.CborString("val") 24 | require.NoError(t, m.Put(abi.IntKey(5), &val)) 25 | 26 | isEmpty, err = m.IsEmpty() 27 | require.NoError(t, err) 28 | require.False(t, isEmpty) 29 | } 30 | -------------------------------------------------------------------------------- /builtin/v15/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v15/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v15/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v15/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | 17 | const MinimumVerifiedAllocationSize = 1 << 20 18 | -------------------------------------------------------------------------------- /builtin/v16/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v16/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v16/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | type StateSummary struct { 9 | PubKeyAddr address.Address 10 | } 11 | 12 | // Checks internal invariants of account state. 13 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 14 | acc := &builtin.MessageAccumulator{} 15 | accountSummary := &StateSummary{ 16 | PubKeyAddr: st.Address, 17 | } 18 | 19 | if id, err := address.IDFromAddress(idAddr); err != nil { 20 | acc.Addf("error extracting actor ID from address: %v", err) 21 | } else if id >= builtin.FirstNonSingletonActorId { 22 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 23 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 24 | } 25 | 26 | return accountSummary, acc 27 | } 28 | -------------------------------------------------------------------------------- /builtin/v16/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | typegen "github.com/whyrusleeping/cbor-gen" 5 | 6 | "github.com/filecoin-project/go-address" 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | ) 10 | 11 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 12 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 13 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 14 | builtin.MustGenerateFRCMethodNum("AuthenticateMessage"): builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *typegen.CborBool)), // AuthenticateMessage 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v16/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v16/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v16/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | "github.com/shorttermbons/go-state-types/builtin/v16/util/adt" 7 | ) 8 | 9 | type StateSummary struct { 10 | EntryCount int 11 | } 12 | 13 | // Checks internal invariants of cron state. 14 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | cronSummary := &StateSummary{ 17 | EntryCount: len(st.Entries), 18 | } 19 | for i, e := range st.Entries { 20 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 21 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 22 | } 23 | return cronSummary, acc 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v16/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v16/eam/eam_types.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type CreateParams struct { 8 | Initcode []byte 9 | Nonce uint64 10 | } 11 | 12 | type Create2Params struct { 13 | Initcode []byte 14 | Salt [32]byte 15 | } 16 | 17 | type Return struct { 18 | ActorID uint64 19 | RobustAddress *address.Address 20 | EthAddress [20]byte 21 | } 22 | 23 | type CreateReturn Return 24 | type Create2Return Return 25 | type CreateExternalReturn Return 26 | -------------------------------------------------------------------------------- /builtin/v16/eam/methods.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Create", *new(func(*CreateParams) *CreateReturn)), // Create 11 | 3: builtin.NewMethodMeta("Create2", *new(func(*Create2Params) *Create2Return)), // Create2 12 | 4: builtin.NewMethodMeta("CreateExternal", *new(func(*abi.CborBytes) *CreateExternalReturn)), // CreateExternal 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v16/ethaccount/methods.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(value *abi.EmptyValue) *abi.EmptyValue)), 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v16/ethaccount/types.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v16/evm/evm_types_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/ipfs/go-cid" 8 | "github.com/stretchr/testify/require" 9 | cbg "github.com/whyrusleeping/cbor-gen" 10 | ) 11 | 12 | func TestGetBytecodeReturn(t *testing.T) { 13 | randomCid, err := cid.Decode("bafy2bzacecu7n7wbtogznrtuuvf73dsz7wasgyneqasksdblxupnyovmtwxxu") 14 | require.NoError(t, err) 15 | 16 | var cidbuf bytes.Buffer 17 | require.NoError(t, cbg.WriteCid(&cidbuf, randomCid)) 18 | 19 | in := &GetBytecodeReturn{ 20 | Cid: &randomCid, 21 | } 22 | var buf bytes.Buffer 23 | require.NoError(t, in.MarshalCBOR(&buf)) 24 | require.Equal(t, cidbuf.Bytes(), buf.Bytes()) 25 | 26 | var out GetBytecodeReturn 27 | require.NoError(t, out.UnmarshalCBOR(&buf)) 28 | require.Equal(t, &randomCid, out.Cid) 29 | 30 | in.Cid = nil 31 | buf.Reset() 32 | require.NoError(t, in.MarshalCBOR(&buf)) 33 | require.Equal(t, cbg.CborNull, buf.Bytes()) 34 | 35 | require.NoError(t, out.UnmarshalCBOR(&buf)) 36 | require.Nil(t, out.Cid) 37 | } 38 | -------------------------------------------------------------------------------- /builtin/v16/evm/methods.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), 10 | 2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)), 11 | 3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)), 12 | 4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)), 13 | 5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)), 14 | 6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)), 15 | builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)), 16 | } 17 | -------------------------------------------------------------------------------- /builtin/v16/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | 6 | addr "github.com/filecoin-project/go-address" 7 | ) 8 | 9 | type ConstructorParams struct { 10 | NetworkName string 11 | } 12 | 13 | type ExecParams struct { 14 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 15 | ConstructorParams []byte 16 | } 17 | 18 | type ExecReturn struct { 19 | IDAddress addr.Address // The canonical ID-based address for the actor. 20 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 21 | } 22 | 23 | type Exec4Params struct { 24 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 25 | ConstructorParams []byte 26 | SubAddress []byte 27 | } 28 | 29 | type Exec4Return = ExecReturn 30 | -------------------------------------------------------------------------------- /builtin/v16/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | // TODO Are we exporting Exec4 12 | 3: builtin.NewMethodMeta("Exec4", *new(func(*Exec4Params) *ExecReturn)), // Exec4 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v16/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v16/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v16/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v16/placeholder/methods.go: -------------------------------------------------------------------------------- 1 | package placeholder 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | // Placeholder has no methods, not even a constructor 9 | var Methods = map[abi.MethodNum]builtin.MethodMeta{} 10 | -------------------------------------------------------------------------------- /builtin/v16/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v16/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v16/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v16/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v16/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/ipfs/go-cid" 7 | "golang.org/x/xerrors" 8 | 9 | "github.com/shorttermbons/go-state-types/builtin/v16/util/adt" 10 | "github.com/shorttermbons/go-state-types/manifest" 11 | ) 12 | 13 | type State struct { 14 | BuiltinActors cid.Cid // ManifestData 15 | } 16 | 17 | func ConstructState(store adt.Store) (*State, error) { 18 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 19 | if err != nil { 20 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 21 | } 22 | 23 | return &State{BuiltinActors: empty}, nil 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v16/util/adt/map_test.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | 9 | "github.com/shorttermbons/go-state-types/test_util" 10 | cbor "github.com/ipfs/go-ipld-cbor" 11 | 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestIsEmpty(t *testing.T) { 16 | m, err := MakeEmptyMap(WrapStore(context.Background(), cbor.NewCborStore(test_util.NewBlockStoreInMemory())), 5) 17 | require.NoError(t, err) 18 | 19 | isEmpty, err := m.IsEmpty() 20 | require.NoError(t, err) 21 | require.True(t, isEmpty) 22 | 23 | val := abi.CborString("val") 24 | require.NoError(t, m.Put(abi.IntKey(5), &val)) 25 | 26 | isEmpty, err = m.IsEmpty() 27 | require.NoError(t, err) 28 | require.False(t, isEmpty) 29 | } 30 | -------------------------------------------------------------------------------- /builtin/v16/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v16/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v16/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v16/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | 17 | const MinimumVerifiedAllocationSize = 1 << 20 18 | -------------------------------------------------------------------------------- /builtin/v17/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v17/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v17/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | type StateSummary struct { 9 | PubKeyAddr address.Address 10 | } 11 | 12 | // Checks internal invariants of account state. 13 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 14 | acc := &builtin.MessageAccumulator{} 15 | accountSummary := &StateSummary{ 16 | PubKeyAddr: st.Address, 17 | } 18 | 19 | if id, err := address.IDFromAddress(idAddr); err != nil { 20 | acc.Addf("error extracting actor ID from address: %v", err) 21 | } else if id >= builtin.FirstNonSingletonActorId { 22 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 23 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 24 | } 25 | 26 | return accountSummary, acc 27 | } 28 | -------------------------------------------------------------------------------- /builtin/v17/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | typegen "github.com/whyrusleeping/cbor-gen" 5 | 6 | "github.com/filecoin-project/go-address" 7 | "github.com/shorttermbons/go-state-types/abi" 8 | "github.com/shorttermbons/go-state-types/builtin" 9 | ) 10 | 11 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 12 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 13 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 14 | builtin.MustGenerateFRCMethodNum("AuthenticateMessage"): builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *typegen.CborBool)), // AuthenticateMessage 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v17/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v17/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v17/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | "github.com/shorttermbons/go-state-types/builtin/v17/util/adt" 7 | ) 8 | 9 | type StateSummary struct { 10 | EntryCount int 11 | } 12 | 13 | // Checks internal invariants of cron state. 14 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | cronSummary := &StateSummary{ 17 | EntryCount: len(st.Entries), 18 | } 19 | for i, e := range st.Entries { 20 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 21 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 22 | } 23 | return cronSummary, acc 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v17/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v17/eam/eam_types.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type CreateParams struct { 8 | Initcode []byte 9 | Nonce uint64 10 | } 11 | 12 | type Create2Params struct { 13 | Initcode []byte 14 | Salt [32]byte 15 | } 16 | 17 | type Return struct { 18 | ActorID uint64 19 | RobustAddress *address.Address 20 | EthAddress [20]byte 21 | } 22 | 23 | type CreateReturn Return 24 | type Create2Return Return 25 | type CreateExternalReturn Return 26 | -------------------------------------------------------------------------------- /builtin/v17/eam/methods.go: -------------------------------------------------------------------------------- 1 | package eam 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Create", *new(func(*CreateParams) *CreateReturn)), // Create 11 | 3: builtin.NewMethodMeta("Create2", *new(func(*Create2Params) *Create2Return)), // Create2 12 | 4: builtin.NewMethodMeta("CreateExternal", *new(func(*abi.CborBytes) *CreateExternalReturn)), // CreateExternal 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v17/ethaccount/methods.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(value *abi.EmptyValue) *abi.EmptyValue)), 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v17/ethaccount/types.go: -------------------------------------------------------------------------------- 1 | package ethaccount 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v17/evm/evm_types_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/ipfs/go-cid" 8 | "github.com/stretchr/testify/require" 9 | cbg "github.com/whyrusleeping/cbor-gen" 10 | ) 11 | 12 | func TestGetBytecodeReturn(t *testing.T) { 13 | randomCid, err := cid.Decode("bafy2bzacecu7n7wbtogznrtuuvf73dsz7wasgyneqasksdblxupnyovmtwxxu") 14 | require.NoError(t, err) 15 | 16 | var cidbuf bytes.Buffer 17 | require.NoError(t, cbg.WriteCid(&cidbuf, randomCid)) 18 | 19 | in := &GetBytecodeReturn{ 20 | Cid: &randomCid, 21 | } 22 | var buf bytes.Buffer 23 | require.NoError(t, in.MarshalCBOR(&buf)) 24 | require.Equal(t, cidbuf.Bytes(), buf.Bytes()) 25 | 26 | var out GetBytecodeReturn 27 | require.NoError(t, out.UnmarshalCBOR(&buf)) 28 | require.Equal(t, &randomCid, out.Cid) 29 | 30 | in.Cid = nil 31 | buf.Reset() 32 | require.NoError(t, in.MarshalCBOR(&buf)) 33 | require.Equal(t, cbg.CborNull, buf.Bytes()) 34 | 35 | require.NoError(t, out.UnmarshalCBOR(&buf)) 36 | require.Nil(t, out.Cid) 37 | } 38 | -------------------------------------------------------------------------------- /builtin/v17/evm/methods.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), 10 | 2: builtin.NewMethodMeta("Resurrect", *new(func(*ResurrectParams) *abi.EmptyValue)), 11 | 3: builtin.NewMethodMeta("GetBytecode", *new(func(*abi.EmptyValue) *GetBytecodeReturn)), 12 | 4: builtin.NewMethodMeta("GetBytecodeHash", *new(func(*abi.EmptyValue) *abi.CborBytes)), 13 | 5: builtin.NewMethodMeta("GetStorageAt", *new(func(*GetStorageAtParams) *abi.CborBytes)), 14 | 6: builtin.NewMethodMeta("InvokeContractDelegate", *new(func(params *DelegateCallParams) *abi.CborBytes)), 15 | builtin.MustGenerateFRCMethodNum("InvokeEVM"): builtin.NewMethodMeta("InvokeContract", *new(func(bytes *abi.CborBytes) *abi.CborBytes)), 16 | } 17 | -------------------------------------------------------------------------------- /builtin/v17/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/ipfs/go-cid" 5 | 6 | addr "github.com/filecoin-project/go-address" 7 | ) 8 | 9 | type ConstructorParams struct { 10 | NetworkName string 11 | } 12 | 13 | type ExecParams struct { 14 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 15 | ConstructorParams []byte 16 | } 17 | 18 | type ExecReturn struct { 19 | IDAddress addr.Address // The canonical ID-based address for the actor. 20 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 21 | } 22 | 23 | type Exec4Params struct { 24 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 25 | ConstructorParams []byte 26 | SubAddress []byte 27 | } 28 | 29 | type Exec4Return = ExecReturn 30 | -------------------------------------------------------------------------------- /builtin/v17/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | // TODO Are we exporting Exec4 12 | 3: builtin.NewMethodMeta("Exec4", *new(func(*Exec4Params) *ExecReturn)), // Exec4 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v17/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v17/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v17/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v17/placeholder/methods.go: -------------------------------------------------------------------------------- 1 | package placeholder 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | // Placeholder has no methods, not even a constructor 9 | var Methods = map[abi.MethodNum]builtin.MethodMeta{} 10 | -------------------------------------------------------------------------------- /builtin/v17/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v17/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v17/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v17/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v17/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/ipfs/go-cid" 7 | "golang.org/x/xerrors" 8 | 9 | "github.com/shorttermbons/go-state-types/builtin/v17/util/adt" 10 | "github.com/shorttermbons/go-state-types/manifest" 11 | ) 12 | 13 | type State struct { 14 | BuiltinActors cid.Cid // ManifestData 15 | } 16 | 17 | func ConstructState(store adt.Store) (*State, error) { 18 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 19 | if err != nil { 20 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 21 | } 22 | 23 | return &State{BuiltinActors: empty}, nil 24 | } 25 | -------------------------------------------------------------------------------- /builtin/v17/util/adt/map_test.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | 9 | "github.com/shorttermbons/go-state-types/test_util" 10 | cbor "github.com/ipfs/go-ipld-cbor" 11 | 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestIsEmpty(t *testing.T) { 16 | m, err := MakeEmptyMap(WrapStore(context.Background(), cbor.NewCborStore(test_util.NewBlockStoreInMemory())), 5) 17 | require.NoError(t, err) 18 | 19 | isEmpty, err := m.IsEmpty() 20 | require.NoError(t, err) 21 | require.True(t, isEmpty) 22 | 23 | val := abi.CborString("val") 24 | require.NoError(t, m.Put(abi.IntKey(5), &val)) 25 | 26 | isEmpty, err = m.IsEmpty() 27 | require.NoError(t, err) 28 | require.False(t, isEmpty) 29 | } 30 | -------------------------------------------------------------------------------- /builtin/v17/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v17/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v17/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v17/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | 17 | const MinimumVerifiedAllocationSize = 1 << 20 18 | -------------------------------------------------------------------------------- /builtin/v8/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v8/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type StateSummary struct { 10 | PubKeyAddr address.Address 11 | } 12 | 13 | // Checks internal invariants of account state. 14 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | accountSummary := &StateSummary{ 17 | PubKeyAddr: st.Address, 18 | } 19 | 20 | if id, err := address.IDFromAddress(idAddr); err != nil { 21 | acc.Addf("error extracting actor ID from address: %v", err) 22 | } else if id >= builtin.FirstNonSingletonActorId { 23 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 24 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 25 | } 26 | 27 | return accountSummary, acc 28 | } 29 | -------------------------------------------------------------------------------- /builtin/v8/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/abi" 7 | "github.com/shorttermbons/go-state-types/builtin" 8 | ) 9 | 10 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 11 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 12 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v8/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v8/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v8/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | "github.com/shorttermbons/go-state-types/builtin/v8/util/adt" 8 | ) 9 | 10 | type StateSummary struct { 11 | EntryCount int 12 | } 13 | 14 | // Checks internal invariants of cron state. 15 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 16 | acc := &builtin.MessageAccumulator{} 17 | cronSummary := &StateSummary{ 18 | EntryCount: len(st.Entries), 19 | } 20 | for i, e := range st.Entries { 21 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 22 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 23 | } 24 | return cronSummary, acc 25 | } 26 | -------------------------------------------------------------------------------- /builtin/v8/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v8/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/ipfs/go-cid" 6 | ) 7 | 8 | type ConstructorParams struct { 9 | NetworkName string 10 | } 11 | 12 | type ExecParams struct { 13 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 14 | ConstructorParams []byte 15 | } 16 | 17 | type ExecReturn struct { 18 | IDAddress addr.Address // The canonical ID-based address for the actor. 19 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 20 | } 21 | -------------------------------------------------------------------------------- /builtin/v8/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v8/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v8/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v8/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v8/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v8/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v8/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v8/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v8/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/shorttermbons/go-state-types/manifest" 7 | 8 | "github.com/shorttermbons/go-state-types/builtin/v8/util/adt" 9 | 10 | "github.com/ipfs/go-cid" 11 | "golang.org/x/xerrors" 12 | ) 13 | 14 | type State struct { 15 | BuiltinActors cid.Cid // ManifestData 16 | } 17 | 18 | func ConstructState(store adt.Store) (*State, error) { 19 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 20 | if err != nil { 21 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 22 | } 23 | 24 | return &State{BuiltinActors: empty}, nil 25 | } 26 | -------------------------------------------------------------------------------- /builtin/v8/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v8/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v8/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v8/verifreg/verifreg_types.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | ) 7 | 8 | type AddVerifierParams struct { 9 | Address addr.Address 10 | Allowance DataCap 11 | } 12 | 13 | type AddVerifiedClientParams struct { 14 | Address addr.Address 15 | Allowance DataCap 16 | } 17 | 18 | type UseBytesParams struct { 19 | Address addr.Address // Address of verified client. 20 | DealSize abi.StoragePower // Number of bytes to use. 21 | } 22 | 23 | type RestoreBytesParams struct { 24 | Address addr.Address 25 | DealSize abi.StoragePower 26 | } 27 | 28 | type RemoveDataCapParams struct { 29 | VerifiedClientToRemove addr.Address 30 | DataCapAmountToRemove DataCap 31 | VerifierRequest1 RemoveDataCapRequest 32 | VerifierRequest2 RemoveDataCapRequest 33 | } 34 | 35 | type RemoveDataCapReturn struct { 36 | VerifiedClient addr.Address 37 | DataCapRemoved DataCap 38 | } 39 | -------------------------------------------------------------------------------- /builtin/v9/account/account_state.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | ) 6 | 7 | type State struct { 8 | Address addr.Address 9 | } 10 | -------------------------------------------------------------------------------- /builtin/v9/account/account_types.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | type AuthenticateMessageParams struct { 4 | Signature []byte 5 | Message []byte 6 | } 7 | -------------------------------------------------------------------------------- /builtin/v9/account/invariants.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type StateSummary struct { 10 | PubKeyAddr address.Address 11 | } 12 | 13 | // Checks internal invariants of account state. 14 | func CheckStateInvariants(st *State, idAddr address.Address) (*StateSummary, *builtin.MessageAccumulator) { 15 | acc := &builtin.MessageAccumulator{} 16 | accountSummary := &StateSummary{ 17 | PubKeyAddr: st.Address, 18 | } 19 | 20 | if id, err := address.IDFromAddress(idAddr); err != nil { 21 | acc.Addf("error extracting actor ID from address: %v", err) 22 | } else if id >= builtin.FirstNonSingletonActorId { 23 | acc.Require(st.Address.Protocol() == address.BLS || st.Address.Protocol() == address.SECP256K1, 24 | "actor address %v must be BLS or SECP256K1 protocol", st.Address) 25 | } 26 | 27 | return accountSummary, acc 28 | } 29 | -------------------------------------------------------------------------------- /builtin/v9/account/methods.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/abi" 7 | "github.com/shorttermbons/go-state-types/builtin" 8 | ) 9 | 10 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 11 | 1: builtin.NewMethodMeta("Constructor", *new(func(*address.Address) *abi.EmptyValue)), // Constructor 12 | 2: builtin.NewMethodMeta("PubkeyAddress", *new(func(*abi.EmptyValue) *address.Address)), // PubkeyAddress 13 | 3: builtin.NewMethodMeta("AuthenticateMessage", *new(func(*AuthenticateMessageParams) *abi.EmptyValue)), // AuthenticateMessage 14 | builtin.MustGenerateFRCMethodNum("Receive"): builtin.NewMethodMeta("UniversalReceiverHook", *new(func(*abi.CborBytesTransparent) *abi.EmptyValue)), // UniversalReceiverHook 15 | } 16 | -------------------------------------------------------------------------------- /builtin/v9/cron/cron_state.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | ) 8 | 9 | type State struct { 10 | Entries []Entry 11 | } 12 | 13 | type Entry struct { 14 | Receiver addr.Address // The actor to call (must be an ID-address) 15 | MethodNum abi.MethodNum // The method number to call (must accept empty parameters) 16 | } 17 | 18 | func ConstructState(entries []Entry) *State { 19 | return &State{Entries: entries} 20 | } 21 | 22 | // The default entries to install in the cron actor's state at genesis. 23 | func BuiltInEntries() []Entry { 24 | return []Entry{ 25 | { 26 | Receiver: builtin.StoragePowerActorAddr, 27 | MethodNum: builtin.MethodsPower.CronTick, 28 | }, 29 | { 30 | Receiver: builtin.StorageMarketActorAddr, 31 | MethodNum: builtin.MethodsMarket.CronTick, 32 | }, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v9/cron/cron_types.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | type ConstructorParams struct { 4 | Entries []Entry 5 | } 6 | -------------------------------------------------------------------------------- /builtin/v9/cron/invariants.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin" 7 | "github.com/shorttermbons/go-state-types/builtin/v9/util/adt" 8 | ) 9 | 10 | type StateSummary struct { 11 | EntryCount int 12 | } 13 | 14 | // Checks internal invariants of cron state. 15 | func CheckStateInvariants(st *State, _ adt.Store) (*StateSummary, *builtin.MessageAccumulator) { 16 | acc := &builtin.MessageAccumulator{} 17 | cronSummary := &StateSummary{ 18 | EntryCount: len(st.Entries), 19 | } 20 | for i, e := range st.Entries { 21 | acc.Require(e.Receiver.Protocol() == address.ID, "entry %d receiver address %v must be ID protocol", i, e.Receiver) 22 | acc.Require(e.MethodNum > 0, "entry %d has invalid method number %d", i, e.MethodNum) 23 | } 24 | return cronSummary, acc 25 | } 26 | -------------------------------------------------------------------------------- /builtin/v9/cron/methods.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("EpochTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // EpochTick 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v9/init/init_actor_params.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | addr "github.com/filecoin-project/go-address" 5 | "github.com/ipfs/go-cid" 6 | ) 7 | 8 | type ConstructorParams struct { 9 | NetworkName string 10 | } 11 | 12 | type ExecParams struct { 13 | CodeCID cid.Cid `checked:"true"` // invalid CIDs won't get committed to the state tree 14 | ConstructorParams []byte 15 | } 16 | 17 | type ExecReturn struct { 18 | IDAddress addr.Address // The canonical ID-based address for the actor. 19 | RobustAddress addr.Address // A more expensive but re-org-safe address for the newly created actor. 20 | } 21 | -------------------------------------------------------------------------------- /builtin/v9/init/methods.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("Exec", *new(func(*ExecParams) *ExecReturn)), // Exec 11 | } 12 | -------------------------------------------------------------------------------- /builtin/v9/migration/system.go: -------------------------------------------------------------------------------- 1 | package migration 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/shorttermbons/go-state-types/builtin/v8/system" 7 | 8 | "github.com/ipfs/go-cid" 9 | cbor "github.com/ipfs/go-ipld-cbor" 10 | ) 11 | 12 | // System Actor migrator 13 | type systemActorMigrator struct { 14 | OutCodeCID cid.Cid 15 | ManifestData cid.Cid 16 | } 17 | 18 | func (m systemActorMigrator) migratedCodeCID() cid.Cid { 19 | return m.OutCodeCID 20 | } 21 | 22 | func (m systemActorMigrator) migrateState(ctx context.Context, store cbor.IpldStore, in actorMigrationInput) (*actorMigrationResult, error) { 23 | // The ManifestData itself is already in the blockstore 24 | state := system.State{BuiltinActors: m.ManifestData} 25 | stateHead, err := store.Put(ctx, &state) 26 | if err != nil { 27 | return nil, err 28 | } 29 | 30 | return &actorMigrationResult{ 31 | newCodeCID: m.OutCodeCID, 32 | newHead: stateHead, 33 | }, nil 34 | } 35 | -------------------------------------------------------------------------------- /builtin/v9/multisig/policy.go: -------------------------------------------------------------------------------- 1 | package multisig 2 | 3 | // SignersMax is the maximum number of signers allowed in a multisig. If more 4 | // are required, please use a combining tree of multisigs. 5 | const SignersMax = 256 6 | -------------------------------------------------------------------------------- /builtin/v9/paych/methods.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*ConstructorParams) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("UpdateChannelState", *new(func(*UpdateChannelStateParams) *abi.EmptyValue)), // UpdateChannelState 11 | 3: builtin.NewMethodMeta("Settle", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Settle 12 | 4: builtin.NewMethodMeta("Collect", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Collect 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v9/paych/policy.go: -------------------------------------------------------------------------------- 1 | package paych 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const SettleDelay = builtin.EpochsInHour * 12 8 | -------------------------------------------------------------------------------- /builtin/v9/reward/methods.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.StoragePower) *abi.EmptyValue)), // Constructor 10 | 2: builtin.NewMethodMeta("AwardBlockReward", *new(func(*AwardBlockRewardParams) *abi.EmptyValue)), // AwardBlockReward 11 | 3: builtin.NewMethodMeta("ThisEpochReward", *new(func(*abi.EmptyValue) *ThisEpochRewardReturn)), // ThisEpochReward 12 | 4: builtin.NewMethodMeta("UpdateNetworkKPI", *new(func(*abi.StoragePower) *abi.EmptyValue)), // UpdateNetworkKPI 13 | } 14 | -------------------------------------------------------------------------------- /builtin/v9/reward/reward_types.go: -------------------------------------------------------------------------------- 1 | package reward 2 | 3 | import ( 4 | "github.com/filecoin-project/go-address" 5 | "github.com/shorttermbons/go-state-types/abi" 6 | "github.com/shorttermbons/go-state-types/builtin/v9/util/smoothing" 7 | ) 8 | 9 | type AwardBlockRewardParams struct { 10 | Miner address.Address 11 | Penalty abi.TokenAmount // penalty for including bad messages in a block, >= 0 12 | GasReward abi.TokenAmount // gas reward from all gas fees in a block, >= 0 13 | WinCount int64 // number of reward units won, > 0 14 | } 15 | 16 | type ThisEpochRewardReturn struct { 17 | ThisEpochRewardSmoothed smoothing.FilterEstimate 18 | ThisEpochBaselinePower abi.StoragePower 19 | } 20 | -------------------------------------------------------------------------------- /builtin/v9/system/methods.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/abi" 5 | "github.com/shorttermbons/go-state-types/builtin" 6 | ) 7 | 8 | var Methods = map[abi.MethodNum]builtin.MethodMeta{ 9 | 1: builtin.NewMethodMeta("Constructor", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // Constructor 10 | } 11 | -------------------------------------------------------------------------------- /builtin/v9/system/system_actor_state.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/shorttermbons/go-state-types/manifest" 7 | 8 | "github.com/shorttermbons/go-state-types/builtin/v9/util/adt" 9 | 10 | "github.com/ipfs/go-cid" 11 | "golang.org/x/xerrors" 12 | ) 13 | 14 | type State struct { 15 | BuiltinActors cid.Cid // ManifestData 16 | } 17 | 18 | func ConstructState(store adt.Store) (*State, error) { 19 | empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) 20 | if err != nil { 21 | return nil, xerrors.Errorf("failed to create empty manifest: %w", err) 22 | } 23 | 24 | return &State{BuiltinActors: empty}, nil 25 | } 26 | -------------------------------------------------------------------------------- /builtin/v9/util/adt/store.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | // Store defines an interface required to back the ADTs in this package. 10 | type Store interface { 11 | Context() context.Context 12 | ipldcbor.IpldStore 13 | } 14 | 15 | // Adapts a vanilla IPLD store as an ADT store. 16 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 17 | return &wstore{ 18 | ctx: ctx, 19 | IpldStore: store, 20 | } 21 | } 22 | 23 | type wstore struct { 24 | ctx context.Context 25 | ipldcbor.IpldStore 26 | } 27 | 28 | var _ Store = &wstore{} 29 | 30 | func (s *wstore) Context() context.Context { 31 | return s.ctx 32 | } 33 | -------------------------------------------------------------------------------- /builtin/v9/util/math/parse.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // Parse a slice of strings (representing integers in decimal) 6 | // Convention: this function is to be applied to strings representing Q.128 fixed-point numbers, and thus returns numbers in binary Q.128 representation 7 | func Parse(coefs []string) []*big.Int { 8 | out := make([]*big.Int, len(coefs)) 9 | for i, coef := range coefs { 10 | c, ok := new(big.Int).SetString(coef, 10) 11 | if !ok { 12 | panic("could not parse q128 parameter") 13 | } 14 | // << 128 (Q.0 to Q.128) >> 128 to transform integer params to coefficients 15 | out[i] = c 16 | } 17 | return out 18 | } 19 | -------------------------------------------------------------------------------- /builtin/v9/util/math/polyval.go: -------------------------------------------------------------------------------- 1 | package math 2 | 3 | import "math/big" 4 | 5 | // note: all coefficients for which Polyval is used would need to be updated if this precision changes 6 | const Precision128 = 128 7 | 8 | // Polyval evaluates a polynomial given by coefficients `p` in Q.128 format 9 | // at point `x` in Q.128 format. Output is in Q.128. 10 | // Coefficients should be ordered from the highest order coefficient to the lowest. 11 | func Polyval(p []*big.Int, x *big.Int) *big.Int { 12 | // evaluation using Horner's method 13 | res := new(big.Int).Set(p[0]) // Q.128 14 | tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output 15 | for _, c := range p[1:] { 16 | tmp = tmp.Mul(res, x) // Q.128 * Q.128 => Q.256 17 | res = res.Rsh(tmp, Precision128) // Q.256 >> 128 => Q.128 18 | res = res.Add(res, c) 19 | } 20 | 21 | return res 22 | } 23 | -------------------------------------------------------------------------------- /builtin/v9/verifreg/policy.go: -------------------------------------------------------------------------------- 1 | package verifreg 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | ) 6 | 7 | const EndOfLifeClaimDropPeriod = 30 * builtin.EpochsInDay 8 | 9 | const MaximumVerifiedAllocationExpiration = 60 * builtin.EpochsInDay 10 | 11 | const MinimumVerifiedAllocationTerm = 180 * builtin.EpochsInDay 12 | 13 | const MaximumVerifiedAllocationTerm = 5 * builtin.EpochsInYear 14 | 15 | const NoAllocationID = AllocationId(0) 16 | -------------------------------------------------------------------------------- /cbor/cbor.go: -------------------------------------------------------------------------------- 1 | package cbor 2 | 3 | import "io" 4 | 5 | // These interfaces are intended to match those from whyrusleeping/cbor-gen, such that code generated from that 6 | // system is automatically usable here (but not mandatory). 7 | type Marshaler interface { 8 | MarshalCBOR(w io.Writer) error 9 | } 10 | 11 | type Unmarshaler interface { 12 | UnmarshalCBOR(r io.Reader) error 13 | } 14 | 15 | type Er interface { 16 | Marshaler 17 | Unmarshaler 18 | } 19 | -------------------------------------------------------------------------------- /crypto/randomness.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | // Specifies a domain for randomness generation. 4 | type DomainSeparationTag int64 5 | 6 | const ( 7 | DomainSeparationTag_TicketProduction DomainSeparationTag = 1 + iota 8 | DomainSeparationTag_ElectionProofProduction 9 | DomainSeparationTag_WinningPoStChallengeSeed 10 | DomainSeparationTag_WindowedPoStChallengeSeed 11 | DomainSeparationTag_SealRandomness 12 | DomainSeparationTag_InteractiveSealChallengeSeed 13 | DomainSeparationTag_WindowedPoStDeadlineAssignment 14 | DomainSeparationTag_MarketDealCronSeed 15 | DomainSeparationTag_PoStChainCommit 16 | ) 17 | -------------------------------------------------------------------------------- /gen/gen.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/builtin" 5 | gen "github.com/whyrusleeping/cbor-gen" 6 | 7 | "github.com/shorttermbons/go-state-types/abi" 8 | ) 9 | 10 | func main() { 11 | // Common types 12 | if err := gen.WriteTupleEncodersToFile("./abi/cbor_gen.go", "abi", 13 | abi.PieceInfo{}, 14 | abi.SectorID{}, 15 | abi.AddrPairKey{}, 16 | abi.DealIDList{}, 17 | ); err != nil { 18 | panic(err) 19 | } 20 | if err := gen.WriteTupleEncodersToFile("./builtin/cbor_gen.go", "builtin", 21 | builtin.ActorV4{}, 22 | builtin.ActorV5{}, 23 | ); err != nil { 24 | panic(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /manifest/gen/gen.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/manifest" 5 | gen "github.com/whyrusleeping/cbor-gen" 6 | ) 7 | 8 | func main() { 9 | // Actor manifest 10 | if err := gen.WriteTupleEncodersToFile("./manifest/cbor_gen.go", "manifest", 11 | // actor manifest 12 | manifest.Manifest{}, 13 | manifest.ManifestEntry{}, 14 | ); err != nil { 15 | panic(err) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /proof/gen/gen.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/shorttermbons/go-state-types/proof" 5 | gen "github.com/whyrusleeping/cbor-gen" 6 | ) 7 | 8 | func main() { 9 | // Actor manifest 10 | if err := gen.WriteTupleEncodersToFile("./proof/cbor_gen.go", "proof", 11 | // actor manifest 12 | proof.PoStProof{}, 13 | proof.SectorInfo{}, 14 | proof.ExtendedSectorInfo{}, 15 | proof.WinningPoStVerifyInfo{}, 16 | proof.WindowPoStVerifyInfo{}, 17 | proof.SealVerifyInfo{}, 18 | proof.AggregateSealVerifyInfo{}, 19 | proof.AggregateSealVerifyProofAndInfos{}, 20 | proof.ReplicaUpdateInfo{}, 21 | ); err != nil { 22 | panic(err) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /rt/log.go: -------------------------------------------------------------------------------- 1 | package rt 2 | 3 | // Specifies importance of message, LogLevel numbering is consistent with the uber-go/zap package. 4 | type LogLevel int 5 | 6 | const ( 7 | // DebugLevel logs are typically voluminous, and are usually disabled in 8 | // production. 9 | DEBUG LogLevel = iota - 1 10 | // InfoLevel is the default logging priority. 11 | INFO 12 | // WarnLevel logs are more important than Info, but don't need individual 13 | // human review. 14 | WARN 15 | // ErrorLevel logs are high-priority. If an application is running smoothly, 16 | // it shouldn't generate any error-level logs. 17 | ERROR 18 | ) 19 | -------------------------------------------------------------------------------- /store/ctx_store.go: -------------------------------------------------------------------------------- 1 | package store 2 | 3 | import ( 4 | "context" 5 | 6 | ipldcbor "github.com/ipfs/go-ipld-cbor" 7 | ) 8 | 9 | type Store interface { 10 | Context() context.Context 11 | ipldcbor.IpldStore 12 | } 13 | 14 | // WrapStore Adapts a vanilla IPLD store as an ADT store. 15 | func WrapStore(ctx context.Context, store ipldcbor.IpldStore) Store { 16 | return &wstore{ 17 | ctx: ctx, 18 | IpldStore: store, 19 | } 20 | } 21 | 22 | // WrapBlockStore Adapts a block store as an ADT store. 23 | func WrapBlockStore(ctx context.Context, bs ipldcbor.IpldBlockstore) Store { 24 | return WrapStore(ctx, ipldcbor.NewCborStore(bs)) 25 | } 26 | 27 | type wstore struct { 28 | ctx context.Context 29 | ipldcbor.IpldStore 30 | } 31 | 32 | var _ Store = &wstore{} 33 | 34 | func (s *wstore) Context() context.Context { 35 | return s.ctx 36 | } 37 | -------------------------------------------------------------------------------- /version.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v0.17.0-dev" 3 | } 4 | --------------------------------------------------------------------------------