Skip to content

Commit

Permalink
fix(core): set miner.etherbase in clique mode
Browse files Browse the repository at this point in the history
 * ethereum/go-ethereum#26413 caused the default
   clique configuration for the GethInstance to fail to start, because
   we did not pass a `miner.etherbase` flag on startup
 * adds a `miner.etherbase` flag with the clique signer address as the
   argument
  • Loading branch information
Rjected committed Feb 28, 2023
1 parent 537d0a9 commit ad6b625
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions ethers-core/src/utils/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,24 +392,30 @@ impl Geth {
let clique_config = CliqueConfig { period: Some(0), epoch: Some(8) };
genesis.config.clique = Some(clique_config);

let clique_addr = secret_key_to_address(
self.clique_private_key.as_ref().expect("is_clique == true"),
);

// set the extraData field
let extra_data_bytes = [
&[0u8; 32][..],
secret_key_to_address(
self.clique_private_key.as_ref().expect("is_clique == true"),
)
.as_ref(),
&[0u8; 65][..],
]
.concat();
let extra_data_bytes =
[&[0u8; 32][..], clique_addr.as_ref(), &[0u8; 65][..]].concat();
let extra_data = Bytes::from(extra_data_bytes);
genesis.extra_data = extra_data;

// we must set the etherbase if using clique
cmd.arg("--miner.etherbase").arg(clique_addr.to_string());
}
} else if is_clique {
let clique_addr =
secret_key_to_address(self.clique_private_key.as_ref().expect("is_clique == true"));

self.genesis = Some(Genesis::new(
self.chain_id.expect("chain id must be set in clique mode"),
secret_key_to_address(self.clique_private_key.as_ref().expect("is_clique == true")),
clique_addr,
));

// we must set the etherbase if using clique
cmd.arg("--miner.etherbase").arg(clique_addr.to_string());
}

if let Some(ref genesis) = self.genesis {
Expand Down

0 comments on commit ad6b625

Please sign in to comment.